-
Notifications
You must be signed in to change notification settings - Fork 95
Add initial set of block-related commands #555
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Copilot
wants to merge
9
commits into
main
Choose a base branch
from
copilot/add-block-related-commands
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+846
−0
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
29b129e
Initial plan
Copilot a337f73
Add block and pattern commands with WordPress 5.0+ support
Copilot 0f5c31a
Add comprehensive Behat tests for block and pattern commands
Copilot 7ff3625
Add WordPress version checks for post block commands and improve erro…
Copilot bd07143
Lint fixes
swissspidy 94f6828
Address code review feedback: simplify error messages and fix documen…
Copilot d573631
Test fixes
swissspidy dd156dd
Fix one test
swissspidy 4ce213f
Add test case for filtering patterns by category
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| Feature: Manage WordPress block types | ||
|
|
||
| Background: | ||
| Given a WP install | ||
|
|
||
| @require-wp-5.0 | ||
| Scenario: Listing block types | ||
| When I run `wp block list --format=csv` | ||
| Then STDOUT should contain: | ||
| """ | ||
| name,title | ||
| """ | ||
| And STDOUT should contain: | ||
| """ | ||
| core/paragraph | ||
| """ | ||
|
|
||
| @require-wp-5.0 | ||
| Scenario: Listing block types with specific fields | ||
| When I run `wp block list --fields=name,title,category` | ||
| Then STDOUT should be a table containing rows: | ||
| | name | title | category | | ||
| | core/paragraph | Paragraph | text | | ||
|
|
||
| @require-wp-5.0 | ||
| Scenario: Getting a specific block type | ||
| When I run `wp block get core/paragraph --fields=name,title,category` | ||
| Then STDOUT should be a table containing rows: | ||
| | Field | Value | | ||
| | name | core/paragraph | | ||
| | title | Paragraph | | ||
| | category | text | | ||
|
|
||
| @require-wp-5.0 | ||
| Scenario: Getting a non-existent block type | ||
| When I try `wp block get core/nonexistent-block` | ||
| Then STDERR should contain: | ||
| """ | ||
| Error: Block type 'core/nonexistent-block' is not registered. | ||
| """ | ||
| And the return code should be 1 | ||
|
|
||
| @require-wp-5.0 | ||
| Scenario: Getting a specific field from a block type | ||
| When I run `wp block get core/paragraph --field=title` | ||
| Then STDOUT should be: | ||
| """ | ||
| Paragraph | ||
| """ | ||
|
|
||
| @require-wp-5.0 | ||
| Scenario: Listing block types in JSON format | ||
| When I run `wp block list --format=json` | ||
| Then STDOUT should contain: | ||
| """ | ||
| {"name":"core\/paragraph","title":"Paragraph","description":"Start with the basic building block of all narrative.","category":"text"} | ||
| """ | ||
|
|
||
| @require-wp-5.0 | ||
| Scenario: Count block types | ||
| When I run `wp block list --format=count` | ||
| Then STDOUT should match /^\d+$/ | ||
|
|
||
| @less-than-wp-5.0 | ||
| Scenario: Block commands require WordPress 5.0+ | ||
| When I try `wp block list` | ||
| Then STDERR should contain: | ||
| """ | ||
| Error: Requires WordPress 5.0 or greater. | ||
| """ | ||
| And the return code should be 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| Feature: Manage WordPress block patterns | ||
|
|
||
| Background: | ||
| Given a WP install | ||
|
|
||
| @require-wp-5.5 | ||
| Scenario: Listing block patterns | ||
| When I run `wp pattern list --format=csv` | ||
| Then STDOUT should contain: | ||
| """ | ||
| name,title | ||
| """ | ||
|
|
||
| When I run `wp pattern list --format=json` | ||
| Then STDOUT should be JSON containing: | ||
| """ | ||
| [{"name":"core\/query-standard-posts","title":"Standard"}] | ||
| """ | ||
|
|
||
| @require-wp-5.5 | ||
| Scenario: Filtering block patterns by category | ||
| When I run `wp pattern list --category=buttons --format=count` | ||
| Then STDOUT should match /^\d+$/ | ||
|
|
||
| @require-wp-5.5 | ||
| Scenario: Getting a specific block pattern | ||
| When I run `wp pattern list --format=csv --fields=name` | ||
| Then STDOUT should contain: | ||
| """ | ||
| name | ||
| """ | ||
|
|
||
| When I run `wp pattern list --format=count` | ||
| Then STDOUT should match /^\d+$/ | ||
|
|
||
| @require-wp-5.5 | ||
| Scenario: Getting a non-existent block pattern | ||
| When I try `wp pattern get nonexistent/pattern` | ||
| Then STDERR should contain: | ||
| """ | ||
| Error: Block pattern 'nonexistent/pattern' is not registered. | ||
| """ | ||
| And the return code should be 1 | ||
|
|
||
| @require-wp-5.5 | ||
| Scenario: Count block patterns | ||
| When I run `wp pattern list --format=count` | ||
| Then STDOUT should match /^\d+$/ | ||
|
|
||
| @less-than-wp-5.0 | ||
| Scenario: Pattern commands require WordPress 5.5+ | ||
| When I try `wp pattern list` | ||
| Then STDERR should contain: | ||
| """ | ||
| Error: Requires WordPress 5.5 or greater. | ||
| """ | ||
| And the return code should be 1 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| Feature: Manage WordPress post blocks | ||
|
|
||
| Background: | ||
| Given a WP install | ||
|
|
||
| @require-wp-5.0 | ||
| Scenario: Check if a post has blocks | ||
| When I run `wp post create --post_title='Block post' --post_content='<!-- wp:paragraph --><p>Hello World</p><!-- /wp:paragraph -->' --porcelain` | ||
| Then STDOUT should be a number | ||
| And save STDOUT as {POST_ID} | ||
|
|
||
| When I run `wp post has-blocks {POST_ID}` | ||
| Then STDOUT should contain: | ||
| """ | ||
| Success: Post {POST_ID} has blocks. | ||
| """ | ||
| And the return code should be 0 | ||
|
|
||
| @require-wp-5.0 | ||
| Scenario: Check if a post does not have blocks | ||
| When I run `wp post create --post_title='Regular post' --post_content='<p>Hello World</p>' --porcelain` | ||
| Then STDOUT should be a number | ||
| And save STDOUT as {POST_ID} | ||
|
|
||
| When I try `wp post has-blocks {POST_ID}` | ||
| Then STDERR should be empty | ||
| And the return code should be 1 | ||
|
|
||
| @require-wp-5.0 | ||
| Scenario: Check if a post contains a specific block type | ||
| When I run `wp post create --post_title='Block post' --post_content='<!-- wp:paragraph --><p>Hello World</p><!-- /wp:paragraph -->' --porcelain` | ||
| Then STDOUT should be a number | ||
| And save STDOUT as {POST_ID} | ||
|
|
||
| When I run `wp post has-block {POST_ID} core/paragraph` | ||
| Then STDOUT should contain: | ||
| """ | ||
| Success: Post {POST_ID} contains the block 'core/paragraph'. | ||
| """ | ||
| And the return code should be 0 | ||
|
|
||
| When I try `wp post has-block {POST_ID} core/image` | ||
| Then STDERR should be empty | ||
| And the return code should be 1 | ||
|
|
||
| @require-wp-5.0 | ||
| Scenario: Parse blocks from a post | ||
| When I run `wp post create --post_title='Block post' --post_content='<!-- wp:paragraph --><p>Hello World</p><!-- /wp:paragraph -->' --porcelain` | ||
| Then STDOUT should be a number | ||
| And save STDOUT as {POST_ID} | ||
|
|
||
| When I run `wp post parse-blocks {POST_ID}` | ||
| Then STDOUT should be JSON containing: | ||
| """ | ||
| [ | ||
| { | ||
| "blockName": "core/paragraph", | ||
| "attrs": [], | ||
| "innerBlocks": [], | ||
| "innerHTML": "<p>Hello World</p>", | ||
| "innerContent": [ | ||
| "<p>Hello World</p>" | ||
| ] | ||
| } | ||
| ] | ||
| """ | ||
|
|
||
| When I run `wp post parse-blocks {POST_ID} --format=yaml` | ||
| Then STDOUT should contain: | ||
| """ | ||
| blockName: | ||
| """ | ||
| And STDOUT should contain: | ||
| """ | ||
| core/paragraph | ||
| """ | ||
|
|
||
| @require-wp-5.0 | ||
| Scenario: Render blocks from a post | ||
| When I run `wp post create --post_title='Block post' --post_content='<!-- wp:paragraph --><p>Hello World</p><!-- /wp:paragraph -->' --porcelain` | ||
| Then STDOUT should be a number | ||
| And save STDOUT as {POST_ID} | ||
|
|
||
| When I run `wp post render-blocks {POST_ID}` | ||
| Then STDOUT should contain: | ||
| """ | ||
| <p>Hello World</p> | ||
| """ | ||
|
|
||
| @require-wp-5.0 | ||
| Scenario: Post get command includes block_version field | ||
| When I run `wp post create --post_title='Block post' --post_content='<!-- wp:paragraph --><p>Hello World</p><!-- /wp:paragraph -->' --porcelain` | ||
| Then STDOUT should be a number | ||
| And save STDOUT as {POST_ID} | ||
|
|
||
| When I run `wp post get {POST_ID} --field=block_version` | ||
| Then STDOUT should match /^\d+$/ | ||
|
|
||
| @less-than-wp-5.0 | ||
| Scenario: Post block commands require WordPress 5.0+ | ||
| When I try `wp post has-blocks 1` | ||
| Then STDERR should contain: | ||
| """ | ||
| Error: This command requires WordPress 5.0 or greater. | ||
| """ | ||
| And the return code should be 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.