@wordpress/e2e-tests 2.5.3 → 2.5.7

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.
@@ -157,4 +157,31 @@ export const siteEditor = {
157
157
  return '';
158
158
  } );
159
159
  },
160
+
161
+ async disableWelcomeGuide() {
162
+ const isWelcomeGuideActive = await page.evaluate( () =>
163
+ wp.data.select( 'core/edit-site' ).isFeatureActive( 'welcomeGuide' )
164
+ );
165
+ const isWelcomeGuideStyesActive = await page.evaluate( () =>
166
+ wp.data
167
+ .select( 'core/edit-site' )
168
+ .isFeatureActive( 'welcomeGuideStyles' )
169
+ );
170
+
171
+ if ( isWelcomeGuideActive ) {
172
+ await page.evaluate( () =>
173
+ wp.data
174
+ .dispatch( 'core/edit-site' )
175
+ .toggleFeature( 'welcomeGuide' )
176
+ );
177
+ }
178
+
179
+ if ( isWelcomeGuideStyesActive ) {
180
+ await page.evaluate( () =>
181
+ wp.data
182
+ .dispatch( 'core/edit-site' )
183
+ .toggleFeature( 'welcomeGuideStyles' )
184
+ );
185
+ }
186
+ },
160
187
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/e2e-tests",
3
- "version": "2.5.3",
3
+ "version": "2.5.7",
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": "^5.4.6",
27
- "@wordpress/jest-console": "^4.1.0",
28
- "@wordpress/jest-puppeteer-axe": "^3.1.0",
29
- "@wordpress/scripts": "^19.1.0",
30
- "@wordpress/url": "^3.3.0",
26
+ "@wordpress/e2e-test-utils": "^5.4.8",
27
+ "@wordpress/jest-console": "^4.1.1",
28
+ "@wordpress/jest-puppeteer-axe": "^3.1.1",
29
+ "@wordpress/scripts": "^19.2.2",
30
+ "@wordpress/url": "^3.3.1",
31
31
  "chalk": "^4.0.0",
32
32
  "expect-puppeteer": "^4.4.0",
33
33
  "jest-message-util": "^27.0.6",
@@ -43,5 +43,5 @@
43
43
  "publishConfig": {
44
44
  "access": "public"
45
45
  },
46
- "gitHead": "393c2b5533837fd637e998d23f0124c081a10df0"
46
+ "gitHead": "ca22e8852fcc91889510e417bdaa180ad60f8dac"
47
47
  }
@@ -51,8 +51,9 @@ describe( 'Classic', () => {
51
51
  await page.click( '.media-menu-item#menu-item-gallery' );
52
52
 
53
53
  // Wait for media modal to appear and upload image.
54
- await page.waitForSelector( '.media-modal input[type=file]' );
55
- const inputElement = await page.$( '.media-modal input[type=file]' );
54
+ const inputElement = await page.waitForSelector(
55
+ '.media-modal .moxie-shim input[type=file]'
56
+ );
56
57
  const testImagePath = path.join(
57
58
  __dirname,
58
59
  '..',
@@ -1,3 +1,11 @@
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
+
1
9
  /**
2
10
  * WordPress dependencies
3
11
  */
@@ -5,13 +13,110 @@ import {
5
13
  insertBlock,
6
14
  createNewPost,
7
15
  openDocumentSettingsSidebar,
16
+ transformBlockTo,
8
17
  } from '@wordpress/e2e-test-utils';
9
18
 
19
+ async function upload( selector ) {
20
+ const inputElement = await page.waitForSelector(
21
+ `${ selector } input[type="file"]`
22
+ );
23
+ const testImagePath = path.join(
24
+ __dirname,
25
+ '..',
26
+ '..',
27
+ '..',
28
+ 'assets',
29
+ '10x10_e2e_test_image_z9T8jK.png'
30
+ );
31
+ const filename = uuid();
32
+ const tmpFileName = path.join( os.tmpdir(), filename + '.png' );
33
+ fs.copyFileSync( testImagePath, tmpFileName );
34
+ await inputElement.uploadFile( tmpFileName );
35
+ await page.waitForSelector( `${ selector } img[src$="${ filename }.png"]` );
36
+ return filename;
37
+ }
38
+
10
39
  describe( 'Cover', () => {
11
40
  beforeEach( async () => {
12
41
  await createNewPost();
13
42
  } );
14
43
 
44
+ it( 'can set overlay color using color picker on block placeholder', async () => {
45
+ await insertBlock( 'Cover' );
46
+ // Get the first color option from the block placeholder's color picker
47
+ const colorPickerButton = await page.waitForSelector(
48
+ '.wp-block-cover__placeholder-background-options .components-circular-option-picker__option-wrapper:first-child button'
49
+ );
50
+ // Get the RGB value of the picked color
51
+ const pickedColor = await colorPickerButton.evaluate(
52
+ ( node ) => node.style.backgroundColor
53
+ );
54
+ // Create the block by clicking selected color button
55
+ await colorPickerButton.click();
56
+ // Get the block's background dim element
57
+ const backgroundDim = await page.waitForSelector(
58
+ '.wp-block-cover .has-background-dim'
59
+ );
60
+ // Get the RGB value of the background dim
61
+ const dimColor = await backgroundDim.evaluate(
62
+ ( node ) => node.style.backgroundColor
63
+ );
64
+
65
+ expect( pickedColor ).toEqual( dimColor );
66
+ } );
67
+
68
+ it( 'can set background image using image upload on block placeholder', async () => {
69
+ await insertBlock( 'Cover' );
70
+ // Create the block using uploaded image
71
+ const sourceImageFilename = await upload( '.wp-block-cover' );
72
+ // Get the block's background image URL
73
+ const blockImage = await page.waitForSelector( '.wp-block-cover img' );
74
+ const blockImageUrl = await blockImage.evaluate( ( el ) => el.src );
75
+
76
+ expect( blockImageUrl ).toContain( sourceImageFilename );
77
+ } );
78
+
79
+ it( 'dims background image down by 50% by default', async () => {
80
+ await insertBlock( 'Cover' );
81
+ // Create the block using uploaded image
82
+ await upload( '.wp-block-cover' );
83
+ // Get the block's background dim color and its opacity
84
+ const backgroundDim = await page.waitForSelector(
85
+ '.wp-block-cover .has-background-dim'
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 );
94
+
95
+ expect( backgroundDimColor ).toBe( 'rgb(0, 0, 0)' );
96
+ expect( backgroundDimOpacity ).toBe( '0.5' );
97
+ } );
98
+
99
+ it( 'can have the title edited', async () => {
100
+ await insertBlock( 'Cover' );
101
+ // Click first color option from the block placeholder's color picker
102
+ const colorPickerButton = await page.waitForSelector(
103
+ '.wp-block-cover__placeholder-background-options .components-circular-option-picker__option-wrapper:first-child button'
104
+ );
105
+ await colorPickerButton.click();
106
+ // Click the title placeholder to put the cursor inside
107
+ const coverTitle = await page.waitForSelector(
108
+ '.wp-block-cover .wp-block-paragraph'
109
+ );
110
+ await coverTitle.click();
111
+ // Type the title
112
+ await page.keyboard.type( 'foo' );
113
+ const coverTitleText = await coverTitle.evaluate(
114
+ ( el ) => el.innerText
115
+ );
116
+
117
+ expect( coverTitleText ).toEqual( 'foo' );
118
+ } );
119
+
15
120
  it( 'can be resized using drag & drop', async () => {
16
121
  await insertBlock( 'Cover' );
17
122
  // Close the inserter
@@ -87,4 +192,26 @@ describe( 'Cover', () => {
87
192
  )
88
193
  ).toBeGreaterThan( 100 );
89
194
  } );
195
+
196
+ it( 'dims the background image down by 50% when transformed from the Image block', async () => {
197
+ await insertBlock( 'Image' );
198
+ // Upload image and transform to the Cover block
199
+ await upload( '.wp-block-image' );
200
+ await transformBlockTo( 'Cover' );
201
+
202
+ // Get the block's background dim color and its opacity
203
+ const backgroundDim = await page.waitForSelector(
204
+ '.wp-block-cover .has-background-dim'
205
+ );
206
+ const [
207
+ backgroundDimColor,
208
+ backgroundDimOpacity,
209
+ ] = await page.evaluate( ( el ) => {
210
+ const computedStyle = window.getComputedStyle( el );
211
+ return [ computedStyle.backgroundColor, computedStyle.opacity ];
212
+ }, backgroundDim );
213
+
214
+ expect( backgroundDimColor ).toBe( 'rgb(0, 0, 0)' );
215
+ expect( backgroundDimOpacity ).toBe( '0.5' );
216
+ } );
90
217
  } );
@@ -74,7 +74,7 @@ describe( 'Image', () => {
74
74
  expect( await getEditedPostContent() ).toMatch( regex );
75
75
  } );
76
76
 
77
- it( 'should replace, reset size, and keep selection', async () => {
77
+ it.skip( 'should replace, reset size, and keep selection', async () => {
78
78
  await insertBlock( 'Image' );
79
79
  const filename1 = await upload( '.wp-block-image input[type="file"]' );
80
80
  await waitForImage( filename1 );
@@ -12,7 +12,6 @@ import { v4 as uuid } from 'uuid';
12
12
  import {
13
13
  activatePlugin,
14
14
  createNewPost,
15
- clickButton,
16
15
  deactivatePlugin,
17
16
  insertBlock,
18
17
  openDocumentSettingsSidebar,
@@ -30,11 +29,9 @@ describe( 'changing image size', () => {
30
29
 
31
30
  it( 'should insert and change my image size', async () => {
32
31
  await insertBlock( 'Image' );
33
- await clickButton( 'Media Library' );
34
-
35
- // Wait for media modal to appear and upload image.
36
- await page.waitForSelector( '.media-modal input[type=file]' );
37
- const inputElement = await page.$( '.media-modal input[type=file]' );
32
+ const inputElement = await page.waitForSelector(
33
+ 'figure[aria-label="Block: Image"] input[type=file]'
34
+ );
38
35
  const testImagePath = path.join(
39
36
  __dirname,
40
37
  '..',
@@ -49,12 +46,7 @@ describe( 'changing image size', () => {
49
46
  await inputElement.uploadFile( tmpFileName );
50
47
 
51
48
  // Wait for upload to finish.
52
- await page.waitForSelector(
53
- `.media-modal li[aria-label="${ filename }"]`
54
- );
55
-
56
- // Insert the uploaded image.
57
- await page.click( '.media-modal button.media-button-select' );
49
+ await page.waitForXPath( `//img[contains(@src, "${ filename }")]` );
58
50
 
59
51
  // Select the new size updated with the plugin.
60
52
  await openDocumentSettingsSidebar();
@@ -9,6 +9,7 @@ import {
9
9
  insertBlock,
10
10
  openGlobalBlockInserter,
11
11
  closeGlobalBlockInserter,
12
+ clickBlockToolbarButton,
12
13
  } from '@wordpress/e2e-test-utils';
13
14
 
14
15
  describe( 'Allowed Blocks Setting on InnerBlocks', () => {
@@ -75,6 +76,7 @@ describe( 'Allowed Blocks Setting on InnerBlocks', () => {
75
76
  await insertBlock( 'Image' );
76
77
  await closeGlobalBlockInserter();
77
78
  await page.waitForSelector( '.product[data-number-of-children="2"]' );
79
+ await clickBlockToolbarButton( 'Select Allowed Blocks Dynamic' );
78
80
  // This focus shouldn't be neessary but there's a bug in trunk right now
79
81
  // Where if you open the inserter, don't do anything and click the "appender" on the canvas
80
82
  // the appender is not opened right away.
@@ -32,8 +32,10 @@ describe( 'adding inline tokens', () => {
32
32
  await clickButton( 'Inline image' );
33
33
 
34
34
  // Wait for media modal to appear and upload image.
35
- await page.waitForSelector( '.media-modal input[type=file]' );
36
- const inputElement = await page.$( '.media-modal input[type=file]' );
35
+ // Wait for media modal to appear and upload image.
36
+ const inputElement = await page.waitForSelector(
37
+ '.media-modal .moxie-shim input[type=file]'
38
+ );
37
39
  const testImagePath = path.join(
38
40
  __dirname,
39
41
  '..',
@@ -38,12 +38,12 @@ const menusFixture = [
38
38
  // Matching against variations of the same URL encoded and non-encoded
39
39
  // produces the most reliable mocking.
40
40
  const REST_MENUS_ROUTES = [
41
- '/__experimental/menus',
42
- `rest_route=${ encodeURIComponent( '/__experimental/menus' ) }`,
41
+ '/wp/v2/menus',
42
+ `rest_route=${ encodeURIComponent( '/wp/v2/menus' ) }`,
43
43
  ];
44
44
  const REST_MENU_ITEMS_ROUTES = [
45
- '/__experimental/menu-items',
46
- `rest_route=${ encodeURIComponent( '/__experimental/menu-items' ) }`,
45
+ '/wp/v2/menu-items',
46
+ `rest_route=${ encodeURIComponent( '/wp/v2/menu-items' ) }`,
47
47
  ];
48
48
 
49
49
  const REST_PAGES_ROUTES = [
@@ -36,6 +36,7 @@ describe( 'Document Settings', () => {
36
36
 
37
37
  beforeEach( async () => {
38
38
  await siteEditor.visit();
39
+ await siteEditor.disableWelcomeGuide();
39
40
  } );
40
41
 
41
42
  describe( 'when a template is selected from the navigation sidebar', () => {
@@ -145,6 +145,7 @@ describe( 'Multi-entity editor states', () => {
145
145
 
146
146
  it( 'should not display any dirty entities when loading the site editor', async () => {
147
147
  await siteEditor.visit();
148
+ await siteEditor.disableWelcomeGuide();
148
149
  expect( await openEntitySavePanel() ).toBe( false );
149
150
  } );
150
151
 
@@ -204,6 +205,7 @@ describe( 'Multi-entity editor states', () => {
204
205
  );
205
206
  await saveAllEntities();
206
207
  await siteEditor.visit();
208
+ await siteEditor.disableWelcomeGuide();
207
209
 
208
210
  // Wait for site editor to load.
209
211
  await canvas().waitForSelector(
@@ -244,6 +244,7 @@ describe( 'Multi-entity save flow', () => {
244
244
  postId: 'tt1-blocks//index',
245
245
  postType: 'wp_template',
246
246
  } );
247
+ await siteEditor.disableWelcomeGuide();
247
248
 
248
249
  // Select the header template part via list view.
249
250
  await page.click( '.edit-site-header-toolbar__list-view-toggle' );
@@ -53,6 +53,7 @@ describe( 'Settings sidebar', () => {
53
53
  } );
54
54
  beforeEach( async () => {
55
55
  await siteEditor.visit();
56
+ await siteEditor.disableWelcomeGuide();
56
57
  } );
57
58
 
58
59
  describe( 'Template tab', () => {
@@ -41,6 +41,7 @@ describe( 'Site Editor Templates Export', () => {
41
41
 
42
42
  beforeEach( async () => {
43
43
  await siteEditor.visit();
44
+ await siteEditor.disableWelcomeGuide();
44
45
  } );
45
46
 
46
47
  it( 'clicking export should download edit-site-export.zip file', async () => {
@@ -19,6 +19,7 @@ describe( 'Site Editor Inserter', () => {
19
19
  } );
20
20
  beforeEach( async () => {
21
21
  await siteEditor.visit();
22
+ await siteEditor.disableWelcomeGuide();
22
23
  } );
23
24
 
24
25
  it( 'inserter toggle button should toggle global inserter', async () => {
@@ -19,7 +19,7 @@ import {
19
19
  import { siteEditor } from '../../experimental-features';
20
20
 
21
21
  const templatePartNameInput =
22
- '.edit-site-template-part-converter__modal .components-text-control__input';
22
+ '.edit-site-create-template-part-modal .components-text-control__input';
23
23
 
24
24
  describe( 'Template Part', () => {
25
25
  beforeAll( async () => {
@@ -36,6 +36,7 @@ describe( 'Template Part', () => {
36
36
  describe( 'Template part block', () => {
37
37
  beforeEach( async () => {
38
38
  await siteEditor.visit();
39
+ await siteEditor.disableWelcomeGuide();
39
40
  } );
40
41
 
41
42
  async function navigateToHeader() {
@@ -16,7 +16,11 @@ import { addQueryArgs } from '@wordpress/url';
16
16
  */
17
17
  import { siteEditor } from '../../experimental-features';
18
18
 
19
- const { visit: visitSiteEditor, getEditedPostContent } = siteEditor;
19
+ const {
20
+ visit: visitSiteEditor,
21
+ getEditedPostContent,
22
+ disableWelcomeGuide,
23
+ } = siteEditor;
20
24
 
21
25
  const assertSaveButtonIsDisabled = () =>
22
26
  page.waitForSelector(
@@ -97,6 +101,7 @@ describe( 'Template Revert', () => {
97
101
  beforeEach( async () => {
98
102
  await trashAllPosts( 'wp_template' );
99
103
  await visitSiteEditor();
104
+ await disableWelcomeGuide();
100
105
  } );
101
106
 
102
107
  it( 'should delete the template after saving the reverted template', async () => {
@@ -84,6 +84,7 @@ describe( 'Site Editor Performance', () => {
84
84
  );
85
85
 
86
86
  await siteEditor.visit( { postId: id, postType: 'page' } );
87
+ await siteEditor.disableWelcomeGuide();
87
88
 
88
89
  let i = 3;
89
90