@wordpress/e2e-tests 2.5.9 → 3.0.1-next.33ec3857e2.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 (35) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/config/flaky-tests-reporter.js +2 -1
  3. package/package.json +10 -9
  4. package/specs/editor/blocks/__snapshots__/heading.test.js.snap +2 -2
  5. package/specs/editor/blocks/__snapshots__/navigation.test.js.snap +27 -59
  6. package/specs/editor/blocks/columns.test.js +1 -1
  7. package/specs/editor/blocks/cover.test.js +4 -1
  8. package/specs/editor/blocks/heading.test.js +15 -3
  9. package/specs/editor/blocks/image.test.js +15 -11
  10. package/specs/editor/blocks/navigation.test.js +264 -370
  11. package/specs/editor/blocks/preformatted.test.js +2 -1
  12. package/specs/editor/blocks/site-title.test.js +2 -31
  13. package/specs/editor/fixtures/menu-items-request-fixture.json +84 -0
  14. package/specs/editor/fixtures/menu-items-response-fixture.json +240 -144
  15. package/specs/editor/plugins/custom-post-types.test.js +4 -3
  16. package/specs/editor/various/adding-patterns.test.js +1 -1
  17. package/specs/editor/various/block-grouping.test.js +30 -0
  18. package/specs/editor/various/block-hierarchy-navigation.test.js +3 -3
  19. package/specs/editor/various/change-detection.test.js +5 -0
  20. package/specs/editor/various/editor-modes.test.js +7 -0
  21. package/specs/editor/various/font-size-picker.test.js +1 -7
  22. package/specs/editor/various/format-library/__snapshots__/text-color.test.js.snap +13 -0
  23. package/specs/editor/various/format-library/text-color.test.js +46 -0
  24. package/specs/editor/various/inserting-blocks.test.js +6 -2
  25. package/specs/editor/various/keyboard-navigable-blocks.test.js +6 -0
  26. package/specs/editor/various/list-view.test.js +2 -2
  27. package/specs/editor/various/navigable-toolbar.test.js +2 -2
  28. package/specs/editor/various/preview.test.js +1 -1
  29. package/specs/editor/various/reusable-blocks.test.js +1 -26
  30. package/specs/editor/various/writing-flow.test.js +8 -4
  31. package/specs/site-editor/document-settings.test.js +6 -6
  32. package/specs/site-editor/multi-entity-saving.test.js +108 -55
  33. package/specs/site-editor/settings-sidebar.test.js +2 -3
  34. package/specs/site-editor/template-part.test.js +88 -68
  35. package/specs/widgets/customizing-widgets.test.js +4 -0
@@ -7,6 +7,7 @@ import {
7
7
  deactivatePlugin,
8
8
  publishPost,
9
9
  findSidebarPanelWithTitle,
10
+ clickBlockAppender,
10
11
  } from '@wordpress/e2e-test-utils';
11
12
 
12
13
  const openPageAttributesPanel = async () => {
@@ -40,7 +41,7 @@ describe( 'Test Custom Post Types', () => {
40
41
 
41
42
  // Create a parent post.
42
43
  await createNewPost( { postType: 'hierar-no-title' } );
43
- await page.click( '.block-editor-writing-flow' );
44
+ await clickBlockAppender();
44
45
  await page.keyboard.type( 'Parent Post' );
45
46
  await publishPost();
46
47
  // Create a post that is a child of the previously created post.
@@ -55,7 +56,7 @@ describe( 'Test Custom Post Types', () => {
55
56
  ( element ) => element.textContent
56
57
  );
57
58
  await optionToSelect.click();
58
- await page.click( '.block-editor-writing-flow' );
59
+ await clickBlockAppender();
59
60
  await page.keyboard.type( 'Child Post' );
60
61
  await publishPost();
61
62
  // Reload the child post and verify it is still correctly selected as a child post.
@@ -72,7 +73,7 @@ describe( 'Test Custom Post Types', () => {
72
73
  } );
73
74
  it( 'should create a cpt with a legacy block in its template without WSOD', async () => {
74
75
  await createNewPost( { postType: 'leg_block_in_tpl' } );
75
- await page.click( '.block-editor-writing-flow' );
76
+ await clickBlockAppender();
76
77
  await page.keyboard.type( 'Hello there' );
77
78
  await page.waitForSelector( '[data-type="core/embed"]' );
78
79
  await publishPost();
@@ -7,7 +7,7 @@ import {
7
7
  getEditedPostContent,
8
8
  } from '@wordpress/e2e-test-utils';
9
9
 
10
- /** @typedef {import('puppeteer').ElementHandle} ElementHandle */
10
+ /** @typedef {import('puppeteer-core').ElementHandle} ElementHandle */
11
11
 
12
12
  describe( 'adding patterns', () => {
13
13
  beforeEach( async () => {
@@ -13,6 +13,7 @@ import {
13
13
  getAvailableBlockTransforms,
14
14
  activatePlugin,
15
15
  deactivatePlugin,
16
+ createReusableBlock,
16
17
  } from '@wordpress/e2e-test-utils';
17
18
 
18
19
  async function insertBlocksOfSameType() {
@@ -110,6 +111,35 @@ describe( 'Block Grouping', () => {
110
111
  );
111
112
  expect( ungroupButtons ).toHaveLength( 0 );
112
113
  } );
114
+ it( 'should group and ungroup a controlled block properly', async () => {
115
+ const getParagraphText = async () => {
116
+ const paragraphInReusableSelector =
117
+ '.block-editor-block-list__block[data-type="core/block"] p';
118
+ await page.waitForSelector( paragraphInReusableSelector );
119
+ return page.$eval(
120
+ paragraphInReusableSelector,
121
+ ( element ) => element.innerText
122
+ );
123
+ };
124
+
125
+ const paragraphText = 'hi';
126
+ await createReusableBlock( paragraphText, 'Block' );
127
+ // Group
128
+ await clickBlockToolbarButton( 'Options' );
129
+ await clickMenuItem( 'Group' );
130
+
131
+ let group = await page.$$( '[data-type="core/group"]' );
132
+ expect( group ).toHaveLength( 1 );
133
+ // Make sure the paragraph in reusable block exists.
134
+ expect( await getParagraphText() ).toMatch( paragraphText );
135
+
136
+ await clickBlockToolbarButton( 'Options' );
137
+ await clickMenuItem( 'Ungroup' );
138
+ group = await page.$$( '[data-type="core/group"]' );
139
+ expect( group ).toHaveLength( 0 );
140
+ // Make sure the paragraph in reusable block exists.
141
+ expect( await getParagraphText() ).toEqual( paragraphText );
142
+ } );
113
143
  } );
114
144
 
115
145
  describe( 'Grouping Block availability', () => {
@@ -51,7 +51,7 @@ describe( 'Navigating the block hierarchy', () => {
51
51
  await page.click( '.edit-post-header-toolbar__list-view-toggle' );
52
52
  const columnsBlockMenuItem = (
53
53
  await page.$x(
54
- "//button[contains(@class,'block-editor-list-view-block-select-button') and contains(text(), 'Columns')]"
54
+ "//a[contains(@class,'block-editor-list-view-block-select-button') and contains(text(), 'Columns')]"
55
55
  )
56
56
  )[ 0 ];
57
57
  await columnsBlockMenuItem.click();
@@ -75,7 +75,7 @@ describe( 'Navigating the block hierarchy', () => {
75
75
  // Navigate to the last column block.
76
76
  const lastColumnsBlockMenuItem = (
77
77
  await page.$x(
78
- "//button[contains(@class,'block-editor-list-view-block-select-button') and contains(text(), 'Column')]"
78
+ "//a[contains(@class,'block-editor-list-view-block-select-button') and contains(text(), 'Column')]"
79
79
  )
80
80
  )[ 3 ];
81
81
  await lastColumnsBlockMenuItem.click();
@@ -188,7 +188,7 @@ describe( 'Navigating the block hierarchy', () => {
188
188
  await page.click( '.edit-post-header-toolbar__list-view-toggle' );
189
189
  const groupMenuItem = (
190
190
  await page.$x(
191
- "//button[contains(@class,'block-editor-list-view-block-select-button') and contains(text(), 'Group')]"
191
+ "//a[contains(@class,'block-editor-list-view-block-select-button') and contains(text(), 'Group')]"
192
192
  )
193
193
  )[ 0 ];
194
194
  await groupMenuItem.click();
@@ -10,6 +10,7 @@ import {
10
10
  saveDraft,
11
11
  openDocumentSettingsSidebar,
12
12
  isCurrentURL,
13
+ openTypographyToolsPanelMenu,
13
14
  } from '@wordpress/e2e-test-utils';
14
15
 
15
16
  describe( 'Change detection', () => {
@@ -381,6 +382,10 @@ describe( 'Change detection', () => {
381
382
 
382
383
  // Change the paragraph's `drop cap`.
383
384
  await page.click( '[data-type="core/paragraph"]' );
385
+
386
+ await openTypographyToolsPanelMenu();
387
+ await page.click( 'button[aria-label="Show Drop cap"]' );
388
+
384
389
  const [ dropCapToggle ] = await page.$x(
385
390
  "//label[contains(text(), 'Drop cap')]"
386
391
  );
@@ -10,6 +10,7 @@ import {
10
10
  switchEditorModeTo,
11
11
  pressKeyTimes,
12
12
  pressKeyWithModifier,
13
+ openTypographyToolsPanelMenu,
13
14
  } from '@wordpress/e2e-test-utils';
14
15
 
15
16
  describe( 'Editing modes (visual/HTML)', () => {
@@ -54,6 +55,9 @@ describe( 'Editing modes (visual/HTML)', () => {
54
55
 
55
56
  // The `drop cap` toggle for the paragraph block should appear, even in
56
57
  // HTML editing mode.
58
+ await openTypographyToolsPanelMenu();
59
+ await page.click( 'button[aria-label="Show Drop cap"]' );
60
+
57
61
  const dropCapToggle = await page.$x(
58
62
  "//label[contains(text(), 'Drop cap')]"
59
63
  );
@@ -74,6 +78,9 @@ describe( 'Editing modes (visual/HTML)', () => {
74
78
  expect( htmlBlockContent ).toEqual( '<p>Hello world!</p>' );
75
79
 
76
80
  // Change the `drop cap` using the sidebar.
81
+ await openTypographyToolsPanelMenu();
82
+ await page.click( 'button[aria-label="Show Drop cap"]' );
83
+
77
84
  const [ dropCapToggle ] = await page.$x(
78
85
  "//label[contains(text(), 'Drop cap')]"
79
86
  );
@@ -8,6 +8,7 @@ import {
8
8
  pressKeyWithModifier,
9
9
  pressKeyTimes,
10
10
  activateTheme,
11
+ openTypographyToolsPanelMenu,
11
12
  } from '@wordpress/e2e-test-utils';
12
13
 
13
14
  const openFontSizeSelectControl = async () => {
@@ -17,13 +18,6 @@ const openFontSizeSelectControl = async () => {
17
18
  return selectControl.click();
18
19
  };
19
20
 
20
- const openTypographyToolsPanelMenu = async () => {
21
- const toggleSelector =
22
- "//div[contains(@class, 'typography-block-support-panel')]//button[contains(@class, 'components-dropdown-menu__toggle')]";
23
- const toggle = await page.waitForXPath( toggleSelector );
24
- return toggle.click();
25
- };
26
-
27
21
  const FONT_SIZE_TOGGLE_GROUP_SELECTOR =
28
22
  "//div[contains(@class, 'components-font-size-picker__controls')]//div[contains(@class, 'components-toggle-group-control')]";
29
23
 
@@ -0,0 +1,13 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`RichText should remove highlighting element 1`] = `
4
+ "<!-- wp:paragraph -->
5
+ <p><mark style=\\"background-color:rgba(0, 0, 0, 0)\\" class=\\"has-inline-color has-cyan-bluish-gray-color\\">1</mark></p>
6
+ <!-- /wp:paragraph -->"
7
+ `;
8
+
9
+ exports[`RichText should remove highlighting element 2`] = `
10
+ "<!-- wp:paragraph -->
11
+ <p>1</p>
12
+ <!-- /wp:paragraph -->"
13
+ `;
@@ -0,0 +1,46 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import {
5
+ createNewPost,
6
+ getEditedPostContent,
7
+ clickBlockAppender,
8
+ pressKeyWithModifier,
9
+ clickBlockToolbarButton,
10
+ } from '@wordpress/e2e-test-utils';
11
+
12
+ describe( 'RichText', () => {
13
+ beforeEach( async () => {
14
+ await createNewPost();
15
+ } );
16
+
17
+ it( 'should remove highlighting element', async () => {
18
+ await clickBlockAppender();
19
+
20
+ // Add text and select to color.
21
+ await page.keyboard.type( '1' );
22
+ await pressKeyWithModifier( 'primary', 'a' );
23
+ await clickBlockToolbarButton( 'More' );
24
+
25
+ const button = await page.waitForXPath(
26
+ `//button[text()='Highlight']`
27
+ );
28
+ // Clicks may fail if the button is out of view. Assure it is before click.
29
+ await button.evaluate( ( element ) => element.scrollIntoView() );
30
+ await button.click();
31
+
32
+ // Use a color name with multiple words to ensure that it becomes
33
+ // active. Previously we had a broken regular expression.
34
+ const option = await page.waitForSelector(
35
+ '[aria-label="Color: Cyan bluish gray"]'
36
+ );
37
+
38
+ await option.click();
39
+
40
+ expect( await getEditedPostContent() ).toMatchSnapshot();
41
+
42
+ await option.click();
43
+
44
+ expect( await getEditedPostContent() ).toMatchSnapshot();
45
+ } );
46
+ } );
@@ -14,7 +14,7 @@ import {
14
14
  pressKeyWithModifier,
15
15
  } from '@wordpress/e2e-test-utils';
16
16
 
17
- /** @typedef {import('puppeteer').ElementHandle} ElementHandle */
17
+ /** @typedef {import('puppeteer-core').ElementHandle} ElementHandle */
18
18
 
19
19
  /**
20
20
  * Waits for all patterns in the inserter to have a height, which should
@@ -173,7 +173,7 @@ describe( 'Inserting blocks', () => {
173
173
  // Check for regression of https://github.com/WordPress/gutenberg/issues/9583
174
174
  it( 'should not allow transfer of focus outside of the block-insertion menu once open', async () => {
175
175
  // Enter the default block and click the inserter toggle button to the left of it.
176
- await page.keyboard.press( 'ArrowDown' );
176
+ await page.keyboard.press( 'Enter' );
177
177
  await showBlockToolbar();
178
178
  await page.click(
179
179
  '.block-editor-block-list__empty-block-inserter .block-editor-inserter__toggle'
@@ -243,6 +243,10 @@ describe( 'Inserting blocks', () => {
243
243
  );
244
244
  expect( selectedButtonBlocks.length ).toBe( 1 );
245
245
 
246
+ // The block appender is only visible when there's no selection.
247
+ await page.evaluate( () =>
248
+ window.wp.data.dispatch( 'core/block-editor' ).clearSelectedBlock()
249
+ );
246
250
  // Specifically click the root container appender.
247
251
  await page.click(
248
252
  '.block-editor-block-list__layout.is-root-container > .block-list-appender .block-editor-inserter__toggle'
@@ -155,6 +155,12 @@ describe( 'Order of block keyboard navigation', () => {
155
155
  .focus();
156
156
  } );
157
157
 
158
+ await pressKeyWithModifier( 'shift', 'Tab' );
159
+ await expect( await getActiveLabel() ).toBe( 'Add block' );
160
+
161
+ await pressKeyWithModifier( 'shift', 'Tab' );
162
+ await expect( await getActiveLabel() ).toBe( 'Add default block' );
163
+
158
164
  await pressKeyWithModifier( 'shift', 'Tab' );
159
165
  await expect( await getActiveLabel() ).toBe(
160
166
  'Paragraph Block. Row 2. 1'
@@ -42,12 +42,12 @@ describe( 'List view', () => {
42
42
  await pressKeyWithModifier( 'access', 'o' );
43
43
 
44
44
  const paragraphBlock = await page.waitForXPath(
45
- '//button[contains(., "Paragraph")][@draggable="true"]'
45
+ '//a[contains(., "Paragraph")][@draggable="true"]'
46
46
  );
47
47
 
48
48
  // Drag above the heading block
49
49
  const headingBlock = await page.waitForXPath(
50
- '//button[contains(., "Heading")][@draggable="true"]'
50
+ '//a[contains(., "Heading")][@draggable="true"]'
51
51
  );
52
52
 
53
53
  await dragAndDrop( paragraphBlock, headingBlock, -5 );
@@ -31,8 +31,8 @@ describe.each( [
31
31
 
32
32
  it( 'navigates in and out of toolbar by keyboard (Alt+F10, Escape)', async () => {
33
33
  // Assumes new post focus starts in title. Create first new
34
- // block by ArrowDown.
35
- await page.keyboard.press( 'ArrowDown' );
34
+ // block by Enter.
35
+ await page.keyboard.press( 'Enter' );
36
36
 
37
37
  // [TEMPORARY]: A new paragraph is not technically a block yet
38
38
  // until starting to type within it.
@@ -14,7 +14,7 @@ import {
14
14
  pressKeyWithModifier,
15
15
  } from '@wordpress/e2e-test-utils';
16
16
 
17
- /** @typedef {import('puppeteer').Page} Page */
17
+ /** @typedef {import('puppeteer-core').Page} Page */
18
18
 
19
19
  /**
20
20
  * Given the Page instance for the editor, opens preview drodpdown, and
@@ -14,6 +14,7 @@ import {
14
14
  toggleGlobalBlockInserter,
15
15
  openDocumentSettingsSidebar,
16
16
  saveDraft,
17
+ createReusableBlock,
17
18
  } from '@wordpress/e2e-test-utils';
18
19
 
19
20
  const reusableBlockNameInputSelector =
@@ -44,32 +45,6 @@ const clearAllBlocks = async () => {
44
45
  } );
45
46
  };
46
47
 
47
- const createReusableBlock = async ( content, title ) => {
48
- // Insert a paragraph block
49
- await insertBlock( 'Paragraph' );
50
- await page.keyboard.type( content );
51
-
52
- await clickBlockToolbarButton( 'Options' );
53
- await clickMenuItem( 'Add to Reusable blocks' );
54
- const nameInput = await page.waitForSelector(
55
- reusableBlockNameInputSelector
56
- );
57
- await nameInput.click();
58
- await page.keyboard.type( title );
59
- await page.keyboard.press( 'Enter' );
60
-
61
- // Wait for creation to finish
62
- await page.waitForXPath(
63
- '//*[contains(@class, "components-snackbar")]/*[text()="Reusable block created."]'
64
- );
65
-
66
- // Check that we have a reusable block on the page
67
- const block = await page.waitForSelector(
68
- '.block-editor-block-list__block[data-type="core/block"]'
69
- );
70
- expect( block ).not.toBeNull();
71
- };
72
-
73
48
  describe( 'Reusable blocks', () => {
74
49
  afterAll( async () => {
75
50
  await trashAllPosts( 'wp_block' );
@@ -45,9 +45,11 @@ const addParagraphsAndColumnsDemo = async () => {
45
45
  await page.keyboard.press( 'Enter' ); // Insert paragraph.
46
46
  await page.keyboard.type( '2nd col' ); // If this text is too long, it may wrap to a new line and cause test failure. That's why we're using "2nd" instead of "Second" here.
47
47
 
48
- // Arrow down from last of layouts exits nested context to default
49
- // appender of root level.
50
- await page.keyboard.press( 'ArrowDown' );
48
+ await page.keyboard.press( 'Escape' ); // Enter navigation mode
49
+ await page.keyboard.press( 'ArrowLeft' ); // move to the column block
50
+ await page.keyboard.press( 'ArrowLeft' ); // move to the columns block
51
+ await page.keyboard.press( 'Enter' ); // Enter edit mode with the columns block selected
52
+ await page.keyboard.press( 'Enter' ); // Creates a paragraph after the columns block.
51
53
  await page.keyboard.type( 'Second paragraph' );
52
54
  };
53
55
 
@@ -289,6 +291,8 @@ describe( 'Writing Flow', () => {
289
291
  // See: https://github.com/WordPress/gutenberg/issues/9626
290
292
 
291
293
  await insertBlock( 'Shortcode' );
294
+ await insertBlock( 'Paragraph' );
295
+ await await page.click( '.wp-block-shortcode' );
292
296
 
293
297
  // Should remain in title upon ArrowRight:
294
298
  await page.keyboard.press( 'ArrowRight' );
@@ -304,7 +308,7 @@ describe( 'Writing Flow', () => {
304
308
  );
305
309
  expect( isInShortcodeBlock ).toBe( true );
306
310
 
307
- // Should navigate into blocks list upon ArrowDown:
311
+ // Should navigate to the next block.
308
312
  await page.keyboard.press( 'ArrowDown' );
309
313
  const isInParagraphBlock = await page.evaluate(
310
314
  () => !! document.activeElement.closest( '.wp-block-paragraph' )
@@ -13,7 +13,7 @@ async function getDocumentSettingsTitle() {
13
13
  '.edit-site-document-actions__title'
14
14
  );
15
15
 
16
- return titleElement.evaluate( ( el ) => el.innerText );
16
+ return titleElement.evaluate( ( el ) => el.textContent );
17
17
  }
18
18
 
19
19
  async function getDocumentSettingsSecondaryTitle() {
@@ -21,7 +21,7 @@ async function getDocumentSettingsSecondaryTitle() {
21
21
  '.edit-site-document-actions__secondary-item'
22
22
  );
23
23
 
24
- return secondaryTitleElement.evaluate( ( el ) => el.innerText );
24
+ return secondaryTitleElement.evaluate( ( el ) => el.textContent );
25
25
  }
26
26
 
27
27
  describe( 'Document Settings', () => {
@@ -50,7 +50,7 @@ describe( 'Document Settings', () => {
50
50
  // Evaluate the document settings title
51
51
  const actual = await getDocumentSettingsTitle();
52
52
 
53
- expect( actual ).toEqual( 'Index' );
53
+ expect( actual ).toEqual( 'Editing template: Index' );
54
54
  } );
55
55
 
56
56
  describe( 'and a template part is clicked in the template', () => {
@@ -60,7 +60,7 @@ describe( 'Document Settings', () => {
60
60
  '.edit-post-header-toolbar__list-view-toggle'
61
61
  );
62
62
  const headerTemplatePartListViewButton = await page.waitForXPath(
63
- '//button[contains(@class, "block-editor-list-view-block-select-button")][contains(., "Header")]'
63
+ '//a[contains(@class, "block-editor-list-view-block-select-button")][contains(., "Header")]'
64
64
  );
65
65
  headerTemplatePartListViewButton.click();
66
66
  await page.click(
@@ -70,7 +70,7 @@ describe( 'Document Settings', () => {
70
70
  // Evaluate the document settings secondary title
71
71
  const actual = await getDocumentSettingsSecondaryTitle();
72
72
 
73
- expect( actual ).toEqual( 'Header' );
73
+ expect( actual ).toEqual( 'Editing template part: header' );
74
74
  } );
75
75
  } );
76
76
  } );
@@ -86,7 +86,7 @@ describe( 'Document Settings', () => {
86
86
  // Evaluate the document settings title
87
87
  const actual = await getDocumentSettingsTitle();
88
88
 
89
- expect( actual ).toEqual( 'header' );
89
+ expect( actual ).toEqual( 'Editing template part: header' );
90
90
  } );
91
91
  } );
92
92
  } );