@wordpress/e2e-tests 4.9.1 → 5.0.1-next.957ca95e4c.0

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 (38) hide show
  1. package/CHANGELOG.md +7 -1
  2. package/README.md +1 -1
  3. package/assets/large-post.html +364 -182
  4. package/package.json +8 -8
  5. package/specs/editor/blocks/__snapshots__/navigation.test.js.snap +2 -2
  6. package/specs/editor/blocks/__snapshots__/quote.test.js.snap +5 -1
  7. package/specs/editor/blocks/navigation.test.js +392 -154
  8. package/specs/editor/blocks/quote.test.js +4 -1
  9. package/specs/editor/plugins/__snapshots__/cpt-locking.test.js.snap +5 -3
  10. package/specs/editor/plugins/inner-blocks-allowed-blocks.test.js +3 -0
  11. package/specs/editor/various/__snapshots__/block-deletion.test.js.snap +3 -1
  12. package/specs/editor/various/__snapshots__/block-grouping.test.js.snap +5 -5
  13. package/specs/editor/various/__snapshots__/block-hierarchy-navigation.test.js.snap +1 -1
  14. package/specs/editor/various/__snapshots__/draggable-block.test.js.snap +22 -2
  15. package/specs/editor/various/__snapshots__/inserting-blocks.test.js.snap +1 -1
  16. package/specs/editor/various/__snapshots__/keep-styles-on-block-transforms.test.js.snap +1 -7
  17. package/specs/editor/various/__snapshots__/multi-block-selection.test.js.snap +34 -6
  18. package/specs/editor/various/__snapshots__/rich-text.test.js.snap +19 -5
  19. package/specs/editor/various/__snapshots__/writing-flow.test.js.snap +3 -11
  20. package/specs/editor/various/block-grouping.test.js +2 -2
  21. package/specs/editor/various/block-switcher.test.js +11 -3
  22. package/specs/editor/various/draggable-block.test.js +83 -14
  23. package/specs/editor/various/inserting-blocks.test.js +4 -0
  24. package/specs/editor/various/keep-styles-on-block-transforms.test.js +0 -17
  25. package/specs/editor/various/multi-block-selection.test.js +36 -5
  26. package/specs/editor/various/post-visibility.test.js +2 -4
  27. package/specs/editor/various/rich-text.test.js +9 -6
  28. package/specs/editor/various/scheduling.test.js +2 -6
  29. package/specs/editor/various/splitting-merging.test.js +7 -2
  30. package/specs/editor/various/switch-to-draft.test.js +2 -4
  31. package/specs/editor/various/toolbar-roving-tabindex.test.js +2 -1
  32. package/specs/editor/various/writing-flow.test.js +8 -4
  33. package/specs/performance/post-editor.test.js +3 -3
  34. package/specs/site-editor/global-styles-sidebar.test.js +2 -1
  35. package/specs/editor/plugins/register-block-type-hooks.test.js +0 -32
  36. package/specs/editor/plugins/wp-editor-meta-box.test.js +0 -58
  37. package/specs/editor/various/__snapshots__/duplicating-blocks.test.js.snap +0 -21
  38. package/specs/editor/various/duplicating-blocks.test.js +0 -47
@@ -331,6 +331,9 @@ describe( 'Multi-block selection', () => {
331
331
  await page.keyboard.up( 'Shift' );
332
332
  await transformBlockTo( 'Group' );
333
333
 
334
+ // Confirm setup.
335
+ expect( await getEditedPostContent() ).toMatchSnapshot();
336
+
334
337
  // Click the first paragraph in the first Group block while pressing `shift` key.
335
338
  const firstParagraph = await page.waitForXPath( "//p[text()='first']" );
336
339
  await page.keyboard.down( 'Shift' );
@@ -356,7 +359,7 @@ describe( 'Multi-block selection', () => {
356
359
  await page.mouse.up();
357
360
  await page.keyboard.type( 'hi' );
358
361
  expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
359
- "<!-- wp:group -->
362
+ "<!-- wp:group {\\"layout\\":{\\"type\\":\\"constrained\\"}} -->
360
363
  <div class=\\"wp-block-group\\"><!-- wp:paragraph -->
361
364
  <p>hih text in group</p>
362
365
  <!-- /wp:paragraph --></div>
@@ -676,6 +679,10 @@ describe( 'Multi-block selection', () => {
676
679
 
677
680
  await pressKeyWithModifier( 'primary', 'a' );
678
681
 
682
+ await page.waitForSelector( '[data-type="core/column"].is-selected' );
683
+
684
+ await pressKeyWithModifier( 'primary', 'a' );
685
+
679
686
  await page.waitForSelector(
680
687
  '[data-type="core/column"].is-multi-selected'
681
688
  );
@@ -699,6 +706,7 @@ describe( 'Multi-block selection', () => {
699
706
  // Confirm correct setup: a paragraph and a list.
700
707
  expect( await getEditedPostContent() ).toMatchSnapshot();
701
708
 
709
+ await pressKeyWithModifier( 'primary', 'a' );
702
710
  await pressKeyWithModifier( 'primary', 'a' );
703
711
  await pressKeyWithModifier( 'primary', 'a' );
704
712
 
@@ -907,11 +915,16 @@ describe( 'Multi-block selection', () => {
907
915
 
908
916
  it( 'should select separator (single element block)', async () => {
909
917
  await clickBlockAppender();
910
- await page.keyboard.type( '/hr' );
918
+ await page.keyboard.type( 'a' );
911
919
  await page.keyboard.press( 'Enter' );
912
920
  await page.keyboard.press( 'Enter' );
913
- await page.keyboard.type( 'a' );
914
- await pressKeyWithModifier( 'shift', 'ArrowUp' );
921
+ await page.keyboard.type( '/hr' );
922
+ await page.keyboard.press( 'Enter' );
923
+ await page.keyboard.press( 'ArrowUp' );
924
+ await page.keyboard.press( 'ArrowUp' );
925
+ await page.keyboard.press( 'ArrowRight' );
926
+ await pressKeyWithModifier( 'shift', 'ArrowDown' );
927
+ await pressKeyWithModifier( 'shift', 'ArrowDown' );
915
928
 
916
929
  // Test setup.
917
930
  expect( await getEditedPostContent() ).toMatchSnapshot();
@@ -921,7 +934,7 @@ describe( 'Multi-block selection', () => {
921
934
  // Ensure selection is in the correct place.
922
935
  await page.keyboard.type( '&' );
923
936
 
924
- // Expect two blocks with "&" in between.
937
+ // Expect a paragraph with "&".
925
938
  expect( await getEditedPostContent() ).toMatchSnapshot();
926
939
  } );
927
940
 
@@ -996,4 +1009,22 @@ describe( 'Multi-block selection', () => {
996
1009
  expect( selectedBlocks.length ).toBe( 2 );
997
1010
  } );
998
1011
  } );
1012
+
1013
+ it( 'should select by dragging into separator', async () => {
1014
+ await clickBlockAppender();
1015
+ await page.keyboard.type( '1' );
1016
+ await insertBlock( 'Separator' );
1017
+ await page.keyboard.press( 'ArrowUp' );
1018
+
1019
+ const [ paragraph, hr ] = await page.$$( '[data-type]' );
1020
+ const coord1 = await paragraph.clickablePoint();
1021
+ const coord2 = await hr.clickablePoint();
1022
+
1023
+ await page.mouse.move( coord1.x, coord1.y );
1024
+ await page.mouse.down();
1025
+ await page.mouse.move( coord2.x, coord2.y, { steps: 10 } );
1026
+ await page.mouse.up();
1027
+
1028
+ expect( await getSelectedFlatIndices() ).toEqual( [ 1, 2 ] );
1029
+ } );
999
1030
  } );
@@ -91,12 +91,10 @@ describe( 'Post visibility', () => {
91
91
 
92
92
  // Set a publish date for the next month.
93
93
  await page.click( '*[aria-label^="Change date"]' );
94
- await page.click(
95
- '*[aria-label="Move forward to switch to the next month."]'
96
- );
94
+ await page.click( '*[aria-label="View next month"]' );
97
95
  await (
98
96
  await page.$x(
99
- '//*[@role="application"][@aria-label="Calendar"]//td[@role="button"]/*[text() = "15"]'
97
+ '//*[@role="application"][@aria-label="Calendar"]//button[text()="15"]'
100
98
  )
101
99
  )[ 0 ].click();
102
100
 
@@ -473,15 +473,18 @@ describe( 'RichText', () => {
473
473
  await page.keyboard.press( 'Enter' );
474
474
  await page.keyboard.type( ' 2' );
475
475
 
476
- // Select all and copy.
476
+ // Select all text.
477
+ await pressKeyWithModifier( 'primary', 'a' );
478
+ // Select the nested list.
479
+ await pressKeyWithModifier( 'primary', 'a' );
480
+ // Select the parent list item.
481
+ await pressKeyWithModifier( 'primary', 'a' );
482
+ // Select all the parent list item text.
483
+ await pressKeyWithModifier( 'primary', 'a' );
484
+ // Select the entire list.
477
485
  await pressKeyWithModifier( 'primary', 'a' );
478
486
  await pressKeyWithModifier( 'primary', 'c' );
479
487
 
480
- // Collapse the selection to the end.
481
- await page.keyboard.press( 'ArrowRight' );
482
-
483
- // Create a paragraph.
484
- await page.keyboard.press( 'Enter' );
485
488
  await page.keyboard.press( 'Enter' );
486
489
 
487
490
  // Paste paragraph contents.
@@ -57,13 +57,9 @@ describe( 'Scheduling', () => {
57
57
  await createNewPost();
58
58
 
59
59
  await page.click( '*[aria-label^="Change date"]' );
60
- await page.click(
61
- '*[aria-label="Move backward to switch to the previous month."]'
62
- );
60
+ await page.click( '*[aria-label="View previous month"]' );
63
61
  expect( await isDateTimeComponentFocused() ).toBe( true );
64
- await page.click(
65
- '*[aria-label="Move forward to switch to the next month."]'
66
- );
62
+ await page.click( '*[aria-label="View next month"]' );
67
63
  expect( await isDateTimeComponentFocused() ).toBe( true );
68
64
  } );
69
65
  } );
@@ -235,7 +235,7 @@ describe( 'splitting and merging blocks', () => {
235
235
  await page.keyboard.type( 'item 1' );
236
236
  await page.keyboard.press( 'Enter' );
237
237
  await page.keyboard.type( 'item 2' );
238
- await pressKeyTimes( 'ArrowUp', 2 );
238
+ await pressKeyTimes( 'ArrowUp', 5 );
239
239
  await page.keyboard.press( 'Delete' );
240
240
  // Carret should be in the first block and at the proper position.
241
241
  await page.keyboard.type( '-' );
@@ -257,13 +257,18 @@ describe( 'splitting and merging blocks', () => {
257
257
  await page.keyboard.press( 'Enter' );
258
258
  await page.keyboard.type( 'item 2' );
259
259
  await page.keyboard.press( 'ArrowUp' );
260
+ await page.keyboard.press( 'ArrowUp' );
260
261
  await pressKeyTimes( 'ArrowLeft', 6 );
261
262
  await page.keyboard.press( 'Backspace' );
262
263
  // Carret should be in the first block and at the proper position.
263
264
  await page.keyboard.type( '-' );
264
265
  expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
265
266
  "<!-- wp:paragraph -->
266
- <p>hi-item 1</p>
267
+ <p>hi</p>
268
+ <!-- /wp:paragraph -->
269
+
270
+ <!-- wp:paragraph -->
271
+ <p>-item 1</p>
267
272
  <!-- /wp:paragraph -->
268
273
 
269
274
  <!-- wp:paragraph -->
@@ -62,13 +62,11 @@ async function scheduleTestPost( postType, viewport ) {
62
62
  }
63
63
  // Set a publish date for the next month.
64
64
  await page.click( '.edit-post-post-schedule__toggle' );
65
- await page.click(
66
- '*[aria-label="Move forward to switch to the next month."]'
67
- );
65
+ await page.click( '*[aria-label="View next month"]' );
68
66
 
69
67
  await (
70
68
  await page.$x(
71
- '//*[@role="application"][@aria-label="Calendar"]//td[@role="button"]/*[text() = "15"]'
69
+ '//*[@role="application"][@aria-label="Calendar"]//button[text()="15"]'
72
70
  )
73
71
  )[ 0 ].click();
74
72
 
@@ -86,7 +86,8 @@ describe( 'Toolbar roving tabindex', () => {
86
86
  it( 'ensures list block toolbar uses roving tabindex', async () => {
87
87
  await insertBlock( 'List' );
88
88
  await page.keyboard.type( 'List' );
89
- await testBlockToolbarKeyboardNavigation( 'Block: List', 'List' );
89
+ await testBlockToolbarKeyboardNavigation( 'List text', 'Select List' );
90
+ await page.click( `[aria-label="Select List"]` );
90
91
  await wrapCurrentBlockWithGroup( 'List' );
91
92
  await testGroupKeyboardNavigation( 'Block: List', 'List' );
92
93
  } );
@@ -570,21 +570,25 @@ describe( 'Writing Flow', () => {
570
570
  expect( await getEditedPostContent() ).toMatchSnapshot();
571
571
  } );
572
572
 
573
- it( 'should allow selecting entire list with longer last item', async () => {
573
+ it( 'should extend selection into paragraph for list with longer last item', async () => {
574
574
  await page.keyboard.press( 'Enter' );
575
575
  await page.keyboard.type( 'a' );
576
576
  await page.keyboard.press( 'Enter' );
577
577
  await page.keyboard.type( '* b' );
578
578
  await page.keyboard.press( 'Enter' );
579
579
  await page.keyboard.type( 'cd' );
580
+
581
+ // Selects part of the first list item, although invisible.
580
582
  await pressKeyWithModifier( 'shift', 'ArrowUp' );
583
+ await page.evaluate( () => new Promise( window.requestIdleCallback ) );
584
+ // Extends selection into the first paragraph
581
585
  await pressKeyWithModifier( 'shift', 'ArrowUp' );
586
+ await page.evaluate( () => new Promise( window.requestIdleCallback ) );
582
587
 
583
- // Ensure multi selection is not triggered and selection stays within
584
- // the list.
588
+ // Mixed selection, so all content will be removed.
585
589
  await page.keyboard.press( 'Backspace' );
586
590
 
587
- expect( await getEditedPostContent() ).toMatchSnapshot();
591
+ expect( await getEditedPostContent() ).toBe( '' );
588
592
  } );
589
593
 
590
594
  it( 'should not have a dead zone between blocks (lower)', async () => {
@@ -157,9 +157,9 @@ describe( 'Post Editor Performance', () => {
157
157
  await page.evaluate( () => {
158
158
  const { createBlock } = window.wp.blocks;
159
159
  const { dispatch } = window.wp.data;
160
- const blocks = window.lodash
161
- .times( 1000 )
162
- .map( () => createBlock( 'core/paragraph' ) );
160
+ const blocks = Array.from( { length: 1000 } ).map( () =>
161
+ createBlock( 'core/paragraph' )
162
+ );
163
163
  dispatch( 'core/block-editor' ).resetBlocks( blocks );
164
164
  } );
165
165
  const paragraphs = await page.$$( '.wp-block' );
@@ -36,7 +36,8 @@ describe( 'Global styles sidebar', () => {
36
36
  const results = await page.$$(
37
37
  '.edit-site-block-types-item-list div[role="listitem"]'
38
38
  );
39
- expect( results.length ).toEqual( 1 );
39
+ // Matches both Heading and Table of Contents blocks. (The latter contains "heading" in its description.)
40
+ expect( results.length ).toEqual( 2 );
40
41
  } );
41
42
  } );
42
43
  } );
@@ -1,32 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import {
5
- activatePlugin,
6
- createNewPost,
7
- deactivatePlugin,
8
- openGlobalBlockInserter,
9
- } from '@wordpress/e2e-test-utils';
10
-
11
- describe( 'Register block type hooks', () => {
12
- beforeEach( async () => {
13
- await activatePlugin( 'gutenberg-test-register-block-type-hooks' );
14
- await createNewPost();
15
- } );
16
-
17
- afterEach( async () => {
18
- await deactivatePlugin( 'gutenberg-test-register-block-type-hooks' );
19
- } );
20
-
21
- it( 'has a custom category for Paragraph block', async () => {
22
- await openGlobalBlockInserter();
23
-
24
- const widgetsCategory = await page.waitForSelector(
25
- '.block-editor-block-types-list[aria-label="Widgets"]'
26
- );
27
-
28
- expect(
29
- await widgetsCategory.$( '.editor-block-list-item-paragraph' )
30
- ).toBeDefined();
31
- } );
32
- } );
@@ -1,58 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import {
5
- activatePlugin,
6
- createNewPost,
7
- deactivatePlugin,
8
- publishPost,
9
- } from '@wordpress/e2e-test-utils';
10
-
11
- describe( 'WP Editor Meta Boxes', () => {
12
- beforeAll( async () => {
13
- await activatePlugin( 'gutenberg-test-plugin-wp-editor-meta-box' );
14
- await createNewPost();
15
- } );
16
-
17
- afterAll( async () => {
18
- await deactivatePlugin( 'gutenberg-test-plugin-wp-editor-meta-box' );
19
- } );
20
-
21
- it( 'Should save the changes', async () => {
22
- // Add title to enable valid non-empty post save.
23
- await page.type( '.editor-post-title__input', 'Hello Meta' );
24
-
25
- // Type something.
26
- await expect( page ).toClick( '#test_tinymce_id-html' );
27
- await page.type( '#test_tinymce_id', 'Typing in a metabox' );
28
- await page.click( '#test_tinymce_id-tmce' );
29
-
30
- await publishPost();
31
-
32
- await page.reload();
33
- await page.waitForSelector( '.edit-post-layout' );
34
-
35
- await expect( page ).toClick( '#test_tinymce_id-html' );
36
- await page.waitForSelector( '#test_tinymce_id' );
37
- const content = await page.$eval(
38
- '#test_tinymce_id',
39
- ( textarea ) => textarea.value
40
- );
41
-
42
- /*
43
- * `content` may or may not contain the <p> tags depending on hasWpautop value in this line:
44
- * https://github.com/WordPress/wordpress-develop/blob/2382765afa36e10bf3c74420024ad4e85763a47c/src/js/_enqueues/vendor/tinymce/plugins/wordpress/plugin.js#L15
45
- *
46
- * Now, for the purposes of this e2e test we explicitly set wpautop to true in the test plugin:
47
- * https://github.com/WordPress/gutenberg/blob/3da717b8d0ac7d7821fc6d0475695ccf3ae2829f/packages/e2e-tests/plugins/wp-editor-metabox.php#L36
48
- *
49
- * If this test randomly fails because of the actual value being wrapped in <p> like <p>Typing in a metabox</p>, it means that
50
- * hasWpautop has been errorneously set to false in the line above. You may want to check:
51
- * * Is window.wp.editor.autop a function? It should be one since https://github.com/WordPress/gutenberg/pull/33228
52
- * * Is wpautop still true in the second link mentioned in this comment?
53
- *
54
- * For more context, see https://github.com/WordPress/gutenberg/pull/33228/files#r666897885
55
- */
56
- expect( content ).toBe( 'Typing in a metabox' );
57
- } );
58
- } );
@@ -1,21 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`Duplicating blocks should duplicate blocks using the block settings menu 1`] = `
4
- "<!-- wp:paragraph -->
5
- <p>Clone me</p>
6
- <!-- /wp:paragraph -->
7
-
8
- <!-- wp:paragraph -->
9
- <p>Clone me</p>
10
- <!-- /wp:paragraph -->"
11
- `;
12
-
13
- exports[`Duplicating blocks should duplicate blocks using the keyboard shortcut 1`] = `
14
- "<!-- wp:paragraph -->
15
- <p>Clone me</p>
16
- <!-- /wp:paragraph -->
17
-
18
- <!-- wp:paragraph -->
19
- <p>Clone me</p>
20
- <!-- /wp:paragraph -->"
21
- `;
@@ -1,47 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import {
5
- clickMenuItem,
6
- createNewPost,
7
- insertBlock,
8
- getEditedPostContent,
9
- clickBlockToolbarButton,
10
- pressKeyWithModifier,
11
- } from '@wordpress/e2e-test-utils';
12
-
13
- describe( 'Duplicating blocks', () => {
14
- beforeEach( async () => {
15
- await createNewPost();
16
- } );
17
-
18
- it( 'should duplicate blocks using the block settings menu', async () => {
19
- await insertBlock( 'Paragraph' );
20
- await page.keyboard.type( 'Clone me' );
21
-
22
- // Select the test we just typed
23
- // This doesn't do anything but we previously had a duplicationi bug
24
- // When the selection was not collapsed.
25
- await pressKeyWithModifier( 'primary', 'a' );
26
-
27
- await clickBlockToolbarButton( 'Options' );
28
- await clickMenuItem( 'Duplicate' );
29
-
30
- expect( await getEditedPostContent() ).toMatchSnapshot();
31
- } );
32
-
33
- it( 'should duplicate blocks using the keyboard shortcut', async () => {
34
- await insertBlock( 'Paragraph' );
35
- await page.keyboard.type( 'Clone me' );
36
-
37
- // Select the test we just typed
38
- // This doesn't do anything but we previously had a duplicationi bug
39
- // When the selection was not collapsed.
40
- await pressKeyWithModifier( 'primary', 'a' );
41
-
42
- // Duplicate using the keyboard shortccut.
43
- await pressKeyWithModifier( 'primaryShift', 'd' );
44
-
45
- expect( await getEditedPostContent() ).toMatchSnapshot();
46
- } );
47
- } );