@wordpress/e2e-tests 3.1.1 → 4.0.2

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 (44) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +2 -0
  3. package/config/flaky-tests-reporter.js +1 -0
  4. package/package.json +10 -8
  5. package/specs/editor/blocks/__snapshots__/buttons.test.js.snap +8 -0
  6. package/specs/editor/blocks/__snapshots__/navigation.test.js.snap +2 -2
  7. package/specs/editor/blocks/__snapshots__/separator.test.js.snap +1 -1
  8. package/specs/editor/blocks/buttons.test.js +10 -0
  9. package/specs/editor/blocks/columns.test.js +3 -3
  10. package/specs/editor/blocks/gallery.test.js +36 -6
  11. package/specs/editor/blocks/heading.test.js +1 -1
  12. package/specs/editor/blocks/navigation.test.js +370 -72
  13. package/specs/editor/blocks/query.test.js +13 -3
  14. package/specs/editor/plugins/annotations.test.js +63 -67
  15. package/specs/editor/various/__snapshots__/block-deletion.test.js.snap +20 -12
  16. package/specs/editor/various/__snapshots__/block-editor-keyboard-shortcuts.test.js.snap +26 -0
  17. package/specs/editor/various/__snapshots__/block-hierarchy-navigation.test.js.snap +1 -1
  18. package/specs/editor/various/__snapshots__/multi-block-selection.test.js.snap +122 -6
  19. package/specs/editor/various/__snapshots__/writing-flow.test.js.snap +6 -6
  20. package/specs/editor/various/autosave.test.js +3 -3
  21. package/specs/editor/various/block-deletion.test.js +1 -0
  22. package/specs/editor/various/block-editor-keyboard-shortcuts.test.js +3 -5
  23. package/specs/editor/various/block-hierarchy-navigation.test.js +10 -16
  24. package/specs/editor/various/block-locking.test.js +120 -0
  25. package/specs/editor/various/keyboard-navigable-blocks.test.js +23 -0
  26. package/specs/editor/various/list-view.test.js +139 -7
  27. package/specs/editor/various/multi-block-selection.test.js +153 -9
  28. package/specs/editor/various/toolbar-roving-tabindex.test.js +10 -4
  29. package/specs/editor/various/writing-flow.test.js +10 -5
  30. package/specs/experiments/blocks/comments-query.test.js +139 -0
  31. package/specs/experiments/navigation-editor.test.js +126 -121
  32. package/specs/performance/post-editor.test.js +4 -6
  33. package/specs/site-editor/global-styles-sidebar.test.js +42 -0
  34. package/specs/site-editor/iframe-rendering-mode.test.js +31 -0
  35. package/specs/site-editor/site-editor-export.test.js +2 -2
  36. package/specs/site-editor/style-variations.test.js +9 -7
  37. package/specs/site-editor/template-part.test.js +3 -1
  38. package/specs/editor/various/__snapshots__/copy-cut-paste-whole-blocks.test.js.snap +0 -125
  39. package/specs/editor/various/__snapshots__/post-editor-template-mode.test.js.snap +0 -27
  40. package/specs/editor/various/copy-cut-paste-whole-blocks.test.js +0 -187
  41. package/specs/editor/various/new-post.test.js +0 -99
  42. package/specs/editor/various/post-editor-template-mode.test.js +0 -377
  43. package/specs/site-editor/document-settings.test.js +0 -90
  44. package/specs/widgets/customizing-widgets.test.js +0 -913
package/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 4.0.0 (2022-04-08)
6
+
7
+ ### Breaking Changes
8
+
9
+ - There's currently an ongoing [project](https://github.com/WordPress/gutenberg/issues/38851) to migrate E2E tests to Playwright instead. This package is deprecated and will only accept bug fixes until fully migrated.
10
+
5
11
  ## 3.0.0 (2022-01-27)
6
12
 
7
13
  ### Breaking Changes
package/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  End-To-End (E2E) tests for WordPress.
4
4
 
5
+ **Note that there's currently an ongoing [project](https://github.com/WordPress/gutenberg/issues/38851) to migrate E2E tests to Playwright instead. This package is deprecated and will only accept bug fixes until fully migrated.**
6
+
5
7
  ## Installation
6
8
 
7
9
  Install the module
@@ -56,6 +56,7 @@ class FlakyTestsReporter {
56
56
  await fs.writeFile(
57
57
  `flaky-tests/${ filenamify( testTitle ) }.json`,
58
58
  JSON.stringify( {
59
+ runner: 'jest-circus',
59
60
  title: testTitle,
60
61
  path: testPath,
61
62
  results: failingResults,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/e2e-tests",
3
- "version": "3.1.1",
3
+ "version": "4.0.2",
4
4
  "description": "End-To-End (E2E) tests for WordPress.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -23,11 +23,11 @@
23
23
  "node": ">=12"
24
24
  },
25
25
  "dependencies": {
26
- "@wordpress/e2e-test-utils": "^7.0.1",
27
- "@wordpress/jest-console": "^5.0.2",
28
- "@wordpress/jest-puppeteer-axe": "^4.0.2",
29
- "@wordpress/scripts": "^22.2.1",
30
- "@wordpress/url": "^3.5.1",
26
+ "@wordpress/e2e-test-utils": "^7.2.1",
27
+ "@wordpress/jest-console": "^5.0.3",
28
+ "@wordpress/jest-puppeteer-axe": "^4.0.3",
29
+ "@wordpress/scripts": "^22.4.1",
30
+ "@wordpress/url": "^3.7.1",
31
31
  "chalk": "^4.0.0",
32
32
  "expect-puppeteer": "^4.4.0",
33
33
  "filenamify": "^4.2.0",
@@ -39,10 +39,12 @@
39
39
  },
40
40
  "peerDependencies": {
41
41
  "jest": ">=27",
42
- "puppeteer-core": ">=11"
42
+ "puppeteer-core": ">=11",
43
+ "react": "^17.0.0",
44
+ "react-dom": "^17.0.0"
43
45
  },
44
46
  "publishConfig": {
45
47
  "access": "public"
46
48
  },
47
- "gitHead": "3494eafea7cb345728166c902b3d1223c4a8db6f"
49
+ "gitHead": "446565ecaa40370173c18926535e975ec5652b71"
48
50
  }
@@ -16,6 +16,14 @@ exports[`Buttons dismisses link editor when escape is pressed 1`] = `
16
16
  <!-- /wp:buttons -->"
17
17
  `;
18
18
 
19
+ exports[`Buttons has focus on button content (slash inserter) 1`] = `
20
+ "<!-- wp:buttons -->
21
+ <div class=\\"wp-block-buttons\\"><!-- wp:button -->
22
+ <div class=\\"wp-block-button\\"><a class=\\"wp-block-button__link\\">Content</a></div>
23
+ <!-- /wp:button --></div>
24
+ <!-- /wp:buttons -->"
25
+ `;
26
+
19
27
  exports[`Buttons has focus on button content 1`] = `
20
28
  "<!-- wp:buttons -->
21
29
  <div class=\\"wp-block-buttons\\"><!-- wp:button -->
@@ -1,5 +1,7 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
+ exports[`Navigation Creating and restarting converts uncontrolled inner blocks to an entity when modifications are made to the blocks 1`] = `"<!-- wp:navigation-link {\\"label\\":\\"A Test Page\\",\\"type\\":\\"page\\",\\"id\\":[number],\\"url\\":\\"http://localhost:8889/?page_id=[number]\\",\\"kind\\":\\"post-type\\"} /-->"`;
4
+
3
5
  exports[`Navigation Placeholder placeholder actions allows a navigation block to be created from existing menus 1`] = `
4
6
  "<!-- wp:navigation-link {\\"label\\":\\"Home\\",\\"type\\":\\"custom\\",\\"url\\":\\"http://localhost:8889/\\",\\"kind\\":\\"custom\\"} /-->
5
7
 
@@ -43,5 +45,3 @@ exports[`Navigation encodes URL when create block if needed 1`] = `
43
45
 
44
46
  <!-- wp:navigation-link {\\"label\\":\\"お問い合わせ\\",\\"type\\":\\"page\\",\\"id\\":[number],\\"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} /-->"
45
47
  `;
46
-
47
- exports[`Navigation supports navigation blocks that have inner blocks within their markup and converts them to wp_navigation posts 1`] = `"<!-- wp:page-list /-->"`;
@@ -2,6 +2,6 @@
2
2
 
3
3
  exports[`Separator can be created by three dashes and enter 1`] = `
4
4
  "<!-- wp:separator -->
5
- <hr class=\\"wp-block-separator\\"/>
5
+ <hr class=\\"wp-block-separator has-alpha-channel-opacity\\"/>
6
6
  <!-- /wp:separator -->"
7
7
  `;
@@ -6,6 +6,7 @@ import {
6
6
  getEditedPostContent,
7
7
  createNewPost,
8
8
  pressKeyWithModifier,
9
+ clickBlockAppender,
9
10
  } from '@wordpress/e2e-test-utils';
10
11
 
11
12
  describe( 'Buttons', () => {
@@ -20,6 +21,15 @@ describe( 'Buttons', () => {
20
21
  expect( await getEditedPostContent() ).toMatchSnapshot();
21
22
  } );
22
23
 
24
+ it( 'has focus on button content (slash inserter)', async () => {
25
+ await clickBlockAppender();
26
+ await page.keyboard.type( '/buttons' );
27
+ await page.keyboard.press( 'Enter' );
28
+ await page.keyboard.type( 'Content' );
29
+
30
+ expect( await getEditedPostContent() ).toMatchSnapshot();
31
+ } );
32
+
23
33
  it( 'dismisses link editor when escape is pressed', async () => {
24
34
  // Regression: https://github.com/WordPress/gutenberg/pull/19885
25
35
  await insertBlock( 'Buttons' );
@@ -7,6 +7,7 @@ import {
7
7
  insertBlock,
8
8
  openGlobalBlockInserter,
9
9
  closeGlobalBlockInserter,
10
+ getListViewBlocks,
10
11
  } from '@wordpress/e2e-test-utils';
11
12
 
12
13
  describe( 'Columns', () => {
@@ -19,10 +20,9 @@ describe( 'Columns', () => {
19
20
  await closeGlobalBlockInserter();
20
21
  await page.click( '[aria-label="Two columns; equal split"]' );
21
22
  await page.click( '.edit-post-header-toolbar__list-view-toggle' );
23
+
22
24
  const columnBlockMenuItem = (
23
- await page.$x(
24
- '//a[contains(concat(" ", @class, " "), " block-editor-list-view-block-select-button ")][text()="Column"]'
25
- )
25
+ await getListViewBlocks( 'Column' )
26
26
  )[ 0 ];
27
27
  await columnBlockMenuItem.click();
28
28
  await openGlobalBlockInserter();
@@ -14,6 +14,8 @@ import {
14
14
  getEditedPostContent,
15
15
  createNewPost,
16
16
  clickButton,
17
+ openListView,
18
+ getListViewBlocks,
17
19
  } from '@wordpress/e2e-test-utils';
18
20
 
19
21
  async function upload( selector ) {
@@ -47,7 +49,7 @@ describe( 'Gallery', () => {
47
49
  const filename = await upload( '.wp-block-gallery input[type="file"]' );
48
50
 
49
51
  const regex = new RegExp(
50
- `<!-- wp:gallery {\\"linkTo\\":\\"none\\"} -->\\s*<figure class=\\"wp-block-gallery has-nested-images columns-default is-cropped\\"><!-- wp:image {\\"id\\":\\d+,\\"sizeSlug\\":\\"full\\",\\"linkDestination\\":\\"none\\"} -->\\s*<figure class=\\"wp-block-image size-full\\"><img src=\\"[^"]+\/${ filename }\.png\\" alt=\\"\\" class=\\"wp-image-\\d+\\"\/><\/figure>\\s*<!-- \/wp:image --><\/figure>\\s*<!-- \/wp:gallery -->`
52
+ `<!-- wp:gallery {\\"linkTo\\":\\"none\\"} -->\\s*<figure class=\\"wp-block-gallery has-nested-images columns-default is-cropped\\"><!-- wp:image {\\"id\\":\\d+,\\"sizeSlug\\":\\"(?:full|large)\\",\\"linkDestination\\":\\"none\\"} -->\\s*<figure class=\\"wp-block-image (?:size-full|size-large)\\"><img src=\\"[^"]+\/${ filename }\.png\\" alt=\\"\\" class=\\"wp-image-\\d+\\"\/><\/figure>\\s*<!-- \/wp:image --><\/figure>\\s*<!-- \/wp:gallery -->`
51
53
  );
52
54
  expect( await getEditedPostContent() ).toMatch( regex );
53
55
  } );
@@ -59,11 +61,15 @@ describe( 'Gallery', () => {
59
61
  await upload( '.wp-block-gallery input[type="file"]' );
60
62
  await page.waitForSelector( '.wp-block-gallery .wp-block-image' );
61
63
 
62
- // The newly added image gets the focus, so refocus parent Gallery
63
- // block before trying to edit caption.
64
- await clickButton( 'Gallery' );
64
+ // The Gallery needs to be selected from the List view panel due to the
65
+ // way that Image uploads take and lose focus.
66
+ await openListView();
67
+
68
+ const galleryListLink = ( await getListViewBlocks( 'Gallery' ) )[ 0 ];
69
+ await galleryListLink.click();
65
70
 
66
71
  await page.click( '.wp-block-gallery .blocks-gallery-caption' );
72
+
67
73
  await page.keyboard.type( galleryCaption );
68
74
 
69
75
  expect( await getEditedPostContent() ).toMatch(
@@ -79,15 +85,39 @@ describe( 'Gallery', () => {
79
85
  '.wp-block-gallery .wp-block-image'
80
86
  );
81
87
 
82
- await figureElement.click();
88
+ // Check that the Image is unselected, in which case the figcaption won't be
89
+ // in the DOM - due the way that the Gallery block handles the upload the latest
90
+ // image gets selected in order to scroll to the position of it, as in large
91
+ // galleries the new upload may be off-canvas. After upload the image is unselected
92
+ // so if we don't check for that it may get unselected again by this flow after we
93
+ // have re-selected it to edit it.
94
+ await page.waitForFunction(
95
+ () => ! document.querySelector( '.wp-block-image figcaption' )
96
+ );
97
+
98
+ // The Image needs to be selected from the List view panel due to the
99
+ // way that Image uploads take and lose focus.
100
+ await openListView();
101
+
102
+ // Due to collapsed state of ListView nodes Gallery must be expanded to reveal the child blocks.
103
+ // This xpath selects the anchor node for the block which has a child span which contains the text
104
+ // label of the block and then selects the expander span for that node.
105
+ const galleryExpander = await page.waitForXPath(
106
+ `//a[span[text()='Gallery']]/span[contains(@class, 'block-editor-list-view__expander')]`
107
+ );
108
+
109
+ await galleryExpander.click();
110
+
111
+ const imageListLink = ( await getListViewBlocks( 'Image' ) )[ 0 ];
112
+ await imageListLink.click();
83
113
 
84
114
  const captionElement = await figureElement.$(
85
115
  '.block-editor-rich-text__editable'
86
116
  );
87
117
 
118
+ await captionElement.click();
88
119
  const caption = 'Tested caption';
89
120
 
90
- await captionElement.click();
91
121
  await page.keyboard.type( caption );
92
122
 
93
123
  expect( await getEditedPostContent() ).toMatch(
@@ -88,7 +88,7 @@ describe( 'Heading', () => {
88
88
  await pressKeyWithModifier( 'primary', 'A' );
89
89
  await page.keyboard.type( '0782f6' );
90
90
  await page.click( 'h3[data-type="core/heading"]' );
91
- await page.waitForXPath( '//button[text()="#0782f6"]' );
91
+ await page.waitForXPath( '//button//span[contains(text(), "0782f6")]' );
92
92
  expect( await getEditedPostContent() ).toMatchSnapshot();
93
93
  } );
94
94