@wordpress/e2e-tests 4.1.0 → 4.2.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.
@@ -13,6 +13,7 @@ import {
13
13
  clearLocalStorage,
14
14
  enablePageDialogAccept,
15
15
  isOfflineMode,
16
+ resetPreferences,
16
17
  setBrowserViewport,
17
18
  trashAllPosts,
18
19
  } from '@wordpress/e2e-test-utils';
@@ -242,6 +243,7 @@ beforeAll( async () => {
242
243
  enablePageDialogAccept();
243
244
  observeConsoleLogging();
244
245
  await simulateAdverseConditions();
246
+ await resetPreferences();
245
247
  await activateTheme( 'twentytwentyone' );
246
248
  await trashAllPosts();
247
249
  await trashAllPosts( 'wp_block' );
@@ -253,6 +255,7 @@ beforeAll( async () => {
253
255
  } );
254
256
 
255
257
  afterEach( async () => {
258
+ await resetPreferences();
256
259
  await setupBrowser();
257
260
  } );
258
261
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/e2e-tests",
3
- "version": "4.1.0",
3
+ "version": "4.2.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.3.0",
26
+ "@wordpress/e2e-test-utils": "^7.4.0",
27
27
  "@wordpress/jest-console": "^5.0.2",
28
28
  "@wordpress/jest-puppeteer-axe": "^4.0.2",
29
- "@wordpress/scripts": "^22.5.0",
30
- "@wordpress/url": "^3.8.0",
29
+ "@wordpress/scripts": "^23.0.0",
30
+ "@wordpress/url": "^3.9.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": "1ba52312b56db563df2d8d4fba5b00613fb46d8c"
49
+ "gitHead": "4631d515033397fcfeda77e5755960253caef9bf"
50
50
  }
@@ -11,7 +11,7 @@ import {
11
11
  trashAllComments,
12
12
  } from '@wordpress/e2e-test-utils';
13
13
 
14
- describe( 'Comment Query Loop', () => {
14
+ describe( 'Comments', () => {
15
15
  let previousPageComments,
16
16
  previousCommentsPerPage,
17
17
  previousDefaultCommentsPage;
@@ -27,19 +27,12 @@ describe( 'Comment Query Loop', () => {
27
27
  it( 'We show no results message if there are no comments', async () => {
28
28
  await trashAllComments();
29
29
  await createNewPost();
30
- await insertBlock( 'Comments Query Loop' );
31
- await page.waitForSelector( '[data-testid="noresults"]' );
32
- expect(
33
- await page.evaluate(
34
- ( el ) => el.innerText,
35
- await page.$( '[data-testid="noresults"]' )
36
- )
37
- ).toEqual( 'No results found.' );
30
+ await insertBlock( 'Comments' );
31
+ await page.waitForXPath( '//p[contains(text(), "No results found.")]' );
38
32
  } );
39
33
  it( 'Pagination links are working as expected', async () => {
40
34
  await createNewPost();
41
- await insertBlock( 'Comments Query Loop' );
42
- await insertBlock( 'Post Comments Form' );
35
+ await insertBlock( 'Comments' );
43
36
  await publishPost();
44
37
  // Visit the post that was just published.
45
38
  await page.click(
@@ -99,8 +92,7 @@ describe( 'Comment Query Loop', () => {
99
92
  it( 'Pagination links are not appearing if break comments is not enabled', async () => {
100
93
  await setOption( 'page_comments', '0' );
101
94
  await createNewPost();
102
- await insertBlock( 'Comments Query Loop' );
103
- await insertBlock( 'Post Comments Form' );
95
+ await insertBlock( 'Comments' );
104
96
  await publishPost();
105
97
  // Visit the post that was just published.
106
98
  await page.click(
@@ -9,19 +9,18 @@ import {
9
9
  } from '@wordpress/e2e-test-utils';
10
10
 
11
11
  describe( 'Nonce', () => {
12
- beforeAll( async () => {
12
+ // While using beforeEach/afterEach is suboptimal for multiple tests, they
13
+ // are used here to ensure that the nonce plugin doesn't interfere with API
14
+ // calls made in global before/after calls, which may perform API requests.
15
+ beforeEach( async () => {
13
16
  await activatePlugin( 'gutenberg-test-plugin-nonce' );
14
17
  } );
15
-
16
- afterAll( async () => {
18
+ afterEach( async () => {
17
19
  await deactivatePlugin( 'gutenberg-test-plugin-nonce' );
18
20
  } );
19
21
 
20
- beforeEach( async () => {
21
- await createNewPost();
22
- } );
23
-
24
22
  it( 'should refresh when expired', async () => {
23
+ await createNewPost();
25
24
  await page.keyboard.press( 'Enter' );
26
25
  // eslint-disable-next-line no-restricted-syntax
27
26
  await page.waitForTimeout( 5000 );
@@ -10,6 +10,7 @@ import {
10
10
  clickBlockToolbarButton,
11
11
  clickButton,
12
12
  clickMenuItem,
13
+ insertBlock,
13
14
  openListView,
14
15
  saveDraft,
15
16
  transformBlockTo,
@@ -975,4 +976,51 @@ describe( 'Multi-block selection', () => {
975
976
  // Expect two blocks with "&" in between.
976
977
  expect( await getEditedPostContent() ).toMatchSnapshot();
977
978
  } );
979
+ describe( 'shift+click multi-selection', () => {
980
+ it( 'should multi-select block with text selection and a block without text selection', async () => {
981
+ await page.keyboard.press( 'Enter' );
982
+ await page.keyboard.type( 'hi' );
983
+ await page.keyboard.press( 'Enter' );
984
+ await insertBlock( 'Spacer' );
985
+ await page.keyboard.press( 'ArrowUp' );
986
+
987
+ const spacerBlock = await page.waitForSelector(
988
+ '.wp-block.wp-block-spacer'
989
+ );
990
+ const boundingBox = await spacerBlock.boundingBox();
991
+ const mousePosition = {
992
+ x: boundingBox.x + boundingBox.width / 2,
993
+ y: boundingBox.y + boundingBox.height / 2,
994
+ };
995
+ await page.keyboard.down( 'Shift' );
996
+ await page.mouse.click( mousePosition.x, mousePosition.y );
997
+ await page.keyboard.up( 'Shift' );
998
+
999
+ const selectedBlocks = await page.$$(
1000
+ '.wp-block.is-multi-selected'
1001
+ );
1002
+ expect( selectedBlocks.length ).toBe( 2 );
1003
+ } );
1004
+ it( 'should multi-select blocks without text selection', async () => {
1005
+ await insertBlock( 'Spacer' );
1006
+ // Get the first spacer block element.
1007
+ const spacerBlock = await page.waitForSelector(
1008
+ '.wp-block.wp-block-spacer'
1009
+ );
1010
+ const boundingBox = await spacerBlock.boundingBox();
1011
+ await page.keyboard.press( 'Enter' );
1012
+ await insertBlock( 'Spacer' );
1013
+ const mousePosition = {
1014
+ x: boundingBox.x + boundingBox.width / 2,
1015
+ y: boundingBox.y + boundingBox.height / 2,
1016
+ };
1017
+ await page.keyboard.down( 'Shift' );
1018
+ await page.mouse.click( mousePosition.x, mousePosition.y );
1019
+ await page.keyboard.up( 'Shift' );
1020
+ const selectedBlocks = await page.$$(
1021
+ '.wp-block.is-multi-selected'
1022
+ );
1023
+ expect( selectedBlocks.length ).toBe( 2 );
1024
+ } );
1025
+ } );
978
1026
  } );
@@ -9,6 +9,7 @@ import {
9
9
  pressKeyWithModifier,
10
10
  insertBlock,
11
11
  clickBlockToolbarButton,
12
+ openDocumentSettingsSidebar,
12
13
  } from '@wordpress/e2e-test-utils';
13
14
 
14
15
  const getActiveBlockName = async () =>
@@ -701,7 +702,7 @@ describe( 'Writing Flow', () => {
701
702
  ).toBe( 'Table' );
702
703
  } );
703
704
 
704
- it( 'Should unselect all blocks when hitting double escape', async () => {
705
+ it( 'should unselect all blocks when hitting double escape', async () => {
705
706
  // Add demo content.
706
707
  await page.keyboard.press( 'Enter' );
707
708
  await page.keyboard.type( 'Random Paragraph' );
@@ -720,4 +721,33 @@ describe( 'Writing Flow', () => {
720
721
  activeBlockName = await getActiveBlockName();
721
722
  expect( activeBlockName ).toBe( undefined );
722
723
  } );
724
+
725
+ // Checks for regressions of https://github.com/WordPress/gutenberg/issues/40091.
726
+ it( 'does not deselect the block when selecting text outside the editor canvas', async () => {
727
+ await page.keyboard.press( 'Enter' );
728
+ await page.keyboard.type( 'Random Paragraph' );
729
+ await openDocumentSettingsSidebar();
730
+ const blockDescription = await page.waitForSelector(
731
+ '.block-editor-block-card__description'
732
+ );
733
+ const boundingBox = await blockDescription.boundingBox();
734
+ const startPosition = {
735
+ x: boundingBox.x + 10,
736
+ y: boundingBox.y + 8,
737
+ };
738
+ const endPosition = {
739
+ x: startPosition.x + 50,
740
+ y: startPosition.y,
741
+ };
742
+
743
+ await page.mouse.move( startPosition.x, startPosition.y );
744
+ await page.mouse.down();
745
+ await page.mouse.move( endPosition.x, endPosition.y );
746
+ await page.mouse.up();
747
+
748
+ const selectedParagraph = await page.waitForSelector(
749
+ '.wp-block-paragraph.is-selected'
750
+ );
751
+ expect( selectedParagraph ).toBeDefined();
752
+ } );
723
753
  } );
@@ -0,0 +1,46 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import {
5
+ insertBlock,
6
+ activateTheme,
7
+ setOption,
8
+ visitSiteEditor,
9
+ openSiteEditorNavigationPanel,
10
+ navigateSiteEditorBackToRoot,
11
+ deleteAllTemplates,
12
+ canvas,
13
+ } from '@wordpress/e2e-test-utils';
14
+
15
+ describe( 'Post Comments Form', () => {
16
+ beforeAll( async () => {
17
+ await activateTheme( 'emptytheme' );
18
+ await deleteAllTemplates( 'wp_template' );
19
+ } );
20
+
21
+ describe( 'placeholder', () => {
22
+ it( 'displays in site editor even when comments are closed by default', async () => {
23
+ await setOption( 'default_comment_status', 'closed' );
24
+
25
+ // Navigate to "Singular" post template
26
+ await visitSiteEditor();
27
+ await openSiteEditorNavigationPanel();
28
+ await navigateSiteEditorBackToRoot();
29
+ await expect( page ).toClick(
30
+ '.components-navigation__item-title',
31
+ { text: /templates/i }
32
+ );
33
+ await expect( page ).toClick( '.components-heading > a', {
34
+ text: /singular/i,
35
+ } );
36
+
37
+ // Insert post comments form
38
+ await insertBlock( 'Post Comments Form' );
39
+
40
+ // Ensure the placeholder is there
41
+ await expect( canvas() ).toMatchElement(
42
+ '.wp-block-post-comments-form .comment-form'
43
+ );
44
+ } );
45
+ } );
46
+ } );
@@ -1,26 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { createNewPost, insertBlock } from '@wordpress/e2e-test-utils';
5
-
6
- describe( 'Paragraph', () => {
7
- beforeEach( async () => {
8
- await createNewPost();
9
- } );
10
-
11
- it( 'should output unwrapped editable paragraph', async () => {
12
- await insertBlock( 'Paragraph' );
13
- await page.keyboard.type( '1' );
14
-
15
- const firstBlockTagName = await page.evaluate( () => {
16
- return document.querySelector(
17
- '.block-editor-block-list__layout .wp-block'
18
- ).tagName;
19
- } );
20
-
21
- // The outer element should be a paragraph. Blocks should never have any
22
- // additional div wrappers so the markup remains simple and easy to
23
- // style.
24
- expect( firstBlockTagName ).toBe( 'P' );
25
- } );
26
- } );
@@ -1,71 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import path from 'path';
5
- import fs from 'fs';
6
- import os from 'os';
7
- import { v4 as uuid } from 'uuid';
8
-
9
- /**
10
- * WordPress dependencies
11
- */
12
- import {
13
- activatePlugin,
14
- createNewPost,
15
- deactivatePlugin,
16
- insertBlock,
17
- openDocumentSettingsSidebar,
18
- } from '@wordpress/e2e-test-utils';
19
-
20
- describe( 'changing image size', () => {
21
- beforeEach( async () => {
22
- await activatePlugin( 'gutenberg-test-image-size' );
23
- await createNewPost();
24
- } );
25
-
26
- afterEach( async () => {
27
- await deactivatePlugin( 'gutenberg-test-image-size' );
28
- } );
29
-
30
- it( 'should insert and change my image size', async () => {
31
- await insertBlock( 'Image' );
32
- const inputElement = await page.waitForSelector(
33
- 'figure[aria-label="Block: Image"] input[type=file]'
34
- );
35
- const testImagePath = path.join(
36
- __dirname,
37
- '..',
38
- '..',
39
- '..',
40
- 'assets',
41
- '1024x768_e2e_test_image_size.jpg'
42
- );
43
- const filename = uuid();
44
- const tmpFileName = path.join( os.tmpdir(), filename + '.jpg' );
45
- fs.copyFileSync( testImagePath, tmpFileName );
46
- await inputElement.uploadFile( tmpFileName );
47
-
48
- // Wait for upload to finish.
49
- await page.waitForXPath( `//img[contains(@src, "${ filename }")]` );
50
-
51
- // Select the new size updated with the plugin.
52
- await openDocumentSettingsSidebar();
53
- const imageSizeLabel = await page.waitForXPath(
54
- '//label[text()="Image size"]'
55
- );
56
- await imageSizeLabel.click();
57
- const imageSizeSelect = await page.evaluateHandle(
58
- () => document.activeElement
59
- );
60
- await imageSizeSelect.select( 'custom-size-one' );
61
-
62
- // Verify that the custom size was applied to the image.
63
- await page.waitForSelector( '.wp-block-image.size-custom-size-one' );
64
- await page.waitForFunction(
65
- () =>
66
- document.querySelector(
67
- '.block-editor-image-size-control__width input'
68
- ).value === '499'
69
- );
70
- } );
71
- } );