@wordpress/e2e-tests 2.4.1-next.253d9b6e21.0 → 2.5.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 (49) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +62 -0
  3. package/config/flaky-tests-reporter.js +94 -0
  4. package/config/setup-test-framework.js +10 -0
  5. package/jest.config.js +11 -1
  6. package/package.json +8 -7
  7. package/plugins/class-test-widget.php +5 -2
  8. package/plugins/iframed-block/block.json +16 -0
  9. package/plugins/iframed-block/editor.css +6 -0
  10. package/plugins/iframed-block/editor.js +18 -0
  11. package/plugins/iframed-block/jquery.test.js +7 -0
  12. package/plugins/iframed-block/script.js +7 -0
  13. package/plugins/iframed-block/style.css +9 -0
  14. package/plugins/iframed-block.php +46 -0
  15. package/specs/editor/blocks/buttons.test.js +30 -0
  16. package/specs/editor/blocks/post-title.test.js +1 -1
  17. package/specs/editor/plugins/__snapshots__/iframed-block.test.js.snap +7 -0
  18. package/specs/editor/plugins/align-hook.test.js +116 -105
  19. package/specs/editor/plugins/annotations.test.js +3 -3
  20. package/specs/editor/plugins/iframed-block.test.js +58 -0
  21. package/specs/editor/various/__snapshots__/copy-cut-paste-whole-blocks.test.js.snap +28 -0
  22. package/specs/editor/various/__snapshots__/rich-text.test.js.snap +15 -3
  23. package/specs/editor/various/a11y.test.js +1 -1
  24. package/specs/editor/various/block-deletion.test.js +2 -2
  25. package/specs/editor/various/block-grouping.test.js +2 -2
  26. package/specs/editor/various/block-mover.test.js +1 -1
  27. package/specs/editor/various/change-detection.test.js +2 -1
  28. package/specs/editor/various/copy-cut-paste-whole-blocks.test.js +92 -0
  29. package/specs/editor/various/embedding.test.js +1 -1
  30. package/specs/editor/various/inserting-blocks.test.js +23 -0
  31. package/specs/editor/various/keyboard-navigable-blocks.test.js +2 -2
  32. package/specs/editor/various/multi-block-selection.test.js +23 -0
  33. package/specs/editor/various/new-post.test.js +6 -3
  34. package/specs/editor/various/preview.test.js +5 -1
  35. package/specs/editor/various/rich-text.test.js +29 -1
  36. package/specs/editor/various/splitting-merging.test.js +48 -2
  37. package/specs/editor/various/writing-flow.test.js +14 -13
  38. package/specs/experiments/__snapshots__/navigation-editor.test.js.snap +27 -33
  39. package/specs/experiments/blocks/__snapshots__/navigation.test.js.snap +35 -25
  40. package/specs/experiments/blocks/navigation.test.js +93 -17
  41. package/specs/experiments/fixtures/menu-items-request-fixture.json +84 -0
  42. package/specs/experiments/navigation-editor.test.js +341 -231
  43. package/specs/experiments/template-part.test.js +6 -3
  44. package/specs/experiments/template-revert.test.js +1 -1
  45. package/specs/performance/post-editor.test.js +108 -80
  46. package/specs/performance/site-editor.test.js +2 -17
  47. package/specs/widgets/customizing-widgets.test.js +118 -7
  48. package/specs/widgets/editing-widgets.test.js +52 -88
  49. package/plugins/classic-widgets.php +0 -11
@@ -116,7 +116,7 @@ describe( 'Order of block keyboard navigation', () => {
116
116
  await page.keyboard.press( 'Tab' );
117
117
  await expect(
118
118
  await page.evaluate( () => {
119
- return document.activeElement.placeholder;
119
+ return document.activeElement.getAttribute( 'aria-label' );
120
120
  } )
121
121
  ).toBe( 'Add title' );
122
122
 
@@ -168,7 +168,7 @@ describe( 'Order of block keyboard navigation', () => {
168
168
  await pressKeyWithModifier( 'shift', 'Tab' );
169
169
  await expect(
170
170
  await page.evaluate( () => {
171
- return document.activeElement.placeholder;
171
+ return document.activeElement.getAttribute( 'aria-label' );
172
172
  } )
173
173
  ).toBe( 'Add title' );
174
174
  } );
@@ -10,6 +10,7 @@ import {
10
10
  clickBlockToolbarButton,
11
11
  clickButton,
12
12
  clickMenuItem,
13
+ saveDraft,
13
14
  } from '@wordpress/e2e-test-utils';
14
15
 
15
16
  async function getSelectedFlatIndices() {
@@ -288,6 +289,28 @@ describe( 'Multi-block selection', () => {
288
289
  expect( await getSelectedFlatIndices() ).toEqual( [ 2, 3 ] );
289
290
  } );
290
291
 
292
+ // @see https://github.com/WordPress/gutenberg/issues/34118
293
+ it( 'should properly select a single block even if `shift` was held for the selection', async () => {
294
+ await clickBlockAppender();
295
+ await page.keyboard.type( 'test' );
296
+
297
+ await saveDraft();
298
+ await page.reload();
299
+ await page.waitForSelector( '.edit-post-layout' );
300
+
301
+ await page.keyboard.down( 'Shift' );
302
+ await page.click( '[data-type="core/paragraph"]', { visible: true } );
303
+ await page.keyboard.up( 'Shift' );
304
+
305
+ await pressKeyWithModifier( 'primary', 'a' );
306
+ await page.keyboard.type( 'new content' );
307
+ expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
308
+ "<!-- wp:paragraph -->
309
+ <p>new content</p>
310
+ <!-- /wp:paragraph -->"
311
+ ` );
312
+ } );
313
+
291
314
  it( 'should select by dragging', async () => {
292
315
  await clickBlockAppender();
293
316
  await page.keyboard.type( '1' );
@@ -25,9 +25,12 @@ describe( 'new editor state', () => {
25
25
  expect.stringContaining( 'post-new.php' )
26
26
  );
27
27
  // Should display the blank title.
28
- const title = await page.$( '[placeholder="Add title"]' );
28
+ const title = await page.$( '[aria-label="Add title"]' );
29
29
  expect( title ).not.toBeNull();
30
- expect( title.innerHTML ).toBeFalsy();
30
+ // Trim padding non-breaking space
31
+ expect(
32
+ await title.evaluate( ( el ) => el.textContent.trim() )
33
+ ).toBeFalsy();
31
34
  // Should display the Preview button.
32
35
  const postPreviewButton = await page.$(
33
36
  '.editor-post-preview.components-button'
@@ -59,7 +62,7 @@ describe( 'new editor state', () => {
59
62
  } );
60
63
 
61
64
  expect( activeElementClasses ).toContain( 'editor-post-title__input' );
62
- expect( activeElementTagName ).toEqual( 'textarea' );
65
+ expect( activeElementTagName ).toEqual( 'h1' );
63
66
  } );
64
67
 
65
68
  it( 'should not focus the title if the title exists', async () => {
@@ -11,6 +11,7 @@ import {
11
11
  publishPost,
12
12
  saveDraft,
13
13
  openPreviewPage,
14
+ pressKeyWithModifier,
14
15
  } from '@wordpress/e2e-test-utils';
15
16
 
16
17
  /** @typedef {import('puppeteer').Page} Page */
@@ -216,7 +217,10 @@ describe( 'Preview', () => {
216
217
  await editorPage.bringToFront();
217
218
 
218
219
  // Append bbbbb to the title, and tab away from the title so blur event is triggered.
219
- await editorPage.type( '.editor-post-title__input', 'bbbbb' );
220
+ await editorPage.focus( '.editor-post-title__input' );
221
+ await pressKeyWithModifier( 'primary', 'a' );
222
+ await editorPage.keyboard.press( 'ArrowRight' );
223
+ await editorPage.keyboard.type( 'bbbbb' );
220
224
  await editorPage.keyboard.press( 'Tab' );
221
225
 
222
226
  // Save draft and open the preview page right after.
@@ -385,12 +385,16 @@ describe( 'RichText', () => {
385
385
  await clickBlockToolbarButton( 'More' );
386
386
 
387
387
  const button = await page.waitForXPath(
388
- `//button[contains(text(), 'Text color')]`
388
+ `//button[text()='Highlight']`
389
389
  );
390
390
  // Clicks may fail if the button is out of view. Assure it is before click.
391
391
  await button.evaluate( ( element ) => element.scrollIntoView() );
392
392
  await button.click();
393
393
 
394
+ // Tab to the "Text" tab.
395
+ await page.keyboard.press( 'Tab' );
396
+ // Tab to black.
397
+ await page.keyboard.press( 'Tab' );
394
398
  // Select color other than black.
395
399
  await page.keyboard.press( 'Tab' );
396
400
  await page.keyboard.press( 'Enter' );
@@ -470,4 +474,28 @@ describe( 'RichText', () => {
470
474
 
471
475
  expect( await getEditedPostContent() ).toMatchSnapshot();
472
476
  } );
477
+
478
+ it( 'should navigate consecutive format boundaries', async () => {
479
+ await clickBlockAppender();
480
+ await pressKeyWithModifier( 'primary', 'b' );
481
+ await page.keyboard.type( '1' );
482
+ await pressKeyWithModifier( 'primary', 'b' );
483
+ await pressKeyWithModifier( 'primary', 'i' );
484
+ await page.keyboard.type( '2' );
485
+ await pressKeyWithModifier( 'primary', 'i' );
486
+
487
+ expect( await getEditedPostContent() ).toMatchSnapshot();
488
+
489
+ // Should move into the second format.
490
+ await page.keyboard.press( 'ArrowLeft' );
491
+ // Should move to the start of the second format.
492
+ await page.keyboard.press( 'ArrowLeft' );
493
+ // Should move between the first and second format.
494
+ await page.keyboard.press( 'ArrowLeft' );
495
+
496
+ await page.keyboard.type( '-' );
497
+
498
+ // Expect: <strong>1</strong>-<em>2</em>
499
+ expect( await getEditedPostContent() ).toMatchSnapshot();
500
+ } );
473
501
  } );
@@ -193,10 +193,10 @@ describe( 'splitting and merging blocks', () => {
193
193
  await insertBlock( 'Paragraph' );
194
194
  await page.keyboard.press( 'Backspace' );
195
195
 
196
- // There is a default block:
196
+ // There is a default block and post title:
197
197
  expect(
198
198
  await page.$$( '.block-editor-block-list__block' )
199
- ).toHaveLength( 1 );
199
+ ).toHaveLength( 2 );
200
200
 
201
201
  // But the effective saved content is still empty:
202
202
  expect( await getEditedPostContent() ).toBe( '' );
@@ -226,4 +226,50 @@ describe( 'splitting and merging blocks', () => {
226
226
 
227
227
  expect( await getEditedPostContent() ).toMatchSnapshot();
228
228
  } );
229
+
230
+ describe( 'test restore selection when merge produces more than one block', () => {
231
+ it( 'on forward delete', async () => {
232
+ await insertBlock( 'Paragraph' );
233
+ await page.keyboard.type( 'hi' );
234
+ await insertBlock( 'List' );
235
+ await page.keyboard.type( 'item 1' );
236
+ await page.keyboard.press( 'Enter' );
237
+ await page.keyboard.type( 'item 2' );
238
+ await pressKeyTimes( 'ArrowUp', 2 );
239
+ await page.keyboard.press( 'Delete' );
240
+ // Carret should be in the first block and at the proper position.
241
+ await page.keyboard.type( '-' );
242
+ expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
243
+ "<!-- wp:paragraph -->
244
+ <p>hi-item 1</p>
245
+ <!-- /wp:paragraph -->
246
+
247
+ <!-- wp:paragraph -->
248
+ <p>item 2</p>
249
+ <!-- /wp:paragraph -->"
250
+ ` );
251
+ } );
252
+ it( 'on backspace', async () => {
253
+ await insertBlock( 'Paragraph' );
254
+ await page.keyboard.type( 'hi' );
255
+ await insertBlock( 'List' );
256
+ await page.keyboard.type( 'item 1' );
257
+ await page.keyboard.press( 'Enter' );
258
+ await page.keyboard.type( 'item 2' );
259
+ await page.keyboard.press( 'ArrowUp' );
260
+ await pressKeyTimes( 'ArrowLeft', 6 );
261
+ await page.keyboard.press( 'Backspace' );
262
+ // Carret should be in the first block and at the proper position.
263
+ await page.keyboard.type( '-' );
264
+ expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
265
+ "<!-- wp:paragraph -->
266
+ <p>hi-item 1</p>
267
+ <!-- /wp:paragraph -->
268
+
269
+ <!-- wp:paragraph -->
270
+ <p>item 2</p>
271
+ <!-- /wp:paragraph -->"
272
+ ` );
273
+ } );
274
+ } );
229
275
  } );
@@ -9,7 +9,6 @@ import {
9
9
  pressKeyWithModifier,
10
10
  insertBlock,
11
11
  clickBlockToolbarButton,
12
- clickButton,
13
12
  } from '@wordpress/e2e-test-utils';
14
13
 
15
14
  const getActiveBlockName = async () =>
@@ -289,29 +288,28 @@ describe( 'Writing Flow', () => {
289
288
  it( 'should navigate native inputs vertically, not horizontally', async () => {
290
289
  // See: https://github.com/WordPress/gutenberg/issues/9626
291
290
 
292
- // Title is within the editor's writing flow, and is a <textarea>
293
- await page.click( '.editor-post-title' );
291
+ await insertBlock( 'Shortcode' );
294
292
 
295
293
  // Should remain in title upon ArrowRight:
296
294
  await page.keyboard.press( 'ArrowRight' );
297
- let isInTitle = await page.evaluate(
298
- () => !! document.activeElement.closest( '.editor-post-title' )
295
+ let isInShortcodeBlock = await page.evaluate(
296
+ () => !! document.activeElement.closest( '.wp-block-shortcode' )
299
297
  );
300
- expect( isInTitle ).toBe( true );
298
+ expect( isInShortcodeBlock ).toBe( true );
301
299
 
302
300
  // Should remain in title upon modifier + ArrowDown:
303
301
  await pressKeyWithModifier( 'primary', 'ArrowDown' );
304
- isInTitle = await page.evaluate(
305
- () => !! document.activeElement.closest( '.editor-post-title' )
302
+ isInShortcodeBlock = await page.evaluate(
303
+ () => !! document.activeElement.closest( '.wp-block-shortcode' )
306
304
  );
307
- expect( isInTitle ).toBe( true );
305
+ expect( isInShortcodeBlock ).toBe( true );
308
306
 
309
307
  // Should navigate into blocks list upon ArrowDown:
310
308
  await page.keyboard.press( 'ArrowDown' );
311
- const isInBlock = await page.evaluate(
312
- () => !! document.activeElement.closest( '[data-type]' )
309
+ const isInParagraphBlock = await page.evaluate(
310
+ () => !! document.activeElement.closest( '.wp-block-paragraph' )
313
311
  );
314
- expect( isInBlock ).toBe( true );
312
+ expect( isInParagraphBlock ).toBe( true );
315
313
  } );
316
314
 
317
315
  it( 'should not delete surrounding space when deleting a word with Backspace', async () => {
@@ -557,7 +555,10 @@ describe( 'Writing Flow', () => {
557
555
  await page.keyboard.type( '/image' );
558
556
  await page.keyboard.press( 'Enter' );
559
557
  await clickBlockToolbarButton( 'Align' );
560
- await clickButton( 'Wide width' );
558
+ const wideButton = await page.waitForXPath(
559
+ `//button[contains(@class,'components-dropdown-menu__menu-item')]//span[contains(text(), 'Wide width')]`
560
+ );
561
+ await wideButton.click();
561
562
 
562
563
  // Select the previous block.
563
564
  await page.keyboard.press( 'ArrowUp' );
@@ -4,42 +4,36 @@ exports[`Navigation editor allows creation of a menu when there are existing men
4
4
 
5
5
  exports[`Navigation editor allows creation of a menu when there are no current menu items 1`] = `
6
6
  "<!-- wp:navigation {\\"orientation\\":\\"vertical\\"} -->
7
- <!-- wp:page-list /-->
7
+ <!-- wp:navigation-link {\\"label\\":\\"My page\\",\\"type\\":\\"page\\",\\"id\\":\\"number\\",\\"url\\":\\"string\\",\\"isTopLevelLink\\":true} /-->
8
8
  <!-- /wp:navigation -->"
9
9
  `;
10
10
 
11
- exports[`Navigation editor displays the first menu from the REST response when at least one menu exists 1`] = `
11
+ exports[`Navigation editor displays the first created menu when at least one menu exists 1`] = `
12
12
  "<!-- wp:navigation {\\"orientation\\":\\"vertical\\"} -->
13
- <!-- wp:navigation-link {\\"label\\":\\"Home\\",\\"type\\":\\"custom\\",\\"url\\":\\"http://localhost:8889/\\",\\"kind\\":\\"custom\\",\\"isTopLevelLink\\":true} /-->
14
-
15
- <!-- wp:navigation-link {\\"label\\":\\"Accusamus quo repellat illum magnam quas\\",\\"type\\":\\"page\\",\\"id\\":41,\\"url\\":\\"http://localhost:8889/?page_id=41\\",\\"kind\\":\\"post-type\\",\\"isTopLevelLink\\":true} -->
16
- <!-- wp:navigation-link {\\"label\\":\\"Debitis cum consequatur sit doloremque\\",\\"type\\":\\"page\\",\\"id\\":51,\\"url\\":\\"http://localhost:8889/?page_id=51\\",\\"kind\\":\\"post-type\\",\\"isTopLevelLink\\":false} /-->
17
- <!-- /wp:navigation-link -->
18
-
19
- <!-- wp:navigation-link {\\"label\\":\\"Est ea vero non nihil officiis in\\",\\"type\\":\\"page\\",\\"id\\":53,\\"url\\":\\"http://localhost:8889/?page_id=53\\",\\"kind\\":\\"post-type\\",\\"isTopLevelLink\\":true} -->
20
- <!-- wp:navigation-link {\\"label\\":\\"Fuga odio quis tempora\\",\\"type\\":\\"page\\",\\"id\\":56,\\"url\\":\\"http://localhost:8889/?page_id=56\\",\\"kind\\":\\"post-type\\",\\"isTopLevelLink\\":false} -->
21
- <!-- wp:navigation-link {\\"label\\":\\"In consectetur repellendus eveniet maiores aperiam\\",\\"type\\":\\"page\\",\\"id\\":15,\\"url\\":\\"http://localhost:8889/?page_id=15\\",\\"kind\\":\\"post-type\\",\\"isTopLevelLink\\":false} -->
22
- <!-- wp:navigation-link {\\"label\\":\\"Mollitia maiores consequatur ea dolorem blanditiis\\",\\"type\\":\\"page\\",\\"id\\":45,\\"url\\":\\"http://localhost:8889/?page_id=45\\",\\"kind\\":\\"post-type\\",\\"isTopLevelLink\\":false} -->
23
- <!-- wp:navigation-link {\\"label\\":\\"Necessitatibus nisi qui qui necessitatibus quaerat possimus\\",\\"type\\":\\"page\\",\\"id\\":27,\\"url\\":\\"http://localhost:8889/?page_id=27\\",\\"kind\\":\\"post-type\\",\\"isTopLevelLink\\":false} /-->
24
- <!-- /wp:navigation-link -->
25
- <!-- /wp:navigation-link -->
26
- <!-- /wp:navigation-link -->
27
- <!-- /wp:navigation-link -->
28
-
29
- <!-- wp:navigation-link {\\"label\\":\\"Nulla omnis autem dolores eligendi\\",\\"type\\":\\"page\\",\\"id\\":43,\\"url\\":\\"http://localhost:8889/?page_id=43\\",\\"kind\\":\\"post-type\\",\\"isTopLevelLink\\":true} /-->
30
-
31
- <!-- wp:navigation-link {\\"label\\":\\"Sample Page\\",\\"type\\":\\"page\\",\\"id\\":2,\\"url\\":\\"http://localhost:8889/?page_id=2\\",\\"kind\\":\\"post-type\\",\\"isTopLevelLink\\":true} /-->
32
-
33
- <!-- wp:navigation-link {\\"label\\":\\"Beatae qui labore voluptas eveniet officia quia voluptas qui porro sequi et aut est\\",\\"type\\":\\"category\\",\\"description\\":\\"Ratione nemo ut aut ullam sed assumenda quis est exercitationem\\",\\"id\\":7,\\"url\\":\\"http://localhost:8889/?cat=7\\",\\"kind\\":\\"taxonomy\\",\\"isTopLevelLink\\":true} -->
34
- <!-- wp:navigation-link {\\"label\\":\\"Et minus itaque velit tempore hic quisquam saepe quas asperiores\\",\\"type\\":\\"category\\",\\"description\\":\\"Vel fuga enim rerum perspiciatis sapiente mollitia magni ut molestiae labore quae quia quia libero perspiciatis voluptatem quidem deleniti eveniet laboriosam doloribus dolor laborum accusantium modi ducimus itaque rerum cum nostrum\\",\\"id\\":19,\\"url\\":\\"http://localhost:8889/?cat=19\\",\\"kind\\":\\"taxonomy\\",\\"isTopLevelLink\\":false} -->
35
- <!-- wp:navigation-link {\\"label\\":\\"Et quas a et mollitia et voluptas optio voluptate quia quo unde aut in nostrum iste impedit quisquam id aut\\",\\"type\\":\\"category\\",\\"description\\":\\"Quas sit labore earum omnis eos sint iste est possimus harum aut soluta sint optio quos distinctio inventore voluptate non ut aliquam ad ut voluptates fugiat numquam magnam modi repellendus modi laudantium et debitis officia est voluptatum quidem unde molestiae animi vero fuga accusamus nam\\",\\"id\\":6,\\"url\\":\\"http://localhost:8889/?cat=6\\",\\"kind\\":\\"taxonomy\\",\\"isTopLevelLink\\":false} -->
36
- <!-- wp:navigation-link {\\"label\\":\\"Illo quis sit impedit itaque expedita earum deserunt magni doloremque velit eum id error\\",\\"type\\":\\"category\\",\\"description\\":\\"Doloremque vero sunt officiis iste voluptatibus voluptas molestiae sint asperiores recusandae amet praesentium et explicabo nesciunt similique voluptatum laudantium amet officiis quas distinctio quis enim nihil tempora\\",\\"id\\":16,\\"url\\":\\"http://localhost:8889/?cat=16\\",\\"kind\\":\\"taxonomy\\",\\"isTopLevelLink\\":false} /-->
37
- <!-- /wp:navigation-link -->
38
- <!-- /wp:navigation-link -->
39
- <!-- /wp:navigation-link -->
40
-
41
- <!-- wp:navigation-link {\\"label\\":\\"WordPress.org\\",\\"type\\":\\"custom\\",\\"url\\":\\"https://wordpress.org\\",\\"kind\\":\\"custom\\",\\"isTopLevelLink\\":true} -->
42
- <!-- wp:navigation-link {\\"label\\":\\"Google\\",\\"type\\":\\"custom\\",\\"url\\":\\"https://google.com\\",\\"kind\\":\\"custom\\",\\"isTopLevelLink\\":false} /-->
43
- <!-- /wp:navigation-link -->
13
+ <!-- wp:navigation-link {\\"label\\":\\"Home\\",\\"type\\":\\"custom\\",\\"url\\":\\"string\\",\\"kind\\":\\"custom\\",\\"isTopLevelLink\\":true} /-->
14
+
15
+ <!-- wp:navigation-submenu {\\"label\\":\\"About\\",\\"type\\":\\"page\\",\\"id\\":\\"number\\",\\"url\\":\\"string\\",\\"kind\\":\\"post-type\\",\\"isTopLevelItem\\":true} -->
16
+ <!-- wp:navigation-link {\\"label\\":\\"Our team\\",\\"type\\":\\"page\\",\\"id\\":\\"number\\",\\"url\\":\\"string\\",\\"kind\\":\\"post-type\\",\\"isTopLevelLink\\":false} /-->
17
+ <!-- /wp:navigation-submenu -->
18
+
19
+ <!-- wp:navigation-submenu {\\"label\\":\\"Shop\\",\\"type\\":\\"page\\",\\"id\\":\\"number\\",\\"url\\":\\"string\\",\\"kind\\":\\"post-type\\",\\"isTopLevelItem\\":true} -->
20
+ <!-- wp:navigation-submenu {\\"label\\":\\"Winter apparel\\",\\"type\\":\\"page\\",\\"id\\":\\"number\\",\\"url\\":\\"string\\",\\"kind\\":\\"post-type\\",\\"isTopLevelItem\\":false} -->
21
+ <!-- wp:navigation-link {\\"label\\":\\"Chunky socks\\",\\"type\\":\\"page\\",\\"id\\":\\"number\\",\\"url\\":\\"string\\",\\"kind\\":\\"post-type\\",\\"isTopLevelLink\\":false} /-->
22
+
23
+ <!-- wp:navigation-link {\\"label\\":\\"Hideous hats\\",\\"type\\":\\"page\\",\\"id\\":\\"number\\",\\"url\\":\\"string\\",\\"kind\\":\\"post-type\\",\\"isTopLevelLink\\":false} /-->
24
+
25
+ <!-- wp:navigation-link {\\"label\\":\\"Glorious gloves\\",\\"type\\":\\"page\\",\\"id\\":\\"number\\",\\"url\\":\\"string\\",\\"kind\\":\\"post-type\\",\\"isTopLevelLink\\":false} /-->
26
+
27
+ <!-- wp:navigation-link {\\"label\\":\\"Jazzy Jumpers\\",\\"type\\":\\"page\\",\\"id\\":\\"number\\",\\"url\\":\\"string\\",\\"kind\\":\\"post-type\\",\\"isTopLevelLink\\":false} /-->
28
+ <!-- /wp:navigation-submenu -->
29
+ <!-- /wp:navigation-submenu -->
30
+
31
+ <!-- wp:navigation-link {\\"label\\":\\"Shipping\\",\\"type\\":\\"page\\",\\"id\\":\\"number\\",\\"url\\":\\"string\\",\\"kind\\":\\"post-type\\",\\"isTopLevelLink\\":true} /-->
32
+
33
+ <!-- wp:navigation-link {\\"label\\":\\"Contact Us\\",\\"type\\":\\"page\\",\\"id\\":\\"number\\",\\"url\\":\\"string\\",\\"kind\\":\\"post-type\\",\\"isTopLevelLink\\":true} /-->
34
+
35
+ <!-- wp:navigation-submenu {\\"label\\":\\"WordPress.org\\",\\"type\\":\\"custom\\",\\"url\\":\\"string\\",\\"kind\\":\\"custom\\",\\"isTopLevelItem\\":true} -->
36
+ <!-- wp:navigation-link {\\"label\\":\\"Google\\",\\"type\\":\\"custom\\",\\"url\\":\\"string\\",\\"kind\\":\\"custom\\",\\"isTopLevelLink\\":false} /-->
37
+ <!-- /wp:navigation-submenu -->
44
38
  <!-- /wp:navigation -->"
45
39
  `;
@@ -1,51 +1,61 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`Navigation Creating from existing Menus allows a navigation block to be created from existing menus 1`] = `
4
- "<!-- wp:navigation {\\"orientation\\":\\"horizontal\\"} -->
4
+ "<!-- wp:navigation -->
5
5
  <!-- wp:navigation-link {\\"label\\":\\"Home\\",\\"type\\":\\"custom\\",\\"url\\":\\"http://localhost:8889/\\",\\"kind\\":\\"custom\\",\\"isTopLevelLink\\":true} /-->
6
6
 
7
- <!-- wp:navigation-link {\\"label\\":\\"Accusamus quo repellat illum magnam quas\\",\\"type\\":\\"page\\",\\"id\\":41,\\"url\\":\\"http://localhost:8889/?page_id=41\\",\\"kind\\":\\"post-type\\",\\"isTopLevelLink\\":true} -->
7
+ <!-- wp:navigation-submenu {\\"label\\":\\"Accusamus quo repellat illum magnam quas\\",\\"type\\":\\"page\\",\\"id\\":41,\\"url\\":\\"http://localhost:8889/?page_id=41\\",\\"kind\\":\\"post-type\\",\\"isTopLevelItem\\":true} -->
8
8
  <!-- wp:navigation-link {\\"label\\":\\"Debitis cum consequatur sit doloremque\\",\\"type\\":\\"page\\",\\"id\\":51,\\"url\\":\\"http://localhost:8889/?page_id=51\\",\\"kind\\":\\"post-type\\",\\"isTopLevelLink\\":false} /-->
9
- <!-- /wp:navigation-link -->
9
+ <!-- /wp:navigation-submenu -->
10
10
 
11
- <!-- wp:navigation-link {\\"label\\":\\"Est ea vero non nihil officiis in\\",\\"type\\":\\"page\\",\\"id\\":53,\\"url\\":\\"http://localhost:8889/?page_id=53\\",\\"kind\\":\\"post-type\\",\\"isTopLevelLink\\":true} -->
12
- <!-- wp:navigation-link {\\"label\\":\\"Fuga odio quis tempora\\",\\"type\\":\\"page\\",\\"id\\":56,\\"url\\":\\"http://localhost:8889/?page_id=56\\",\\"kind\\":\\"post-type\\",\\"isTopLevelLink\\":false} -->
13
- <!-- wp:navigation-link {\\"label\\":\\"In consectetur repellendus eveniet maiores aperiam\\",\\"type\\":\\"page\\",\\"id\\":15,\\"url\\":\\"http://localhost:8889/?page_id=15\\",\\"kind\\":\\"post-type\\",\\"isTopLevelLink\\":false} -->
14
- <!-- wp:navigation-link {\\"label\\":\\"Mollitia maiores consequatur ea dolorem blanditiis\\",\\"type\\":\\"page\\",\\"id\\":45,\\"url\\":\\"http://localhost:8889/?page_id=45\\",\\"kind\\":\\"post-type\\",\\"isTopLevelLink\\":false} -->
11
+ <!-- wp:navigation-submenu {\\"label\\":\\"Est ea vero non nihil officiis in\\",\\"type\\":\\"page\\",\\"id\\":53,\\"url\\":\\"http://localhost:8889/?page_id=53\\",\\"kind\\":\\"post-type\\",\\"isTopLevelItem\\":true} -->
12
+ <!-- wp:navigation-submenu {\\"label\\":\\"Fuga odio quis tempora\\",\\"type\\":\\"page\\",\\"id\\":56,\\"url\\":\\"http://localhost:8889/?page_id=56\\",\\"kind\\":\\"post-type\\",\\"isTopLevelItem\\":false} -->
13
+ <!-- wp:navigation-submenu {\\"label\\":\\"In consectetur repellendus eveniet maiores aperiam\\",\\"type\\":\\"page\\",\\"id\\":15,\\"url\\":\\"http://localhost:8889/?page_id=15\\",\\"kind\\":\\"post-type\\",\\"isTopLevelItem\\":false} -->
14
+ <!-- wp:navigation-submenu {\\"label\\":\\"Mollitia maiores consequatur ea dolorem blanditiis\\",\\"type\\":\\"page\\",\\"id\\":45,\\"url\\":\\"http://localhost:8889/?page_id=45\\",\\"kind\\":\\"post-type\\",\\"isTopLevelItem\\":false} -->
15
15
  <!-- wp:navigation-link {\\"label\\":\\"Necessitatibus nisi qui qui necessitatibus quaerat possimus\\",\\"type\\":\\"page\\",\\"id\\":27,\\"url\\":\\"http://localhost:8889/?page_id=27\\",\\"kind\\":\\"post-type\\",\\"isTopLevelLink\\":false} /-->
16
- <!-- /wp:navigation-link -->
17
- <!-- /wp:navigation-link -->
18
- <!-- /wp:navigation-link -->
19
- <!-- /wp:navigation-link -->
16
+ <!-- /wp:navigation-submenu -->
17
+ <!-- /wp:navigation-submenu -->
18
+ <!-- /wp:navigation-submenu -->
19
+ <!-- /wp:navigation-submenu -->
20
20
 
21
21
  <!-- wp:navigation-link {\\"label\\":\\"Nulla omnis autem dolores eligendi\\",\\"type\\":\\"page\\",\\"id\\":43,\\"url\\":\\"http://localhost:8889/?page_id=43\\",\\"kind\\":\\"post-type\\",\\"isTopLevelLink\\":true} /-->
22
22
 
23
23
  <!-- wp:navigation-link {\\"label\\":\\"Sample Page\\",\\"type\\":\\"page\\",\\"id\\":2,\\"url\\":\\"http://localhost:8889/?page_id=2\\",\\"kind\\":\\"post-type\\",\\"isTopLevelLink\\":true} /-->
24
24
 
25
- <!-- wp:navigation-link {\\"label\\":\\"Beatae qui labore voluptas eveniet officia quia voluptas qui porro sequi et aut est\\",\\"type\\":\\"category\\",\\"description\\":\\"Ratione nemo ut aut ullam sed assumenda quis est exercitationem\\",\\"id\\":7,\\"url\\":\\"http://localhost:8889/?cat=7\\",\\"kind\\":\\"taxonomy\\",\\"isTopLevelLink\\":true} -->
26
- <!-- wp:navigation-link {\\"label\\":\\"Et minus itaque velit tempore hic quisquam saepe quas asperiores\\",\\"type\\":\\"category\\",\\"description\\":\\"Vel fuga enim rerum perspiciatis sapiente mollitia magni ut molestiae labore quae quia quia libero perspiciatis voluptatem quidem deleniti eveniet laboriosam doloribus dolor laborum accusantium modi ducimus itaque rerum cum nostrum\\",\\"id\\":19,\\"url\\":\\"http://localhost:8889/?cat=19\\",\\"kind\\":\\"taxonomy\\",\\"isTopLevelLink\\":false} -->
27
- <!-- wp:navigation-link {\\"label\\":\\"Et quas a et mollitia et voluptas optio voluptate quia quo unde aut in nostrum iste impedit quisquam id aut\\",\\"type\\":\\"category\\",\\"description\\":\\"Quas sit labore earum omnis eos sint iste est possimus harum aut soluta sint optio quos distinctio inventore voluptate non ut aliquam ad ut voluptates fugiat numquam magnam modi repellendus modi laudantium et debitis officia est voluptatum quidem unde molestiae animi vero fuga accusamus nam\\",\\"id\\":6,\\"url\\":\\"http://localhost:8889/?cat=6\\",\\"kind\\":\\"taxonomy\\",\\"isTopLevelLink\\":false} -->
25
+ <!-- wp:navigation-submenu {\\"label\\":\\"Beatae qui labore voluptas eveniet officia quia voluptas qui porro sequi et aut est\\",\\"type\\":\\"category\\",\\"description\\":\\"Ratione nemo ut aut ullam sed assumenda quis est exercitationem\\",\\"id\\":7,\\"url\\":\\"http://localhost:8889/?cat=7\\",\\"kind\\":\\"taxonomy\\",\\"isTopLevelItem\\":true} -->
26
+ <!-- wp:navigation-submenu {\\"label\\":\\"Et minus itaque velit tempore hic quisquam saepe quas asperiores\\",\\"type\\":\\"category\\",\\"description\\":\\"Vel fuga enim rerum perspiciatis sapiente mollitia magni ut molestiae labore quae quia quia libero perspiciatis voluptatem quidem deleniti eveniet laboriosam doloribus dolor laborum accusantium modi ducimus itaque rerum cum nostrum\\",\\"id\\":19,\\"url\\":\\"http://localhost:8889/?cat=19\\",\\"kind\\":\\"taxonomy\\",\\"isTopLevelItem\\":false} -->
27
+ <!-- wp:navigation-submenu {\\"label\\":\\"Et quas a et mollitia et voluptas optio voluptate quia quo unde aut in nostrum iste impedit quisquam id aut\\",\\"type\\":\\"category\\",\\"description\\":\\"Quas sit labore earum omnis eos sint iste est possimus harum aut soluta sint optio quos distinctio inventore voluptate non ut aliquam ad ut voluptates fugiat numquam magnam modi repellendus modi laudantium et debitis officia est voluptatum quidem unde molestiae animi vero fuga accusamus nam\\",\\"id\\":6,\\"url\\":\\"http://localhost:8889/?cat=6\\",\\"kind\\":\\"taxonomy\\",\\"isTopLevelItem\\":false} -->
28
28
  <!-- wp:navigation-link {\\"label\\":\\"Illo quis sit impedit itaque expedita earum deserunt magni doloremque velit eum id error\\",\\"type\\":\\"category\\",\\"description\\":\\"Doloremque vero sunt officiis iste voluptatibus voluptas molestiae sint asperiores recusandae amet praesentium et explicabo nesciunt similique voluptatum laudantium amet officiis quas distinctio quis enim nihil tempora\\",\\"id\\":16,\\"url\\":\\"http://localhost:8889/?cat=16\\",\\"kind\\":\\"taxonomy\\",\\"isTopLevelLink\\":false} /-->
29
- <!-- /wp:navigation-link -->
30
- <!-- /wp:navigation-link -->
31
- <!-- /wp:navigation-link -->
29
+ <!-- /wp:navigation-submenu -->
30
+ <!-- /wp:navigation-submenu -->
31
+ <!-- /wp:navigation-submenu -->
32
32
 
33
- <!-- wp:navigation-link {\\"label\\":\\"WordPress.org\\",\\"type\\":\\"custom\\",\\"url\\":\\"https://wordpress.org\\",\\"kind\\":\\"custom\\",\\"isTopLevelLink\\":true} -->
33
+ <!-- wp:navigation-submenu {\\"label\\":\\"WordPress.org\\",\\"type\\":\\"custom\\",\\"url\\":\\"https://wordpress.org\\",\\"kind\\":\\"custom\\",\\"isTopLevelItem\\":true} -->
34
34
  <!-- wp:navigation-link {\\"label\\":\\"Google\\",\\"type\\":\\"custom\\",\\"url\\":\\"https://google.com\\",\\"kind\\":\\"custom\\",\\"isTopLevelLink\\":false} /-->
35
- <!-- /wp:navigation-link -->
35
+ <!-- /wp:navigation-submenu -->
36
36
  <!-- /wp:navigation -->"
37
37
  `;
38
38
 
39
- exports[`Navigation Creating from existing Menus creates an empty navigation block when the selected existing menu is also empty 1`] = `"<!-- wp:navigation {\\"orientation\\":\\"horizontal\\"} /-->"`;
39
+ exports[`Navigation Creating from existing Menus creates an empty navigation block when the selected existing menu is also empty 1`] = `"<!-- wp:navigation /-->"`;
40
40
 
41
41
  exports[`Navigation Creating from existing Pages allows a navigation block to be created using existing pages 1`] = `
42
- "<!-- wp:navigation {\\"orientation\\":\\"horizontal\\"} -->
43
- <!-- wp:page-list /-->
42
+ "<!-- wp:navigation -->
43
+ <!-- wp:page-list {\\"isNavigationChild\\":true,\\"showSubmenuIcon\\":true,\\"openSubmenusOnClick\\":false} /-->
44
+ <!-- /wp:navigation -->"
45
+ `;
46
+
47
+ exports[`Navigation Shows the quick inserter when the block contains non-navigation specific blocks 1`] = `
48
+ "<!-- wp:navigation -->
49
+ <!-- wp:navigation-link {\\"label\\":\\"WP\\",\\"url\\":\\"https://wordpress.org\\",\\"kind\\":\\"custom\\",\\"isTopLevelLink\\":true} /-->
50
+
51
+ <!-- wp:site-title /-->
52
+
53
+ <!-- wp:navigation-link {\\"label\\":\\"WP News\\",\\"url\\":\\"https://wordpress.org/news/\\",\\"kind\\":\\"custom\\",\\"isTopLevelLink\\":true} /-->
44
54
  <!-- /wp:navigation -->"
45
55
  `;
46
56
 
47
57
  exports[`Navigation allows an empty navigation block to be created and manually populated using a mixture of internal and external links 1`] = `
48
- "<!-- wp:navigation {\\"orientation\\":\\"horizontal\\"} -->
58
+ "<!-- wp:navigation -->
49
59
  <!-- wp:navigation-link {\\"label\\":\\"WP\\",\\"url\\":\\"https://wordpress.org\\",\\"kind\\":\\"custom\\",\\"isTopLevelLink\\":true} /-->
50
60
 
51
61
  <!-- wp:navigation-link {\\"label\\":\\"Contact\\",\\"type\\":\\"page\\",\\"id\\":1,\\"url\\":\\"https://this/is/a/test/search/get-in-touch\\",\\"kind\\":\\"post-type\\",\\"isTopLevelLink\\":true} /-->
@@ -53,13 +63,13 @@ exports[`Navigation allows an empty navigation block to be created and manually
53
63
  `;
54
64
 
55
65
  exports[`Navigation allows pages to be created from the navigation block and their links added to menu 1`] = `
56
- "<!-- wp:navigation {\\"orientation\\":\\"horizontal\\"} -->
66
+ "<!-- wp:navigation -->
57
67
  <!-- wp:navigation-link {\\"label\\":\\"A really long page name that will not exist\\",\\"type\\":\\"page\\",\\"id\\":1,\\"url\\":\\"https://this/is/a/test/create/page/my-new-page\\",\\"kind\\":\\"post-type\\",\\"isTopLevelLink\\":true} /-->
58
68
  <!-- /wp:navigation -->"
59
69
  `;
60
70
 
61
71
  exports[`Navigation encodes URL when create block if needed 1`] = `
62
- "<!-- wp:navigation {\\"orientation\\":\\"horizontal\\"} -->
72
+ "<!-- wp:navigation -->
63
73
  <!-- wp:navigation-link {\\"label\\":\\"wordpress.org/шеллы\\",\\"url\\":\\"https://wordpress.org/%D1%88%D0%B5%D0%BB%D0%BB%D1%8B\\",\\"kind\\":\\"custom\\",\\"isTopLevelLink\\":true} /-->
64
74
 
65
75
  <!-- wp:navigation-link {\\"label\\":\\"お問い合わせ\\",\\"type\\":\\"page\\",\\"id\\":1,\\"url\\":\\"https://this/is/a/test/search/%E3%81%8A%E5%95%8F%E3%81%84%E5%90%88%E3%82%8F%E3%81%9B\\",\\"kind\\":\\"post-type\\",\\"isTopLevelLink\\":true} /-->
@@ -246,17 +246,6 @@ async function createEmptyNavBlock() {
246
246
  await startEmptyButton.click();
247
247
  }
248
248
 
249
- async function addLinkBlock() {
250
- // Using 'click' here checks for regressions of https://github.com/WordPress/gutenberg/issues/18329,
251
- // an issue where the block appender requires two clicks.
252
- await page.click( '.wp-block-navigation .block-list-appender' );
253
-
254
- const [ linkButton ] = await page.$x(
255
- "//*[contains(@class, 'block-editor-inserter__quick-inserter')]//*[text()='Custom Link']"
256
- );
257
- await linkButton.click();
258
- }
259
-
260
249
  async function toggleSidebar() {
261
250
  await page.click(
262
251
  '.edit-post-header__settings button[aria-label="Settings"]'
@@ -346,7 +335,7 @@ describe( 'Navigation', () => {
346
335
  // Scope element selector to the Editor's "Content" region as otherwise it picks up on
347
336
  // block previews.
348
337
  const navLinkSelector =
349
- '[aria-label="Editor content"][role="region"] div[aria-label="Block: Custom Link"]';
338
+ '[aria-label="Editor content"][role="region"] .wp-block-navigation-item';
350
339
 
351
340
  await page.waitForSelector( navLinkSelector );
352
341
 
@@ -414,7 +403,7 @@ describe( 'Navigation', () => {
414
403
 
415
404
  await createEmptyNavBlock();
416
405
 
417
- await addLinkBlock();
406
+ await page.click( '.wp-block-navigation .block-list-appender' );
418
407
 
419
408
  // Add a link to the Link block.
420
409
  await updateActiveNavigationLink( {
@@ -425,7 +414,7 @@ describe( 'Navigation', () => {
425
414
 
426
415
  await showBlockToolbar();
427
416
 
428
- await addLinkBlock();
417
+ await page.click( '.wp-block-navigation .block-list-appender' );
429
418
 
430
419
  // After adding a new block, search input should be shown immediately.
431
420
  // Verify that Escape would close the popover.
@@ -477,7 +466,7 @@ describe( 'Navigation', () => {
477
466
 
478
467
  await createEmptyNavBlock();
479
468
 
480
- await addLinkBlock();
469
+ await page.click( '.wp-block-navigation .block-list-appender' );
481
470
 
482
471
  // Add a link to the Link block.
483
472
  await updateActiveNavigationLink( {
@@ -487,7 +476,7 @@ describe( 'Navigation', () => {
487
476
 
488
477
  await showBlockToolbar();
489
478
 
490
- await addLinkBlock();
479
+ await page.click( '.wp-block-navigation .block-list-appender' );
491
480
 
492
481
  // Wait for URL input to be focused
493
482
  await page.waitForSelector(
@@ -548,7 +537,7 @@ describe( 'Navigation', () => {
548
537
  // Create an empty nav block.
549
538
  await createEmptyNavBlock();
550
539
 
551
- await addLinkBlock();
540
+ await page.click( '.wp-block-navigation .block-list-appender' );
552
541
 
553
542
  // Wait for URL input to be focused
554
543
  await page.waitForSelector(
@@ -595,6 +584,93 @@ describe( 'Navigation', () => {
595
584
  expect( await getEditedPostContent() ).toMatchSnapshot();
596
585
  } );
597
586
 
587
+ it( 'allows navigation submenus to open on click instead of hover', async () => {
588
+ await mockAllMenusResponses();
589
+
590
+ // Add the navigation block.
591
+ await insertBlock( 'Navigation' );
592
+
593
+ await selectDropDownOption( 'Test Menu 2' );
594
+
595
+ // const blocks = await getAllBlocks();
596
+ // await selectBlockByClientId( blocks[ 0 ].clientId );
597
+
598
+ await toggleSidebar();
599
+
600
+ const [ openOnClickButton ] = await page.$x(
601
+ '//label[contains(text(),"Open submenus on click")]'
602
+ );
603
+
604
+ await openOnClickButton.click();
605
+
606
+ await saveDraft();
607
+
608
+ // Scope element selector to the Editor's "Content" region as otherwise it picks up on
609
+ // block previews.
610
+ const navSubmenuSelector =
611
+ '[aria-label="Editor content"][role="region"] [aria-label="Block: Submenu"]';
612
+
613
+ await page.waitForSelector( navSubmenuSelector );
614
+
615
+ const navSubmenusLength = await page.$$eval(
616
+ navSubmenuSelector,
617
+ ( els ) => els.length
618
+ );
619
+
620
+ const navButtonTogglesSelector =
621
+ '[aria-label="Editor content"][role="region"] [aria-label="Block: Submenu"] button.wp-block-navigation-item__content';
622
+
623
+ await page.waitForSelector( navButtonTogglesSelector );
624
+
625
+ const navButtonTogglesLength = await page.$$eval(
626
+ navButtonTogglesSelector,
627
+ ( els ) => els.length
628
+ );
629
+
630
+ // Assert the correct number of button toggles are present.
631
+ expect( navSubmenusLength ).toEqual( navButtonTogglesLength );
632
+ } );
633
+
634
+ it( 'Shows the quick inserter when the block contains non-navigation specific blocks', async () => {
635
+ // Add the navigation block.
636
+ await insertBlock( 'Navigation' );
637
+
638
+ // Create an empty nav block.
639
+ await page.waitForSelector( '.wp-block-navigation-placeholder' );
640
+
641
+ await createEmptyNavBlock();
642
+
643
+ // Add a Link block first.
644
+ await page.click( '.wp-block-navigation .block-list-appender' );
645
+
646
+ // Add a link to the Link block.
647
+ await updateActiveNavigationLink( {
648
+ url: 'https://wordpress.org',
649
+ label: 'WP',
650
+ type: 'url',
651
+ } );
652
+
653
+ // Now add a different block type.
654
+ await insertBlock( 'Site Title' );
655
+
656
+ // Now try inserting another Link block via the quick inserter.
657
+ await page.click( '.wp-block-navigation .block-list-appender' );
658
+
659
+ const linkButton = await page.waitForSelector(
660
+ '.block-editor-inserter__quick-inserter .editor-block-list-item-navigation-link'
661
+ );
662
+ await linkButton.click();
663
+
664
+ await updateActiveNavigationLink( {
665
+ url: 'https://wordpress.org/news/',
666
+ label: 'WP News',
667
+ type: 'url',
668
+ } );
669
+
670
+ // Expect a Navigation block with two links and a Site Title.
671
+ expect( await getEditedPostContent() ).toMatchSnapshot();
672
+ } );
673
+
598
674
  // The following tests are unstable, roughly around when https://github.com/WordPress/wordpress-develop/pull/1412
599
675
  // landed. The block manually tests well, so let's skip to unblock other PRs and immediately follow up. cc @vcanales
600
676
  it.skip( 'loads frontend code only if the block is present', async () => {