@wordpress/e2e-tests 2.5.16 → 2.5.19

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.
@@ -0,0 +1,24 @@
1
+ <?php
2
+ /**
3
+ * Plugin Name: Gutenberg Test Plugin, Enable Templates UI
4
+ * Plugin URI: https://github.com/WordPress/gutenberg
5
+ * Author: Gutenberg Team
6
+ *
7
+ * @package gutenberg-test-enable-templates-ui
8
+ */
9
+
10
+ /**
11
+ * Enable Templates & Template Parts post type UI during e2e testing.
12
+ */
13
+ add_filter(
14
+ 'register_post_type_args',
15
+ static function( $args, $name ) {
16
+ if ( in_array( $name, array( 'wp_template', 'wp_template_part' ), true ) ) {
17
+ $args['show_ui'] = wp_is_block_theme();
18
+ }
19
+
20
+ return $args;
21
+ },
22
+ 20,
23
+ 2
24
+ );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/e2e-tests",
3
- "version": "2.5.16",
3
+ "version": "2.5.19",
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.10",
26
+ "@wordpress/e2e-test-utils": "^5.4.11",
27
27
  "@wordpress/jest-console": "^4.1.1",
28
28
  "@wordpress/jest-puppeteer-axe": "^3.1.1",
29
29
  "@wordpress/scripts": "^19.2.4",
30
- "@wordpress/url": "^3.3.1",
30
+ "@wordpress/url": "^3.3.2",
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": "8c2cd6a5fd8781266da858a2e7d1bdd9a3a279e4"
46
+ "gitHead": "3cf1fca7ff79c72899d55df13b4339a4d8099871"
47
47
  }
@@ -2,25 +2,25 @@
2
2
 
3
3
  exports[`Heading can be created by prefixing existing content with number signs and a space 1`] = `
4
4
  "<!-- wp:heading {\\"level\\":4} -->
5
- <h4 id=\\"4\\">4</h4>
5
+ <h4>4</h4>
6
6
  <!-- /wp:heading -->"
7
7
  `;
8
8
 
9
9
  exports[`Heading can be created by prefixing number sign and a space 1`] = `
10
10
  "<!-- wp:heading {\\"level\\":3} -->
11
- <h3 id=\\"3\\">3</h3>
11
+ <h3>3</h3>
12
12
  <!-- /wp:heading -->"
13
13
  `;
14
14
 
15
15
  exports[`Heading should correctly apply custom colors 1`] = `
16
- "<!-- wp:heading {\\"level\\":3,\\"style\\":{\\"color\\":{\\"text\\":\\"#7700ff\\"}}} -->
17
- <h3 class=\\"has-text-color\\" id=\\"heading\\" style=\\"color:#7700ff\\">Heading</h3>
16
+ "<!-- wp:heading {\\"level\\":3,\\"style\\":{\\"color\\":{\\"text\\":\\"#0782f6\\"}}} -->
17
+ <h3 class=\\"has-text-color\\" style=\\"color:#0782f6\\">Heading</h3>
18
18
  <!-- /wp:heading -->"
19
19
  `;
20
20
 
21
21
  exports[`Heading should correctly apply named colors 1`] = `
22
22
  "<!-- wp:heading {\\"textColor\\":\\"luminous-vivid-orange\\"} -->
23
- <h2 class=\\"has-luminous-vivid-orange-color has-text-color\\" id=\\"heading\\">Heading</h2>
23
+ <h2 class=\\"has-luminous-vivid-orange-color has-text-color\\">Heading</h2>
24
24
  <!-- /wp:heading -->"
25
25
  `;
26
26
 
@@ -30,13 +30,13 @@ exports[`Heading should create a paragraph block above when pressing enter at th
30
30
  <!-- /wp:paragraph -->
31
31
 
32
32
  <!-- wp:heading -->
33
- <h2 id=\\"a\\">a</h2>
33
+ <h2>a</h2>
34
34
  <!-- /wp:heading -->"
35
35
  `;
36
36
 
37
37
  exports[`Heading should create a paragraph block below when pressing enter at the end 1`] = `
38
38
  "<!-- wp:heading -->
39
- <h2 id=\\"a\\">a</h2>
39
+ <h2>a</h2>
40
40
  <!-- /wp:heading -->
41
41
 
42
42
  <!-- wp:paragraph -->
@@ -46,12 +46,12 @@ exports[`Heading should create a paragraph block below when pressing enter at th
46
46
 
47
47
  exports[`Heading should not work with the list input rule 1`] = `
48
48
  "<!-- wp:heading -->
49
- <h2 id=\\"1-h\\">1. H</h2>
49
+ <h2>1. H</h2>
50
50
  <!-- /wp:heading -->"
51
51
  `;
52
52
 
53
53
  exports[`Heading should work with the format input rules 1`] = `
54
54
  "<!-- wp:heading -->
55
- <h2 id=\\"code\\"><code>code</code></h2>
55
+ <h2><code>code</code></h2>
56
56
  <!-- /wp:heading -->"
57
57
  `;
@@ -40,7 +40,7 @@ exports[`Quote can be converted to paragraphs and renders only one paragraph for
40
40
 
41
41
  exports[`Quote can be created by converting a heading 1`] = `
42
42
  "<!-- wp:quote -->
43
- <blockquote class=\\"wp-block-quote\\" id=\\"test\\"><p>test</p></blockquote>
43
+ <blockquote class=\\"wp-block-quote\\"><p>test</p></blockquote>
44
44
  <!-- /wp:quote -->"
45
45
  `;
46
46
 
@@ -144,7 +144,7 @@ exports[`Quote can be split in the middle and merged back 4`] = `
144
144
 
145
145
  exports[`Quote is transformed to a heading and a quote if the quote contains a citation 1`] = `
146
146
  "<!-- wp:heading -->
147
- <h2 id=\\"one\\">one</h2>
147
+ <h2>one</h2>
148
148
  <!-- /wp:heading -->
149
149
 
150
150
  <!-- wp:quote -->
@@ -154,7 +154,7 @@ exports[`Quote is transformed to a heading and a quote if the quote contains a c
154
154
 
155
155
  exports[`Quote is transformed to a heading and a quote if the quote contains multiple paragraphs 1`] = `
156
156
  "<!-- wp:heading -->
157
- <h2 id=\\"one\\">one</h2>
157
+ <h2>one</h2>
158
158
  <!-- /wp:heading -->
159
159
 
160
160
  <!-- wp:quote -->
@@ -164,7 +164,7 @@ exports[`Quote is transformed to a heading and a quote if the quote contains mul
164
164
 
165
165
  exports[`Quote is transformed to a heading if the quote just contains one paragraph 1`] = `
166
166
  "<!-- wp:heading -->
167
- <h2 id=\\"one\\">one</h2>
167
+ <h2>one</h2>
168
168
  <!-- /wp:heading -->"
169
169
  `;
170
170
 
@@ -176,7 +176,7 @@ exports[`Quote is transformed to an empty heading if the quote is empty 1`] = `
176
176
 
177
177
  exports[`Quote the resuling quote after transforming to a heading can be transformed again 1`] = `
178
178
  "<!-- wp:heading -->
179
- <h2 id=\\"one\\">one</h2>
179
+ <h2>one</h2>
180
180
  <!-- /wp:heading -->
181
181
 
182
182
  <!-- wp:quote -->
@@ -186,11 +186,11 @@ exports[`Quote the resuling quote after transforming to a heading can be transfo
186
186
 
187
187
  exports[`Quote the resuling quote after transforming to a heading can be transformed again 2`] = `
188
188
  "<!-- wp:heading -->
189
- <h2 id=\\"one\\">one</h2>
189
+ <h2>one</h2>
190
190
  <!-- /wp:heading -->
191
191
 
192
192
  <!-- wp:heading -->
193
- <h2 id=\\"two\\">two</h2>
193
+ <h2>two</h2>
194
194
  <!-- /wp:heading -->
195
195
 
196
196
  <!-- wp:quote -->
@@ -200,14 +200,14 @@ exports[`Quote the resuling quote after transforming to a heading can be transfo
200
200
 
201
201
  exports[`Quote the resuling quote after transforming to a heading can be transformed again 3`] = `
202
202
  "<!-- wp:heading -->
203
- <h2 id=\\"one\\">one</h2>
203
+ <h2>one</h2>
204
204
  <!-- /wp:heading -->
205
205
 
206
206
  <!-- wp:heading -->
207
- <h2 id=\\"two\\">two</h2>
207
+ <h2>two</h2>
208
208
  <!-- /wp:heading -->
209
209
 
210
210
  <!-- wp:heading -->
211
- <h2 id=\\"cite\\">cite</h2>
211
+ <h2>cite</h2>
212
212
  <!-- /wp:heading -->"
213
213
  `;
@@ -7,7 +7,7 @@ exports[`Spacer can be created by typing "/spacer" 1`] = `
7
7
  `;
8
8
 
9
9
  exports[`Spacer can be resized using the drag handle and remains selected after being dragged 1`] = `
10
- "<!-- wp:spacer {\\"height\\":150} -->
10
+ "<!-- wp:spacer {\\"height\\":\\"150px\\"} -->
11
11
  <div style=\\"height:150px\\" aria-hidden=\\"true\\" class=\\"wp-block-spacer\\"></div>
12
12
  <!-- /wp:spacer -->"
13
13
  `;
@@ -68,7 +68,7 @@ describe( 'Heading', () => {
68
68
  expect( await getEditedPostContent() ).toMatchSnapshot();
69
69
  } );
70
70
 
71
- it( 'should correctly apply custom colors', async () => {
71
+ it.skip( 'should correctly apply custom colors', async () => {
72
72
  await clickBlockAppender();
73
73
  await page.keyboard.type( '### Heading' );
74
74
  const colorPanelToggle = await page.waitForXPath(
@@ -91,7 +91,7 @@ describe( 'Heading', () => {
91
91
  expect( await getEditedPostContent() ).toMatchSnapshot();
92
92
  } );
93
93
 
94
- it( 'should correctly apply named colors', async () => {
94
+ it.skip( 'should correctly apply named colors', async () => {
95
95
  await clickBlockAppender();
96
96
  await page.keyboard.type( '## Heading' );
97
97
  const [ colorPanelToggle ] = await page.$x(
@@ -3,7 +3,7 @@
3
3
  exports[`Block Grouping Group creation creates a group from multiple blocks of different types via block transforms 1`] = `
4
4
  "<!-- wp:group -->
5
5
  <div class=\\"wp-block-group\\"><!-- wp:heading -->
6
- <h2 id=\\"group-heading\\">Group Heading</h2>
6
+ <h2>Group Heading</h2>
7
7
  <!-- /wp:heading -->
8
8
 
9
9
  <!-- wp:image -->
@@ -51,7 +51,7 @@ exports[`Block Grouping Group creation creates a group from multiple blocks of t
51
51
  exports[`Block Grouping Group creation groups and ungroups multiple blocks of different types via options toolbar 1`] = `
52
52
  "<!-- wp:group -->
53
53
  <div class=\\"wp-block-group\\"><!-- wp:heading -->
54
- <h2 id=\\"group-heading\\">Group Heading</h2>
54
+ <h2>Group Heading</h2>
55
55
  <!-- /wp:heading -->
56
56
 
57
57
  <!-- wp:image -->
@@ -66,7 +66,7 @@ exports[`Block Grouping Group creation groups and ungroups multiple blocks of di
66
66
 
67
67
  exports[`Block Grouping Group creation groups and ungroups multiple blocks of different types via options toolbar 2`] = `
68
68
  "<!-- wp:heading -->
69
- <h2 id=\\"group-heading\\">Group Heading</h2>
69
+ <h2>Group Heading</h2>
70
70
  <!-- /wp:heading -->
71
71
 
72
72
  <!-- wp:image -->
@@ -81,7 +81,7 @@ exports[`Block Grouping Group creation groups and ungroups multiple blocks of di
81
81
  exports[`Block Grouping Preserving selected blocks attributes preserves width alignment settings of selected blocks 1`] = `
82
82
  "<!-- wp:group {\\"align\\":\\"full\\"} -->
83
83
  <div class=\\"wp-block-group alignfull\\"><!-- wp:heading -->
84
- <h2 id=\\"group-heading\\">Group Heading</h2>
84
+ <h2>Group Heading</h2>
85
85
  <!-- /wp:heading -->
86
86
 
87
87
  <!-- wp:image {\\"align\\":\\"full\\"} -->
@@ -71,7 +71,7 @@ exports[`Inserting blocks inserts a block in proper place after having clicked \
71
71
  <!-- /wp:paragraph -->
72
72
 
73
73
  <!-- wp:heading -->
74
- <h2 id=\\"heading\\">Heading</h2>
74
+ <h2>Heading</h2>
75
75
  <!-- /wp:heading -->
76
76
 
77
77
  <!-- wp:paragraph -->
@@ -93,7 +93,7 @@ exports[`Inserting blocks inserts a block in proper place after having clicked \
93
93
  <!-- /wp:cover -->
94
94
 
95
95
  <!-- wp:heading -->
96
- <h2 id=\\"heading\\">Heading</h2>
96
+ <h2>Heading</h2>
97
97
  <!-- /wp:heading -->
98
98
 
99
99
  <!-- wp:paragraph -->
@@ -420,4 +420,25 @@ describe( 'undo', () => {
420
420
  // Expect "1".
421
421
  expect( await getEditedPostContent() ).toMatchSnapshot();
422
422
  } );
423
+
424
+ it( 'should be able to undo and redo when transient changes have been made and we update/publish', async () => {
425
+ // Typing consecutive characters in a `Paragraph` block updates the same
426
+ // block attribute as in the previous action and results in transient edits
427
+ // and skipping `undo` history steps.
428
+ const text = 'tonis';
429
+ await clickBlockAppender();
430
+ await page.keyboard.type( text );
431
+ await publishPost();
432
+ await pressKeyWithModifier( 'primary', 'z' );
433
+ expect( await getEditedPostContent() ).toBe( '' );
434
+ await page.waitForSelector(
435
+ '.editor-history__redo[aria-disabled="false"]'
436
+ );
437
+ await page.click( '.editor-history__redo[aria-disabled="false"]' );
438
+ expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
439
+ "<!-- wp:paragraph -->
440
+ <p>tonis</p>
441
+ <!-- /wp:paragraph -->"
442
+ ` );
443
+ } );
423
444
  } );
@@ -250,6 +250,19 @@ describe( 'Multi-entity save flow', () => {
250
250
  const disabledSaveSiteSelector = `${ saveSiteSelector }[aria-disabled=true]`;
251
251
  const saveA11ySelector = '.edit-site-editor__toggle-save-panel-button';
252
252
 
253
+ const saveAllChanges = async () => {
254
+ // Clicking button should open panel with boxes checked.
255
+ await page.click( activeSaveSiteSelector );
256
+ await page.waitForSelector( savePanelSelector );
257
+ await assertAllBoxesChecked();
258
+
259
+ // Save a11y button should not be present with save panel open.
260
+ await assertExistance( saveA11ySelector, false );
261
+
262
+ // Saving should result in items being saved.
263
+ await page.click( entitiesSaveSelector );
264
+ };
265
+
253
266
  it( 'Save flow should work as expected', async () => {
254
267
  // Navigate to site editor.
255
268
  await siteEditor.visit( {
@@ -279,20 +292,55 @@ describe( 'Multi-entity save flow', () => {
279
292
  // Save a11y button should be present.
280
293
  await assertExistance( saveA11ySelector, true );
281
294
 
282
- // Clicking button should open panel with boxes checked.
283
- await page.click( activeSaveSiteSelector );
284
- await page.waitForSelector( savePanelSelector );
285
- await assertAllBoxesChecked();
286
-
287
- // Save a11y button should not be present with save panel open.
288
- await assertExistance( saveA11ySelector, false );
295
+ // Save all changes.
296
+ await saveAllChanges();
289
297
 
290
- // Saving should result in items being saved.
291
- await page.click( entitiesSaveSelector );
292
298
  const disabledButton = await page.waitForSelector(
293
299
  disabledSaveSiteSelector
294
300
  );
295
301
  expect( disabledButton ).not.toBeNull();
296
302
  } );
303
+
304
+ it( 'Save flow should allow re-saving after changing the same block attribute', async () => {
305
+ // Navigate to site editor.
306
+ await siteEditor.visit( {
307
+ postId: 'tt1-blocks//index',
308
+ postType: 'wp_template',
309
+ } );
310
+ await siteEditor.disableWelcomeGuide();
311
+
312
+ // Insert a paragraph at the bottom.
313
+ await insertBlock( 'Paragraph' );
314
+
315
+ // Open the block settings.
316
+ await page.click( 'button[aria-label="Settings"]' );
317
+
318
+ // Click on font size selector.
319
+ await page.click( 'button[aria-label="Font size"]' );
320
+
321
+ // Click on a different font size.
322
+ const extraSmallFontSize = await page.waitForXPath(
323
+ '//li[contains(text(), "Extra small")]'
324
+ );
325
+ await extraSmallFontSize.click();
326
+
327
+ // Save all changes.
328
+ await saveAllChanges();
329
+
330
+ // Click on font size selector again.
331
+ await page.click( 'button[aria-label="Font size"]' );
332
+
333
+ // Select another font size.
334
+ const normalFontSize = await page.waitForXPath(
335
+ '//li[contains(text(), "Normal")]'
336
+ );
337
+ await normalFontSize.click();
338
+
339
+ // Assert that the save button has been re-enabled.
340
+ const saveButton = await page.waitForSelector(
341
+ activeSaveSiteSelector
342
+ );
343
+ expect( saveButton ).not.toBeNull();
344
+ } );
297
345
  } );
298
346
  } );
@@ -22,29 +22,31 @@ const {
22
22
  disableWelcomeGuide,
23
23
  } = siteEditor;
24
24
 
25
- const assertSaveButtonIsDisabled = () =>
25
+ const assertSaveButtonIsDisabled = async () =>
26
26
  page.waitForSelector(
27
27
  '.edit-site-save-button__button[aria-disabled="true"]'
28
28
  );
29
29
 
30
- const assertSaveButtonIsEnabled = () =>
30
+ const assertSaveButtonIsEnabled = async () =>
31
31
  page.waitForSelector(
32
32
  '.edit-site-save-button__button[aria-disabled="false"]'
33
33
  );
34
34
 
35
- const waitForNotice = () => page.waitForSelector( '.components-snackbar' );
36
-
37
35
  const clickButtonInNotice = async () => {
38
36
  const selector = '.components-snackbar button';
39
37
  await page.waitForSelector( selector );
40
38
  await page.click( selector );
41
39
  };
42
40
 
43
- const clickUndoInHeaderToolbar = () =>
41
+ const clickUndoInHeaderToolbar = async () =>
44
42
  page.click( '.edit-site-header__toolbar button[aria-label="Undo"]' );
45
43
 
46
- const clickRedoInHeaderToolbar = () =>
47
- page.click( '.edit-site-header__toolbar button[aria-label="Redo"]' );
44
+ const clickRedoInHeaderToolbar = async () => {
45
+ await page.waitForSelector(
46
+ '.edit-site-header__toolbar button[aria-label="Redo"][aria-disabled="false"]'
47
+ );
48
+ return page.click( '.edit-site-header__toolbar button[aria-label="Redo"]' );
49
+ };
48
50
 
49
51
  const undoRevertInHeaderToolbar = async () => {
50
52
  await clickUndoInHeaderToolbar();
@@ -72,7 +74,9 @@ const save = async () => {
72
74
  const revertTemplate = async () => {
73
75
  await page.click( '.edit-site-document-actions__get-info' );
74
76
  await page.click( '.edit-site-template-details__revert-button' );
75
- await waitForNotice();
77
+ await page.waitForXPath(
78
+ '//*[contains(@class, "components-snackbar") and contains(text(), "Template reverted")]'
79
+ );
76
80
  await assertSaveButtonIsEnabled();
77
81
  };
78
82