@wordpress/e2e-tests 4.9.0 → 5.0.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.
Files changed (24) hide show
  1. package/CHANGELOG.md +7 -1
  2. package/README.md +1 -1
  3. package/assets/large-post.html +364 -182
  4. package/package.json +8 -8
  5. package/specs/editor/blocks/__snapshots__/navigation.test.js.snap +2 -2
  6. package/specs/editor/blocks/__snapshots__/quote.test.js.snap +5 -1
  7. package/specs/editor/blocks/navigation.test.js +394 -154
  8. package/specs/editor/blocks/quote.test.js +4 -1
  9. package/specs/editor/plugins/__snapshots__/cpt-locking.test.js.snap +2 -2
  10. package/specs/editor/various/__snapshots__/block-grouping.test.js.snap +5 -5
  11. package/specs/editor/various/__snapshots__/block-hierarchy-navigation.test.js.snap +1 -1
  12. package/specs/editor/various/__snapshots__/draggable-block.test.js.snap +22 -2
  13. package/specs/editor/various/__snapshots__/inserting-blocks.test.js.snap +1 -1
  14. package/specs/editor/various/__snapshots__/keep-styles-on-block-transforms.test.js.snap +1 -1
  15. package/specs/editor/various/__snapshots__/multi-block-selection.test.js.snap +9 -5
  16. package/specs/editor/various/block-grouping.test.js +2 -2
  17. package/specs/editor/various/draggable-block.test.js +83 -14
  18. package/specs/editor/various/multi-block-selection.test.js +28 -5
  19. package/specs/editor/various/post-visibility.test.js +2 -4
  20. package/specs/editor/various/scheduling.test.js +2 -6
  21. package/specs/editor/various/switch-to-draft.test.js +2 -4
  22. package/specs/performance/post-editor.test.js +3 -3
  23. package/specs/site-editor/global-styles-sidebar.test.js +2 -1
  24. package/specs/editor/plugins/wp-editor-meta-box.test.js +0 -58
@@ -143,8 +143,11 @@ describe( 'Quote', () => {
143
143
  expect( await getEditedPostContent() ).toMatchSnapshot();
144
144
 
145
145
  await page.keyboard.press( 'Backspace' );
146
+ // Allow time for selection to update.
147
+ await page.evaluate( () => new Promise( window.requestIdleCallback ) );
148
+ await page.keyboard.type( '2' );
146
149
 
147
- // Expect the paragraph to be deleted.
150
+ // Expect the paragraph to be merged into the quote block.
148
151
  expect( await getEditedPostContent() ).toMatchSnapshot();
149
152
  } );
150
153
 
@@ -41,7 +41,7 @@ exports[`cpt locking template_lock all should not error when deleting the cotent
41
41
  `;
42
42
 
43
43
  exports[`cpt locking template_lock all unlocked group should allow blocks to be moved 1`] = `
44
- "<!-- wp:group {\\"templateLock\\":false} -->
44
+ "<!-- wp:group {\\"templateLock\\":false,\\"layout\\":{\\"type\\":\\"constrained\\"}} -->
45
45
  <div class=\\"wp-block-group\\"><!-- wp:paragraph {\\"placeholder\\":\\"Add a description\\"} -->
46
46
  <p>p1</p>
47
47
  <!-- /wp:paragraph -->
@@ -55,7 +55,7 @@ exports[`cpt locking template_lock all unlocked group should allow blocks to be
55
55
  `;
56
56
 
57
57
  exports[`cpt locking template_lock all unlocked group should allow blocks to be removed 1`] = `
58
- "<!-- wp:group {\\"templateLock\\":false} -->
58
+ "<!-- wp:group {\\"templateLock\\":false,\\"layout\\":{\\"type\\":\\"constrained\\"}} -->
59
59
  <div class=\\"wp-block-group\\"><!-- wp:quote -->
60
60
  <blockquote class=\\"wp-block-quote\\"><!-- wp:paragraph -->
61
61
  <p></p>
@@ -1,7 +1,7 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`Block Grouping Group creation creates a group from multiple blocks of different types via block transforms 1`] = `
4
- "<!-- wp:group -->
4
+ "<!-- wp:group {\\"layout\\":{\\"type\\":\\"constrained\\"}} -->
5
5
  <div class=\\"wp-block-group\\"><!-- wp:heading -->
6
6
  <h2>Group Heading</h2>
7
7
  <!-- /wp:heading -->
@@ -17,7 +17,7 @@ exports[`Block Grouping Group creation creates a group from multiple blocks of d
17
17
  `;
18
18
 
19
19
  exports[`Block Grouping Group creation creates a group from multiple blocks of the same type via block transforms 1`] = `
20
- "<!-- wp:group -->
20
+ "<!-- wp:group {\\"layout\\":{\\"type\\":\\"constrained\\"}} -->
21
21
  <div class=\\"wp-block-group\\"><!-- wp:paragraph -->
22
22
  <p>First Paragraph</p>
23
23
  <!-- /wp:paragraph -->
@@ -33,7 +33,7 @@ exports[`Block Grouping Group creation creates a group from multiple blocks of t
33
33
  `;
34
34
 
35
35
  exports[`Block Grouping Group creation creates a group from multiple blocks of the same type via options toolbar 1`] = `
36
- "<!-- wp:group -->
36
+ "<!-- wp:group {\\"layout\\":{\\"type\\":\\"constrained\\"}} -->
37
37
  <div class=\\"wp-block-group\\"><!-- wp:paragraph -->
38
38
  <p>First Paragraph</p>
39
39
  <!-- /wp:paragraph -->
@@ -49,7 +49,7 @@ exports[`Block Grouping Group creation creates a group from multiple blocks of t
49
49
  `;
50
50
 
51
51
  exports[`Block Grouping Group creation groups and ungroups multiple blocks of different types via options toolbar 1`] = `
52
- "<!-- wp:group -->
52
+ "<!-- wp:group {\\"layout\\":{\\"type\\":\\"constrained\\"}} -->
53
53
  <div class=\\"wp-block-group\\"><!-- wp:heading -->
54
54
  <h2>Group Heading</h2>
55
55
  <!-- /wp:heading -->
@@ -79,7 +79,7 @@ exports[`Block Grouping Group creation groups and ungroups multiple blocks of di
79
79
  `;
80
80
 
81
81
  exports[`Block Grouping Preserving selected blocks attributes preserves width alignment settings of selected blocks 1`] = `
82
- "<!-- wp:group {\\"align\\":\\"full\\"} -->
82
+ "<!-- wp:group {\\"layout\\":{\\"type\\":\\"constrained\\"},\\"align\\":\\"full\\"} -->
83
83
  <div class=\\"wp-block-group alignfull\\"><!-- wp:heading -->
84
84
  <h2>Group Heading</h2>
85
85
  <!-- /wp:heading -->
@@ -51,7 +51,7 @@ exports[`Navigating the block hierarchy should navigate using the list view side
51
51
  `;
52
52
 
53
53
  exports[`Navigating the block hierarchy should select the wrapper div for a group 1`] = `
54
- "<!-- wp:group -->
54
+ "<!-- wp:group {\\"layout\\":{\\"type\\":\\"constrained\\"}} -->
55
55
  <div class=\\"wp-block-group\\"><!-- wp:paragraph -->
56
56
  <p>just a paragraph</p>
57
57
  <!-- /wp:paragraph -->
@@ -1,6 +1,6 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`Draggable block should drag and drop 1`] = `
3
+ exports[`Draggable block can drag and drop to the bottom of a block list 1`] = `
4
4
  "<!-- wp:paragraph -->
5
5
  <p>1</p>
6
6
  <!-- /wp:paragraph -->
@@ -10,7 +10,27 @@ exports[`Draggable block should drag and drop 1`] = `
10
10
  <!-- /wp:paragraph -->"
11
11
  `;
12
12
 
13
- exports[`Draggable block should drag and drop 2`] = `
13
+ exports[`Draggable block can drag and drop to the bottom of a block list 2`] = `
14
+ "<!-- wp:paragraph -->
15
+ <p>2</p>
16
+ <!-- /wp:paragraph -->
17
+
18
+ <!-- wp:paragraph -->
19
+ <p>1</p>
20
+ <!-- /wp:paragraph -->"
21
+ `;
22
+
23
+ exports[`Draggable block can drag and drop to the top of a block list 1`] = `
24
+ "<!-- wp:paragraph -->
25
+ <p>1</p>
26
+ <!-- /wp:paragraph -->
27
+
28
+ <!-- wp:paragraph -->
29
+ <p>2</p>
30
+ <!-- /wp:paragraph -->"
31
+ `;
32
+
33
+ exports[`Draggable block can drag and drop to the top of a block list 2`] = `
14
34
  "<!-- wp:paragraph -->
15
35
  <p>2</p>
16
36
  <!-- /wp:paragraph -->
@@ -54,7 +54,7 @@ lines preserved[/myshortcode]
54
54
  `;
55
55
 
56
56
  exports[`Inserting blocks inserts a block in proper place after having clicked \`Browse All\` from block appender 1`] = `
57
- "<!-- wp:group -->
57
+ "<!-- wp:group {\\"layout\\":{\\"type\\":\\"constrained\\"}} -->
58
58
  <div class=\\"wp-block-group\\"><!-- wp:paragraph -->
59
59
  <p>Paragraph inside group</p>
60
60
  <!-- /wp:paragraph --></div>
@@ -27,7 +27,7 @@ exports[`Keep styles on block transforms Should keep the font size during a tran
27
27
  `;
28
28
 
29
29
  exports[`Keep styles on block transforms Should not include styles in the group block when grouping a block 1`] = `
30
- "<!-- wp:group -->
30
+ "<!-- wp:group {\\"layout\\":{\\"type\\":\\"constrained\\"}} -->
31
31
  <div class=\\"wp-block-group\\"><!-- wp:paragraph {\\"fontSize\\":\\"large\\"} -->
32
32
  <p class=\\"has-large-font-size\\">Line 1 to be made large</p>
33
33
  <!-- /wp:paragraph --></div>
@@ -267,13 +267,17 @@ exports[`Multi-block selection should select all from empty selection 1`] = `
267
267
  exports[`Multi-block selection should select all from empty selection 2`] = `""`;
268
268
 
269
269
  exports[`Multi-block selection should select separator (single element block) 1`] = `
270
- "<!-- wp:separator -->
271
- <hr class=\\"wp-block-separator has-alpha-channel-opacity\\"/>
272
- <!-- /wp:separator -->
270
+ "<!-- wp:paragraph -->
271
+ <p>a</p>
272
+ <!-- /wp:paragraph -->
273
273
 
274
274
  <!-- wp:paragraph -->
275
- <p>a</p>
276
- <!-- /wp:paragraph -->"
275
+ <p></p>
276
+ <!-- /wp:paragraph -->
277
+
278
+ <!-- wp:separator -->
279
+ <hr class=\\"wp-block-separator has-alpha-channel-opacity\\"/>
280
+ <!-- /wp:separator -->"
277
281
  `;
278
282
 
279
283
  exports[`Multi-block selection should select separator (single element block) 2`] = `
@@ -148,8 +148,8 @@ describe( 'Block Grouping', () => {
148
148
  await clickBlockToolbarButton( 'Options' );
149
149
  await clickMenuItem( 'Group' );
150
150
  expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
151
- "<!-- wp:group -->
152
- <div class=\\"wp-block-group\\"><!-- wp:group -->
151
+ "<!-- wp:group {\\"layout\\":{\\"type\\":\\"constrained\\"}} -->
152
+ <div class=\\"wp-block-group\\"><!-- wp:group {\\"layout\\":{\\"type\\":\\"constrained\\"}} -->
153
153
  <div class=\\"wp-block-group\\"><!-- wp:paragraph -->
154
154
  <p>1</p>
155
155
  <!-- /wp:paragraph --></div>
@@ -7,51 +7,120 @@ import {
7
7
  deactivatePlugin,
8
8
  activatePlugin,
9
9
  showBlockToolbar,
10
+ setBrowserViewport,
11
+ waitForWindowDimensions,
10
12
  } from '@wordpress/e2e-test-utils';
11
13
 
12
14
  describe( 'Draggable block', () => {
13
- beforeAll( async () => {
14
- await page.setDragInterception( true );
15
+ // Tests don't seem to pass if beforeAll and afterAll are used.
16
+ // Unsure why.
17
+ beforeEach( async () => {
15
18
  await deactivatePlugin(
16
19
  'gutenberg-test-plugin-disables-the-css-animations'
17
20
  );
21
+
22
+ // Set the viewport at a larger size than normal to ensure scrolling doesn't occur.
23
+ // Scrolling can interfere with the drag coordinates.
24
+ await page.setViewport( { width: 960, height: 1024 } );
25
+ await waitForWindowDimensions( 960, 1024 );
26
+ await createNewPost();
27
+ await page.setDragInterception( true );
18
28
  } );
19
29
 
20
- afterAll( async () => {
30
+ afterEach( async () => {
21
31
  await page.setDragInterception( false );
32
+
33
+ // Reset the viewport to normal large size.
34
+ await setBrowserViewport( 'large' );
22
35
  await activatePlugin(
23
36
  'gutenberg-test-plugin-disables-the-css-animations'
24
37
  );
25
38
  } );
26
39
 
27
- beforeEach( async () => {
28
- await createNewPost();
40
+ it( 'can drag and drop to the top of a block list', async () => {
41
+ await page.keyboard.press( 'Enter' );
42
+ await page.keyboard.type( '1' );
43
+ await page.keyboard.press( 'Enter' );
44
+ await page.keyboard.type( '2' );
45
+
46
+ // Confirm correct setup.
47
+ expect( await getEditedPostContent() ).toMatchSnapshot();
48
+
49
+ await showBlockToolbar();
50
+ const dragHandle = await page.waitForSelector(
51
+ '.block-editor-block-mover__drag-handle'
52
+ );
53
+ const dragHandlePoint = await dragHandle.clickablePoint();
54
+
55
+ const firstParagraph = await page.$( '[data-type="core/paragraph"]' );
56
+ const targetPoint = await firstParagraph.clickablePoint();
57
+ const targetRect = await firstParagraph.boundingBox();
58
+ const target = {
59
+ x: targetPoint.x,
60
+ // Drag to the top half.
61
+ y: targetPoint.y - targetRect.height * 0.25,
62
+ };
63
+
64
+ const dragData = await page.mouse.drag( dragHandlePoint, target );
65
+ await page.mouse.dragEnter( target, dragData );
66
+ await page.mouse.dragOver( target, dragData );
67
+
68
+ // Wait for the insertion point to be visible.
69
+ const insertionPoint = await page.waitForSelector(
70
+ '.block-editor-block-list__insertion-point'
71
+ );
72
+
73
+ // Expect the insertion point to be visible above the first paragraph.
74
+ const insertionPointBoundingBox = await insertionPoint.boundingBox();
75
+ expect( insertionPointBoundingBox.y ).toBeLessThan( target.y );
76
+
77
+ await page.mouse.drop( target, dragData );
78
+
79
+ expect( await getEditedPostContent() ).toMatchSnapshot();
29
80
  } );
30
81
 
31
- it( 'should drag and drop', async () => {
82
+ it( 'can drag and drop to the bottom of a block list', async () => {
32
83
  await page.keyboard.press( 'Enter' );
33
84
  await page.keyboard.type( '1' );
34
85
  await page.keyboard.press( 'Enter' );
35
86
  await page.keyboard.type( '2' );
87
+ await page.keyboard.press( 'ArrowUp' );
36
88
 
37
89
  // Confirm correct setup.
38
90
  expect( await getEditedPostContent() ).toMatchSnapshot();
39
91
 
92
+ const [ , secondParagraph ] = await page.$$(
93
+ '[data-type="core/paragraph"]'
94
+ );
95
+
40
96
  await showBlockToolbar();
41
97
  const dragHandle = await page.waitForSelector(
42
98
  '.block-editor-block-mover__drag-handle'
43
99
  );
44
100
  const dragHandlePoint = await dragHandle.clickablePoint();
45
101
 
46
- const paragraph = await page.$( '[data-type="core/paragraph"]' );
47
- const paragraphPoint = await paragraph.clickablePoint();
48
- const paragraphRect = await paragraph.boundingBox();
102
+ const targetPoint = await secondParagraph.clickablePoint();
103
+ const targetRect = await secondParagraph.boundingBox();
104
+ const target = {
105
+ x: targetPoint.x,
106
+ // Drag to the bottom half.
107
+ y: targetPoint.y + targetRect.height * 0.25,
108
+ };
49
109
 
50
- await page.mouse.dragAndDrop( dragHandlePoint, {
51
- x: paragraphPoint.x,
52
- // Drag to the top half.
53
- y: paragraphPoint.y - paragraphRect.height / 4,
54
- } );
110
+ const dragData = await page.mouse.drag( dragHandlePoint, target );
111
+ await page.mouse.dragEnter( target, dragData );
112
+ await page.mouse.dragOver( target, dragData );
113
+
114
+ // Wait for the insertion point to be visible.
115
+ const insertionPoint = await page.waitForSelector(
116
+ '.block-editor-block-list__insertion-point'
117
+ );
118
+
119
+ // Expect the insertion point to be visible below the first paragraph.
120
+ const insertionPointBoundingBox = await insertionPoint.boundingBox();
121
+ expect( insertionPointBoundingBox.y ).toBeGreaterThan( target.y );
122
+
123
+ await page.mouse.drop( target, dragData );
55
124
 
56
125
  expect( await getEditedPostContent() ).toMatchSnapshot();
57
126
  } );
@@ -356,7 +356,7 @@ describe( 'Multi-block selection', () => {
356
356
  await page.mouse.up();
357
357
  await page.keyboard.type( 'hi' );
358
358
  expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
359
- "<!-- wp:group -->
359
+ "<!-- wp:group {\\"layout\\":{\\"type\\":\\"constrained\\"}} -->
360
360
  <div class=\\"wp-block-group\\"><!-- wp:paragraph -->
361
361
  <p>hih text in group</p>
362
362
  <!-- /wp:paragraph --></div>
@@ -907,11 +907,16 @@ describe( 'Multi-block selection', () => {
907
907
 
908
908
  it( 'should select separator (single element block)', async () => {
909
909
  await clickBlockAppender();
910
- await page.keyboard.type( '/hr' );
910
+ await page.keyboard.type( 'a' );
911
911
  await page.keyboard.press( 'Enter' );
912
912
  await page.keyboard.press( 'Enter' );
913
- await page.keyboard.type( 'a' );
914
- await pressKeyWithModifier( 'shift', 'ArrowUp' );
913
+ await page.keyboard.type( '/hr' );
914
+ await page.keyboard.press( 'Enter' );
915
+ await page.keyboard.press( 'ArrowUp' );
916
+ await page.keyboard.press( 'ArrowUp' );
917
+ await page.keyboard.press( 'ArrowRight' );
918
+ await pressKeyWithModifier( 'shift', 'ArrowDown' );
919
+ await pressKeyWithModifier( 'shift', 'ArrowDown' );
915
920
 
916
921
  // Test setup.
917
922
  expect( await getEditedPostContent() ).toMatchSnapshot();
@@ -921,7 +926,7 @@ describe( 'Multi-block selection', () => {
921
926
  // Ensure selection is in the correct place.
922
927
  await page.keyboard.type( '&' );
923
928
 
924
- // Expect two blocks with "&" in between.
929
+ // Expect a paragraph with "&".
925
930
  expect( await getEditedPostContent() ).toMatchSnapshot();
926
931
  } );
927
932
 
@@ -996,4 +1001,22 @@ describe( 'Multi-block selection', () => {
996
1001
  expect( selectedBlocks.length ).toBe( 2 );
997
1002
  } );
998
1003
  } );
1004
+
1005
+ it( 'should select by dragging into separator', async () => {
1006
+ await clickBlockAppender();
1007
+ await page.keyboard.type( '1' );
1008
+ await insertBlock( 'Separator' );
1009
+ await page.keyboard.press( 'ArrowUp' );
1010
+
1011
+ const [ paragraph, hr ] = await page.$$( '[data-type]' );
1012
+ const coord1 = await paragraph.clickablePoint();
1013
+ const coord2 = await hr.clickablePoint();
1014
+
1015
+ await page.mouse.move( coord1.x, coord1.y );
1016
+ await page.mouse.down();
1017
+ await page.mouse.move( coord2.x, coord2.y, { steps: 10 } );
1018
+ await page.mouse.up();
1019
+
1020
+ expect( await getSelectedFlatIndices() ).toEqual( [ 1, 2 ] );
1021
+ } );
999
1022
  } );
@@ -91,12 +91,10 @@ describe( 'Post visibility', () => {
91
91
 
92
92
  // Set a publish date for the next month.
93
93
  await page.click( '*[aria-label^="Change date"]' );
94
- await page.click(
95
- '*[aria-label="Move forward to switch to the next month."]'
96
- );
94
+ await page.click( '*[aria-label="View next month"]' );
97
95
  await (
98
96
  await page.$x(
99
- '//*[@role="application"][@aria-label="Calendar"]//td[@role="button"]/*[text() = "15"]'
97
+ '//*[@role="application"][@aria-label="Calendar"]//button[text()="15"]'
100
98
  )
101
99
  )[ 0 ].click();
102
100
 
@@ -57,13 +57,9 @@ describe( 'Scheduling', () => {
57
57
  await createNewPost();
58
58
 
59
59
  await page.click( '*[aria-label^="Change date"]' );
60
- await page.click(
61
- '*[aria-label="Move backward to switch to the previous month."]'
62
- );
60
+ await page.click( '*[aria-label="View previous month"]' );
63
61
  expect( await isDateTimeComponentFocused() ).toBe( true );
64
- await page.click(
65
- '*[aria-label="Move forward to switch to the next month."]'
66
- );
62
+ await page.click( '*[aria-label="View next month"]' );
67
63
  expect( await isDateTimeComponentFocused() ).toBe( true );
68
64
  } );
69
65
  } );
@@ -62,13 +62,11 @@ async function scheduleTestPost( postType, viewport ) {
62
62
  }
63
63
  // Set a publish date for the next month.
64
64
  await page.click( '.edit-post-post-schedule__toggle' );
65
- await page.click(
66
- '*[aria-label="Move forward to switch to the next month."]'
67
- );
65
+ await page.click( '*[aria-label="View next month"]' );
68
66
 
69
67
  await (
70
68
  await page.$x(
71
- '//*[@role="application"][@aria-label="Calendar"]//td[@role="button"]/*[text() = "15"]'
69
+ '//*[@role="application"][@aria-label="Calendar"]//button[text()="15"]'
72
70
  )
73
71
  )[ 0 ].click();
74
72
 
@@ -157,9 +157,9 @@ describe( 'Post Editor Performance', () => {
157
157
  await page.evaluate( () => {
158
158
  const { createBlock } = window.wp.blocks;
159
159
  const { dispatch } = window.wp.data;
160
- const blocks = window.lodash
161
- .times( 1000 )
162
- .map( () => createBlock( 'core/paragraph' ) );
160
+ const blocks = Array.from( { length: 1000 } ).map( () =>
161
+ createBlock( 'core/paragraph' )
162
+ );
163
163
  dispatch( 'core/block-editor' ).resetBlocks( blocks );
164
164
  } );
165
165
  const paragraphs = await page.$$( '.wp-block' );
@@ -36,7 +36,8 @@ describe( 'Global styles sidebar', () => {
36
36
  const results = await page.$$(
37
37
  '.edit-site-block-types-item-list div[role="listitem"]'
38
38
  );
39
- expect( results.length ).toEqual( 1 );
39
+ // Matches both Heading and Table of Contents blocks. (The latter contains "heading" in its description.)
40
+ expect( results.length ).toEqual( 2 );
40
41
  } );
41
42
  } );
42
43
  } );
@@ -1,58 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import {
5
- activatePlugin,
6
- createNewPost,
7
- deactivatePlugin,
8
- publishPost,
9
- } from '@wordpress/e2e-test-utils';
10
-
11
- describe( 'WP Editor Meta Boxes', () => {
12
- beforeAll( async () => {
13
- await activatePlugin( 'gutenberg-test-plugin-wp-editor-meta-box' );
14
- await createNewPost();
15
- } );
16
-
17
- afterAll( async () => {
18
- await deactivatePlugin( 'gutenberg-test-plugin-wp-editor-meta-box' );
19
- } );
20
-
21
- it( 'Should save the changes', async () => {
22
- // Add title to enable valid non-empty post save.
23
- await page.type( '.editor-post-title__input', 'Hello Meta' );
24
-
25
- // Type something.
26
- await expect( page ).toClick( '#test_tinymce_id-html' );
27
- await page.type( '#test_tinymce_id', 'Typing in a metabox' );
28
- await page.click( '#test_tinymce_id-tmce' );
29
-
30
- await publishPost();
31
-
32
- await page.reload();
33
- await page.waitForSelector( '.edit-post-layout' );
34
-
35
- await expect( page ).toClick( '#test_tinymce_id-html' );
36
- await page.waitForSelector( '#test_tinymce_id' );
37
- const content = await page.$eval(
38
- '#test_tinymce_id',
39
- ( textarea ) => textarea.value
40
- );
41
-
42
- /*
43
- * `content` may or may not contain the <p> tags depending on hasWpautop value in this line:
44
- * https://github.com/WordPress/wordpress-develop/blob/2382765afa36e10bf3c74420024ad4e85763a47c/src/js/_enqueues/vendor/tinymce/plugins/wordpress/plugin.js#L15
45
- *
46
- * Now, for the purposes of this e2e test we explicitly set wpautop to true in the test plugin:
47
- * https://github.com/WordPress/gutenberg/blob/3da717b8d0ac7d7821fc6d0475695ccf3ae2829f/packages/e2e-tests/plugins/wp-editor-metabox.php#L36
48
- *
49
- * If this test randomly fails because of the actual value being wrapped in <p> like <p>Typing in a metabox</p>, it means that
50
- * hasWpautop has been errorneously set to false in the line above. You may want to check:
51
- * * Is window.wp.editor.autop a function? It should be one since https://github.com/WordPress/gutenberg/pull/33228
52
- * * Is wpautop still true in the second link mentioned in this comment?
53
- *
54
- * For more context, see https://github.com/WordPress/gutenberg/pull/33228/files#r666897885
55
- */
56
- expect( content ).toBe( 'Typing in a metabox' );
57
- } );
58
- } );