@wordpress/e2e-tests 4.3.0 → 4.6.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 (52) hide show
  1. package/config/flaky-tests-reporter.js +3 -3
  2. package/package.json +6 -6
  3. package/specs/editor/blocks/cover.test.js +10 -14
  4. package/specs/editor/blocks/heading.test.js +1 -5
  5. package/specs/editor/blocks/navigation.test.js +72 -23
  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-inline-styles.test.js +1 -0
  9. package/specs/editor/plugins/iframed-masonry-block.test.js +3 -2
  10. package/specs/editor/plugins/inner-blocks-allowed-blocks.test.js +3 -1
  11. package/specs/editor/various/__snapshots__/inserting-blocks.test.js.snap +1 -1
  12. package/specs/editor/various/datepicker.test.js +30 -18
  13. package/specs/editor/various/embedding.test.js +2 -4
  14. package/specs/editor/various/links.test.js +2 -3
  15. package/specs/editor/various/navigable-toolbar.test.js +2 -3
  16. package/specs/editor/various/post-visibility.test.js +1 -1
  17. package/specs/editor/various/publishing.test.js +4 -2
  18. package/specs/editor/various/scheduling.test.js +2 -2
  19. package/specs/editor/various/sidebar.test.js +4 -6
  20. package/specs/editor/various/switch-to-draft.test.js +1 -1
  21. package/specs/editor/various/taxonomies.test.js +8 -7
  22. package/specs/editor/various/writing-flow.test.js +19 -0
  23. package/specs/experiments/navigation-editor.test.js +4 -6
  24. package/specs/performance/post-editor.test.js +10 -14
  25. package/specs/performance/site-editor.test.js +2 -5
  26. package/specs/widgets/editing-widgets.test.js +12 -8
  27. package/specs/editor/blocks/__snapshots__/buttons.test.js.snap +0 -33
  28. package/specs/editor/blocks/__snapshots__/code.test.js.snap +0 -14
  29. package/specs/editor/blocks/__snapshots__/html.test.js.snap +0 -8
  30. package/specs/editor/blocks/__snapshots__/preformatted.test.js.snap +0 -24
  31. package/specs/editor/blocks/__snapshots__/separator.test.js.snap +0 -7
  32. package/specs/editor/blocks/__snapshots__/spacer.test.js.snap +0 -13
  33. package/specs/editor/blocks/__snapshots__/table.test.js.snap +0 -61
  34. package/specs/editor/blocks/buttons.test.js +0 -95
  35. package/specs/editor/blocks/code.test.js +0 -48
  36. package/specs/editor/blocks/html.test.js +0 -31
  37. package/specs/editor/blocks/preformatted.test.js +0 -62
  38. package/specs/editor/blocks/separator.test.js +0 -22
  39. package/specs/editor/blocks/spacer.test.js +0 -48
  40. package/specs/editor/blocks/table.test.js +0 -296
  41. package/specs/editor/various/__snapshots__/rtl.test.js.snap +0 -63
  42. package/specs/editor/various/preview.test.js +0 -425
  43. package/specs/editor/various/rtl.test.js +0 -129
  44. package/specs/site-editor/style-variations.test.js +0 -213
  45. package/specs/site-editor/template-part.test.js +0 -346
  46. package/specs/site-editor/template-revert.test.js +0 -209
  47. package/themes/style-variations/block-templates/index.html +0 -11
  48. package/themes/style-variations/index.php +0 -0
  49. package/themes/style-variations/style.css +0 -15
  50. package/themes/style-variations/styles/pink.json +0 -33
  51. package/themes/style-variations/styles/yellow.json +0 -12
  52. package/themes/style-variations/theme.json +0 -8
@@ -49,13 +49,13 @@ 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`,
58
57
  JSON.stringify( {
58
+ version: 1,
59
59
  runner: 'jest-circus',
60
60
  title: testTitle,
61
61
  path: testPath,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/e2e-tests",
3
- "version": "4.3.0",
3
+ "version": "4.6.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.5.0",
27
- "@wordpress/jest-console": "^5.1.0",
26
+ "@wordpress/e2e-test-utils": "^7.8.0",
27
+ "@wordpress/jest-console": "^5.3.0",
28
28
  "@wordpress/jest-puppeteer-axe": "^4.0.2",
29
- "@wordpress/scripts": "^23.1.0",
30
- "@wordpress/url": "^3.10.0",
29
+ "@wordpress/scripts": "^23.4.0",
30
+ "@wordpress/url": "^3.13.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": "198fa129cf1af8dc615918987ea6795cd40ab7df"
49
+ "gitHead": "a80eeb62ec7cb1418b9915c277e084a29d6665e3"
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' );
@@ -12,8 +12,6 @@ describe( 'Heading', () => {
12
12
  const COLOR_ITEM_SELECTOR =
13
13
  '.block-editor-panel-color-gradient-settings__dropdown';
14
14
  const CUSTOM_COLOR_BUTTON_X_SELECTOR = `.components-color-palette__custom-color`;
15
- const CUSTOM_COLOR_DETAILS_BUTTON_SELECTOR =
16
- '.components-color-picker button[aria-label="Show detailed inputs"]';
17
15
  const COLOR_INPUT_FIELD_SELECTOR =
18
16
  '.components-color-picker .components-input-control__input';
19
17
 
@@ -82,13 +80,11 @@ describe( 'Heading', () => {
82
80
  );
83
81
 
84
82
  await customTextColorButton.click();
85
- await page.click( CUSTOM_COLOR_DETAILS_BUTTON_SELECTOR );
86
83
  await page.waitForSelector( COLOR_INPUT_FIELD_SELECTOR );
87
84
  await page.click( COLOR_INPUT_FIELD_SELECTOR );
88
85
  await pressKeyWithModifier( 'primary', 'A' );
89
86
  await page.keyboard.type( '4b7f4d' );
90
- await page.waitForXPath( '//button//span[contains(text(), "4b7f4d")]' );
91
- await page.click( '.wp-block-post-title' );
87
+ await page.keyboard.press( 'Enter' );
92
88
  expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
93
89
  "<!-- wp:heading {\\"level\\":3,\\"style\\":{\\"color\\":{\\"text\\":\\"#4b7f4d\\"}}} -->
94
90
  <h3 class=\\"has-text-color\\" style=\\"color:#4b7f4d\\">Heading</h3>
@@ -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(
@@ -807,6 +808,58 @@ describe( 'Navigation', () => {
807
808
  );
808
809
  } );
809
810
 
811
+ it( 'correctly decodes special characters in the created Page title for display', async () => {
812
+ await createNewPost();
813
+ await insertBlock( 'Navigation' );
814
+ const startEmptyButton = await page.waitForXPath( START_EMPTY_XPATH );
815
+ await startEmptyButton.click();
816
+ const appender = await page.waitForSelector(
817
+ '.wp-block-navigation .block-list-appender'
818
+ );
819
+ await appender.click();
820
+
821
+ // Wait for URL input to be focused
822
+ // Insert name for the new page.
823
+ const pageTitle = 'This & That & Some < other > chars';
824
+ const input = await page.waitForSelector(
825
+ 'input.block-editor-url-input__input:focus'
826
+ );
827
+ await input.type( pageTitle );
828
+
829
+ // When creating a page, the URLControl makes a request to the
830
+ // url-details endpoint to fetch information about the page.
831
+ // Because the draft is inaccessible publicly, this request
832
+ // returns a 404 response. Wait for the response and expect
833
+ // the error to have occurred.
834
+ const createPageButton = await page.waitForSelector(
835
+ '.block-editor-link-control__search-create'
836
+ );
837
+ const responsePromise = page.waitForResponse(
838
+ ( response ) =>
839
+ response.url().includes( 'url-details' ) &&
840
+ response.status() === 404
841
+ );
842
+ const createPagePromise = createPageButton.click();
843
+ await Promise.all( [ responsePromise, createPagePromise ] );
844
+
845
+ await waitForBlock( 'Navigation' );
846
+
847
+ const innerLinkBlock = await waitForBlock( 'Custom Link' );
848
+
849
+ const linkText = await innerLinkBlock.$eval(
850
+ '[aria-label="Navigation link text"]',
851
+ ( element ) => {
852
+ return element.innerText;
853
+ }
854
+ );
855
+
856
+ expect( linkText ).toContain( pageTitle );
857
+
858
+ expect( console ).toHaveErroredWith(
859
+ 'Failed to load resource: the server responded with a status of 404 (Not Found)'
860
+ );
861
+ } );
862
+
810
863
  it( 'renders buttons for the submenu opener elements when the block is set to open on click instead of hover', async () => {
811
864
  await createClassicMenu( { name: 'Test Menu 2' }, menuItemsFixture );
812
865
  await createNewPost();
@@ -1294,11 +1347,9 @@ describe( 'Navigation', () => {
1294
1347
  `//*[contains(@class, 'components-snackbar__content')][ text()="You do not have permission to edit this Menu. Any changes made will not be saved." ]`
1295
1348
  );
1296
1349
 
1297
- // Expect a console 403 for request to Navigation Areas for lower permission users.
1298
- // This is because reading requires the `edit_theme_options` capability
1299
- // which the Contributor level user does not have.
1300
- // See: https://github.com/WordPress/gutenberg/blob/4cedaf0c4abb0aeac4bfd4289d63e9889efe9733/lib/class-wp-rest-block-navigation-areas-controller.php#L81-L91.
1301
- // Todo: removed once Nav Areas are removed from the Gutenberg Plugin.
1350
+ // Expect a console 403 for requests to:
1351
+ // * /wp/v2/settings?_locale=user
1352
+ // * /wp/v2/templates?context=edit&post_type=post&per_page=100&_locale=user
1302
1353
  expect( console ).toHaveErrored();
1303
1354
  } );
1304
1355
 
@@ -1317,11 +1368,9 @@ describe( 'Navigation', () => {
1317
1368
  `//*[contains(@class, 'components-snackbar__content')][ text()="${ noticeText }" ]`
1318
1369
  );
1319
1370
 
1320
- // Expect a console 403 for request to Navigation Areas for lower permission users.
1321
- // This is because reading requires the `edit_theme_options` capability
1322
- // which the Contributor level user does not have.
1323
- // See: https://github.com/WordPress/gutenberg/blob/4cedaf0c4abb0aeac4bfd4289d63e9889efe9733/lib/class-wp-rest-block-navigation-areas-controller.php#L81-L91.
1324
- // Todo: removed once Nav Areas are removed from the Gutenberg Plugin.
1371
+ // Expect a console 403 for requests to:
1372
+ // * /wp/v2/settings?_locale=user
1373
+ // * /wp/v2/templates?context=edit&post_type=post&per_page=100&_locale=user
1325
1374
  expect( console ).toHaveErrored();
1326
1375
  } );
1327
1376
  } );
@@ -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' );
@@ -32,6 +32,7 @@ describe( 'iframed inline styles', () => {
32
32
  await deactivatePlugin( 'gutenberg-test-iframed-inline-styles' );
33
33
  } );
34
34
 
35
+ // Skip flaky test. See https://github.com/WordPress/gutenberg/issues/35172
35
36
  it.skip( 'should load inline styles in iframe', async () => {
36
37
  await insertBlock( 'Iframed Inline Styles' );
37
38
 
@@ -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
 
@@ -108,7 +108,7 @@ exports[`Inserting blocks inserts a block in proper place after having clicked \
108
108
  exports[`Inserting blocks inserts blocks at root level when using the root appender while selection is in an inner block 1`] = `
109
109
  "<!-- wp:buttons -->
110
110
  <div class=\\"wp-block-buttons\\"><!-- wp:button -->
111
- <div class=\\"wp-block-button\\"><a class=\\"wp-block-button__link\\">1.1</a></div>
111
+ <div class=\\"wp-block-button\\"><a class=\\"wp-block-button__link wp-element-button\\">1.1</a></div>
112
112
  <!-- /wp:button --></div>
113
113
  <!-- /wp:buttons -->
114
114
 
@@ -15,12 +15,24 @@ async function getSelectedOptionLabel( selector ) {
15
15
  }
16
16
 
17
17
  async function getDatePickerValues() {
18
- const year = await getInputValue( '[aria-label="Year"]' );
19
- const month = await getInputValue( '[aria-label="Month"]' );
20
- const monthLabel = await getSelectedOptionLabel( '[aria-label="Month"]' );
21
- const day = await getInputValue( '[aria-label="Day"]' );
22
- const hours = await getInputValue( '[aria-label="Hours"]' );
23
- const minutes = await getInputValue( '[aria-label="Minutes"]' );
18
+ const year = await getInputValue(
19
+ '.components-datetime__time-field-year input'
20
+ );
21
+ const month = await getInputValue(
22
+ '.components-datetime__time-field-month select'
23
+ );
24
+ const monthLabel = await getSelectedOptionLabel(
25
+ '.components-datetime__time-field-month select'
26
+ );
27
+ const day = await getInputValue(
28
+ '.components-datetime__time-field-day input'
29
+ );
30
+ const hours = await getInputValue(
31
+ '.components-datetime__time-field-hours-input input'
32
+ );
33
+ const minutes = await getInputValue(
34
+ '.components-datetime__time-field-minutes-input input'
35
+ );
24
36
  const amOrPm = await page.$eval(
25
37
  '.components-datetime__time-field-am-pm .is-primary',
26
38
  ( element ) => element.innerText.toLowerCase()
@@ -33,17 +45,13 @@ function trimLeadingZero( str ) {
33
45
  return str[ 0 ] === '0' ? str.slice( 1 ) : str;
34
46
  }
35
47
 
36
- function formatDatePickerValues( {
37
- year,
38
- monthLabel,
39
- day,
40
- hours,
41
- minutes,
42
- amOrPm,
43
- } ) {
48
+ function formatDatePickerValues(
49
+ { year, monthLabel, day, hours, minutes, amOrPm },
50
+ timezone
51
+ ) {
44
52
  const dayTrimmed = trimLeadingZero( day );
45
53
  const hoursTrimmed = trimLeadingZero( hours );
46
- return `${ monthLabel } ${ dayTrimmed }, ${ year } ${ hoursTrimmed }:${ minutes } ${ amOrPm }`;
54
+ return `${ monthLabel } ${ dayTrimmed }, ${ year } ${ hoursTrimmed }:${ minutes }\xa0${ amOrPm } ${ timezone }`;
47
55
  }
48
56
 
49
57
  async function getPublishingDate() {
@@ -58,11 +66,13 @@ describe.each( [ [ 'UTC-10' ], [ 'UTC' ], [ 'UTC+10' ] ] )(
58
66
  ( timezone ) => {
59
67
  let oldTimezone;
60
68
  beforeEach( async () => {
69
+ await page.emulateTimezone( 'America/New_York' ); // Set browser to a timezone that's different to `timezone`.
61
70
  oldTimezone = await changeSiteTimezone( timezone );
62
71
  await createNewPost();
63
72
  } );
64
73
  afterEach( async () => {
65
74
  await changeSiteTimezone( oldTimezone );
75
+ await page.emulateTimezone( null );
66
76
  } );
67
77
 
68
78
  it( 'should show the publishing date as "Immediately" if the date is not altered', async () => {
@@ -86,7 +96,7 @@ describe.each( [ [ 'UTC-10' ], [ 'UTC' ], [ 'UTC+10' ] ] )(
86
96
  const publishingDate = await getPublishingDate();
87
97
 
88
98
  expect( publishingDate ).toBe(
89
- formatDatePickerValues( datePickerValues )
99
+ formatDatePickerValues( datePickerValues, timezone )
90
100
  );
91
101
  } );
92
102
 
@@ -107,7 +117,7 @@ describe.each( [ [ 'UTC-10' ], [ 'UTC' ], [ 'UTC+10' ] ] )(
107
117
  expect( publishingDate ).not.toEqual( 'Immediately' );
108
118
  // The expected date format will be "Sep 26, 2018 11:52 pm".
109
119
  expect( publishingDate ).toBe(
110
- formatDatePickerValues( datePickerValues )
120
+ formatDatePickerValues( datePickerValues, timezone )
111
121
  );
112
122
  } );
113
123
 
@@ -126,7 +136,9 @@ describe.each( [ [ 'UTC-10' ], [ 'UTC' ], [ 'UTC+10' ] ] )(
126
136
  await page.click( '.edit-post-post-schedule__toggle' );
127
137
 
128
138
  // Clear the date.
129
- await page.click( '.components-datetime__date-reset-button' );
139
+ await page.click(
140
+ '.block-editor-publish-date-time-picker button[aria-label="Now"]'
141
+ );
130
142
 
131
143
  const publishingDate = await getPublishingDate();
132
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
  }
@@ -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
  }
@@ -92,7 +92,7 @@ describe( 'Post visibility', () => {
92
92
  // Set a publish date for the next month.
93
93
  await page.click( '.edit-post-post-schedule__toggle' );
94
94
  await page.click(
95
- 'div[aria-label="Move forward to switch to the next month."]'
95
+ '*[aria-label="Move forward to switch to the next month."]'
96
96
  );
97
97
  await (
98
98
  await page.$x(
@@ -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
  }
@@ -58,11 +58,11 @@ describe( 'Scheduling', () => {
58
58
 
59
59
  await page.click( '.edit-post-post-schedule__toggle' );
60
60
  await page.click(
61
- 'div[aria-label="Move backward to switch to the previous month."]'
61
+ '*[aria-label="Move backward to switch to the previous month."]'
62
62
  );
63
63
  expect( await isDateTimeComponentFocused() ).toBe( true );
64
64
  await page.click(
65
- 'div[aria-label="Move forward to switch to the next month."]'
65
+ '*[aria-label="Move forward to switch to the next month."]'
66
66
  );
67
67
  expect( await isDateTimeComponentFocused() ).toBe( true );
68
68
  } );
@@ -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
  } );
@@ -63,7 +63,7 @@ async function scheduleTestPost( postType, viewport ) {
63
63
  // Set a publish date for the next month.
64
64
  await page.click( '.edit-post-post-schedule__toggle' );
65
65
  await page.click(
66
- 'div[aria-label="Move forward to switch to the next month."]'
66
+ '*[aria-label="Move forward to switch to the next month."]'
67
67
  );
68
68
 
69
69
  await (
@@ -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 );
@@ -734,4 +734,23 @@ describe( 'Writing Flow', () => {
734
734
  );
735
735
  expect( selectedParagraph ).toBeDefined();
736
736
  } );
737
+ it( 'should prevent browser default formatting on multi selection', async () => {
738
+ await page.keyboard.press( 'Enter' );
739
+ await page.keyboard.type( 'first' );
740
+ await page.keyboard.press( 'Enter' );
741
+ await page.keyboard.type( 'second' );
742
+
743
+ // Multi select both paragraphs.
744
+ await pressKeyTimes( 'ArrowLeft', 2 );
745
+ await page.keyboard.down( 'Shift' );
746
+ await pressKeyTimes( 'ArrowLeft', 2 );
747
+ await page.keyboard.press( 'ArrowUp' );
748
+ await page.keyboard.up( 'Shift' );
749
+ await pressKeyWithModifier( 'primary', 'b' );
750
+ const paragraphs = await page.$$eval(
751
+ '[data-type="core/paragraph"]',
752
+ ( nodes ) => Array.from( nodes ).map( ( node ) => node.innerHTML )
753
+ );
754
+ expect( paragraphs ).toEqual( [ 'first', 'second' ] );
755
+ } );
737
756
  } );