@wordpress/e2e-tests 4.4.0 → 4.7.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 (49) hide show
  1. package/config/flaky-tests-reporter.js +2 -3
  2. package/package.json +6 -6
  3. package/specs/editor/blocks/cover.test.js +10 -14
  4. package/specs/editor/blocks/gallery.test.js +1 -1
  5. package/specs/editor/blocks/navigation.test.js +15 -50
  6. package/specs/editor/plugins/cpt-locking.test.js +2 -3
  7. package/specs/editor/plugins/iframed-block.test.js +3 -2
  8. package/specs/editor/plugins/iframed-masonry-block.test.js +3 -2
  9. package/specs/editor/plugins/inner-blocks-allowed-blocks.test.js +3 -1
  10. package/specs/editor/plugins/meta-boxes.test.js +1 -1
  11. package/specs/editor/various/compatibility-classic-editor.test.js +1 -1
  12. package/specs/editor/various/datepicker.test.js +12 -12
  13. package/specs/editor/various/embedding.test.js +2 -4
  14. package/specs/editor/various/links.test.js +5 -6
  15. package/specs/editor/various/multi-block-selection.test.js +0 -2
  16. package/specs/editor/various/navigable-toolbar.test.js +2 -3
  17. package/specs/editor/various/post-visibility.test.js +4 -4
  18. package/specs/editor/various/publishing.test.js +4 -2
  19. package/specs/editor/various/scheduling.test.js +2 -2
  20. package/specs/editor/various/{sidebar-permalink-panel.test.js → sidebar-permalink.test.js} +9 -19
  21. package/specs/editor/various/sidebar.test.js +4 -6
  22. package/specs/editor/various/taxonomies.test.js +8 -7
  23. package/specs/editor/various/typewriter.test.js +2 -2
  24. package/specs/experiments/navigation-editor.test.js +4 -6
  25. package/specs/performance/post-editor.test.js +10 -14
  26. package/specs/performance/site-editor.test.js +2 -5
  27. package/specs/widgets/editing-widgets.test.js +12 -8
  28. package/specs/editor/blocks/__snapshots__/buttons.test.js.snap +0 -33
  29. package/specs/editor/blocks/__snapshots__/list.test.js.snap +0 -337
  30. package/specs/editor/blocks/__snapshots__/spacer.test.js.snap +0 -13
  31. package/specs/editor/blocks/__snapshots__/table.test.js.snap +0 -61
  32. package/specs/editor/blocks/buttons.test.js +0 -95
  33. package/specs/editor/blocks/comments.test.js +0 -131
  34. package/specs/editor/blocks/list.test.js +0 -542
  35. package/specs/editor/blocks/spacer.test.js +0 -48
  36. package/specs/editor/blocks/table.test.js +0 -296
  37. package/specs/editor/plugins/__snapshots__/format-api.test.js.snap +0 -7
  38. package/specs/editor/plugins/format-api.test.js +0 -36
  39. package/specs/editor/various/__snapshots__/rtl.test.js.snap +0 -63
  40. package/specs/editor/various/block-mover.test.js +0 -42
  41. package/specs/editor/various/preview.test.js +0 -425
  42. package/specs/editor/various/rtl.test.js +0 -129
  43. package/specs/site-editor/style-variations.test.js +0 -213
  44. package/themes/style-variations/block-templates/index.html +0 -11
  45. package/themes/style-variations/index.php +0 -0
  46. package/themes/style-variations/style.css +0 -15
  47. package/themes/style-variations/styles/pink.json +0 -33
  48. package/themes/style-variations/styles/yellow.json +0 -12
  49. package/themes/style-variations/theme.json +0 -8
@@ -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.7.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.9.0",
27
+ "@wordpress/jest-console": "^5.4.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.5.0",
30
+ "@wordpress/url": "^3.14.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": "9d9d33bbdf317a4381b8ca1713e43bb50df653b3"
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' );
@@ -103,7 +103,7 @@ describe( 'Gallery', () => {
103
103
  // This xpath selects the anchor node for the block which has a child span which contains the text
104
104
  // label of the block and then selects the expander span for that node.
105
105
  const galleryExpander = await page.waitForXPath(
106
- `//a[span[text()='Gallery']]/span[contains(@class, 'block-editor-list-view__expander')]`
106
+ `//a[.//span[text()='Gallery']]/span[contains(@class, 'block-editor-list-view__expander')]`
107
107
  );
108
108
 
109
109
  await galleryExpander.click();
@@ -1,8 +1,3 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { uniqueId } from 'lodash';
5
-
6
1
  /**
7
2
  * WordPress dependencies
8
3
  */
@@ -48,6 +43,7 @@ const REST_PAGES_ROUTES = [
48
43
  '/wp/v2/pages',
49
44
  `rest_route=${ encodeURIComponent( '/wp/v2/pages' ) }`,
50
45
  ];
46
+ let uniqueId = 0;
51
47
 
52
48
  /**
53
49
  * Determines if a given URL matches any of a given collection of
@@ -312,7 +308,7 @@ async function waitForBlock( blockName ) {
312
308
  // Disable reason - these tests are to be re-written.
313
309
  // eslint-disable-next-line jest/no-disabled-tests
314
310
  describe( 'Navigation', () => {
315
- const contributorUsername = uniqueId( 'contributoruser_' );
311
+ const contributorUsername = `contributoruser_${ ++uniqueId }`;
316
312
  let contributorPassword;
317
313
 
318
314
  beforeAll( async () => {
@@ -388,7 +384,10 @@ describe( 'Navigation', () => {
388
384
  expect( loadingSpinner ).toBeNull();
389
385
  } );
390
386
 
391
- it( 'shows a loading indicator whilst ref resolves to Navigation post items', async () => {
387
+ // Skip reason: This test is quite flaky recently.
388
+ // See https://github.com/WordPress/gutenberg/issues/39231.
389
+ // eslint-disable-next-line jest/no-disabled-tests
390
+ it.skip( 'shows a loading indicator whilst ref resolves to Navigation post items', async () => {
392
391
  const testNavId = 1;
393
392
 
394
393
  let resolveNavigationRequest;
@@ -399,11 +398,11 @@ describe( 'Navigation', () => {
399
398
  // relying on variable factors such as network conditions.
400
399
  await setUpResponseMocking( [
401
400
  {
402
- match: ( request ) =>
403
- request.method() === 'GET' &&
404
- request.url().includes( `rest_route` ) &&
405
- request.url().includes( `navigation` ) &&
406
- request.url().includes( testNavId ),
401
+ match: ( request ) => {
402
+ return decodeURIComponent( request.url() ).includes(
403
+ `navigation/`
404
+ );
405
+ },
407
406
  onRequestMatch: ( request ) => {
408
407
  // The Promise simulates a REST API request whose resolultion
409
408
  // the test has full control over.
@@ -417,7 +416,9 @@ describe( 'Navigation', () => {
417
416
  },
418
417
  },
419
418
  ] );
420
-
419
+ /*
420
+ 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
421
+ */
421
422
  await createNewPost();
422
423
  await clickOnMoreMenuItem( 'Code editor' );
423
424
  const codeEditorInput = await page.waitForSelector(
@@ -1046,7 +1047,7 @@ describe( 'Navigation', () => {
1046
1047
  await openListView();
1047
1048
 
1048
1049
  const navExpander = await page.waitForXPath(
1049
- `//a[span[text()='Navigation']]/span[contains(@class, 'block-editor-list-view__expander')]`
1050
+ `//a[.//span[text()='Navigation']]/span[contains(@class, 'block-editor-list-view__expander')]`
1050
1051
  );
1051
1052
 
1052
1053
  await navExpander.click();
@@ -1316,42 +1317,6 @@ describe( 'Navigation', () => {
1316
1317
  await switchUserToAdmin();
1317
1318
  } );
1318
1319
 
1319
- it( 'shows a warning if user does not have permission to edit or update navigation menus', async () => {
1320
- await createNewPost();
1321
- await insertBlock( 'Navigation' );
1322
-
1323
- const startEmptyButton = await page.waitForXPath(
1324
- START_EMPTY_XPATH
1325
- );
1326
-
1327
- // This creates an empty Navigation post type entity.
1328
- await startEmptyButton.click();
1329
-
1330
- // Publishing the Post ensures the Navigation entity is saved.
1331
- // The Post itself is irrelevant.
1332
- await publishPost();
1333
-
1334
- // Switch to a Contributor role user - they should not have
1335
- // permission to update Navigation menus.
1336
- await loginUser( contributorUsername, contributorPassword );
1337
-
1338
- await createNewPost();
1339
-
1340
- // At this point the block will automatically pick the first Navigation Menu
1341
- // which will be the one created by the Admin User.
1342
- await insertBlock( 'Navigation' );
1343
-
1344
- // Make sure the snackbar error shows up.
1345
- await page.waitForXPath(
1346
- `//*[contains(@class, 'components-snackbar__content')][ text()="You do not have permission to edit this Menu. Any changes made will not be saved." ]`
1347
- );
1348
-
1349
- // Expect a console 403 for requests to:
1350
- // * /wp/v2/settings?_locale=user
1351
- // * /wp/v2/templates?context=edit&post_type=post&per_page=100&_locale=user
1352
- expect( console ).toHaveErrored();
1353
- } );
1354
-
1355
1320
  it( 'shows a warning if user does not have permission to create navigation menus', async () => {
1356
1321
  const noticeText =
1357
1322
  'You do not have permission to create Navigation Menus.';
@@ -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,8 +36,9 @@ describe( 'changing image size', () => {
36
36
 
37
37
  await openDocumentSettingsSidebar();
38
38
  await clickButton( 'Page' );
39
- await clickButton( 'Template' );
40
- await clickButton( 'New' );
39
+ await page.click( 'button[aria-label^="Select template"]' );
40
+ await page.waitForSelector( 'button[aria-label="Add template"]' );
41
+ await page.click( 'button[aria-label="Add template"]' );
41
42
  await page.keyboard.press( 'Tab' );
42
43
  await page.keyboard.press( 'Tab' );
43
44
  await page.keyboard.type( 'Iframed Test' );
@@ -44,8 +44,9 @@ describe( 'iframed masonry block', () => {
44
44
 
45
45
  await openDocumentSettingsSidebar();
46
46
  await clickButton( 'Page' );
47
- await clickButton( 'Template' );
48
- await clickButton( 'New' );
47
+ await page.click( 'button[aria-label^="Select template"]' );
48
+ await page.waitForSelector( 'button[aria-label="Add template"]' );
49
+ await page.click( 'button[aria-label="Add template"]' );
49
50
  await page.keyboard.press( 'Tab' );
50
51
  await page.keyboard.press( 'Tab' );
51
52
  await page.keyboard.type( 'Iframed Test' );
@@ -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
 
@@ -59,7 +59,7 @@ describe( 'Meta boxes', () => {
59
59
  await viewPostLinks[ 0 ].click();
60
60
  await page.waitForNavigation();
61
61
 
62
- // Check the the dynamic block appears.
62
+ // Check the dynamic block appears.
63
63
  const latestPostsBlock = await page.waitForSelector(
64
64
  '.wp-block-latest-posts'
65
65
  );
@@ -28,7 +28,7 @@ describe( 'Compatibility with classic editor', () => {
28
28
  await viewPostLinks[ 0 ].click();
29
29
  await page.waitForNavigation();
30
30
 
31
- // Check the the content doesn't contain <p> tags.
31
+ // Check the content doesn't contain <p> tags.
32
32
  await page.waitForSelector( '.entry-content' );
33
33
  const content = await page.$eval( '.entry-content', ( element ) =>
34
34
  element.innerHTML.trim()
@@ -45,17 +45,13 @@ function trimLeadingZero( str ) {
45
45
  return str[ 0 ] === '0' ? str.slice( 1 ) : str;
46
46
  }
47
47
 
48
- function formatDatePickerValues( {
49
- year,
50
- monthLabel,
51
- day,
52
- hours,
53
- minutes,
54
- amOrPm,
55
- } ) {
48
+ function formatDatePickerValues(
49
+ { year, monthLabel, day, hours, minutes, amOrPm },
50
+ timezone
51
+ ) {
56
52
  const dayTrimmed = trimLeadingZero( day );
57
53
  const hoursTrimmed = trimLeadingZero( hours );
58
- return `${ monthLabel } ${ dayTrimmed }, ${ year } ${ hoursTrimmed }:${ minutes } ${ amOrPm }`;
54
+ return `${ monthLabel } ${ dayTrimmed }, ${ year } ${ hoursTrimmed }:${ minutes }\xa0${ amOrPm } ${ timezone }`;
59
55
  }
60
56
 
61
57
  async function getPublishingDate() {
@@ -70,11 +66,13 @@ describe.each( [ [ 'UTC-10' ], [ 'UTC' ], [ 'UTC+10' ] ] )(
70
66
  ( timezone ) => {
71
67
  let oldTimezone;
72
68
  beforeEach( async () => {
69
+ await page.emulateTimezone( 'America/New_York' ); // Set browser to a timezone that's different to `timezone`.
73
70
  oldTimezone = await changeSiteTimezone( timezone );
74
71
  await createNewPost();
75
72
  } );
76
73
  afterEach( async () => {
77
74
  await changeSiteTimezone( oldTimezone );
75
+ await page.emulateTimezone( null );
78
76
  } );
79
77
 
80
78
  it( 'should show the publishing date as "Immediately" if the date is not altered', async () => {
@@ -98,7 +96,7 @@ describe.each( [ [ 'UTC-10' ], [ 'UTC' ], [ 'UTC+10' ] ] )(
98
96
  const publishingDate = await getPublishingDate();
99
97
 
100
98
  expect( publishingDate ).toBe(
101
- formatDatePickerValues( datePickerValues )
99
+ formatDatePickerValues( datePickerValues, timezone )
102
100
  );
103
101
  } );
104
102
 
@@ -119,7 +117,7 @@ describe.each( [ [ 'UTC-10' ], [ 'UTC' ], [ 'UTC+10' ] ] )(
119
117
  expect( publishingDate ).not.toEqual( 'Immediately' );
120
118
  // The expected date format will be "Sep 26, 2018 11:52 pm".
121
119
  expect( publishingDate ).toBe(
122
- formatDatePickerValues( datePickerValues )
120
+ formatDatePickerValues( datePickerValues, timezone )
123
121
  );
124
122
  } );
125
123
 
@@ -138,7 +136,9 @@ describe.each( [ [ 'UTC-10' ], [ 'UTC' ], [ 'UTC+10' ] ] )(
138
136
  await page.click( '.edit-post-post-schedule__toggle' );
139
137
 
140
138
  // Clear the date.
141
- await page.click( '.block-editor-publish-date-time-picker__reset' );
139
+ await page.click(
140
+ '.block-editor-publish-date-time-picker button[aria-label="Now"]'
141
+ );
142
142
 
143
143
  const publishingDate = await getPublishingDate();
144
144
 
@@ -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
  }
@@ -393,7 +392,7 @@ describe( 'Links', () => {
393
392
  await page.waitForSelector( '.block-editor-link-control__search-item' );
394
393
  await page.keyboard.press( 'ArrowDown' );
395
394
 
396
- // Expect the the escape key to dismiss the popover when the autocomplete suggestion list is open.
395
+ // Expect the escape key to dismiss the popover when the autocomplete suggestion list is open.
397
396
  await page.keyboard.press( 'Escape' );
398
397
  expect(
399
398
  await page.$(
@@ -418,7 +417,7 @@ describe( 'Links', () => {
418
417
  )
419
418
  ).not.toBeNull();
420
419
 
421
- // Expect the the escape key to dismiss the popover normally.
420
+ // Expect the escape key to dismiss the popover normally.
422
421
  await page.keyboard.press( 'Escape' );
423
422
  expect(
424
423
  await page.$(
@@ -441,7 +440,7 @@ describe( 'Links', () => {
441
440
  await page.keyboard.press( 'Tab' );
442
441
  await page.keyboard.press( 'Tab' );
443
442
 
444
- // Expect the the escape key to dismiss the popover normally.
443
+ // Expect the escape key to dismiss the popover normally.
445
444
  await page.keyboard.press( 'Escape' );
446
445
  expect(
447
446
  await page.$(
@@ -108,7 +108,6 @@ describe( 'Multi-block selection', () => {
108
108
  await pressKeyWithModifier( 'primary', 'a' );
109
109
  await pressKeyWithModifier( 'primary', 'a' );
110
110
 
111
- await testNativeSelection();
112
111
  expect( await getSelectedFlatIndices() ).toEqual( [ 1, 2, 3 ] );
113
112
 
114
113
  // TODO: It would be great to do this test by spying on `wp.a11y.speak`,
@@ -420,7 +419,6 @@ describe( 'Multi-block selection', () => {
420
419
  await page.mouse.move( coord2.x, coord2.y, { steps: 10 } );
421
420
  await page.mouse.up();
422
421
 
423
- await testNativeSelection();
424
422
  expect( await getSelectedFlatIndices() ).toEqual( [ 1, 2 ] );
425
423
  } );
426
424
 
@@ -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
  }
@@ -19,7 +19,7 @@ describe( 'Post visibility', () => {
19
19
 
20
20
  await openDocumentSettingsSidebar();
21
21
 
22
- await page.click( '.edit-post-post-visibility__toggle' );
22
+ await page.click( '*[aria-label^="Select visibility"]' );
23
23
 
24
24
  const [ privateLabel ] = await page.$x(
25
25
  '//label[text()="Private"]'
@@ -57,7 +57,7 @@ describe( 'Post visibility', () => {
57
57
  .getEditedPostAttribute( 'status' );
58
58
  } );
59
59
 
60
- await page.click( '.edit-post-post-visibility__toggle' );
60
+ await page.click( '*[aria-label^="Select visibility"]' );
61
61
 
62
62
  const [ privateLabel ] = await page.$x(
63
63
  '//label[text()="Private"]'
@@ -90,7 +90,7 @@ describe( 'Post visibility', () => {
90
90
  await openDocumentSettingsSidebar();
91
91
 
92
92
  // Set a publish date for the next month.
93
- await page.click( '.edit-post-post-schedule__toggle' );
93
+ await page.click( '*[aria-label^="Change date"]' );
94
94
  await page.click(
95
95
  '*[aria-label="Move forward to switch to the next month."]'
96
96
  );
@@ -100,7 +100,7 @@ describe( 'Post visibility', () => {
100
100
  )
101
101
  )[ 0 ].click();
102
102
 
103
- await page.click( '.edit-post-post-visibility__toggle' );
103
+ await page.click( '*[aria-label^="Select visibility"]' );
104
104
 
105
105
  const [ privateLabel ] = await page.$x( '//label[text()="Private"]' );
106
106
  await privateLabel.click();
@@ -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
  }
@@ -39,7 +39,7 @@ describe( 'Scheduling', () => {
39
39
  expect( await getPublishButtonText() ).toBe( 'Publish' );
40
40
 
41
41
  // Open the datepicker.
42
- await page.click( '.edit-post-post-schedule__toggle' );
42
+ await page.click( '*[aria-label^="Change date"]' );
43
43
 
44
44
  // Change the publishing date to a year in the future.
45
45
  await page.click( '.components-datetime__time-field-year' );
@@ -56,7 +56,7 @@ describe( 'Scheduling', () => {
56
56
  it( 'Should keep date time UI focused when the previous and next month buttons are clicked', async () => {
57
57
  await createNewPost();
58
58
 
59
- await page.click( '.edit-post-post-schedule__toggle' );
59
+ await page.click( '*[aria-label^="Change date"]' );
60
60
  await page.click(
61
61
  '*[aria-label="Move backward to switch to the previous month."]'
62
62
  );
@@ -5,17 +5,16 @@ import {
5
5
  activatePlugin,
6
6
  createNewPost,
7
7
  deactivatePlugin,
8
- findSidebarPanelWithTitle,
9
8
  publishPost,
10
9
  } from '@wordpress/e2e-test-utils';
11
10
 
12
- const permalinkPanelXPath = `//div[contains(@class, "edit-post-sidebar")]//button[contains(@class, "components-panel__body-toggle") and contains(text(),"Permalink")]`;
11
+ const urlButtonSelector = '*[aria-label^="Change URL"]';
13
12
 
14
13
  // This tests are not together with the remaining sidebar tests,
15
- // because we need to publish/save a post, to correctly test the permalink panel.
14
+ // because we need to publish/save a post, to correctly test the permalink row.
16
15
  // The sidebar test suit enforces that focus is never lost, but during save operations
17
16
  // the focus is lost and a new element is focused once the save is completed.
18
- describe( 'Sidebar Permalink Panel', () => {
17
+ describe( 'Sidebar Permalink', () => {
19
18
  beforeAll( async () => {
20
19
  await activatePlugin( 'gutenberg-test-custom-post-types' );
21
20
  } );
@@ -24,39 +23,30 @@ describe( 'Sidebar Permalink Panel', () => {
24
23
  await deactivatePlugin( 'gutenberg-test-custom-post-types' );
25
24
  } );
26
25
 
27
- it( 'should allow permalink sidebar panel to be removed', async () => {
28
- await createNewPost();
29
- await page.evaluate( () => {
30
- const { removeEditorPanel } = wp.data.dispatch( 'core/edit-post' );
31
- removeEditorPanel( 'post-link' );
32
- } );
33
- expect( await page.$x( permalinkPanelXPath ) ).toEqual( [] );
34
- } );
35
-
36
- it( 'should not render link panel when post is publicly queryable but not public', async () => {
26
+ it( 'should not render URL when post is publicly queryable but not public', async () => {
37
27
  await createNewPost( { postType: 'public_q_not_public' } );
38
28
  await page.keyboard.type( 'aaaaa' );
39
29
  await publishPost();
40
30
  // Start editing again.
41
31
  await page.type( '.editor-post-title__input', ' (Updated)' );
42
- expect( await page.$x( permalinkPanelXPath ) ).toEqual( [] );
32
+ expect( await page.$( urlButtonSelector ) ).toBeNull();
43
33
  } );
44
34
 
45
- it( 'should not render link panel when post is public but not publicly queryable', async () => {
35
+ it( 'should not render URL when post is public but not publicly queryable', async () => {
46
36
  await createNewPost( { postType: 'not_public_q_public' } );
47
37
  await page.keyboard.type( 'aaaaa' );
48
38
  await publishPost();
49
39
  // Start editing again.
50
40
  await page.type( '.editor-post-title__input', ' (Updated)' );
51
- expect( await page.$x( permalinkPanelXPath ) ).toEqual( [] );
41
+ expect( await page.$( urlButtonSelector ) ).toBeNull();
52
42
  } );
53
43
 
54
- it( 'should render link panel when post is public and publicly queryable', async () => {
44
+ it( 'should render URL when post is public and publicly queryable', async () => {
55
45
  await createNewPost( { postType: 'public_q_public' } );
56
46
  await page.keyboard.type( 'aaaaa' );
57
47
  await publishPost();
58
48
  // Start editing again.
59
49
  await page.type( '.editor-post-title__input', ' (Updated)' );
60
- expect( await findSidebarPanelWithTitle( 'Permalink' ) ).toBeDefined();
50
+ expect( await page.$( urlButtonSelector ) ).not.toBeNull();
61
51
  } );
62
52
  } );
@@ -131,9 +131,7 @@ describe( 'Sidebar', () => {
131
131
  ).toBeDefined();
132
132
  expect( await findSidebarPanelWithTitle( 'Excerpt' ) ).toBeDefined();
133
133
  expect( await findSidebarPanelWithTitle( 'Discussion' ) ).toBeDefined();
134
- expect(
135
- await findSidebarPanelWithTitle( 'Status & visibility' )
136
- ).toBeDefined();
134
+ expect( await findSidebarPanelWithTitle( 'Summary' ) ).toBeDefined();
137
135
 
138
136
  await page.evaluate( () => {
139
137
  const { removeEditorPanel } = wp.data.dispatch( 'core/edit-post' );
@@ -165,8 +163,8 @@ describe( 'Sidebar', () => {
165
163
  expect(
166
164
  await page.$x( getPanelToggleSelector( 'Discussion' ) )
167
165
  ).toEqual( [] );
168
- expect(
169
- await page.$x( getPanelToggleSelector( 'Status & visibility' ) )
170
- ).toEqual( [] );
166
+ expect( await page.$x( getPanelToggleSelector( 'Summary' ) ) ).toEqual(
167
+ []
168
+ );
171
169
  } );
172
170
  } );
@@ -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 );