@wordpress/e2e-tests 4.0.4 → 4.3.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.0.4",
3
+ "version": "4.3.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.2",
30
- "@wordpress/url": "^3.7.1",
26
+ "@wordpress/e2e-test-utils": "^7.5.0",
27
+ "@wordpress/jest-console": "^5.1.0",
28
+ "@wordpress/jest-puppeteer-axe": "^4.0.2",
29
+ "@wordpress/scripts": "^23.1.0",
30
+ "@wordpress/url": "^3.10.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": "1fdd4758150247d6b690051aed18fa27c15f3a32"
49
+ "gitHead": "198fa129cf1af8dc615918987ea6795cd40ab7df"
50
50
  }
@@ -12,12 +12,6 @@ exports[`Heading can be created by prefixing number sign and a space 1`] = `
12
12
  <!-- /wp:heading -->"
13
13
  `;
14
14
 
15
- exports[`Heading should correctly apply custom colors 1`] = `
16
- "<!-- wp:heading {\\"level\\":3,\\"style\\":{\\"color\\":{\\"text\\":\\"#0782f6\\"}}} -->
17
- <h3 class=\\"has-text-color\\" style=\\"color:#0782f6\\">Heading</h3>
18
- <!-- /wp:heading -->"
19
- `;
20
-
21
15
  exports[`Heading should correctly apply named colors 1`] = `
22
16
  "<!-- wp:heading {\\"textColor\\":\\"luminous-vivid-orange\\"} -->
23
17
  <h2 class=\\"has-luminous-vivid-orange-color has-text-color\\">Heading</h2>
@@ -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(
@@ -86,10 +86,14 @@ describe( 'Heading', () => {
86
86
  await page.waitForSelector( COLOR_INPUT_FIELD_SELECTOR );
87
87
  await page.click( COLOR_INPUT_FIELD_SELECTOR );
88
88
  await pressKeyWithModifier( 'primary', 'A' );
89
- await page.keyboard.type( '0782f6' );
90
- await page.click( 'h3[data-type="core/heading"]' );
91
- await page.waitForXPath( '//button//span[contains(text(), "0782f6")]' );
92
- expect( await getEditedPostContent() ).toMatchSnapshot();
89
+ await page.keyboard.type( '4b7f4d' );
90
+ await page.waitForXPath( '//button//span[contains(text(), "4b7f4d")]' );
91
+ await page.click( '.wp-block-post-title' );
92
+ expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
93
+ "<!-- wp:heading {\\"level\\":3,\\"style\\":{\\"color\\":{\\"text\\":\\"#4b7f4d\\"}}} -->
94
+ <h3 class=\\"has-text-color\\" style=\\"color:#4b7f4d\\">Heading</h3>
95
+ <!-- /wp:heading -->"
96
+ ` );
93
97
  } );
94
98
 
95
99
  it( 'should correctly apply named colors', async () => {
@@ -269,7 +269,6 @@ describe( 'Table', () => {
269
269
  // Create the table.
270
270
  await clickButton( createButtonLabel );
271
271
 
272
- await page.keyboard.press( 'Tab' );
273
272
  await page.keyboard.type( '1' );
274
273
  await page.keyboard.press( 'ArrowDown' );
275
274
  await page.keyboard.type( '2' );
@@ -280,4 +279,18 @@ describe( 'Table', () => {
280
279
 
281
280
  expect( await getEditedPostContent() ).toMatchSnapshot();
282
281
  } );
282
+
283
+ it( 'should not have focus loss after creation', async () => {
284
+ // Insert table block.
285
+ await insertBlock( 'Table' );
286
+
287
+ // Create the table.
288
+ await clickButton( createButtonLabel );
289
+
290
+ // Focus should be in first td.
291
+ const isInTd = await page.waitForSelector(
292
+ 'td[contentEditable="true"]'
293
+ );
294
+ await expect( isInTd ).toHaveFocus();
295
+ } );
283
296
  } );
@@ -16,16 +16,10 @@
16
16
  "parent": 0,
17
17
  "menu_order": 1,
18
18
  "target": "",
19
- "classes": [
20
- ""
21
- ],
22
- "xfn": [
23
- ""
24
- ],
19
+ "classes": [ "" ],
20
+ "xfn": [ "" ],
25
21
  "meta": [],
26
- "menus": [
27
- 23
28
- ],
22
+ "menus": [ 23 ],
29
23
  "_links": {
30
24
  "self": [
31
25
  {
@@ -95,16 +89,10 @@
95
89
  "parent": 0,
96
90
  "menu_order": 2,
97
91
  "target": "",
98
- "classes": [
99
- ""
100
- ],
101
- "xfn": [
102
- ""
103
- ],
92
+ "classes": [ "" ],
93
+ "xfn": [ "" ],
104
94
  "meta": [],
105
- "menus": [
106
- 23
107
- ],
95
+ "menus": [ 23 ],
108
96
  "_links": {
109
97
  "self": [
110
98
  {
@@ -181,16 +169,10 @@
181
169
  "parent": 95,
182
170
  "menu_order": 3,
183
171
  "target": "",
184
- "classes": [
185
- ""
186
- ],
187
- "xfn": [
188
- ""
189
- ],
172
+ "classes": [ "" ],
173
+ "xfn": [ "" ],
190
174
  "meta": [],
191
- "menus": [
192
- 23
193
- ],
175
+ "menus": [ 23 ],
194
176
  "_links": {
195
177
  "self": [
196
178
  {
@@ -267,16 +249,10 @@
267
249
  "parent": 0,
268
250
  "menu_order": 4,
269
251
  "target": "",
270
- "classes": [
271
- ""
272
- ],
273
- "xfn": [
274
- ""
275
- ],
252
+ "classes": [ "" ],
253
+ "xfn": [ "" ],
276
254
  "meta": [],
277
- "menus": [
278
- 23
279
- ],
255
+ "menus": [ 23 ],
280
256
  "_links": {
281
257
  "self": [
282
258
  {
@@ -353,16 +329,10 @@
353
329
  "parent": 97,
354
330
  "menu_order": 5,
355
331
  "target": "",
356
- "classes": [
357
- ""
358
- ],
359
- "xfn": [
360
- ""
361
- ],
332
+ "classes": [ "" ],
333
+ "xfn": [ "" ],
362
334
  "meta": [],
363
- "menus": [
364
- 23
365
- ],
335
+ "menus": [ 23 ],
366
336
  "_links": {
367
337
  "self": [
368
338
  {
@@ -439,16 +409,10 @@
439
409
  "parent": 98,
440
410
  "menu_order": 6,
441
411
  "target": "",
442
- "classes": [
443
- ""
444
- ],
445
- "xfn": [
446
- ""
447
- ],
412
+ "classes": [ "" ],
413
+ "xfn": [ "" ],
448
414
  "meta": [],
449
- "menus": [
450
- 23
451
- ],
415
+ "menus": [ 23 ],
452
416
  "_links": {
453
417
  "self": [
454
418
  {
@@ -525,16 +489,10 @@
525
489
  "parent": 99,
526
490
  "menu_order": 7,
527
491
  "target": "",
528
- "classes": [
529
- ""
530
- ],
531
- "xfn": [
532
- ""
533
- ],
492
+ "classes": [ "" ],
493
+ "xfn": [ "" ],
534
494
  "meta": [],
535
- "menus": [
536
- 23
537
- ],
495
+ "menus": [ 23 ],
538
496
  "_links": {
539
497
  "self": [
540
498
  {
@@ -611,16 +569,10 @@
611
569
  "parent": 100,
612
570
  "menu_order": 8,
613
571
  "target": "",
614
- "classes": [
615
- ""
616
- ],
617
- "xfn": [
618
- ""
619
- ],
572
+ "classes": [ "" ],
573
+ "xfn": [ "" ],
620
574
  "meta": [],
621
- "menus": [
622
- 23
623
- ],
575
+ "menus": [ 23 ],
624
576
  "_links": {
625
577
  "self": [
626
578
  {
@@ -697,16 +649,10 @@
697
649
  "parent": 0,
698
650
  "menu_order": 9,
699
651
  "target": "",
700
- "classes": [
701
- ""
702
- ],
703
- "xfn": [
704
- ""
705
- ],
652
+ "classes": [ "" ],
653
+ "xfn": [ "" ],
706
654
  "meta": [],
707
- "menus": [
708
- 23
709
- ],
655
+ "menus": [ 23 ],
710
656
  "_links": {
711
657
  "self": [
712
658
  {
@@ -783,16 +729,10 @@
783
729
  "parent": 0,
784
730
  "menu_order": 10,
785
731
  "target": "",
786
- "classes": [
787
- ""
788
- ],
789
- "xfn": [
790
- ""
791
- ],
732
+ "classes": [ "" ],
733
+ "xfn": [ "" ],
792
734
  "meta": [],
793
- "menus": [
794
- 23
795
- ],
735
+ "menus": [ 23 ],
796
736
  "_links": {
797
737
  "self": [
798
738
  {
@@ -869,16 +809,10 @@
869
809
  "parent": 0,
870
810
  "menu_order": 11,
871
811
  "target": "",
872
- "classes": [
873
- ""
874
- ],
875
- "xfn": [
876
- ""
877
- ],
812
+ "classes": [ "" ],
813
+ "xfn": [ "" ],
878
814
  "meta": [],
879
- "menus": [
880
- 23
881
- ],
815
+ "menus": [ 23 ],
882
816
  "_links": {
883
817
  "self": [
884
818
  {
@@ -955,16 +889,10 @@
955
889
  "parent": 104,
956
890
  "menu_order": 12,
957
891
  "target": "",
958
- "classes": [
959
- ""
960
- ],
961
- "xfn": [
962
- ""
963
- ],
892
+ "classes": [ "" ],
893
+ "xfn": [ "" ],
964
894
  "meta": [],
965
- "menus": [
966
- 23
967
- ],
895
+ "menus": [ 23 ],
968
896
  "_links": {
969
897
  "self": [
970
898
  {
@@ -1041,16 +969,10 @@
1041
969
  "parent": 105,
1042
970
  "menu_order": 13,
1043
971
  "target": "",
1044
- "classes": [
1045
- ""
1046
- ],
1047
- "xfn": [
1048
- ""
1049
- ],
972
+ "classes": [ "" ],
973
+ "xfn": [ "" ],
1050
974
  "meta": [],
1051
- "menus": [
1052
- 23
1053
- ],
975
+ "menus": [ 23 ],
1054
976
  "_links": {
1055
977
  "self": [
1056
978
  {
@@ -1127,16 +1049,10 @@
1127
1049
  "parent": 106,
1128
1050
  "menu_order": 14,
1129
1051
  "target": "",
1130
- "classes": [
1131
- ""
1132
- ],
1133
- "xfn": [
1134
- ""
1135
- ],
1052
+ "classes": [ "" ],
1053
+ "xfn": [ "" ],
1136
1054
  "meta": [],
1137
- "menus": [
1138
- 23
1139
- ],
1055
+ "menus": [ 23 ],
1140
1056
  "_links": {
1141
1057
  "self": [
1142
1058
  {
@@ -1213,16 +1129,10 @@
1213
1129
  "parent": 0,
1214
1130
  "menu_order": 15,
1215
1131
  "target": "",
1216
- "classes": [
1217
- ""
1218
- ],
1219
- "xfn": [
1220
- ""
1221
- ],
1132
+ "classes": [ "" ],
1133
+ "xfn": [ "" ],
1222
1134
  "meta": [],
1223
- "menus": [
1224
- 23
1225
- ],
1135
+ "menus": [ 23 ],
1226
1136
  "_links": {
1227
1137
  "self": [
1228
1138
  {
@@ -1292,16 +1202,10 @@
1292
1202
  "parent": 108,
1293
1203
  "menu_order": 16,
1294
1204
  "target": "",
1295
- "classes": [
1296
- ""
1297
- ],
1298
- "xfn": [
1299
- ""
1300
- ],
1205
+ "classes": [ "" ],
1206
+ "xfn": [ "" ],
1301
1207
  "meta": [],
1302
- "menus": [
1303
- 23
1304
- ],
1208
+ "menus": [ 23 ],
1305
1209
  "_links": {
1306
1210
  "self": [
1307
1211
  {
@@ -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 );
@@ -32,6 +32,7 @@ describe( 'Block Switcher', () => {
32
32
  'Heading',
33
33
  'Pullquote',
34
34
  'Columns',
35
+ 'Table of Contents',
35
36
  ] )
36
37
  );
37
38
  } );
@@ -57,6 +58,7 @@ describe( 'Block Switcher', () => {
57
58
  'Paragraph',
58
59
  'Pullquote',
59
60
  'Heading',
61
+ 'Table of Contents',
60
62
  ] )
61
63
  );
62
64
  } );
@@ -71,6 +73,7 @@ describe( 'Block Switcher', () => {
71
73
  'core/group',
72
74
  'core/heading',
73
75
  'core/columns',
76
+ 'core/table-of-contents',
74
77
  ].map( ( block ) => wp.blocks.unregisterBlockType( block ) );
75
78
  } );
76
79
 
@@ -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
 
@@ -364,7 +299,7 @@ describe( 'Inserting blocks', () => {
364
299
  await page.waitForSelector( INSERTER_SEARCH_SELECTOR );
365
300
  await page.focus( INSERTER_SEARCH_SELECTOR );
366
301
  await pressKeyWithModifier( 'primary', 'a' );
367
- const searchTerm = 'Heading';
302
+ const searchTerm = 'Verse';
368
303
  await page.keyboard.type( searchTerm );
369
304
  const browseAll = await page.waitForXPath(
370
305
  '//button[text()="Browse all"]'
@@ -26,9 +26,6 @@ const navigateToContentEditorTop = async () => {
26
26
  };
27
27
 
28
28
  const tabThroughParagraphBlock = async ( paragraphText ) => {
29
- await page.keyboard.press( 'Tab' );
30
- await expect( await getActiveLabel() ).toBe( 'Add block' );
31
-
32
29
  await tabThroughBlockToolbar();
33
30
 
34
31
  await page.keyboard.press( 'Tab' );
@@ -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