From 1124b4385229c08057e83885268356788688bda3 Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Thu, 11 Dec 2025 16:37:20 +0000 Subject: [PATCH 1/2] Adapt block type tests to work across all WP versions --- features/block-type.feature | 52 ++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/features/block-type.feature b/features/block-type.feature index 6d7ff52..d26494a 100644 --- a/features/block-type.feature +++ b/features/block-type.feature @@ -14,7 +14,7 @@ Feature: Block type commands When I run `wp block type list --format=ids` Then STDOUT should contain: """ - core/paragraph + core/archives """ @require-wp-5.0 @@ -24,11 +24,11 @@ Feature: Block type commands When I run `wp block type list --namespace=core --field=name` Then STDOUT should contain: """ - core/paragraph + core/archives """ And STDOUT should contain: """ - core/heading + core/categories """ And STDOUT should not contain: """ @@ -46,54 +46,52 @@ Feature: Block type commands core/archives """ + # Verify dynamic count is a number + When I run `wp block type list --dynamic --format=count` + Then STDOUT should be a number + + When I run `wp block type list --format=count` + Then STDOUT should be a number + + @require-wp-5.5 + Scenario: Filter by static blocks + Given a WP install + # Static blocks don't have render_callback, like core/paragraph + # Static blocks are only registered server-side since WP 5.5 When I run `wp block type list --static --field=name` Then STDOUT should contain: """ core/paragraph """ - # Verify dynamic and static are mutually exclusive - When I run `wp block type list --dynamic --format=count` - Then save STDOUT as {DYNAMIC_COUNT} - When I run `wp block type list --static --format=count` - Then save STDOUT as {STATIC_COUNT} - - When I run `wp block type list --format=count` Then STDOUT should be a number @require-wp-5.0 Scenario: Get a specific block type Given a WP install - When I run `wp block type get core/paragraph --format=json` + When I run `wp block type get core/archives --format=json` Then STDOUT should be JSON containing: """ - {"name":"core/paragraph"} + {"name":"core/archives"} """ - When I run `wp block type get core/paragraph --field=name` + When I run `wp block type get core/archives --field=name` Then STDOUT should be: """ - core/paragraph + core/archives """ # Verify category field is accessible - When I run `wp block type get core/paragraph --field=category` + When I run `wp block type get core/archives --field=category` Then STDOUT should be: """ - text - """ - - # Verify is_dynamic is accessible (static blocks return empty/falsy) - When I run `wp block type get core/paragraph --format=json` - Then STDOUT should be JSON containing: - """ - {"is_dynamic":false} + widgets """ - # Verify dynamic block has is_dynamic=true + # Verify is_dynamic is accessible (dynamic blocks return true) When I run `wp block type get core/archives --format=json` Then STDOUT should be JSON containing: """ @@ -128,7 +126,7 @@ Feature: Block type commands When I run `wp block type list --fields=name --format=table` Then STDOUT should be a table containing rows: | name | - | core/paragraph | + | core/archives | When I run `wp block type list --format=csv` Then STDOUT should contain: @@ -139,7 +137,7 @@ Feature: Block type commands When I run `wp block type list --format=yaml` Then STDOUT should contain: """ - name: core/paragraph + name: core/archives """ @require-wp-5.0 @@ -149,7 +147,7 @@ Feature: Block type commands When I run `wp block type list --fields=name,category --format=table` Then STDOUT should be a table containing rows: | name | category | - | core/paragraph | text | + | core/archives | widgets | @require-wp-5.0 Scenario: Error when using both --dynamic and --static flags From 400d9b40e1b0cf859efdfdaba4500d2202532bbb Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Thu, 11 Dec 2025 18:01:20 +0000 Subject: [PATCH 2/2] Improve tests --- features/block-type.feature | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/features/block-type.feature b/features/block-type.feature index d26494a..7ced9b9 100644 --- a/features/block-type.feature +++ b/features/block-type.feature @@ -68,6 +68,13 @@ Feature: Block type commands When I run `wp block type list --static --format=count` Then STDOUT should be a number + # Verify static block has is_dynamic=false + When I run `wp block type get core/paragraph --format=json` + Then STDOUT should be JSON containing: + """ + {"is_dynamic":false} + """ + @require-wp-5.0 Scenario: Get a specific block type Given a WP install @@ -84,13 +91,6 @@ Feature: Block type commands core/archives """ - # Verify category field is accessible - When I run `wp block type get core/archives --field=category` - Then STDOUT should be: - """ - widgets - """ - # Verify is_dynamic is accessible (dynamic blocks return true) When I run `wp block type get core/archives --format=json` Then STDOUT should be JSON containing: @@ -144,10 +144,10 @@ Feature: Block type commands Scenario: List block types with custom fields Given a WP install - When I run `wp block type list --fields=name,category --format=table` + When I run `wp block type list --fields=name,is_dynamic --format=table` Then STDOUT should be a table containing rows: - | name | category | - | core/archives | widgets | + | name | is_dynamic | + | core/archives | 1 | @require-wp-5.0 Scenario: Error when using both --dynamic and --static flags