@wordpress/e2e-tests 6.5.1 → 7.1.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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 7.1.0 (2023-03-29)
6
+
7
+ ## 7.0.0 (2023-03-15)
8
+
9
+ ### Breaking Changes
10
+
11
+ - Started requiring Jest v29 instead of v27 as a peer dependency. See [breaking changes in Jest 28](https://jestjs.io/blog/2022/04/25/jest-28) and [in jest 29](https://jestjs.io/blog/2022/08/25/jest-29) ([#47388](https://github.com/WordPress/gutenberg/pull/47388))
12
+
5
13
  ## 6.5.0 (2023-03-01)
6
14
 
7
15
  ## 6.4.0 (2023-02-15)
@@ -0,0 +1,7 @@
1
+ module.exports = ( api ) => {
2
+ api.cache( true );
3
+
4
+ return {
5
+ presets: [ '@wordpress/babel-preset-default' ],
6
+ };
7
+ };
@@ -19,9 +19,11 @@ const success = chalk.bold.green;
19
19
 
20
20
  class PerformanceReporter {
21
21
  onTestResult( test ) {
22
- const dirname = path.dirname( test.path );
23
22
  const basename = path.basename( test.path, '.js' );
24
- const filepath = path.join( dirname, basename + '.results.json' );
23
+ const filepath = path.join(
24
+ process.env.WP_ARTIFACTS_PATH,
25
+ basename + '.performance-results.json'
26
+ );
25
27
 
26
28
  if ( ! existsSync( filepath ) ) {
27
29
  return;
@@ -26,24 +26,24 @@ async function setupPage() {
26
26
  ] );
27
27
  }
28
28
 
29
- // Before every test suite run, delete all content created by the test. This ensures
30
- // other posts/comments/etc. aren't dirtying tests and tests don't depend on
31
- // each other's side-effects.
29
+ // Before every test suite run, delete all content created by the test. This
30
+ // ensures other posts/comments/etc. aren't dirtying tests and tests don't
31
+ // depend on each other's side-effects.
32
32
  beforeAll( async () => {
33
33
  enablePageDialogAccept();
34
34
 
35
35
  await trashAllPosts();
36
36
  await trashAllPosts( 'wp_block' );
37
+ await activatePlugin( 'gutenberg-test-plugin-disables-the-css-animations' );
37
38
  await clearLocalStorage();
38
39
  await setupPage();
39
- await activatePlugin( 'gutenberg-test-plugin-disables-the-css-animations' );
40
40
  } );
41
41
 
42
42
  afterEach( async () => {
43
43
  // Clear localStorage between tests so that the next test starts clean.
44
44
  await clearLocalStorage();
45
- // Close the previous page entirely and create a new page, so that the next test
46
- // isn't affected by page unload work.
45
+ // Close the previous page entirely and create a new page, so that the next
46
+ // test isn't affected by page unload work.
47
47
  await page.close();
48
48
  page = await browser.newPage();
49
49
  // Set up testing config on new page.
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { get } from 'lodash';
5
4
  import { toMatchInlineSnapshot, toMatchSnapshot } from 'jest-snapshot';
6
5
 
7
6
  /**
@@ -172,11 +171,7 @@ function observeConsoleLogging() {
172
171
  // correctly. Instead, the logic here synchronously inspects the
173
172
  // internal object shape of the JSHandle to find the error text. If it
174
173
  // cannot be found, the default text value is used instead.
175
- text = get(
176
- message.args(),
177
- [ 0, '_remoteObject', 'description' ],
178
- text
179
- );
174
+ text = message.args()[ 0 ]?._remoteObject?.description ?? text;
180
175
 
181
176
  // Disable reason: We intentionally bubble up the console message
182
177
  // which, unless the test explicitly anticipates the logging via
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/e2e-tests",
3
- "version": "6.5.1",
3
+ "version": "7.1.0",
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,22 +23,21 @@
23
23
  "node": ">=14"
24
24
  },
25
25
  "dependencies": {
26
- "@wordpress/e2e-test-utils": "^9.5.0",
27
- "@wordpress/jest-console": "^6.11.0",
28
- "@wordpress/jest-puppeteer-axe": "^5.11.0",
29
- "@wordpress/scripts": "^25.5.1",
30
- "@wordpress/url": "^3.29.0",
26
+ "@wordpress/e2e-test-utils": "^10.1.0",
27
+ "@wordpress/jest-console": "^7.1.0",
28
+ "@wordpress/jest-puppeteer-axe": "^6.1.0",
29
+ "@wordpress/scripts": "^26.1.0",
30
+ "@wordpress/url": "^3.31.0",
31
31
  "chalk": "^4.0.0",
32
32
  "expect-puppeteer": "^4.4.0",
33
33
  "filenamify": "^4.2.0",
34
- "jest-message-util": "^27.4.2",
35
- "jest-snapshot": "^27.4.5",
36
- "lodash": "^4.17.21",
34
+ "jest-message-util": "^29.5.0",
35
+ "jest-snapshot": "^29.5.0",
37
36
  "puppeteer-testing-library": "^0.5.0",
38
37
  "uuid": "^8.3.0"
39
38
  },
40
39
  "peerDependencies": {
41
- "jest": ">=27",
40
+ "jest": ">=29",
42
41
  "puppeteer-core": ">=11",
43
42
  "react": "^18.0.0",
44
43
  "react-dom": "^18.0.0"
@@ -46,5 +45,5 @@
46
45
  "publishConfig": {
47
46
  "access": "public"
48
47
  },
49
- "gitHead": "9d7acdfd702a19732217460a5c7ed5eb78b10bc4"
48
+ "gitHead": "d5c28a67b11e91e3e4b8e90346bfcb90909364d6"
50
49
  }
@@ -42,30 +42,6 @@ describe( 'Cover', () => {
42
42
  await createNewPost();
43
43
  } );
44
44
 
45
- it( 'can set overlay color using color picker on block placeholder', async () => {
46
- await insertBlock( 'Cover' );
47
- // Get the first color option from the block placeholder's color picker.
48
- const colorPickerButton = await page.waitForSelector(
49
- '.wp-block-cover__placeholder-background-options .components-circular-option-picker__option-wrapper:first-child button'
50
- );
51
- // Get the RGB value of the picked color.
52
- const pickedColor = await colorPickerButton.evaluate(
53
- ( node ) => node.style.backgroundColor
54
- );
55
- // Create the block by clicking selected color button.
56
- await colorPickerButton.click();
57
- // Get the block's background dim element.
58
- const backgroundDim = await page.waitForSelector(
59
- '.wp-block-cover .has-background-dim'
60
- );
61
- // Get the RGB value of the background dim.
62
- const dimColor = await backgroundDim.evaluate(
63
- ( node ) => node.style.backgroundColor
64
- );
65
-
66
- expect( pickedColor ).toEqual( dimColor );
67
- } );
68
-
69
45
  it( 'can set background image using image upload on block placeholder', async () => {
70
46
  await insertBlock( 'Cover' );
71
47
  // Create the block using uploaded image.
@@ -95,27 +71,6 @@ describe( 'Cover', () => {
95
71
  expect( backgroundDimOpacity ).toBe( '0.5' );
96
72
  } );
97
73
 
98
- it( 'can have the title edited', async () => {
99
- await insertBlock( 'Cover' );
100
- // Click first color option from the block placeholder's color picker.
101
- const colorPickerButton = await page.waitForSelector(
102
- '.wp-block-cover__placeholder-background-options .components-circular-option-picker__option-wrapper:first-child button'
103
- );
104
- await colorPickerButton.click();
105
- // Click the title placeholder to put the cursor inside.
106
- const coverTitle = await page.waitForSelector(
107
- '.wp-block-cover .wp-block-paragraph'
108
- );
109
- await coverTitle.click();
110
- // Type the title.
111
- await page.keyboard.type( 'foo' );
112
- const coverTitleText = await coverTitle.evaluate(
113
- ( el ) => el.innerText
114
- );
115
-
116
- expect( coverTitleText ).toEqual( 'foo' );
117
- } );
118
-
119
74
  it( 'can be resized using drag & drop', async () => {
120
75
  await insertBlock( 'Cover' );
121
76
  // Close the inserter.
@@ -88,7 +88,7 @@ exports[`Inserting blocks inserts a block in proper place after having clicked \
88
88
  <p>First paragraph</p>
89
89
  <!-- /wp:paragraph -->
90
90
 
91
- <!-- wp:cover {"isDark":false} -->
91
+ <!-- wp:cover {"isDark":false,"layout":{"type":"constrained"}} -->
92
92
  <div class="wp-block-cover is-light"><span aria-hidden="true" class="wp-block-cover__background has-background-dim-100 has-background-dim"></span><div class="wp-block-cover__inner-container"></div></div>
93
93
  <!-- /wp:cover -->
94
94
 
@@ -58,9 +58,11 @@ describe( 'Navigating the block hierarchy', () => {
58
58
  // Add a paragraph in the first column.
59
59
  await page.keyboard.press( 'ArrowDown' ); // Navigate to inserter.
60
60
  await page.keyboard.press( 'Enter' ); // Activate inserter.
61
- await page.keyboard.type( 'Paragraph' );
62
- await pressKeyTimes( 'Tab', 2 ); // Tab to paragraph result.
63
- await page.keyboard.press( 'Enter' ); // Insert paragraph.
61
+ // Wait for inserter results to appear and then insert a paragraph.
62
+ await page.waitForSelector(
63
+ '.block-editor-inserter__quick-inserter-results .editor-block-list-item-paragraph'
64
+ );
65
+ await page.click( '.editor-block-list-item-paragraph' );
64
66
  await page.keyboard.type( 'First column' );
65
67
 
66
68
  // Navigate to the columns blocks.
@@ -99,9 +101,11 @@ describe( 'Navigating the block hierarchy', () => {
99
101
  // Insert text in the last column block.
100
102
  await page.keyboard.press( 'ArrowDown' ); // Navigate to inserter.
101
103
  await page.keyboard.press( 'Enter' ); // Activate inserter.
102
- await page.keyboard.type( 'Paragraph' );
103
- await pressKeyTimes( 'Tab', 2 ); // Tab to paragraph result.
104
- await page.keyboard.press( 'Enter' ); // Insert paragraph.
104
+ // Wait for inserter results to appear and then insert a paragraph.
105
+ await page.waitForSelector(
106
+ '.block-editor-inserter__quick-inserter-results .editor-block-list-item-paragraph'
107
+ );
108
+ await page.click( '.editor-block-list-item-paragraph' );
105
109
  await page.keyboard.type( 'Third column' );
106
110
 
107
111
  expect( await getEditedPostContent() ).toMatchSnapshot();
@@ -115,9 +119,11 @@ describe( 'Navigating the block hierarchy', () => {
115
119
  // Add a paragraph in the first column.
116
120
  await page.keyboard.press( 'ArrowDown' ); // Navigate to inserter.
117
121
  await page.keyboard.press( 'Enter' ); // Activate inserter.
118
- await page.keyboard.type( 'Paragraph' );
119
- await pressKeyTimes( 'Tab', 2 ); // Tab to paragraph result.
120
- await page.keyboard.press( 'Enter' ); // Insert paragraph.
122
+ // Wait for inserter results to appear and then insert a paragraph.
123
+ await page.waitForSelector(
124
+ '.block-editor-inserter__quick-inserter-results .editor-block-list-item-paragraph'
125
+ );
126
+ await page.click( '.editor-block-list-item-paragraph' );
121
127
  await page.keyboard.type( 'First column' );
122
128
 
123
129
  // Navigate to the columns blocks using the keyboard.
@@ -146,9 +152,11 @@ describe( 'Navigating the block hierarchy', () => {
146
152
  // Insert text in the last column block.
147
153
  await page.keyboard.press( 'ArrowDown' ); // Navigate to inserter.
148
154
  await page.keyboard.press( 'Enter' ); // Activate inserter.
149
- await page.keyboard.type( 'Paragraph' );
150
- await pressKeyTimes( 'Tab', 2 ); // Tab to paragraph result.
151
- await page.keyboard.press( 'Enter' ); // Insert paragraph.
155
+ // Wait for inserter results to appear and then insert a paragraph.
156
+ await page.waitForSelector(
157
+ '.block-editor-inserter__quick-inserter-results .editor-block-list-item-paragraph'
158
+ );
159
+ await page.click( '.editor-block-list-item-paragraph' );
152
160
  await page.keyboard.type( 'Third column' );
153
161
 
154
162
  expect( await getEditedPostContent() ).toMatchSnapshot();
@@ -412,13 +412,13 @@ describe( 'RichText', () => {
412
412
  await page.waitForXPath(
413
413
  '//button[@role="tab"][@aria-selected="true"][text()="Text"]'
414
414
  );
415
- // Tab to the "Text" tab.
415
+ // Initial focus is on the "Text" tab.
416
+ // Tab to the "Custom color picker".
416
417
  await page.keyboard.press( 'Tab' );
417
418
  // Tab to black.
418
419
  await page.keyboard.press( 'Tab' );
419
420
  // Select color other than black.
420
421
  await page.keyboard.press( 'Tab' );
421
- await page.keyboard.press( 'Tab' );
422
422
  await page.keyboard.press( 'Enter' );
423
423
 
424
424
  expect( await getEditedPostContent() ).toMatchSnapshot();
@@ -1,13 +1,12 @@
1
1
  /**
2
- * External dependencies
2
+ * WordPress dependencies
3
3
  */
4
- import { basename, join } from 'path';
5
- import { writeFileSync } from 'fs';
4
+ import { activateTheme, createURL, logout } from '@wordpress/e2e-test-utils';
6
5
 
7
6
  /**
8
- * WordPress dependencies
7
+ * Internal dependencies
9
8
  */
10
- import { activateTheme, createURL, logout } from '@wordpress/e2e-test-utils';
9
+ import { saveResultsFile } from './utils';
11
10
 
12
11
  describe( 'Front End Performance', () => {
13
12
  const results = {
@@ -22,12 +21,8 @@ describe( 'Front End Performance', () => {
22
21
  } );
23
22
 
24
23
  afterAll( async () => {
24
+ saveResultsFile( __filename, results );
25
25
  await activateTheme( 'twentytwentyone' );
26
- const resultsFilename = basename( __filename, '.js' ) + '.results.json';
27
- writeFileSync(
28
- join( __dirname, resultsFilename ),
29
- JSON.stringify( results, null, 2 )
30
- );
31
26
  } );
32
27
 
33
28
  it( 'Report TTFB, LCP, and LCP-TTFB', async () => {
@@ -1,13 +1,12 @@
1
1
  /**
2
- * External dependencies
2
+ * WordPress dependencies
3
3
  */
4
- import { basename, join } from 'path';
5
- import { writeFileSync } from 'fs';
4
+ import { activateTheme, createURL, logout } from '@wordpress/e2e-test-utils';
6
5
 
7
6
  /**
8
- * WordPress dependencies
7
+ * Internal dependencies
9
8
  */
10
- import { activateTheme, createURL, logout } from '@wordpress/e2e-test-utils';
9
+ import { saveResultsFile } from './utils';
11
10
 
12
11
  describe( 'Front End Performance', () => {
13
12
  const results = {
@@ -22,11 +21,7 @@ describe( 'Front End Performance', () => {
22
21
  } );
23
22
 
24
23
  afterAll( async () => {
25
- const resultsFilename = basename( __filename, '.js' ) + '.results.json';
26
- writeFileSync(
27
- join( __dirname, resultsFilename ),
28
- JSON.stringify( results, null, 2 )
29
- );
24
+ saveResultsFile( __filename, results );
30
25
  } );
31
26
 
32
27
  it( 'Report TTFB, LCP, and LCP-TTFB', async () => {
@@ -1,8 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { basename, join } from 'path';
5
- import { writeFileSync } from 'fs';
4
+ import path from 'path';
6
5
 
7
6
  /**
8
7
  * WordPress dependencies
@@ -24,6 +23,8 @@ import {
24
23
  import {
25
24
  readFile,
26
25
  deleteFile,
26
+ saveResultsFile,
27
+ getTraceFilePath,
27
28
  getTypingEventDurations,
28
29
  getClickEventDurations,
29
30
  getHoverEventDurations,
@@ -78,16 +79,13 @@ describe( 'Post Editor Performance', () => {
78
79
  inserterHover: [],
79
80
  inserterSearch: [],
80
81
  };
81
- const traceFile = __dirname + '/trace.json';
82
+ const traceFilePath = getTraceFilePath();
83
+
82
84
  let traceResults;
83
85
 
84
86
  afterAll( async () => {
85
- const resultsFilename = basename( __filename, '.js' ) + '.results.json';
86
- writeFileSync(
87
- join( __dirname, resultsFilename ),
88
- JSON.stringify( results, null, 2 )
89
- );
90
- deleteFile( traceFile );
87
+ saveResultsFile( __filename, results );
88
+ deleteFile( traceFilePath );
91
89
  } );
92
90
 
93
91
  beforeEach( async () => {
@@ -103,7 +101,7 @@ describe( 'Post Editor Performance', () => {
103
101
 
104
102
  it( 'Loading', async () => {
105
103
  await loadHtmlIntoTheBlockEditor(
106
- readFile( join( __dirname, '../../assets/large-post.html' ) )
104
+ readFile( path.join( __dirname, '../../assets/large-post.html' ) )
107
105
  );
108
106
  await saveDraft();
109
107
  const draftURL = await page.url();
@@ -148,12 +146,12 @@ describe( 'Post Editor Performance', () => {
148
146
 
149
147
  it( 'Typing', async () => {
150
148
  await loadHtmlIntoTheBlockEditor(
151
- readFile( join( __dirname, '../../assets/large-post.html' ) )
149
+ readFile( path.join( __dirname, '../../assets/large-post.html' ) )
152
150
  );
153
151
  await insertBlock( 'Paragraph' );
154
152
  let i = 20;
155
153
  await page.tracing.start( {
156
- path: traceFile,
154
+ path: traceFilePath,
157
155
  screenshots: false,
158
156
  categories: [ 'devtools.timeline' ],
159
157
  } );
@@ -166,7 +164,7 @@ describe( 'Post Editor Performance', () => {
166
164
  await page.keyboard.type( 'x' );
167
165
  }
168
166
  await page.tracing.stop();
169
- traceResults = JSON.parse( readFile( traceFile ) );
167
+ traceResults = JSON.parse( readFile( traceFilePath ) );
170
168
  const [ keyDownEvents, keyPressEvents, keyUpEvents ] =
171
169
  getTypingEventDurations( traceResults );
172
170
  if (
@@ -186,7 +184,7 @@ describe( 'Post Editor Performance', () => {
186
184
  it( 'Typing within containers', async () => {
187
185
  await loadHtmlIntoTheBlockEditor(
188
186
  readFile(
189
- join(
187
+ path.join(
190
188
  __dirname,
191
189
  '../../assets/small-post-with-containers.html'
192
190
  )
@@ -202,7 +200,7 @@ describe( 'Post Editor Performance', () => {
202
200
 
203
201
  let i = 10;
204
202
  await page.tracing.start( {
205
- path: traceFile,
203
+ path: traceFilePath,
206
204
  screenshots: false,
207
205
  categories: [ 'devtools.timeline' ],
208
206
  } );
@@ -216,7 +214,7 @@ describe( 'Post Editor Performance', () => {
216
214
  // eslint-disable-next-line no-restricted-syntax
217
215
  await page.waitForTimeout( 500 );
218
216
  await page.tracing.stop();
219
- traceResults = JSON.parse( readFile( traceFile ) );
217
+ traceResults = JSON.parse( readFile( traceFilePath ) );
220
218
  const [ keyDownEvents, keyPressEvents, keyUpEvents ] =
221
219
  getTypingEventDurations( traceResults );
222
220
  if (
@@ -242,13 +240,13 @@ describe( 'Post Editor Performance', () => {
242
240
  // eslint-disable-next-line no-restricted-syntax
243
241
  await page.waitForTimeout( 1000 );
244
242
  await page.tracing.start( {
245
- path: traceFile,
243
+ path: traceFilePath,
246
244
  screenshots: false,
247
245
  categories: [ 'devtools.timeline' ],
248
246
  } );
249
247
  await paragraphs[ j ].click();
250
248
  await page.tracing.stop();
251
- traceResults = JSON.parse( readFile( traceFile ) );
249
+ traceResults = JSON.parse( readFile( traceFilePath ) );
252
250
  const allDurations = getSelectionEventDurations( traceResults );
253
251
  results.focus.push(
254
252
  allDurations.reduce( ( acc, eventDurations ) => {
@@ -262,13 +260,13 @@ describe( 'Post Editor Performance', () => {
262
260
  await load1000Paragraphs();
263
261
  for ( let j = 0; j < 10; j++ ) {
264
262
  await page.tracing.start( {
265
- path: traceFile,
263
+ path: traceFilePath,
266
264
  screenshots: false,
267
265
  categories: [ 'devtools.timeline' ],
268
266
  } );
269
267
  await openListView();
270
268
  await page.tracing.stop();
271
- traceResults = JSON.parse( readFile( traceFile ) );
269
+ traceResults = JSON.parse( readFile( traceFilePath ) );
272
270
  const [ mouseClickEvents ] = getClickEventDurations( traceResults );
273
271
  for ( let k = 0; k < mouseClickEvents.length; k++ ) {
274
272
  results.listViewOpen.push( mouseClickEvents[ k ] );
@@ -281,13 +279,13 @@ describe( 'Post Editor Performance', () => {
281
279
  await load1000Paragraphs();
282
280
  for ( let j = 0; j < 10; j++ ) {
283
281
  await page.tracing.start( {
284
- path: traceFile,
282
+ path: traceFilePath,
285
283
  screenshots: false,
286
284
  categories: [ 'devtools.timeline' ],
287
285
  } );
288
286
  await openGlobalBlockInserter();
289
287
  await page.tracing.stop();
290
- traceResults = JSON.parse( readFile( traceFile ) );
288
+ traceResults = JSON.parse( readFile( traceFilePath ) );
291
289
  const [ mouseClickEvents ] = getClickEventDurations( traceResults );
292
290
  for ( let k = 0; k < mouseClickEvents.length; k++ ) {
293
291
  results.inserterOpen.push( mouseClickEvents[ k ] );
@@ -304,13 +302,13 @@ describe( 'Post Editor Performance', () => {
304
302
  // eslint-disable-next-line no-restricted-syntax
305
303
  await page.waitForTimeout( 500 );
306
304
  await page.tracing.start( {
307
- path: traceFile,
305
+ path: traceFilePath,
308
306
  screenshots: false,
309
307
  categories: [ 'devtools.timeline' ],
310
308
  } );
311
309
  await page.keyboard.type( 'p' );
312
310
  await page.tracing.stop();
313
- traceResults = JSON.parse( readFile( traceFile ) );
311
+ traceResults = JSON.parse( readFile( traceFilePath ) );
314
312
  const [ keyDownEvents, keyPressEvents, keyUpEvents ] =
315
313
  getTypingEventDurations( traceResults );
316
314
  if (
@@ -343,7 +341,7 @@ describe( 'Post Editor Performance', () => {
343
341
  // eslint-disable-next-line no-restricted-syntax
344
342
  await page.waitForTimeout( 200 );
345
343
  await page.tracing.start( {
346
- path: traceFile,
344
+ path: traceFilePath,
347
345
  screenshots: false,
348
346
  categories: [ 'devtools.timeline' ],
349
347
  } );
@@ -351,7 +349,7 @@ describe( 'Post Editor Performance', () => {
351
349
  await page.hover( headingBlockItem );
352
350
  await page.tracing.stop();
353
351
 
354
- traceResults = JSON.parse( readFile( traceFile ) );
352
+ traceResults = JSON.parse( readFile( traceFilePath ) );
355
353
  const [ mouseOverEvents, mouseOutEvents ] =
356
354
  getHoverEventDurations( traceResults );
357
355
  for ( let k = 0; k < mouseOverEvents.length; k++ ) {