Skip to content

Commit 811e8ea

Browse files
authored
Merge pull request #985 from Kit/block-api-v3
Blocks: Upgrade to apiVersion 3
2 parents 8f940c2 + 4962d05 commit 811e8ea

26 files changed

Lines changed: 697 additions & 35 deletions

File tree

.env.example

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,13 @@ WORDPRESS_ROOT_DIR="/Users/tim/Local Sites/convertkit-github/app/public"
55
WORDPRESS_URL=http://kit.local
66

77
# Local site DB SQL dump file
8+
# Set to `tests/Support/Data/dump-6.2.8.sql` when testing in WordPress 6.2.8 or older i.e. to test apiVersion 2 blocks
89
WORDPRESS_DB_SQL_DUMP_FILE="tests/Support/Data/dump.sql"
910

11+
# Use apiVersion 3 of the block editor
12+
# Set to `false` when testing in WordPress 6.2.8 or older i.e. to test apiVersion 2 blocks
13+
WORDPRESS_V3_BLOCK_EDITOR_ENABLED=true
14+
1015
# Kit credentials
1116
CONVERTKIT_OAUTH_ACCESS_TOKEN=
1217
CONVERTKIT_OAUTH_REFRESH_TOKEN=

.github/workflows/tests-backward-compat.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ jobs:
2929
DB_USER: root
3030
DB_PASS: root
3131
DB_HOST: localhost
32+
WORDPRESS_V3_BLOCK_EDITOR_ENABLED: false # Test apiVersion 2 blocks against WordPress 6.2.8
3233
WORDPRESS_DB_SQL_DUMP_FILE: tests/Support/Data/dump-6.2.8.sql # Used to populate the test site database for WordPress 6.2.8
3334
INSTALL_PLUGINS: "autoptimize debloat litespeed-cache rocket-lazy-load sg-cachepress" # Don't include this repository's Plugin here.
3435
INSTALL_PLUGINS_URLS: "http://cktestplugins.wpengine.com/wp-content/uploads/2024/11/disable-doing-it-wrong-notices.zip https://downloads.wordpress.org/plugin/block-visibility.3.3.0.zip https://downloads.wordpress.org/plugin/jetpack-boost.3.5.0.zip" # URLs to specific third party Plugins or versions that support WordPress 6.2.8
@@ -134,7 +135,7 @@ jobs:
134135
- name: Install Paid Third Party WordPress Plugins
135136
working-directory: ${{ env.ROOT_DIR }}
136137
run: wp-cli plugin install ${{ secrets.CONVERTKIT_PAID_PLUGIN_URLS }}
137-
138+
138139
# Move Plugin
139140
- name: Move Plugin
140141
run: mv /home/runner/work/convertkit-wordpress/convertkit-wordpress/convertkit ${{ env.PLUGIN_DIR }}
@@ -244,6 +245,7 @@ jobs:
244245
with:
245246
path: ${{ env.PLUGIN_DIR }}/.env.testing
246247
contents: |
248+
WORDPRESS_V3_BLOCK_EDITOR_ENABLED=${{ env.WORDPRESS_V3_BLOCK_EDITOR_ENABLED }}
247249
WORDPRESS_DB_SQL_DUMP_FILE=${{ env.WORDPRESS_DB_SQL_DUMP_FILE }}
248250
CONVERTKIT_API_KEY=${{ env.CONVERTKIT_API_KEY }}
249251
CONVERTKIT_API_SECRET=${{ env.CONVERTKIT_API_SECRET }}

.github/workflows/tests.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ jobs:
3030
DB_USER: root
3131
DB_PASS: root
3232
DB_HOST: localhost
33-
WORDPRESS_DB_SQL_DUMP_FILE: tests/Support/Data/dump.sql # Used to populate the test site database for WordPress 6.2.8
33+
WORDPRESS_V3_BLOCK_EDITOR_ENABLED: true
34+
WORDPRESS_DB_SQL_DUMP_FILE: tests/Support/Data/dump.sql
3435
INSTALL_PLUGINS: "admin-menu-editor autoptimize beaver-builder-lite-version block-visibility contact-form-7 classic-editor custom-post-type-ui debloat elementor forminator jetpack-boost mailchimp-for-wp rocket-lazy-load woocommerce wordpress-seo wpforms-lite litespeed-cache wp-crontrol wp-super-cache w3-total-cache wp-fastest-cache wp-optimize sg-cachepress" # Don't include this repository's Plugin here.
3536
INSTALL_PLUGINS_URLS: "https://downloads.wordpress.org/plugin/convertkit-for-woocommerce.1.6.4.zip http://cktestplugins.wpengine.com/wp-content/uploads/2024/01/convertkit-action-filter-tests.zip http://cktestplugins.wpengine.com/wp-content/uploads/2024/11/disable-doing-it-wrong-notices.zip http://cktestplugins.wpengine.com/wp-content/uploads/2025/03/uncode-js_composer.7.8.zip http://cktestplugins.wpengine.com/wp-content/uploads/2025/03/uncode-core.zip" # URLs to specific third party Plugins
3637
INSTALL_THEMES_URLS: "http://cktestplugins.wpengine.com/wp-content/uploads/2025/03/uncode.zip http://cktestplugins.wpengine.com/wp-content/uploads/2025/04/Divi.zip http://cktestplugins.wpengine.com/wp-content/uploads/2026/01/impeka.zip"
@@ -266,6 +267,7 @@ jobs:
266267
with:
267268
path: ${{ env.PLUGIN_DIR }}/.env.testing
268269
contents: |
270+
WORDPRESS_V3_BLOCK_EDITOR_ENABLED=${{ env.WORDPRESS_V3_BLOCK_EDITOR_ENABLED }}
269271
WORDPRESS_DB_SQL_DUMP_FILE=${{ env.WORDPRESS_DB_SQL_DUMP_FILE }}
270272
CONVERTKIT_API_KEY=${{ env.CONVERTKIT_API_KEY }}
271273
CONVERTKIT_API_SECRET=${{ env.CONVERTKIT_API_SECRET }}

TESTING.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,29 @@ the Helper's namespace and class under the `enabled` section.
354354

355355
Need to change how Codeception runs? Edit the [codeception.dist.xml](codeception.dist.xml) file.
356356

357+
## Block Testing
358+
359+
To locally test that Kit Blocks are compatible with apiVersion 2, use the following configuration in `.env.testing`:
360+
361+
| Environment Variable | Value |
362+
|----------------------|-------|
363+
| `WORDPRESS_DB_SQL_DUMP_FILE` | `tests/Support/Data/dump-6.2.8.sql` |
364+
| `WORDPRESS_V3_BLOCK_EDITOR_ENABLED` | `false` |
365+
366+
To locally test that Kit Blocks are compatible with apiVersion 3, use the following configuration in `.env.testing`:
367+
368+
| Environment Variable | Value |
369+
|----------------------|-------|
370+
| `WORDPRESS_DB_SQL_DUMP_FILE` | `tests/Support/Data/dump.sql` |
371+
| `WORDPRESS_V3_BLOCK_EDITOR_ENABLED` | `true` |
372+
373+
GitHub Actions are configured to automatically configure the hosted runner with the applicable SQL dump file and block editor version:
374+
375+
| Workflow File | Description |
376+
|---------------|-------------|
377+
| `tests-backward-compat.yml` | Runs tests against WordPress 6.2.8, with apiVersion `2` for blocks |
378+
| `tests.yml` | Runs tests against the latest WordPress version, with apiVersion `3` for blocks |
379+
357380
## Writing a WordPress Unit Test
358381

359382
WordPress Unit tests provide testing of Plugin specific functions and/or classes, typically to assert that they perform as expected

includes/blocks/form-builder-field-custom/block.json renamed to includes/blocks/v2/form-builder-field-custom/block.json

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)