Skip to content

Commit 259b8da

Browse files
authored
Tests: improve Windows compatibility (#15)
1 parent 020d47a commit 259b8da

1 file changed

Lines changed: 65 additions & 13 deletions

File tree

‎features/block-synced-pattern.feature‎

Lines changed: 65 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ Feature: Synced pattern (wp_block) CRUD commands
44
Scenario: Create and manage synced patterns
55
Given a WP install
66

7-
When I run `wp block synced-pattern create --title="Test Pattern" --content='<!-- wp:paragraph --><p>Hello World</p><!-- /wp:paragraph -->' --porcelain`
7+
And a pattern.html file:
8+
"""
9+
<!-- wp:paragraph --><p>Hello World</p><!-- /wp:paragraph -->
10+
"""
11+
When I run `wp block synced-pattern create pattern.html --title="Test Pattern" --porcelain`
812
Then STDOUT should be a number
913
And save STDOUT as {PATTERN_ID}
1014

@@ -61,7 +65,11 @@ Feature: Synced pattern (wp_block) CRUD commands
6165
Scenario: Create unsynced pattern
6266
Given a WP install
6367

64-
When I run `wp block synced-pattern create --title="Unsynced Pattern" --content='<!-- wp:paragraph --><p>Test</p><!-- /wp:paragraph -->' --sync-status=unsynced --porcelain`
68+
And a pattern.html file:
69+
"""
70+
<!-- wp:paragraph --><p>Test</p><!-- /wp:paragraph -->
71+
"""
72+
When I run `wp block synced-pattern create pattern.html --title="Unsynced Pattern" --sync-status=unsynced --porcelain`
6573
Then STDOUT should be a number
6674
And save STDOUT as {PATTERN_ID}
6775

@@ -81,10 +89,18 @@ Feature: Synced pattern (wp_block) CRUD commands
8189
Scenario: Filter by sync status
8290
Given a WP install
8391

84-
When I run `wp block synced-pattern create --title="Synced A" --content='<!-- wp:paragraph --><p>A</p><!-- /wp:paragraph -->' --porcelain`
92+
And a pattern1.html file:
93+
"""
94+
<!-- wp:paragraph --><p>A</p><!-- /wp:paragraph -->
95+
"""
96+
When I run `wp block synced-pattern create pattern1.html --title="Synced A" --porcelain`
8597
Then save STDOUT as {SYNCED_ID}
8698

87-
When I run `wp block synced-pattern create --title="Unsynced B" --content='<!-- wp:paragraph --><p>B</p><!-- /wp:paragraph -->' --sync-status=unsynced --porcelain`
99+
Given a pattern2.html file:
100+
"""
101+
<!-- wp:paragraph --><p>B</p><!-- /wp:paragraph -->
102+
"""
103+
When I run `wp block synced-pattern create pattern2.html --title="Unsynced B" --sync-status=unsynced --porcelain`
88104
Then save STDOUT as {UNSYNCED_ID}
89105

90106
When I run `wp block synced-pattern list --sync-status=synced --format=ids`
@@ -117,7 +133,11 @@ Feature: Synced pattern (wp_block) CRUD commands
117133
Scenario: Trash vs permanent delete
118134
Given a WP install
119135

120-
When I run `wp block synced-pattern create --title="Trash Test" --content='<!-- wp:paragraph --><p>X</p><!-- /wp:paragraph -->' --porcelain`
136+
And a pattern.html file:
137+
"""
138+
<!-- wp:paragraph --><p>X</p><!-- /wp:paragraph -->
139+
"""
140+
When I run `wp block synced-pattern create pattern.html --title="Trash Test" --porcelain`
121141
Then save STDOUT as {PATTERN_ID}
122142

123143
# Delete without --force sends to trash
@@ -138,11 +158,19 @@ Feature: Synced pattern (wp_block) CRUD commands
138158
Scenario: Update content and sync status
139159
Given a WP install
140160

141-
When I run `wp block synced-pattern create --title="Update Test" --content='<!-- wp:paragraph --><p>Original</p><!-- /wp:paragraph -->' --porcelain`
161+
And a pattern1.html file:
162+
"""
163+
<!-- wp:paragraph --><p>Original</p><!-- /wp:paragraph -->
164+
"""
165+
When I run `wp block synced-pattern create pattern1.html --title="Update Test" --porcelain`
142166
Then save STDOUT as {PATTERN_ID}
143167

144168
# Update content
145-
When I run `wp block synced-pattern update {PATTERN_ID} --content='<!-- wp:paragraph --><p>Modified</p><!-- /wp:paragraph -->'`
169+
Given a pattern2.html file:
170+
"""
171+
<!-- wp:paragraph --><p>Modified</p><!-- /wp:paragraph -->
172+
"""
173+
When I run `wp block synced-pattern update {PATTERN_ID} pattern2.html`
146174
Then STDOUT should contain:
147175
"""
148176
Updated
@@ -178,7 +206,11 @@ Feature: Synced pattern (wp_block) CRUD commands
178206
Scenario: Create pattern without title fails
179207
Given a WP install
180208

181-
When I try `wp block synced-pattern create --content='<!-- wp:paragraph --><p>No title</p><!-- /wp:paragraph -->'`
209+
And a pattern.html file:
210+
"""
211+
<!-- wp:paragraph --><p>No title</p><!-- /wp:paragraph -->
212+
"""
213+
When I try `wp block synced-pattern create pattern.html`
182214
Then STDERR should contain:
183215
"""
184216
title is required
@@ -189,10 +221,18 @@ Feature: Synced pattern (wp_block) CRUD commands
189221
Scenario: Search patterns by title
190222
Given a WP install
191223

192-
When I run `wp block synced-pattern create --title="Alpha Hero Section" --content='<!-- wp:paragraph --><p>Alpha</p><!-- /wp:paragraph -->' --porcelain`
224+
And a pattern1.html file:
225+
"""
226+
<!-- wp:paragraph --><p>Alpha</p><!-- /wp:paragraph -->
227+
"""
228+
When I run `wp block synced-pattern create pattern1.html --title="Alpha Hero Section" --porcelain`
193229
Then save STDOUT as {ALPHA_ID}
194230

195-
When I run `wp block synced-pattern create --title="Beta Footer" --content='<!-- wp:paragraph --><p>Beta</p><!-- /wp:paragraph -->' --porcelain`
231+
Given a pattern2.html file:
232+
"""
233+
<!-- wp:paragraph --><p>Beta</p><!-- /wp:paragraph -->
234+
"""
235+
When I run `wp block synced-pattern create pattern2.html --title="Beta Footer" --porcelain`
196236
Then save STDOUT as {BETA_ID}
197237

198238
When I run `wp block synced-pattern list --search=Hero --format=ids`
@@ -227,7 +267,11 @@ Feature: Synced pattern (wp_block) CRUD commands
227267
Scenario: Delete multiple patterns including non-existent
228268
Given a WP install
229269

230-
When I run `wp block synced-pattern create --title="To Delete" --content='<!-- wp:paragraph --><p>X</p><!-- /wp:paragraph -->' --porcelain`
270+
And a pattern.html file:
271+
"""
272+
<!-- wp:paragraph --><p>X</p><!-- /wp:paragraph -->
273+
"""
274+
When I run `wp block synced-pattern create pattern.html --title="To Delete" --porcelain`
231275
Then save STDOUT as {VALID_ID}
232276

233277
# Trying to delete both valid and invalid IDs
@@ -267,7 +311,11 @@ Feature: Synced pattern (wp_block) CRUD commands
267311
Scenario: Create synced pattern with malformed content shows warning
268312
Given a WP install
269313

270-
When I try `wp block synced-pattern create --title="Malformed Pattern" --content='<!-- wp:paragraph' --porcelain`
314+
And a pattern.html file:
315+
"""
316+
<!-- wp:paragraph
317+
"""
318+
When I try `wp block synced-pattern create pattern.html --title="Malformed Pattern" --porcelain`
271319
Then STDERR should contain:
272320
"""
273321
Warning: Content does not appear to contain valid blocks.
@@ -278,7 +326,11 @@ Feature: Synced pattern (wp_block) CRUD commands
278326
@require-wp-5.0
279327
Scenario: List synced patterns in various formats
280328
Given a WP install
281-
When I run `wp block synced-pattern create --title="Format Test" --content='<!-- wp:paragraph --><p>X</p><!-- /wp:paragraph -->' --porcelain`
329+
And a pattern.html file:
330+
"""
331+
<!-- wp:paragraph --><p>X</p><!-- /wp:paragraph -->
332+
"""
333+
When I run `wp block synced-pattern create pattern.html --title="Format Test" --porcelain`
282334
Then save STDOUT as {PATTERN_ID}
283335

284336
When I run `wp block synced-pattern list --fields=ID --format=table`

0 commit comments

Comments
 (0)