Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions features/block-binding.feature
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
Feature: Block binding commands

@less-than-wp-6.5
Scenario: Block binding commands not available on WP < 6.5
Given a WP install

When I try `wp block binding list`
Then STDERR should contain:
"""
Requires WordPress 6.5 or greater.
"""
And the return code should be 1

@require-wp-6.5
Scenario: List block binding sources
Given a WP install
Expand Down Expand Up @@ -36,3 +47,37 @@ Feature: Block binding commands
not registered
"""
And the return code should be 1

@require-wp-6.5
Scenario: List binding sources in various formats
Given a WP install

When I run `wp block binding list --fields=name --format=table`
Then STDOUT should be a table containing rows:
| name |
| core/post-meta |

When I run `wp block binding list --format=yaml`
Then STDOUT should contain:
"""
name: core/post-meta
"""

When I run `wp block binding list --format=csv`
Then STDOUT should contain:
"""
name,
"""

@require-wp-6.5
Scenario: Get binding source field values
Given a WP install

When I run `wp block binding get core/post-meta --field=name`
Then STDOUT should be:
"""
core/post-meta
"""

When I run `wp block binding get core/post-meta --field=label`
Then STDOUT should not be empty
28 changes: 28 additions & 0 deletions features/block-pattern-category.feature
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,31 @@ Feature: Block pattern category commands
not registered
"""
And the return code should be 1

@require-wp-5.5
Scenario: List pattern categories in various formats
Given a WP install

When I run `wp block pattern-category list --fields=name --format=table`
Then STDOUT should be a table containing rows:
| name |
| text |

When I run `wp block pattern-category list --format=csv`
Then STDOUT should contain:
"""
name,
"""

When I run `wp block pattern-category list --format=yaml`
Then STDOUT should contain:
"""
name: text
"""

@require-wp-5.5
Scenario: Get pattern category label field
Given a WP install

When I run `wp block pattern-category get text --field=label`
Then STDOUT should not be empty
34 changes: 34 additions & 0 deletions features/block-pattern.feature
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,37 @@ Feature: Block pattern commands
not registered
"""
And the return code should be 1

@require-wp-5.5
Scenario: Search patterns with no matches returns empty
Given a WP install

When I run `wp block pattern list --search=xyznonexistent123 --format=count`
Then STDOUT should be:
"""
0
"""

@require-wp-5.5
Scenario: Get pattern content field
Given a WP install

When I run `wp block pattern list --field=name`
Then STDOUT should not be empty
And save STDOUT '%s' as {PATTERN_NAME}

When I run `wp block pattern get {PATTERN_NAME} --field=content`
Then STDOUT should contain:
"""
<!-- wp:
"""

@require-wp-5.5
Scenario: Filter by non-existent category returns empty
Given a WP install

When I run `wp block pattern list --category=nonexistent --format=count`
Then STDOUT should be:
"""
0
"""
60 changes: 60 additions & 0 deletions features/block-style.feature
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,63 @@ Feature: Block style commands
"""
0
"""

@require-wp-5.3
Scenario: List styles for block with no registered styles
Given a WP install

# core/html typically has no styles registered
When I run `wp block style list --block=core/html --format=count`
Then STDOUT should be:
"""
0
"""

@require-wp-5.3
Scenario: List block styles in various formats
Given a WP install
# Create theme with style to ensure we have data
And a wp-content/themes/format-test-theme/style.css file:
"""
/*
Theme Name: Format Test Theme
*/
"""
And a wp-content/themes/format-test-theme/index.php file:
"""
<?php
"""
And a wp-content/themes/format-test-theme/functions.php file:
"""
<?php
add_action( 'init', function() {
register_block_style( 'core/paragraph', array(
'name' => 'format-test-style',
'label' => 'Format Test Style',
) );
} );
"""

When I run `wp theme activate format-test-theme`
Then STDOUT should contain:
"""
Success:
"""

When I run `wp block style list --block=core/paragraph --field=name`
Then STDOUT should contain:
"""
format-test-style
"""

When I run `wp block style list --block=core/paragraph --format=yaml`
Then STDOUT should contain:
"""
name: format-test-style
"""

When I run `wp block style list --block=core/paragraph --format=csv`
Then STDOUT should contain:
"""
name,
"""
64 changes: 64 additions & 0 deletions features/block-synced-pattern.feature
Original file line number Diff line number Diff line change
Expand Up @@ -240,3 +240,67 @@ Feature: Synced pattern (wp_block) CRUD commands
"""
not found
"""

@require-wp-5.0
Scenario: Update non-existent synced pattern fails
Given a WP install

When I try `wp block synced-pattern update 999999 --title="Updated"`
Then STDERR should contain:
"""
not found
"""
And the return code should be 1

@require-wp-5.0
Scenario: Create synced pattern without content fails
Given a WP install

When I try `wp block synced-pattern create --title="No Content"`
Then STDERR should contain:
"""
content is required
"""
And the return code should be 1

@require-wp-5.0
Scenario: Create synced pattern with malformed content shows warning
Given a WP install

When I try `wp block synced-pattern create --title="Malformed Pattern" --content='<!-- wp:paragraph' --porcelain`
Then STDERR should contain:
"""
Warning: Content does not appear to contain valid blocks.
"""
And STDOUT should be a number
And the return code should be 0

@require-wp-5.0
Scenario: List synced patterns in various formats
Given a WP install
When I run `wp block synced-pattern create --title="Format Test" --content='<!-- wp:paragraph --><p>X</p><!-- /wp:paragraph -->' --porcelain`
Then save STDOUT as {PATTERN_ID}

When I run `wp block synced-pattern list --fields=ID --format=table`
Then STDOUT should be a table containing rows:
| ID |
| {PATTERN_ID} |

When I run `wp block synced-pattern list --format=csv`
Then STDOUT should contain:
"""
ID,
"""

When I run `wp block synced-pattern list --format=yaml`
Then STDOUT should contain:
"""
post_title: Format Test
"""

# Cleanup
When I run `wp block synced-pattern delete {PATTERN_ID} --force`
Then STDOUT should contain:
"""
Deleted
"""
72 changes: 72 additions & 0 deletions features/block-template.feature
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,75 @@ Feature: Block template commands
not found
"""
And the return code should be 1

@require-wp-5.9
Scenario: Export template to file
Given a WP install
And I try `wp theme install twentytwentyfour --activate`

When I run `wp block template list --field=id`
Then STDOUT should not be empty
And save STDOUT '%s' as {TEMPLATE_ID}

When I run `wp block template export {TEMPLATE_ID} --file=exported-template.html`
Then STDOUT should contain:
"""
Success:
"""
And the exported-template.html file should contain:
"""
<!-- wp:
"""

@require-wp-5.9
Scenario: List templates with classic theme returns empty
Given a WP install
# Default theme is usually a classic theme in test environment
# If twentytwentyone is available, use it as a classic theme example

When I run `wp block template list --format=count`
# Classic themes may return 0 templates
Then STDOUT should be a number

@require-wp-5.9
Scenario: Filter template parts by invalid area returns empty
Given a WP install
And I try `wp theme install twentytwentyfour --activate`

When I run `wp block template list --type=wp_template_part --area=nonexistent --format=count`
Then STDOUT should be:
"""
0
"""

@require-wp-5.9
Scenario: Export template creates subdirectories
Given a WP install
And I try `wp theme install twentytwentyfour --activate`

When I run `wp block template list --field=id`
Then STDOUT should not be empty
And save STDOUT '%s' as {TEMPLATE_ID}

When I run `wp block template export {TEMPLATE_ID} --file=subdir/nested/template.html`
Then STDOUT should contain:
"""
Success: Exported template to 'subdir/nested/template.html'.
"""
And the subdir/nested/template.html file should exist

@require-wp-5.9
Scenario: Export fails when both --file and --dir are provided
Given a WP install
And I try `wp theme install twentytwentyfour --activate`

When I run `wp block template list --field=id`
Then STDOUT should not be empty
And save STDOUT '%s' as {TEMPLATE_ID}

When I try `wp block template export {TEMPLATE_ID} --file=template.html --dir=./exports`
Then STDERR should contain:
"""
The --file and --dir options are mutually exclusive.
"""
And the return code should be 1
51 changes: 51 additions & 0 deletions features/block-type.feature
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,54 @@ Feature: Block type commands
not registered
"""
And the return code should be 1

@require-wp-5.0
Scenario: Filter by non-existent namespace returns empty
Given a WP install

When I run `wp block type list --namespace=nonexistent --format=count`
Then STDOUT should be:
"""
0
"""

@require-wp-5.0
Scenario: List block types in various formats
Given a WP install

When I run `wp block type list --fields=name --format=table`
Then STDOUT should be a table containing rows:
| name |
| core/paragraph |

When I run `wp block type list --format=csv`
Then STDOUT should contain:
"""
name,
"""

When I run `wp block type list --format=yaml`
Then STDOUT should contain:
"""
name: core/paragraph
"""

@require-wp-5.0
Scenario: List block types with custom fields
Given a WP install

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 |

@require-wp-5.0
Scenario: Error when using both --dynamic and --static flags
Given a WP install

When I try `wp block type list --dynamic --static`
Then STDERR should contain:
"""
--dynamic and --static are mutually exclusive
"""
And the return code should be 1
Loading