@wordpress/e2e-tests 7.20.0 → 7.21.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/package.json +9 -8
  3. package/plugins/interactive-blocks/directive-bind/render.php +1 -1
  4. package/plugins/interactive-blocks/directive-body/render.php +1 -1
  5. package/plugins/interactive-blocks/directive-class/render.php +1 -1
  6. package/plugins/interactive-blocks/directive-context/render.php +2 -2
  7. package/plugins/interactive-blocks/directive-context/view.js +10 -6
  8. package/plugins/interactive-blocks/{directive-slots → directive-each}/block.json +3 -3
  9. package/plugins/interactive-blocks/directive-each/render.php +226 -0
  10. package/plugins/interactive-blocks/directive-each/view.js +192 -0
  11. package/plugins/interactive-blocks/directive-init/render.php +1 -1
  12. package/plugins/interactive-blocks/directive-key/render.php +2 -2
  13. package/plugins/interactive-blocks/directive-key/view.js +7 -4
  14. package/plugins/interactive-blocks/directive-on/render.php +1 -1
  15. package/plugins/interactive-blocks/directive-on-document/block.json +15 -0
  16. package/plugins/interactive-blocks/directive-on-document/render.php +29 -0
  17. package/plugins/interactive-blocks/directive-on-document/view.js +39 -0
  18. package/plugins/interactive-blocks/directive-on-window/block.json +15 -0
  19. package/plugins/interactive-blocks/directive-on-window/render.php +26 -0
  20. package/plugins/interactive-blocks/directive-on-window/view.js +39 -0
  21. package/plugins/interactive-blocks/directive-priorities/render.php +1 -1
  22. package/plugins/interactive-blocks/directive-run/block.json +15 -0
  23. package/plugins/interactive-blocks/directive-run/render.php +54 -0
  24. package/plugins/interactive-blocks/directive-run/view.js +110 -0
  25. package/plugins/interactive-blocks/directive-style/render.php +1 -1
  26. package/plugins/interactive-blocks/directive-text/render.php +15 -1
  27. package/plugins/interactive-blocks/directive-text/view.js +4 -1
  28. package/plugins/interactive-blocks/directive-watch/render.php +1 -1
  29. package/plugins/interactive-blocks/negation-operator/render.php +1 -1
  30. package/plugins/interactive-blocks/router-navigate/render.php +2 -2
  31. package/plugins/interactive-blocks/router-navigate/view.js +5 -2
  32. package/plugins/interactive-blocks/router-regions/render.php +4 -4
  33. package/plugins/interactive-blocks/router-regions/view.js +5 -2
  34. package/plugins/interactive-blocks/store-tag/render.php +3 -3
  35. package/plugins/interactive-blocks/tovdom/render.php +1 -1
  36. package/plugins/interactive-blocks/tovdom-islands/render.php +1 -1
  37. package/plugins/interactive-blocks/with-scope/block.json +15 -0
  38. package/plugins/interactive-blocks/with-scope/render.php +14 -0
  39. package/plugins/interactive-blocks/with-scope/view.js +20 -0
  40. package/plugins/interactive-blocks.php +19 -10
  41. package/specs/editor/various/__snapshots__/pattern-blocks.test.js.snap +0 -6
  42. package/specs/editor/various/pattern-blocks.test.js +8 -117
  43. package/plugins/dataviews.php +0 -25
  44. package/plugins/interactive-blocks/directive-slots/render.php +0 -69
  45. package/plugins/interactive-blocks/directive-slots/view.js +0 -20
  46. package/specs/editor/fixtures/menu-items-request-fixture.json +0 -84
  47. package/specs/editor/fixtures/menu-items-response-fixture.json +0 -1261
  48. package/specs/editor/various/__snapshots__/block-grouping.test.js.snap +0 -115
  49. package/specs/editor/various/__snapshots__/embedding.test.js.snap +0 -67
  50. package/specs/editor/various/block-grouping.test.js +0 -283
  51. package/specs/editor/various/embedding.test.js +0 -303
  52. package/specs/editor/various/typewriter.test.js +0 -260
@@ -1,115 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`Block Grouping Group creation creates a group from multiple blocks of different types via block transforms 1`] = `
4
- "<!-- wp:group {"layout":{"type":"constrained"}} -->
5
- <div class="wp-block-group"><!-- wp:heading -->
6
- <h2 class="wp-block-heading">Group Heading</h2>
7
- <!-- /wp:heading -->
8
-
9
- <!-- wp:image -->
10
- <figure class="wp-block-image"><img alt=""/></figure>
11
- <!-- /wp:image -->
12
-
13
- <!-- wp:paragraph -->
14
- <p>Some paragraph</p>
15
- <!-- /wp:paragraph --></div>
16
- <!-- /wp:group -->"
17
- `;
18
-
19
- exports[`Block Grouping Group creation creates a group from multiple blocks of the same type via block transforms 1`] = `
20
- "<!-- wp:group {"layout":{"type":"constrained"}} -->
21
- <div class="wp-block-group"><!-- wp:paragraph -->
22
- <p>First Paragraph</p>
23
- <!-- /wp:paragraph -->
24
-
25
- <!-- wp:paragraph -->
26
- <p>Second Paragraph</p>
27
- <!-- /wp:paragraph -->
28
-
29
- <!-- wp:paragraph -->
30
- <p>Third Paragraph</p>
31
- <!-- /wp:paragraph --></div>
32
- <!-- /wp:group -->"
33
- `;
34
-
35
- exports[`Block Grouping Group creation creates a group from multiple blocks of the same type via options toolbar 1`] = `
36
- "<!-- wp:group {"layout":{"type":"constrained"}} -->
37
- <div class="wp-block-group"><!-- wp:paragraph -->
38
- <p>First Paragraph</p>
39
- <!-- /wp:paragraph -->
40
-
41
- <!-- wp:paragraph -->
42
- <p>Second Paragraph</p>
43
- <!-- /wp:paragraph -->
44
-
45
- <!-- wp:paragraph -->
46
- <p>Third Paragraph</p>
47
- <!-- /wp:paragraph --></div>
48
- <!-- /wp:group -->"
49
- `;
50
-
51
- exports[`Block Grouping Group creation groups and ungroups multiple blocks of different types via options toolbar 1`] = `
52
- "<!-- wp:group {"layout":{"type":"constrained"}} -->
53
- <div class="wp-block-group"><!-- wp:heading -->
54
- <h2 class="wp-block-heading">Group Heading</h2>
55
- <!-- /wp:heading -->
56
-
57
- <!-- wp:image -->
58
- <figure class="wp-block-image"><img alt=""/></figure>
59
- <!-- /wp:image -->
60
-
61
- <!-- wp:paragraph -->
62
- <p>Some paragraph</p>
63
- <!-- /wp:paragraph --></div>
64
- <!-- /wp:group -->"
65
- `;
66
-
67
- exports[`Block Grouping Group creation groups and ungroups multiple blocks of different types via options toolbar 2`] = `
68
- "<!-- wp:heading -->
69
- <h2 class="wp-block-heading">Group Heading</h2>
70
- <!-- /wp:heading -->
71
-
72
- <!-- wp:image -->
73
- <figure class="wp-block-image"><img alt=""/></figure>
74
- <!-- /wp:image -->
75
-
76
- <!-- wp:paragraph -->
77
- <p>Some paragraph</p>
78
- <!-- /wp:paragraph -->"
79
- `;
80
-
81
- exports[`Block Grouping Preserving selected blocks attributes preserves width alignment settings of selected blocks 1`] = `
82
- "<!-- wp:group {"align":"full","layout":{"type":"constrained"}} -->
83
- <div class="wp-block-group alignfull"><!-- wp:heading -->
84
- <h2 class="wp-block-heading">Group Heading</h2>
85
- <!-- /wp:heading -->
86
-
87
- <!-- wp:image {"align":"full"} -->
88
- <figure class="wp-block-image alignfull"><img alt=""/></figure>
89
- <!-- /wp:image -->
90
-
91
- <!-- wp:image {"align":"wide"} -->
92
- <figure class="wp-block-image alignwide"><img alt=""/></figure>
93
- <!-- /wp:image -->
94
-
95
- <!-- wp:paragraph -->
96
- <p>Some paragraph</p>
97
- <!-- /wp:paragraph --></div>
98
- <!-- /wp:group -->"
99
- `;
100
-
101
- exports[`Block Grouping Registering alternative Blocks to handle Grouping interactions should use registered grouping block for grouping interactions 1`] = `
102
- "<!-- wp:test/alternative-group-block -->
103
- <!-- wp:paragraph -->
104
- <p>First Paragraph</p>
105
- <!-- /wp:paragraph -->
106
-
107
- <!-- wp:paragraph -->
108
- <p>Second Paragraph</p>
109
- <!-- /wp:paragraph -->
110
-
111
- <!-- wp:paragraph -->
112
- <p>Third Paragraph</p>
113
- <!-- /wp:paragraph -->
114
- <!-- /wp:test/alternative-group-block -->"
115
- `;
@@ -1,67 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`Embedding content should allow the user to convert unembeddable URLs to a paragraph with a link in it 1`] = `
4
- "<!-- wp:paragraph -->
5
- <p><a href="https://twitter.com/wooyaygutenberg123454312">https://twitter.com/wooyaygutenberg123454312</a></p>
6
- <!-- /wp:paragraph -->"
7
- `;
8
-
9
- exports[`Embedding content should allow the user to try embedding a failed URL again 1`] = `
10
- "<!-- wp:embed {"url":"https://twitter.com/wooyaygutenberg123454312","type":"rich","providerNameSlug":"twitter","responsive":true} -->
11
- <figure class="wp-block-embed is-type-rich is-provider-twitter wp-block-embed-twitter"><div class="wp-block-embed__wrapper">
12
- https://twitter.com/wooyaygutenberg123454312
13
- </div></figure>
14
- <!-- /wp:embed -->"
15
- `;
16
-
17
- exports[`Embedding content should render embeds in the correct state 1`] = `
18
- "<!-- wp:embed {"url":"https://twitter.com/notnownikki","type":"rich","providerNameSlug":"twitter","responsive":true} -->
19
- <figure class="wp-block-embed is-type-rich is-provider-twitter wp-block-embed-twitter"><div class="wp-block-embed__wrapper">
20
- https://twitter.com/notnownikki
21
- </div></figure>
22
- <!-- /wp:embed -->
23
-
24
- <!-- wp:embed {"url":"https://twitter.com/wooyaygutenberg123454312","type":"rich","providerNameSlug":"embed-handler","responsive":true} -->
25
- <figure class="wp-block-embed is-type-rich is-provider-embed-handler wp-block-embed-embed-handler"><div class="wp-block-embed__wrapper">
26
- https://twitter.com/wooyaygutenberg123454312
27
- </div></figure>
28
- <!-- /wp:embed -->
29
-
30
- <!-- wp:embed {"url":"https://wordpress.org/gutenberg/handbook/"} -->
31
- <figure class="wp-block-embed"><div class="wp-block-embed__wrapper">
32
- https://wordpress.org/gutenberg/handbook/
33
- </div></figure>
34
- <!-- /wp:embed -->
35
-
36
- <!-- wp:embed {"url":"https://twitter.com/thatbunty"} -->
37
- <figure class="wp-block-embed"><div class="wp-block-embed__wrapper">
38
- https://twitter.com/thatbunty
39
- </div></figure>
40
- <!-- /wp:embed -->
41
-
42
- <!-- wp:embed {"url":"https://wordpress.org/gutenberg/handbook/block-api/attributes/","type":"wp-embed","providerNameSlug":"wordpress"} -->
43
- <figure class="wp-block-embed is-type-wp-embed is-provider-wordpress wp-block-embed-wordpress"><div class="wp-block-embed__wrapper">
44
- https://wordpress.org/gutenberg/handbook/block-api/attributes/
45
- </div></figure>
46
- <!-- /wp:embed -->
47
-
48
- <!-- wp:embed {"url":"https://www.youtube.com/watch?v=lXMskKTw3Bc","type":"video","providerNameSlug":"youtube","responsive":true,"className":"wp-embed-aspect-16-9 wp-has-aspect-ratio"} -->
49
- <figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
50
- https://www.youtube.com/watch?v=lXMskKTw3Bc
51
- </div></figure>
52
- <!-- /wp:embed -->
53
-
54
- <!-- wp:embed {"url":"https://cloudup.com/cQFlxqtY4ob","type":"photo","providerNameSlug":"cloudup","responsive":true} -->
55
- <figure class="wp-block-embed is-type-photo is-provider-cloudup wp-block-embed-cloudup"><div class="wp-block-embed__wrapper">
56
- https://cloudup.com/cQFlxqtY4ob
57
- </div></figure>
58
- <!-- /wp:embed -->"
59
- `;
60
-
61
- exports[`Embedding content should retry embeds that could not be embedded with trailing slashes, without the trailing slashes 1`] = `
62
- "<!-- wp:embed {"url":"https://twitter.com/notnownikki/","type":"rich","providerNameSlug":"embed-handler","responsive":true} -->
63
- <figure class="wp-block-embed is-type-rich is-provider-embed-handler wp-block-embed-embed-handler"><div class="wp-block-embed__wrapper">
64
- https://twitter.com/notnownikki/
65
- </div></figure>
66
- <!-- /wp:embed -->"
67
- `;
@@ -1,283 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import {
5
- insertBlock,
6
- createNewPost,
7
- clickBlockToolbarButton,
8
- clickMenuItem,
9
- pressKeyWithModifier,
10
- getEditedPostContent,
11
- transformBlockTo,
12
- getAllBlocks,
13
- getAvailableBlockTransforms,
14
- activatePlugin,
15
- deactivatePlugin,
16
- createReusableBlock,
17
- canvas,
18
- } from '@wordpress/e2e-test-utils';
19
-
20
- async function insertBlocksOfSameType() {
21
- await insertBlock( 'Paragraph' );
22
- await page.keyboard.type( 'First Paragraph' );
23
-
24
- await insertBlock( 'Paragraph' );
25
- await page.keyboard.type( 'Second Paragraph' );
26
-
27
- await insertBlock( 'Paragraph' );
28
- await page.keyboard.type( 'Third Paragraph' );
29
- }
30
-
31
- async function insertBlocksOfMultipleTypes() {
32
- await insertBlock( 'Heading' );
33
- await page.keyboard.type( 'Group Heading' );
34
-
35
- await insertBlock( 'Image' );
36
-
37
- await insertBlock( 'Paragraph' );
38
- await page.keyboard.type( 'Some paragraph' );
39
- }
40
-
41
- describe( 'Block Grouping', () => {
42
- beforeEach( async () => {
43
- // Posts are auto-removed at the end of each test run.
44
- await createNewPost();
45
- } );
46
-
47
- describe( 'Group creation', () => {
48
- it( 'creates a group from multiple blocks of the same type via block transforms', async () => {
49
- // Creating test blocks.
50
- await insertBlocksOfSameType();
51
-
52
- // Multiselect via keyboard.
53
- await pressKeyWithModifier( 'primary', 'a' );
54
- await pressKeyWithModifier( 'primary', 'a' );
55
-
56
- await transformBlockTo( 'Group' );
57
-
58
- expect( await getEditedPostContent() ).toMatchSnapshot();
59
- } );
60
-
61
- it( 'creates a group from multiple blocks of different types via block transforms', async () => {
62
- // Creating test blocks.
63
- await insertBlocksOfMultipleTypes();
64
-
65
- // Multiselect via keyboard.
66
- await pressKeyWithModifier( 'primary', 'a' );
67
- await pressKeyWithModifier( 'primary', 'a' );
68
-
69
- await transformBlockTo( 'Group' );
70
-
71
- expect( await getEditedPostContent() ).toMatchSnapshot();
72
- } );
73
-
74
- it( 'creates a group from multiple blocks of the same type via options toolbar', async () => {
75
- // Creating test blocks.
76
- await insertBlocksOfSameType();
77
-
78
- // Multiselect via keyboard.
79
- await pressKeyWithModifier( 'primary', 'a' );
80
- await pressKeyWithModifier( 'primary', 'a' );
81
-
82
- await clickBlockToolbarButton( 'Options' );
83
- await clickMenuItem( 'Group' );
84
-
85
- expect( await getEditedPostContent() ).toMatchSnapshot();
86
- } );
87
-
88
- it( 'groups and ungroups multiple blocks of different types via options toolbar', async () => {
89
- // Creating test blocks.
90
- await insertBlocksOfMultipleTypes();
91
- await pressKeyWithModifier( 'primary', 'a' );
92
- await pressKeyWithModifier( 'primary', 'a' );
93
-
94
- // Group.
95
- await clickBlockToolbarButton( 'Options' );
96
- await clickMenuItem( 'Group' );
97
-
98
- expect( await getEditedPostContent() ).toMatchSnapshot();
99
-
100
- // UnGroup.
101
- await clickBlockToolbarButton( 'Options' );
102
- await clickMenuItem( 'Ungroup' );
103
-
104
- expect( await getEditedPostContent() ).toMatchSnapshot();
105
- } );
106
-
107
- it( 'does not allow ungrouping a group block that has no children', async () => {
108
- await insertBlock( 'Group' );
109
- await clickBlockToolbarButton( 'Options' );
110
- const ungroupButtons = await page.$x(
111
- '//button/span[text()="Ungroup"]'
112
- );
113
- expect( ungroupButtons ).toHaveLength( 0 );
114
- } );
115
- it( 'should group and ungroup a controlled block properly', async () => {
116
- const getParagraphText = async () => {
117
- const paragraphInReusableSelector =
118
- '.block-editor-block-list__block[data-type="core/block"] p';
119
- await canvas().waitForSelector( paragraphInReusableSelector );
120
- return canvas().$eval(
121
- paragraphInReusableSelector,
122
- ( element ) => element.innerText
123
- );
124
- };
125
-
126
- const paragraphText = 'hi';
127
- await createReusableBlock( paragraphText, 'Block' );
128
- // Group
129
- await clickBlockToolbarButton( 'Options' );
130
- await clickMenuItem( 'Group' );
131
-
132
- let group = await canvas().$$( '[data-type="core/group"]' );
133
- expect( group ).toHaveLength( 1 );
134
- // Make sure the paragraph in reusable block exists.
135
- expect( await getParagraphText() ).toMatch( paragraphText );
136
-
137
- await clickBlockToolbarButton( 'Options' );
138
- await clickMenuItem( 'Ungroup' );
139
- group = await canvas().$$( '[data-type="core/group"]' );
140
- expect( group ).toHaveLength( 0 );
141
- // Make sure the paragraph in reusable block exists.
142
- expect( await getParagraphText() ).toEqual( paragraphText );
143
- } );
144
- it( 'should group another Group block via options toolbar', async () => {
145
- await insertBlock( 'Paragraph' );
146
- await page.keyboard.type( '1' );
147
- await clickBlockToolbarButton( 'Options' );
148
- await clickMenuItem( 'Group' );
149
- await clickBlockToolbarButton( 'Options' );
150
- await clickMenuItem( 'Group' );
151
- expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
152
- "<!-- wp:group {"layout":{"type":"constrained"}} -->
153
- <div class="wp-block-group"><!-- wp:group {"layout":{"type":"constrained"}} -->
154
- <div class="wp-block-group"><!-- wp:paragraph -->
155
- <p>1</p>
156
- <!-- /wp:paragraph --></div>
157
- <!-- /wp:group --></div>
158
- <!-- /wp:group -->"
159
- ` );
160
- } );
161
- } );
162
-
163
- describe( 'Grouping Block availability', () => {
164
- beforeEach( async () => {
165
- // Disable the Group block.
166
- await page.evaluate( () => {
167
- const { dispatch } = wp.data;
168
- dispatch( 'core/edit-post' ).hideBlockTypes( [ 'core/group' ] );
169
- } );
170
-
171
- // Create a Group.
172
- await insertBlocksOfMultipleTypes();
173
- await pressKeyWithModifier( 'primary', 'a' );
174
- await pressKeyWithModifier( 'primary', 'a' );
175
- } );
176
-
177
- afterAll( async () => {
178
- // Re-enable the Group block.
179
- await page.evaluate( () => {
180
- const { dispatch } = wp.data;
181
- dispatch( 'core/edit-post' ).showBlockTypes( [ 'core/group' ] );
182
- } );
183
- } );
184
-
185
- it( 'does not show group transform if Grouping block is disabled', async () => {
186
- const availableTransforms = await getAvailableBlockTransforms();
187
-
188
- expect( availableTransforms ).not.toContain( 'Group' );
189
- } );
190
-
191
- it( 'does not show group option in the options toolbar if Grouping block is disabled', async () => {
192
- await clickBlockToolbarButton( 'Options' );
193
-
194
- const blockOptionsDropdownHTML = await page.evaluate(
195
- () =>
196
- document.querySelector(
197
- '.block-editor-block-settings-menu__popover'
198
- ).innerHTML
199
- );
200
-
201
- expect( blockOptionsDropdownHTML ).not.toContain( 'Group' );
202
- } );
203
- } );
204
-
205
- describe( 'Preserving selected blocks attributes', () => {
206
- it( 'preserves width alignment settings of selected blocks', async () => {
207
- await insertBlock( 'Heading' );
208
- await page.keyboard.type( 'Group Heading' );
209
-
210
- // Full width image.
211
- await insertBlock( 'Image' );
212
- await clickBlockToolbarButton( 'Align' );
213
- const fullButton = await page.waitForXPath(
214
- `//button[contains(@class,'components-dropdown-menu__menu-item')]//span[contains(text(), 'Full width')]`
215
- );
216
- await fullButton.evaluate( ( element ) =>
217
- element.scrollIntoView()
218
- );
219
- await fullButton.click();
220
-
221
- // Wide width image.
222
- await insertBlock( 'Image' );
223
- await clickBlockToolbarButton( 'Align' );
224
- const wideButton = await page.waitForXPath(
225
- `//button[contains(@class,'components-dropdown-menu__menu-item')]//span[contains(text(), 'Wide width')]`
226
- );
227
- await wideButton.evaluate( ( element ) =>
228
- element.scrollIntoView()
229
- );
230
- await wideButton.click();
231
-
232
- await insertBlock( 'Paragraph' );
233
- await page.keyboard.type( 'Some paragraph' );
234
-
235
- await pressKeyWithModifier( 'primary', 'a' );
236
- await pressKeyWithModifier( 'primary', 'a' );
237
-
238
- await transformBlockTo( 'Group' );
239
-
240
- const allBlocks = await getAllBlocks();
241
-
242
- // We expect Group block align setting to match that
243
- // of the widest of it's "child" innerBlocks
244
- expect( allBlocks[ 0 ].attributes.align ).toBe( 'full' );
245
-
246
- expect( await getEditedPostContent() ).toMatchSnapshot();
247
- } );
248
- } );
249
-
250
- describe( 'Registering alternative Blocks to handle Grouping interactions', () => {
251
- beforeAll( async () => {
252
- await activatePlugin( 'gutenberg-test-custom-grouping-block' );
253
- } );
254
-
255
- afterAll( async () => {
256
- await deactivatePlugin( 'gutenberg-test-custom-grouping-block' );
257
- } );
258
-
259
- it( 'should use registered grouping block for grouping interactions', async () => {
260
- // Set custom Block as the Block to use for Grouping.
261
- await page.evaluate( () => {
262
- window.wp.blocks.setGroupingBlockName(
263
- 'test/alternative-group-block'
264
- );
265
- } );
266
-
267
- // Creating test blocks.
268
- await insertBlocksOfSameType();
269
-
270
- // Multiselect via keyboard.
271
- await pressKeyWithModifier( 'primary', 'a' );
272
- await pressKeyWithModifier( 'primary', 'a' );
273
-
274
- // Group - this will use whichever Block is registered as the Grouping Block
275
- // as opposed to "transformTo()" which uses whatever is passed to it. To
276
- // ensure this test is meaningful we must rely on what is registered.
277
- await clickBlockToolbarButton( 'Options' );
278
- await clickMenuItem( 'Group' );
279
-
280
- expect( await getEditedPostContent() ).toMatchSnapshot();
281
- } );
282
- } );
283
- } );