@wordpress/e2e-tests 4.0.2 → 4.1.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/e2e-tests",
3
- "version": "4.0.2",
3
+ "version": "4.1.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.2.1",
27
- "@wordpress/jest-console": "^5.0.3",
28
- "@wordpress/jest-puppeteer-axe": "^4.0.3",
29
- "@wordpress/scripts": "^22.4.1",
30
- "@wordpress/url": "^3.7.1",
26
+ "@wordpress/e2e-test-utils": "^7.3.0",
27
+ "@wordpress/jest-console": "^5.0.2",
28
+ "@wordpress/jest-puppeteer-axe": "^4.0.2",
29
+ "@wordpress/scripts": "^22.5.0",
30
+ "@wordpress/url": "^3.8.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": "446565ecaa40370173c18926535e975ec5652b71"
49
+ "gitHead": "1ba52312b56db563df2d8d4fba5b00613fb46d8c"
50
50
  }
@@ -1429,5 +1429,43 @@ describe( 'Navigation', () => {
1429
1429
  '//*[contains(@class, "components-snackbar")]/*[text()="Navigation Menu successfully created."]'
1430
1430
  );
1431
1431
  } );
1432
+
1433
+ it( 'should always focus select menu button after item selection', async () => {
1434
+ // Create some navigation menus to work with.
1435
+ await createNavigationMenu( {
1436
+ title: 'Example Navigation',
1437
+ content:
1438
+ '<!-- wp:navigation-link {"label":"WordPress","type":"custom","url":"http://www.wordpress.org/","kind":"custom","isTopLevelLink":true} /-->',
1439
+ } );
1440
+ await createNavigationMenu( {
1441
+ title: 'Second Example Navigation',
1442
+ content:
1443
+ '<!-- wp:navigation-link {"label":"WordPress","type":"custom","url":"http://www.wordpress.org/","kind":"custom","isTopLevelLink":true} /-->',
1444
+ } );
1445
+
1446
+ // Create new post.
1447
+ await createNewPost();
1448
+
1449
+ // Insert new block and wait for the insert to complete.
1450
+ await insertBlock( 'Navigation' );
1451
+ await waitForBlock( 'Navigation' );
1452
+ await page.waitForXPath( START_EMPTY_XPATH );
1453
+
1454
+ // Change menus via the select menu toolbar button.
1455
+ const selectMenuDropdown = await page.waitForSelector(
1456
+ '[aria-label="Select Menu"]'
1457
+ );
1458
+ await selectMenuDropdown.click();
1459
+ const exampleNavigationOption = await page.waitForXPath(
1460
+ '//span[contains(text(), "Second Example Navigation")]'
1461
+ );
1462
+ await exampleNavigationOption.click();
1463
+
1464
+ // Once the options are closed, does select menu button receive focus?
1465
+ const selectMenuDropdown2 = await page.waitForSelector(
1466
+ '[aria-label="Select Menu"]'
1467
+ );
1468
+ await expect( selectMenuDropdown2 ).toHaveFocus();
1469
+ } );
1432
1470
  } );
1433
1471
  } );
@@ -10,7 +10,6 @@ import {
10
10
  pressKeyTimes,
11
11
  searchForBlock,
12
12
  setBrowserViewport,
13
- showBlockToolbar,
14
13
  pressKeyWithModifier,
15
14
  } from '@wordpress/e2e-test-utils';
16
15
 
@@ -170,68 +169,6 @@ describe( 'Inserting blocks', () => {
170
169
  ).not.toBeNull();
171
170
  } );
172
171
 
173
- // Check for regression of https://github.com/WordPress/gutenberg/issues/9583
174
- it( 'should not allow transfer of focus outside of the block-insertion menu once open', async () => {
175
- // Enter the default block and click the inserter toggle button to the left of it.
176
- await page.keyboard.press( 'Enter' );
177
- await showBlockToolbar();
178
- await page.click(
179
- '.block-editor-block-list__empty-block-inserter .block-editor-inserter__toggle'
180
- );
181
-
182
- // Expect the inserter search input to be the active element.
183
- let activeElementClassList = await page.evaluate(
184
- () => document.activeElement.classList
185
- );
186
- expect( Object.values( activeElementClassList ) ).toContain(
187
- 'components-search-control__input'
188
- );
189
-
190
- // Try using the up arrow key (vertical navigation triggers the issue described in #9583).
191
- await page.keyboard.press( 'ArrowUp' );
192
-
193
- // Expect the inserter search input to still be the active element.
194
- activeElementClassList = await page.evaluate(
195
- () => document.activeElement.classList
196
- );
197
- expect( Object.values( activeElementClassList ) ).toContain(
198
- 'components-search-control__input'
199
- );
200
-
201
- // Tab to the block list.
202
- await page.keyboard.press( 'Tab' );
203
-
204
- // Expect the block list to be the active element.
205
- activeElementClassList = await page.evaluate(
206
- () => document.activeElement.classList
207
- );
208
- expect( Object.values( activeElementClassList ) ).toContain(
209
- 'block-editor-block-types-list__item'
210
- );
211
-
212
- // Try using the up arrow key.
213
- await page.keyboard.press( 'ArrowUp' );
214
-
215
- // Expect the block list to still be the active element.
216
- activeElementClassList = await page.evaluate(
217
- () => document.activeElement.classList
218
- );
219
- expect( Object.values( activeElementClassList ) ).toContain(
220
- 'block-editor-block-types-list__item'
221
- );
222
-
223
- // Press escape to close the block inserter.
224
- await page.keyboard.press( 'Escape' );
225
-
226
- // Expect focus to have transferred back to the inserter toggle button.
227
- activeElementClassList = await page.evaluate(
228
- () => document.activeElement.classList
229
- );
230
- expect( Object.values( activeElementClassList ) ).toContain(
231
- 'block-editor-inserter__toggle'
232
- );
233
- } );
234
-
235
172
  // Check for regression of https://github.com/WordPress/gutenberg/issues/23263
236
173
  it( 'inserts blocks at root level when using the root appender while selection is in an inner block', async () => {
237
174
  await insertBlock( 'Buttons' );
@@ -310,12 +247,11 @@ describe( 'Inserting blocks', () => {
310
247
  await insertBlock( 'Paragraph' );
311
248
  await page.keyboard.type( 'First paragraph' );
312
249
  await insertBlock( 'Image' );
313
- await showBlockToolbar();
314
250
  const paragraphBlock = await page.$(
315
251
  'p[aria-label="Paragraph block"]'
316
252
  );
317
253
  paragraphBlock.click();
318
- await showBlockToolbar();
254
+ await page.evaluate( () => new Promise( window.requestIdleCallback ) );
319
255
 
320
256
  // Open the global inserter and search for the Heading block.
321
257
  await searchForBlock( 'Heading' );
@@ -323,7 +259,6 @@ describe( 'Inserting blocks', () => {
323
259
  const headingButton = (
324
260
  await page.$x( `//button//span[contains(text(), 'Heading')]` )
325
261
  )[ 0 ];
326
-
327
262
  // Hover over the block should show the blue line indicator.
328
263
  await headingButton.hover();
329
264
 
@@ -116,6 +116,24 @@ describe( 'New User Experience (NUX)', () => {
116
116
  expect( welcomeGuide ).toBeNull();
117
117
  } );
118
118
 
119
+ it( 'should focus post title field after welcome guide is dismissed and post is empty', async () => {
120
+ // Create a new post as a first-time user.
121
+ await createNewPost( { showWelcomeGuide: true } );
122
+
123
+ // Guide should be open.
124
+ const welcomeGuide = await page.$( '.edit-post-welcome-guide' );
125
+ expect( welcomeGuide ).not.toBeNull();
126
+
127
+ // Close the guide.
128
+ await page.click( 'button[aria-label="Close dialog"]' );
129
+
130
+ // Focus should be in post title field.
131
+ const postTitle = await page.waitForSelector(
132
+ 'h1[aria-label="Add title"'
133
+ );
134
+ await expect( postTitle ).toHaveFocus();
135
+ } );
136
+
119
137
  it( 'should show the welcome guide if it is manually opened', async () => {
120
138
  let welcomeGuide;
121
139
 
@@ -485,28 +485,6 @@ describe( 'RichText', () => {
485
485
  expect( await getEditedPostContent() ).toMatchSnapshot();
486
486
  } );
487
487
 
488
- it( 'should show/hide toolbar when entering/exiting format', async () => {
489
- const blockToolbarSelector = '.block-editor-block-toolbar';
490
- await clickBlockAppender();
491
- await page.keyboard.type( '1' );
492
- expect( await page.$( blockToolbarSelector ) ).toBe( null );
493
- await pressKeyWithModifier( 'primary', 'b' );
494
- expect( await page.$( blockToolbarSelector ) ).not.toBe( null );
495
- await page.keyboard.type( '2' );
496
- expect( await page.$( blockToolbarSelector ) ).not.toBe( null );
497
- await pressKeyWithModifier( 'primary', 'b' );
498
- expect( await page.$( blockToolbarSelector ) ).toBe( null );
499
- await page.keyboard.type( '3' );
500
- await page.keyboard.press( 'ArrowLeft' );
501
- expect( await page.$( blockToolbarSelector ) ).toBe( null );
502
- await page.keyboard.press( 'ArrowLeft' );
503
- expect( await page.$( blockToolbarSelector ) ).not.toBe( null );
504
- await page.keyboard.press( 'ArrowLeft' );
505
- expect( await page.$( blockToolbarSelector ) ).not.toBe( null );
506
- await page.keyboard.press( 'ArrowLeft' );
507
- expect( await page.$( blockToolbarSelector ) ).toBe( null );
508
- } );
509
-
510
488
  it( 'should run input rules after composition end', async () => {
511
489
  await clickBlockAppender();
512
490
  // Puppeteer doesn't support composition, so emulate it by inserting
@@ -4,7 +4,6 @@
4
4
  import {
5
5
  createNewPost,
6
6
  pressKeyWithModifier,
7
- clickBlockToolbarButton,
8
7
  insertBlock,
9
8
  } from '@wordpress/e2e-test-utils';
10
9
 
@@ -42,9 +41,7 @@ async function testBlockToolbarKeyboardNavigation(
42
41
 
43
42
  async function wrapCurrentBlockWithGroup( currentBlockTitle ) {
44
43
  await page.click( `[aria-label="${ currentBlockTitle }"]` );
45
- await page.evaluate( () => {
46
- document.querySelector( '.editor-block-list-item-group' ).click();
47
- } );
44
+ await page.click( '.editor-block-list-item-group' );
48
45
  }
49
46
 
50
47
  async function testGroupKeyboardNavigation(
@@ -128,10 +125,11 @@ describe( 'Toolbar roving tabindex', () => {
128
125
  await insertBlock( 'Paragraph' );
129
126
  await page.keyboard.type( 'Paragraph' );
130
127
  await focusBlockToolbar();
131
- await clickBlockToolbarButton( 'Bold' );
132
- await page.keyboard.type( 'a' );
128
+ await page.keyboard.press( 'ArrowRight' );
129
+ await expectLabelToHaveFocus( 'Move up' );
130
+ await page.keyboard.press( 'Tab' );
133
131
  await pressKeyWithModifier( 'shift', 'Tab' );
134
- await expectLabelToHaveFocus( 'Bold' );
132
+ await expectLabelToHaveFocus( 'Move up' );
135
133
  } );
136
134
 
137
135
  it( 'can reach toolbar items with arrow keys after pressing alt+F10', async () => {
@@ -1,33 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import {
5
- activatePlugin,
6
- createNewPost,
7
- deactivatePlugin,
8
- insertBlock,
9
- } from '@wordpress/e2e-test-utils';
10
-
11
- describe( 'Using Block API', () => {
12
- beforeAll( async () => {
13
- await activatePlugin( 'gutenberg-test-block-api' );
14
- } );
15
-
16
- afterAll( async () => {
17
- await deactivatePlugin( 'gutenberg-test-block-api' );
18
- } );
19
-
20
- beforeEach( async () => {
21
- await createNewPost();
22
- } );
23
-
24
- test( 'Inserts the filtered hello world block even when filter added after block registration', async () => {
25
- await insertBlock( 'Filtered Hello World' );
26
-
27
- const blockContent = await page.$eval(
28
- 'div[data-type="e2e-tests/hello-world"]',
29
- ( element ) => element.textContent
30
- );
31
- expect( blockContent ).toEqual( 'Hello Editor!' );
32
- } );
33
- } );
@@ -1,36 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import {
5
- createNewPost,
6
- clickBlockToolbarButton,
7
- insertBlock,
8
- getEditedPostContent,
9
- } from '@wordpress/e2e-test-utils';
10
-
11
- describe( 'adding blocks', () => {
12
- beforeAll( async () => {
13
- await createNewPost();
14
- } );
15
-
16
- it( 'Should switch to the plain style of the quote block', async () => {
17
- // Inserting a quote block.
18
- await insertBlock( 'Quote' );
19
- await page.keyboard.type( 'Quote content' );
20
-
21
- await clickBlockToolbarButton( 'Quote' );
22
-
23
- const plainStyleButton = await page.waitForXPath(
24
- '//*[@role="menuitem"][contains(., "Plain")]'
25
- );
26
- await plainStyleButton.click();
27
-
28
- // Check the content.
29
- const content = await getEditedPostContent();
30
- expect( content ).toMatchInlineSnapshot( `
31
- "<!-- wp:quote {\\"className\\":\\"is-style-plain\\"} -->
32
- <blockquote class=\\"wp-block-quote is-style-plain\\"><p>Quote content</p></blockquote>
33
- <!-- /wp:quote -->"
34
- ` );
35
- } );
36
- } );