@wordpress/e2e-tests 4.4.0 → 4.5.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.
@@ -49,9 +49,8 @@ class FlakyTestsReporter {
49
49
  }
50
50
  case 'passed': {
51
51
  if ( this.failingTestCaseResults.has( testTitle ) ) {
52
- const failingResults = this.failingTestCaseResults.get(
53
- testTitle
54
- );
52
+ const failingResults =
53
+ this.failingTestCaseResults.get( testTitle );
55
54
 
56
55
  await fs.writeFile(
57
56
  `flaky-tests/${ filenamify( testTitle ) }.json`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/e2e-tests",
3
- "version": "4.4.0",
3
+ "version": "4.5.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,11 +23,11 @@
23
23
  "node": ">=12"
24
24
  },
25
25
  "dependencies": {
26
- "@wordpress/e2e-test-utils": "^7.6.0",
27
- "@wordpress/jest-console": "^5.2.0",
26
+ "@wordpress/e2e-test-utils": "^7.7.0",
27
+ "@wordpress/jest-console": "^5.3.0",
28
28
  "@wordpress/jest-puppeteer-axe": "^4.0.2",
29
- "@wordpress/scripts": "^23.2.0",
30
- "@wordpress/url": "^3.11.0",
29
+ "@wordpress/scripts": "^23.3.0",
30
+ "@wordpress/url": "^3.12.0",
31
31
  "chalk": "^4.0.0",
32
32
  "expect-puppeteer": "^4.4.0",
33
33
  "filenamify": "^4.2.0",
@@ -46,5 +46,5 @@
46
46
  "publishConfig": {
47
47
  "access": "public"
48
48
  },
49
- "gitHead": "a3e0b62091e8a8bdf5e2518e42d60d7098af48cc"
49
+ "gitHead": "48d5f37dfb52d2e77c8eeb662f9874cf141b8c6b"
50
50
  }
@@ -84,13 +84,11 @@ describe( 'Cover', () => {
84
84
  const backgroundDim = await page.waitForSelector(
85
85
  '.wp-block-cover .has-background-dim'
86
86
  );
87
- const [
88
- backgroundDimColor,
89
- backgroundDimOpacity,
90
- ] = await page.evaluate( ( el ) => {
91
- const computedStyle = window.getComputedStyle( el );
92
- return [ computedStyle.backgroundColor, computedStyle.opacity ];
93
- }, backgroundDim );
87
+ const [ backgroundDimColor, backgroundDimOpacity ] =
88
+ await page.evaluate( ( el ) => {
89
+ const computedStyle = window.getComputedStyle( el );
90
+ return [ computedStyle.backgroundColor, computedStyle.opacity ];
91
+ }, backgroundDim );
94
92
 
95
93
  expect( backgroundDimColor ).toBe( 'rgb(0, 0, 0)' );
96
94
  expect( backgroundDimOpacity ).toBe( '0.5' );
@@ -210,13 +208,11 @@ describe( 'Cover', () => {
210
208
  const backgroundDim = await page.waitForSelector(
211
209
  '.wp-block-cover .has-background-dim'
212
210
  );
213
- const [
214
- backgroundDimColor,
215
- backgroundDimOpacity,
216
- ] = await page.evaluate( ( el ) => {
217
- const computedStyle = window.getComputedStyle( el );
218
- return [ computedStyle.backgroundColor, computedStyle.opacity ];
219
- }, backgroundDim );
211
+ const [ backgroundDimColor, backgroundDimOpacity ] =
212
+ await page.evaluate( ( el ) => {
213
+ const computedStyle = window.getComputedStyle( el );
214
+ return [ computedStyle.backgroundColor, computedStyle.opacity ];
215
+ }, backgroundDim );
220
216
 
221
217
  expect( backgroundDimColor ).toBe( 'rgb(0, 0, 0)' );
222
218
  expect( backgroundDimOpacity ).toBe( '0.5' );
@@ -399,11 +399,14 @@ describe( 'Navigation', () => {
399
399
  // relying on variable factors such as network conditions.
400
400
  await setUpResponseMocking( [
401
401
  {
402
- match: ( request ) =>
403
- request.method() === 'GET' &&
404
- request.url().includes( `rest_route` ) &&
405
- request.url().includes( `navigation` ) &&
406
- request.url().includes( testNavId ),
402
+ match: ( request ) => {
403
+ return (
404
+ [ 'GET', 'OPTIONS' ].includes( request.method() ) &&
405
+ decodeURIComponent( request.url() ).includes(
406
+ `navigation/${ testNavId }`
407
+ )
408
+ );
409
+ },
407
410
  onRequestMatch: ( request ) => {
408
411
  // The Promise simulates a REST API request whose resolultion
409
412
  // the test has full control over.
@@ -417,7 +420,9 @@ describe( 'Navigation', () => {
417
420
  },
418
421
  },
419
422
  ] );
420
-
423
+ /*
424
+ Expected mock function not to be called but it was called with: ["POST", "http://localhost:8889/wp-admin/admin-ajax.php", "http://localhost:8889/wp-admin/admin-ajax.php"],["GET", "http://localhost:8889/wp-admin/post-new.php", "http://localhost:8889/wp-admin/post-new.php"],["GET", "http://localhost:8889/wp-includes/js/mediaelement/mediaelementplayer-legacy.min.css?ver=4.2.16", "http://localhost:8889/wp-includes/js/mediaelement/mediaelementplayer-legacy.min.css?ver=4.2.16"],["GET", "http://localhost:8889/wp-includes/js/mediaelement/wp-mediaelement.min.css?ver=6.1-alpha-53506", "http://localhost:8889/wp-includes/js/mediaelement/wp-mediaelement.min.css?ver=6.1-alpha-53506"],["GET", "http://localhost:8889/wp-includes/js/imgareaselect/imgareaselect.css?ver=0.9.8", "http://localhost:8889/wp-includes/js/imgareaselect/imgareaselect.css?ver=0.9.8"],["GET", "http://localhost:8889/wp-content/plugins/gutenberg/build/components/style.css?ver=1655290402", "http://localhost:8889/wp-content/plugins/gutenberg/build/components/style.css?ver=1655290402"],["GET", "http://localhost:8889/wp-content/plugins/gutenberg/build/block-editor/style.css?ver=1655290402", "http://localhost:8889/wp-content/plugins/gutenberg/build/block-editor/style.css?ver=1655290402"],["GET", "http://localhost:8889/wp-content/plugins/gutenberg/build/nux/style.css?ver=1655290402", "http://localhost:8889/wp-content/plugins/gutenberg/build/nux/style.css?ver=1655290402"],["GET", "http://localhost:8889/wp-content/plugins/gutenberg/build/reusable-blocks/style.css?ver=1655290402", "http://localhost:8889/wp-content/plugins/gutenberg/build/reusable-blocks/style.css?ver=1655290402"],["GET", "http://localhost:8889/wp-content/plugins/gutenberg/build/editor/style.css?ver=1655290402", "http://localhost:8889/wp-content/plugins/gutenberg/build/editor/style.css?ver=1655290402"],["GET", "http://localhost:8889/wp-content/plugins/gutenberg/build/block-library/reset.css?ver=1655290402", "http://localhost:8889/wp-content/plugins/gutenberg/build/block-library/reset.css?ver=1655290402"],["GET", "http://localhost:8889/wp-content/plugins/gutenberg/build/block-library/style.css?ver=1655290402", "http://localhost:8889/wp-content/plugins/gutenberg/build/block-library/style.css?ver=1655290402"],["GET", "http://localhost:8889/wp-content/plugins/gutenberg/build/edit-post/classic.css?ver=1655290402", "http://localhost:8889/wp-content/plugins/gutenberg/build/edit-post/classic.css?ver=1655290402"],["GET", "http://localhost:8889/wp-content/plugins/gutenberg/build/block-library/editor.css?ver=1655290402", "http://localhost:8889/wp-content/plugins/gutenberg/build/block-library/editor.css?ver=1655290402"],["GET", "http://localhost:8889/wp-content/plugins/gutenberg/build/edit-post/style.css?ver=1655290402", "http://localhost:8889/wp-content/plugins/gutenberg/build/edit-post/style.css?ver=1655290402"],["GET", "http://localhost:8889/wp-content/plugins/gutenberg/build/block-directory/style.css?ver=1655290402", "http://localhost:8889/wp-content/plugins/gutenberg/build/block-directory/style.css?ver=1655290402"],["GET", "http://localhost:8889/wp-content/plugins/gutenberg/build/format-library/style.css?ver=1655290402", "http://localhost:8889/wp-content/plugins/gutenberg/build/format-library/style.css?ver=1655290402"],["GET", "http://localhost:8889/wp-content/themes/twentytwentyone/assets/css/custom-color-overrides.css?ver=1.6", "http://localhost:8889/wp-content/themes/twentytwentyone/assets/css/custom-color-overrides.css?ver=1.6"],["GET", "http://localhost:8889/wp-content/plugins/gutenberg/build/block-library/theme.css?ver=1655290402", "http://localhost:8889/wp-content/plugins/gutenberg/build/block-library/theme.css?ver=1655290402"],["GET", "http://localhost:8889/wp-content/plugins/gutenberg/build/blob/index.min.js?ver=bccaf46e493181a8db9a", "http://localhost:8889/wp-content/plugins/gutenberg/build/blob/index.min.js?ver=bccaf46e493181a8db9a"],["GET", "http://localhost:8889/wp-content/plugins/gutenberg/build/autop/index.min.js?ver=b1a2f86387be4fa46f89", "http://loca
425
+ */
421
426
  await createNewPost();
422
427
  await clickOnMoreMenuItem( 'Code editor' );
423
428
  const codeEditorInput = await page.waitForSelector(
@@ -232,9 +232,8 @@ describe( 'Table', () => {
232
232
 
233
233
  // Get the bounding client rect for the second cell.
234
234
  const { x: secondCellX, y: secondCellY } = await page.evaluate( () => {
235
- const secondCell = document.querySelectorAll(
236
- '.wp-block-table td'
237
- )[ 1 ];
235
+ const secondCell =
236
+ document.querySelectorAll( '.wp-block-table td' )[ 1 ];
238
237
  // Page.evaluate can only return a serializable value to the
239
238
  // parent process, so destructure and restructure the result
240
239
  // into an object.
@@ -103,9 +103,8 @@ describe( 'cpt locking', () => {
103
103
 
104
104
  it( 'should show invalid template notice if the blocks do not match the templte', async () => {
105
105
  const content = await getEditedPostContent();
106
- const [ , contentWithoutImage ] = content.split(
107
- '<!-- /wp:image -->'
108
- );
106
+ const [ , contentWithoutImage ] =
107
+ content.split( '<!-- /wp:image -->' );
109
108
  await setPostContent( contentWithoutImage );
110
109
  const noticeContent = await page.waitForSelector(
111
110
  '.editor-template-validation-notice .components-notice__content'
@@ -36,7 +36,9 @@ describe( 'Allowed Blocks Setting on InnerBlocks', () => {
36
36
  await page.click( childParagraphSelector );
37
37
  await openGlobalBlockInserter();
38
38
  await expect(
39
- ( await getAllBlockInserterItemTitles() ).length
39
+ (
40
+ await getAllBlockInserterItemTitles()
41
+ ).length
40
42
  ).toBeGreaterThan( 20 );
41
43
  } );
42
44
 
@@ -138,7 +138,9 @@ describe.each( [ [ 'UTC-10' ], [ 'UTC' ], [ 'UTC+10' ] ] )(
138
138
  await page.click( '.edit-post-post-schedule__toggle' );
139
139
 
140
140
  // Clear the date.
141
- await page.click( '.block-editor-publish-date-time-picker__reset' );
141
+ await page.click(
142
+ '.block-editor-publish-date-time-picker button[aria-label="Now"]'
143
+ );
142
144
 
143
145
  const publishingDate = await getPublishingDate();
144
146
 
@@ -16,8 +16,7 @@ import {
16
16
 
17
17
  const MOCK_EMBED_WORDPRESS_SUCCESS_RESPONSE = {
18
18
  url: 'https://wordpress.org/gutenberg/handbook/block-api/attributes/',
19
- html:
20
- '<div class="wp-embedded-content" data-secret="shhhh it is a secret"></div>',
19
+ html: '<div class="wp-embedded-content" data-secret="shhhh it is a secret"></div>',
21
20
  type: 'rich',
22
21
  provider_name: 'WordPress',
23
22
  provider_url: 'https://wordpress.org',
@@ -78,8 +77,7 @@ const MOCK_BAD_EMBED_PROVIDER_RESPONSE = {
78
77
 
79
78
  const MOCK_CANT_EMBED_RESPONSE = {
80
79
  provider_name: 'Embed Handler',
81
- html:
82
- '<a href="https://twitter.com/wooyaygutenberg123454312">https://twitter.com/wooyaygutenberg123454312</a>',
80
+ html: '<a href="https://twitter.com/wooyaygutenberg123454312">https://twitter.com/wooyaygutenberg123454312</a>',
83
81
  };
84
82
 
85
83
  const MOCK_BAD_WORDPRESS_RESPONSE = {
@@ -271,9 +271,8 @@ describe( 'Links', () => {
271
271
  const toggleFixedToolbar = async ( isFixed ) => {
272
272
  await page.evaluate( ( _isFixed ) => {
273
273
  const { select, dispatch } = wp.data;
274
- const isCurrentlyFixed = select( 'core/edit-post' ).isFeatureActive(
275
- 'fixedToolbar'
276
- );
274
+ const isCurrentlyFixed =
275
+ select( 'core/edit-post' ).isFeatureActive( 'fixedToolbar' );
277
276
  if ( isCurrentlyFixed !== _isFixed ) {
278
277
  dispatch( 'core/edit-post' ).toggleFeature( 'fixedToolbar' );
279
278
  }
@@ -20,9 +20,8 @@ describe.each( [
20
20
 
21
21
  await page.evaluate( ( _isUnifiedToolbar ) => {
22
22
  const { select, dispatch } = wp.data;
23
- const isCurrentlyUnified = select(
24
- 'core/edit-post'
25
- ).isFeatureActive( 'fixedToolbar' );
23
+ const isCurrentlyUnified =
24
+ select( 'core/edit-post' ).isFeatureActive( 'fixedToolbar' );
26
25
  if ( isCurrentlyUnified !== _isUnifiedToolbar ) {
27
26
  dispatch( 'core/edit-post' ).toggleFeature( 'fixedToolbar' );
28
27
  }
@@ -103,7 +103,8 @@ describe( 'Publishing', () => {
103
103
 
104
104
  beforeEach( async () => {
105
105
  await createNewPost( postType );
106
- werePrePublishChecksEnabled = await arePrePublishChecksEnabled();
106
+ werePrePublishChecksEnabled =
107
+ await arePrePublishChecksEnabled();
107
108
  if ( werePrePublishChecksEnabled ) {
108
109
  await disablePrePublishChecks();
109
110
  }
@@ -143,7 +144,8 @@ describe( 'Publishing', () => {
143
144
 
144
145
  beforeEach( async () => {
145
146
  await createNewPost( postType );
146
- werePrePublishChecksEnabled = await arePrePublishChecksEnabled();
147
+ werePrePublishChecksEnabled =
148
+ await arePrePublishChecksEnabled();
147
149
  if ( werePrePublishChecksEnabled ) {
148
150
  await disablePrePublishChecks();
149
151
  }
@@ -1,8 +1,3 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { random } from 'lodash';
5
-
6
1
  /**
7
2
  * WordPress dependencies
8
3
  */
@@ -19,6 +14,12 @@ import {
19
14
  const TAG_TOKEN_SELECTOR =
20
15
  '.components-form-token-field__token-text span:not(.components-visually-hidden)';
21
16
 
17
+ function generateRandomNumber() {
18
+ // Using `Math.random()` directly is fine in this testing context.
19
+ // eslint-disable-next-line no-restricted-syntax
20
+ return Math.round( 1 + Math.random() * ( Number.MAX_SAFE_INTEGER - 1 ) );
21
+ }
22
+
22
23
  describe( 'Taxonomies', () => {
23
24
  const canCreatTermInTaxonomy = ( taxonomy ) => {
24
25
  return page.evaluate( ( _taxonomy ) => {
@@ -152,7 +153,7 @@ describe( 'Taxonomies', () => {
152
153
  // Click the tag input field.
153
154
  await tagInput.click();
154
155
 
155
- const tagName = "tag'-" + random( 1, Number.MAX_SAFE_INTEGER );
156
+ const tagName = "tag'-" + generateRandomNumber();
156
157
 
157
158
  // Type the category name in the field.
158
159
  await tagInput.type( tagName );
@@ -211,7 +212,7 @@ describe( 'Taxonomies', () => {
211
212
  // Click the tag input field.
212
213
  await tagInput.click();
213
214
 
214
- const tagName = 'tag-' + random( 1, Number.MAX_SAFE_INTEGER );
215
+ const tagName = 'tag-' + generateRandomNumber();
215
216
 
216
217
  // Type the category name in the field.
217
218
  await tagInput.type( tagName );
@@ -681,17 +681,15 @@ describe.skip( 'Navigation editor', () => {
681
681
 
682
682
  // Get the title/label of the last Nav item inside the Nav block.
683
683
  const lastItemAttributes = await page.evaluate( () => {
684
- const { getBlockOrder, getBlocks } = wp.data.select(
685
- 'core/block-editor'
686
- );
684
+ const { getBlockOrder, getBlocks } =
685
+ wp.data.select( 'core/block-editor' );
687
686
 
688
687
  const lockedNavigationBlock = getBlockOrder()[ 0 ];
689
688
 
690
689
  const navItemBlocks = getBlocks( lockedNavigationBlock );
691
690
 
692
- const { attributes } = navItemBlocks[
693
- navItemBlocks.length - 1
694
- ];
691
+ const { attributes } =
692
+ navItemBlocks[ navItemBlocks.length - 1 ];
695
693
 
696
694
  return attributes;
697
695
  } );
@@ -3,7 +3,6 @@
3
3
  */
4
4
  import { basename, join } from 'path';
5
5
  import { writeFileSync } from 'fs';
6
- import { sum } from 'lodash';
7
6
 
8
7
  /**
9
8
  * WordPress dependencies
@@ -136,11 +135,8 @@ describe( 'Post Editor Performance', () => {
136
135
  }
137
136
  await page.tracing.stop();
138
137
  traceResults = JSON.parse( readFile( traceFile ) );
139
- const [
140
- keyDownEvents,
141
- keyPressEvents,
142
- keyUpEvents,
143
- ] = getTypingEventDurations( traceResults );
138
+ const [ keyDownEvents, keyPressEvents, keyUpEvents ] =
139
+ getTypingEventDurations( traceResults );
144
140
  if (
145
141
  keyDownEvents.length === keyPressEvents.length &&
146
142
  keyPressEvents.length === keyUpEvents.length
@@ -226,6 +222,10 @@ describe( 'Post Editor Performance', () => {
226
222
  } );
227
223
 
228
224
  it( 'Searching the inserter', async () => {
225
+ function sum( arr ) {
226
+ return arr.reduce( ( a, b ) => a + b, 0 );
227
+ }
228
+
229
229
  // Measure time to search the inserter and get results.
230
230
  await openGlobalBlockInserter();
231
231
  for ( let j = 0; j < 10; j++ ) {
@@ -240,11 +240,8 @@ describe( 'Post Editor Performance', () => {
240
240
  await page.keyboard.type( 'p' );
241
241
  await page.tracing.stop();
242
242
  traceResults = JSON.parse( readFile( traceFile ) );
243
- const [
244
- keyDownEvents,
245
- keyPressEvents,
246
- keyUpEvents,
247
- ] = getTypingEventDurations( traceResults );
243
+ const [ keyDownEvents, keyPressEvents, keyUpEvents ] =
244
+ getTypingEventDurations( traceResults );
248
245
  if (
249
246
  keyDownEvents.length === keyPressEvents.length &&
250
247
  keyPressEvents.length === keyUpEvents.length
@@ -284,9 +281,8 @@ describe( 'Post Editor Performance', () => {
284
281
  await page.tracing.stop();
285
282
 
286
283
  traceResults = JSON.parse( readFile( traceFile ) );
287
- const [ mouseOverEvents, mouseOutEvents ] = getHoverEventDurations(
288
- traceResults
289
- );
284
+ const [ mouseOverEvents, mouseOutEvents ] =
285
+ getHoverEventDurations( traceResults );
290
286
  for ( let k = 0; k < mouseOverEvents.length; k++ ) {
291
287
  results.inserterHover.push(
292
288
  mouseOverEvents[ k ] + mouseOutEvents[ k ]
@@ -130,11 +130,8 @@ describe( 'Site Editor Performance', () => {
130
130
  }
131
131
  await page.tracing.stop();
132
132
  const traceResults = JSON.parse( readFile( traceFile ) );
133
- const [
134
- keyDownEvents,
135
- keyPressEvents,
136
- keyUpEvents,
137
- ] = getTypingEventDurations( traceResults );
133
+ const [ keyDownEvents, keyPressEvents, keyUpEvents ] =
134
+ getTypingEventDurations( traceResults );
138
135
 
139
136
  for ( let j = 0; j < keyDownEvents.length; j++ ) {
140
137
  results.type.push(
@@ -113,7 +113,8 @@ describe( 'Widgets screen', () => {
113
113
  const insertionPointIndicator = await page.$(
114
114
  '.block-editor-block-list__insertion-point-indicator'
115
115
  );
116
- const insertionPointIndicatorBoundingBox = await insertionPointIndicator.boundingBox();
116
+ const insertionPointIndicatorBoundingBox =
117
+ await insertionPointIndicator.boundingBox();
117
118
 
118
119
  expect(
119
120
  insertionPointIndicatorBoundingBox.y > lastBlockBoundingBox.y
@@ -298,7 +299,8 @@ describe( 'Widgets screen', () => {
298
299
  firstParagraphBlock
299
300
  );
300
301
 
301
- const secondParagraphBlockBoundingBox = await secondParagraphBlock.boundingBox();
302
+ const secondParagraphBlockBoundingBox =
303
+ await secondParagraphBlock.boundingBox();
302
304
 
303
305
  // Click outside the block to move the focus back to the widget area.
304
306
  await page.mouse.click(
@@ -560,16 +562,18 @@ describe( 'Widgets screen', () => {
560
562
  {},
561
563
  firstParagraphBlock
562
564
  );
563
- const duplicatedParagraphBlock = await firstParagraphBlock.evaluateHandle(
564
- ( paragraph ) => paragraph.nextSibling
565
- );
565
+ const duplicatedParagraphBlock =
566
+ await firstParagraphBlock.evaluateHandle(
567
+ ( paragraph ) => paragraph.nextSibling
568
+ );
566
569
 
567
570
  const firstParagraphBlockClientId = await firstParagraphBlock.evaluate(
568
571
  ( node ) => node.dataset.block
569
572
  );
570
- const duplicatedParagraphBlockClientId = await duplicatedParagraphBlock.evaluate(
571
- ( node ) => node.dataset.block
572
- );
573
+ const duplicatedParagraphBlockClientId =
574
+ await duplicatedParagraphBlock.evaluate(
575
+ ( node ) => node.dataset.block
576
+ );
573
577
 
574
578
  expect( firstParagraphBlockClientId ).not.toBe(
575
579
  duplicatedParagraphBlockClientId