@wordpress/e2e-tests 5.6.0 → 6.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.
- package/CHANGELOG.md +6 -0
- package/config/setup-performance-test.js +3 -0
- package/package.json +9 -9
- package/plugins/inner-blocks-templates/index.js +29 -0
- package/specs/editor/blocks/__snapshots__/heading.test.js.snap +7 -7
- package/specs/editor/blocks/__snapshots__/quote.test.js.snap +1 -1
- package/specs/editor/blocks/heading.test.js +1 -1
- package/specs/editor/blocks/quote.test.js +3 -3
- package/specs/editor/various/__snapshots__/block-grouping.test.js.snap +4 -4
- package/specs/editor/various/__snapshots__/inserting-blocks.test.js.snap +2 -2
- package/specs/editor/various/__snapshots__/keep-styles-on-block-transforms.test.js.snap +3 -3
- package/specs/editor/various/__snapshots__/list-view.test.js.snap +1 -1
- package/specs/editor/various/__snapshots__/multi-block-selection.test.js.snap +4 -4
- package/specs/editor/various/__snapshots__/rich-text.test.js.snap +1 -1
- package/specs/editor/various/block-switcher.test.js +14 -13
- package/specs/editor/various/multi-block-selection.test.js +1 -1
- package/specs/editor/various/reusable-blocks.test.js +2 -2
- package/specs/experiments/blocks/post-comments-form.test.js +7 -8
- package/specs/performance/site-editor.test.js +2 -0
- package/specs/site-editor/global-styles-sidebar.test.js +2 -0
- package/specs/site-editor/multi-entity-saving.test.js +5 -0
- package/specs/site-editor/settings-sidebar.test.js +3 -0
- package/specs/site-editor/site-editor-export.test.js +2 -0
- package/specs/site-editor/multi-entity-editing.test.js +0 -309
package/CHANGELOG.md
CHANGED
@@ -34,6 +34,9 @@ beforeAll( async () => {
|
|
34
34
|
await trashAllPosts( 'wp_block' );
|
35
35
|
await setupBrowser();
|
36
36
|
await activatePlugin( 'gutenberg-test-plugin-disables-the-css-animations' );
|
37
|
+
await page.emulateMediaFeatures( [
|
38
|
+
{ name: 'prefers-reduced-motion', value: 'reduce' },
|
39
|
+
] );
|
37
40
|
} );
|
38
41
|
|
39
42
|
afterEach( async () => {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@wordpress/e2e-tests",
|
3
|
-
"version": "
|
3
|
+
"version": "6.0.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": ">=14"
|
24
24
|
},
|
25
25
|
"dependencies": {
|
26
|
-
"@wordpress/e2e-test-utils": "^
|
27
|
-
"@wordpress/jest-console": "^6.
|
28
|
-
"@wordpress/jest-puppeteer-axe": "^5.
|
29
|
-
"@wordpress/scripts": "^
|
30
|
-
"@wordpress/url": "^3.
|
26
|
+
"@wordpress/e2e-test-utils": "^9.0.0",
|
27
|
+
"@wordpress/jest-console": "^6.6.0",
|
28
|
+
"@wordpress/jest-puppeteer-axe": "^5.6.0",
|
29
|
+
"@wordpress/scripts": "^25.0.0",
|
30
|
+
"@wordpress/url": "^3.24.0",
|
31
31
|
"chalk": "^4.0.0",
|
32
32
|
"expect-puppeteer": "^4.4.0",
|
33
33
|
"filenamify": "^4.2.0",
|
@@ -40,11 +40,11 @@
|
|
40
40
|
"peerDependencies": {
|
41
41
|
"jest": ">=27",
|
42
42
|
"puppeteer-core": ">=11",
|
43
|
-
"react": "^
|
44
|
-
"react-dom": "^
|
43
|
+
"react": "^18.0.0",
|
44
|
+
"react-dom": "^18.0.0"
|
45
45
|
},
|
46
46
|
"publishConfig": {
|
47
47
|
"access": "public"
|
48
48
|
},
|
49
|
-
"gitHead": "
|
49
|
+
"gitHead": "1eb65aabe6738097f4c062e78f69ae8f05879848"
|
50
50
|
}
|
@@ -3,6 +3,8 @@
|
|
3
3
|
const createBlock = wp.blocks.createBlock;
|
4
4
|
const el = wp.element.createElement;
|
5
5
|
const InnerBlocks = wp.blockEditor.InnerBlocks;
|
6
|
+
const useState = window.wp.element.useState;
|
7
|
+
|
6
8
|
const TEMPLATE = [
|
7
9
|
[
|
8
10
|
'core/paragraph',
|
@@ -171,4 +173,31 @@
|
|
171
173
|
|
172
174
|
save,
|
173
175
|
} );
|
176
|
+
|
177
|
+
|
178
|
+
function InnerBlocksAsyncTemplateEdit() {
|
179
|
+
const [ template, setTemplate ] = useState( [] );
|
180
|
+
|
181
|
+
setInterval( () => {
|
182
|
+
setTemplate( TEMPLATE_TWO_PARAGRAPHS );
|
183
|
+
}, 1000 );
|
184
|
+
|
185
|
+
return el( InnerBlocks, {
|
186
|
+
template,
|
187
|
+
} );
|
188
|
+
}
|
189
|
+
|
190
|
+
registerBlockType(
|
191
|
+
'test/test-inner-blocks-async-template',
|
192
|
+
{
|
193
|
+
title: 'Test Inner Blocks Async Template',
|
194
|
+
icon: 'cart',
|
195
|
+
category: 'text',
|
196
|
+
|
197
|
+
edit: InnerBlocksAsyncTemplateEdit,
|
198
|
+
|
199
|
+
// Purposely do not save inner blocks so that it's possible to test template resolution.
|
200
|
+
save() {},
|
201
|
+
}
|
202
|
+
);
|
174
203
|
} )();
|
@@ -2,19 +2,19 @@
|
|
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>4</h4>
|
5
|
+
<h4 class=\\"wp-block-heading\\">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>3</h3>
|
11
|
+
<h3 class=\\"wp-block-heading\\">3</h3>
|
12
12
|
<!-- /wp:heading -->"
|
13
13
|
`;
|
14
14
|
|
15
15
|
exports[`Heading should correctly apply named colors 1`] = `
|
16
16
|
"<!-- wp:heading {\\"textColor\\":\\"luminous-vivid-orange\\"} -->
|
17
|
-
<h2 class=\\"has-luminous-vivid-orange-color has-text-color\\">Heading</h2>
|
17
|
+
<h2 class=\\"wp-block-heading has-luminous-vivid-orange-color has-text-color\\">Heading</h2>
|
18
18
|
<!-- /wp:heading -->"
|
19
19
|
`;
|
20
20
|
|
@@ -24,13 +24,13 @@ exports[`Heading should create a paragraph block above when pressing enter at th
|
|
24
24
|
<!-- /wp:paragraph -->
|
25
25
|
|
26
26
|
<!-- wp:heading -->
|
27
|
-
<h2>a</h2>
|
27
|
+
<h2 class=\\"wp-block-heading\\">a</h2>
|
28
28
|
<!-- /wp:heading -->"
|
29
29
|
`;
|
30
30
|
|
31
31
|
exports[`Heading should create a paragraph block below when pressing enter at the end 1`] = `
|
32
32
|
"<!-- wp:heading -->
|
33
|
-
<h2>a</h2>
|
33
|
+
<h2 class=\\"wp-block-heading\\">a</h2>
|
34
34
|
<!-- /wp:heading -->
|
35
35
|
|
36
36
|
<!-- wp:paragraph -->
|
@@ -40,12 +40,12 @@ exports[`Heading should create a paragraph block below when pressing enter at th
|
|
40
40
|
|
41
41
|
exports[`Heading should not work with the list input rule 1`] = `
|
42
42
|
"<!-- wp:heading -->
|
43
|
-
<h2>1. H</h2>
|
43
|
+
<h2 class=\\"wp-block-heading\\">1. H</h2>
|
44
44
|
<!-- /wp:heading -->"
|
45
45
|
`;
|
46
46
|
|
47
47
|
exports[`Heading should work with the format input rules 1`] = `
|
48
48
|
"<!-- wp:heading -->
|
49
|
-
<h2><code>code</code></h2>
|
49
|
+
<h2 class=\\"wp-block-heading\\"><code>code</code></h2>
|
50
50
|
<!-- /wp:heading -->"
|
51
51
|
`;
|
@@ -45,7 +45,7 @@ exports[`Quote can be converted to paragraphs and renders only one paragraph for
|
|
45
45
|
exports[`Quote can be created by converting a heading 1`] = `
|
46
46
|
"<!-- wp:quote -->
|
47
47
|
<blockquote class=\\"wp-block-quote\\"><!-- wp:heading -->
|
48
|
-
<h2>test</h2>
|
48
|
+
<h2 class=\\"wp-block-heading\\">test</h2>
|
49
49
|
<!-- /wp:heading --></blockquote>
|
50
50
|
<!-- /wp:quote -->"
|
51
51
|
`;
|
@@ -87,7 +87,7 @@ describe( 'Heading', () => {
|
|
87
87
|
await page.keyboard.press( 'Enter' );
|
88
88
|
expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
|
89
89
|
"<!-- wp:heading {\\"level\\":3,\\"style\\":{\\"color\\":{\\"text\\":\\"#4b7f4d\\"}}} -->
|
90
|
-
<h3 class=\\"has-text-color\\" style=\\"color:#4b7f4d\\">Heading</h3>
|
90
|
+
<h3 class=\\"wp-block-heading has-text-color\\" style=\\"color:#4b7f4d\\">Heading</h3>
|
91
91
|
<!-- /wp:heading -->"
|
92
92
|
` );
|
93
93
|
} );
|
@@ -191,9 +191,9 @@ describe( 'Quote', () => {
|
|
191
191
|
<p>1</p>
|
192
192
|
<!-- /wp:paragraph -->
|
193
193
|
|
194
|
-
<!-- wp:
|
195
|
-
<
|
196
|
-
<!-- /wp:
|
194
|
+
<!-- wp:quote -->
|
195
|
+
<blockquote class=\\"wp-block-quote\\"><cite>2</cite></blockquote>
|
196
|
+
<!-- /wp:quote -->"
|
197
197
|
` );
|
198
198
|
} );
|
199
199
|
} );
|
@@ -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 {\\"layout\\":{\\"type\\":\\"constrained\\"}} -->
|
5
5
|
<div class=\\"wp-block-group\\"><!-- wp:heading -->
|
6
|
-
<h2>Group Heading</h2>
|
6
|
+
<h2 class=\\"wp-block-heading\\">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 {\\"layout\\":{\\"type\\":\\"constrained\\"}} -->
|
53
53
|
<div class=\\"wp-block-group\\"><!-- wp:heading -->
|
54
|
-
<h2>Group Heading</h2>
|
54
|
+
<h2 class=\\"wp-block-heading\\">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>Group Heading</h2>
|
69
|
+
<h2 class=\\"wp-block-heading\\">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\\",\\"layout\\":{\\"type\\":\\"constrained\\"}} -->
|
83
83
|
<div class=\\"wp-block-group alignfull\\"><!-- wp:heading -->
|
84
|
-
<h2>Group Heading</h2>
|
84
|
+
<h2 class=\\"wp-block-heading\\">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>Heading</h2>
|
74
|
+
<h2 class=\\"wp-block-heading\\">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>Heading</h2>
|
96
|
+
<h2 class=\\"wp-block-heading\\">Heading</h2>
|
97
97
|
<!-- /wp:heading -->
|
98
98
|
|
99
99
|
<!-- wp:paragraph -->
|
@@ -8,15 +8,15 @@ exports[`Keep styles on block transforms Should keep colors during a transform 1
|
|
8
8
|
|
9
9
|
exports[`Keep styles on block transforms Should keep the font size during a transform from multiple blocks into multiple blocks 1`] = `
|
10
10
|
"<!-- wp:heading {\\"fontSize\\":\\"large\\"} -->
|
11
|
-
<h2 class=\\"has-large-font-size\\">Line 1 to be made large</h2>
|
11
|
+
<h2 class=\\"wp-block-heading has-large-font-size\\">Line 1 to be made large</h2>
|
12
12
|
<!-- /wp:heading -->
|
13
13
|
|
14
14
|
<!-- wp:heading {\\"fontSize\\":\\"large\\"} -->
|
15
|
-
<h2 class=\\"has-large-font-size\\">Line 2 to be made large</h2>
|
15
|
+
<h2 class=\\"wp-block-heading has-large-font-size\\">Line 2 to be made large</h2>
|
16
16
|
<!-- /wp:heading -->
|
17
17
|
|
18
18
|
<!-- wp:heading {\\"fontSize\\":\\"large\\"} -->
|
19
|
-
<h2 class=\\"has-large-font-size\\">Line 3 to be made large</h2>
|
19
|
+
<h2 class=\\"wp-block-heading has-large-font-size\\">Line 3 to be made large</h2>
|
20
20
|
<!-- /wp:heading -->"
|
21
21
|
`;
|
22
22
|
|
@@ -84,13 +84,13 @@ exports[`Multi-block selection should forward delete across blocks 1`] = `
|
|
84
84
|
<!-- /wp:paragraph -->
|
85
85
|
|
86
86
|
<!-- wp:heading -->
|
87
|
-
<h2>]2</h2>
|
87
|
+
<h2 class=\\"wp-block-heading\\">]2</h2>
|
88
88
|
<!-- /wp:heading -->"
|
89
89
|
`;
|
90
90
|
|
91
91
|
exports[`Multi-block selection should forward delete across blocks 2`] = `
|
92
92
|
"<!-- wp:heading -->
|
93
|
-
<h2>1&2</h2>
|
93
|
+
<h2 class=\\"wp-block-heading\\">1&2</h2>
|
94
94
|
<!-- /wp:heading -->"
|
95
95
|
`;
|
96
96
|
|
@@ -128,7 +128,7 @@ exports[`Multi-block selection should handle Enter across blocks 1`] = `
|
|
128
128
|
<!-- /wp:paragraph -->
|
129
129
|
|
130
130
|
<!-- wp:heading -->
|
131
|
-
<h2>]2</h2>
|
131
|
+
<h2 class=\\"wp-block-heading\\">]2</h2>
|
132
132
|
<!-- /wp:heading -->"
|
133
133
|
`;
|
134
134
|
|
@@ -142,7 +142,7 @@ exports[`Multi-block selection should handle Enter across blocks 2`] = `
|
|
142
142
|
<!-- /wp:paragraph -->
|
143
143
|
|
144
144
|
<!-- wp:heading -->
|
145
|
-
<h2>2</h2>
|
145
|
+
<h2 class=\\"wp-block-heading\\">2</h2>
|
146
146
|
<!-- /wp:heading -->"
|
147
147
|
`;
|
148
148
|
|
@@ -32,7 +32,7 @@ exports[`RichText should handle Home and End keys 1`] = `
|
|
32
32
|
|
33
33
|
exports[`RichText should handle change in tag name gracefully 1`] = `
|
34
34
|
"<!-- wp:heading {\\"level\\":3} -->
|
35
|
-
<h3></h3>
|
35
|
+
<h3 class=\\"wp-block-heading\\"></h3>
|
36
36
|
<!-- /wp:heading -->"
|
37
37
|
`;
|
38
38
|
|
@@ -16,8 +16,8 @@ describe( 'Block Switcher', () => {
|
|
16
16
|
|
17
17
|
it( 'Should show the expected block transforms on the list block when the blocks are removed', async () => {
|
18
18
|
// Insert a list block.
|
19
|
-
await
|
20
|
-
await page.keyboard.type( 'List content' );
|
19
|
+
await page.keyboard.press( 'Enter' );
|
20
|
+
await page.keyboard.type( '- List content' );
|
21
21
|
await page.keyboard.press( 'ArrowUp' );
|
22
22
|
await pressKeyWithModifier( 'alt', 'F10' );
|
23
23
|
|
@@ -43,8 +43,8 @@ describe( 'Block Switcher', () => {
|
|
43
43
|
} );
|
44
44
|
|
45
45
|
// Insert a list block.
|
46
|
-
await
|
47
|
-
await page.keyboard.type( 'List content' );
|
46
|
+
await page.keyboard.press( 'Enter' );
|
47
|
+
await page.keyboard.type( '- List content' );
|
48
48
|
await page.keyboard.press( 'ArrowUp' );
|
49
49
|
await pressKeyWithModifier( 'alt', 'F10' );
|
50
50
|
|
@@ -63,6 +63,10 @@ describe( 'Block Switcher', () => {
|
|
63
63
|
} );
|
64
64
|
|
65
65
|
it( 'Should not show the block switcher if all the blocks the list block transforms into are removed', async () => {
|
66
|
+
// Insert a list block.
|
67
|
+
await page.keyboard.press( 'Enter' );
|
68
|
+
await page.keyboard.type( '- List content' );
|
69
|
+
|
66
70
|
// Remove the paragraph and quote block from the list of registered blocks.
|
67
71
|
await page.evaluate( () => {
|
68
72
|
[
|
@@ -75,23 +79,20 @@ describe( 'Block Switcher', () => {
|
|
75
79
|
].map( ( block ) => wp.blocks.unregisterBlockType( block ) );
|
76
80
|
} );
|
77
81
|
|
78
|
-
// Insert a list block.
|
79
|
-
await insertBlock( 'List' );
|
80
|
-
await page.keyboard.type( 'List content' );
|
81
82
|
await page.keyboard.press( 'ArrowUp' );
|
82
83
|
await pressKeyWithModifier( 'alt', 'F10' );
|
83
84
|
|
84
85
|
// Verify the block switcher exists.
|
85
|
-
expect( await hasBlockSwitcher() ).
|
86
|
+
expect( await hasBlockSwitcher() ).toBeFalsy();
|
86
87
|
// Verify the correct block transforms appear.
|
87
|
-
expect( await getAvailableBlockTransforms() ).toHaveLength(
|
88
|
+
expect( await getAvailableBlockTransforms() ).toHaveLength( 0 );
|
88
89
|
} );
|
89
90
|
|
90
91
|
describe( 'Conditional tranformation options', () => {
|
91
92
|
describe( 'Columns tranforms', () => {
|
92
93
|
it( 'Should show Columns block only if selected blocks are between limits (1-6)', async () => {
|
93
|
-
await
|
94
|
-
await page.keyboard.type( 'List content' );
|
94
|
+
await page.keyboard.press( 'Enter' );
|
95
|
+
await page.keyboard.type( '- List content' );
|
95
96
|
await page.keyboard.press( 'ArrowUp' );
|
96
97
|
await insertBlock( 'Heading' );
|
97
98
|
await page.keyboard.type( 'I am a header' );
|
@@ -103,8 +104,8 @@ describe( 'Block Switcher', () => {
|
|
103
104
|
);
|
104
105
|
} );
|
105
106
|
it( 'Should NOT show Columns transform only if selected blocks are more than max limit(6)', async () => {
|
106
|
-
await
|
107
|
-
await page.keyboard.type( 'List content' );
|
107
|
+
await page.keyboard.press( 'Enter' );
|
108
|
+
await page.keyboard.type( '- List content' );
|
108
109
|
await page.keyboard.press( 'ArrowUp' );
|
109
110
|
await insertBlock( 'Heading' );
|
110
111
|
await page.keyboard.type( 'I am a header' );
|
@@ -108,7 +108,7 @@ describe( 'Reusable blocks', () => {
|
|
108
108
|
await insertReusableBlock( 'Surprised greeting block' );
|
109
109
|
|
110
110
|
// Convert block to a regular block.
|
111
|
-
await clickBlockToolbarButton( 'Convert to regular
|
111
|
+
await clickBlockToolbarButton( 'Convert to regular block' );
|
112
112
|
|
113
113
|
// Check that we have a paragraph block on the page.
|
114
114
|
const paragraphBlock = await page.$(
|
@@ -343,7 +343,7 @@ describe( 'Reusable blocks', () => {
|
|
343
343
|
|
344
344
|
// Convert back to regular blocks.
|
345
345
|
await clickBlockToolbarButton( 'Select Reusable block' );
|
346
|
-
await clickBlockToolbarButton( 'Convert to regular
|
346
|
+
await clickBlockToolbarButton( 'Convert to regular block' );
|
347
347
|
await page.waitForXPath( selector, {
|
348
348
|
hidden: true,
|
349
349
|
} );
|
@@ -6,8 +6,7 @@ import {
|
|
6
6
|
activateTheme,
|
7
7
|
setOption,
|
8
8
|
visitSiteEditor,
|
9
|
-
|
10
|
-
navigateSiteEditorBackToRoot,
|
9
|
+
enterEditMode,
|
11
10
|
deleteAllTemplates,
|
12
11
|
canvas,
|
13
12
|
} from '@wordpress/e2e-test-utils';
|
@@ -24,15 +23,15 @@ describe( 'Post Comments Form', () => {
|
|
24
23
|
|
25
24
|
// Navigate to "Singular" post template
|
26
25
|
await visitSiteEditor();
|
27
|
-
await openSiteEditorNavigationPanel();
|
28
|
-
await navigateSiteEditorBackToRoot();
|
29
26
|
await expect( page ).toClick(
|
30
|
-
'.
|
27
|
+
'.edit-site-sidebar-navigation-item',
|
31
28
|
{ text: /templates/i }
|
32
29
|
);
|
33
|
-
await expect( page ).toClick(
|
34
|
-
|
35
|
-
|
30
|
+
await expect( page ).toClick(
|
31
|
+
'.edit-site-sidebar-navigation-item',
|
32
|
+
{ text: /singular/i }
|
33
|
+
);
|
34
|
+
await enterEditMode();
|
36
35
|
|
37
36
|
// Insert post comments form
|
38
37
|
await insertBlock( 'Post Comments Form' );
|
@@ -15,6 +15,7 @@ import {
|
|
15
15
|
saveDraft,
|
16
16
|
insertBlock,
|
17
17
|
deleteAllTemplates,
|
18
|
+
enterEditMode,
|
18
19
|
} from '@wordpress/e2e-test-utils';
|
19
20
|
|
20
21
|
/**
|
@@ -114,6 +115,7 @@ describe( 'Site Editor Performance', () => {
|
|
114
115
|
await canvas().waitForSelector(
|
115
116
|
'[data-type="core/post-content"] [data-type="core/paragraph"]'
|
116
117
|
);
|
118
|
+
await enterEditMode();
|
117
119
|
await canvas().click(
|
118
120
|
'[data-type="core/post-content"] [data-type="core/paragraph"]'
|
119
121
|
);
|
@@ -5,6 +5,7 @@ import {
|
|
5
5
|
deleteAllTemplates,
|
6
6
|
activateTheme,
|
7
7
|
visitSiteEditor,
|
8
|
+
enterEditMode,
|
8
9
|
toggleGlobalStyles,
|
9
10
|
openGlobalStylesPanel,
|
10
11
|
} from '@wordpress/e2e-test-utils';
|
@@ -26,6 +27,7 @@ describe( 'Global styles sidebar', () => {
|
|
26
27
|
} );
|
27
28
|
beforeEach( async () => {
|
28
29
|
await visitSiteEditor();
|
30
|
+
await enterEditMode();
|
29
31
|
} );
|
30
32
|
describe( 'blocks list', () => {
|
31
33
|
it( 'should filter results properly', async () => {
|
@@ -13,6 +13,7 @@ import {
|
|
13
13
|
clickButton,
|
14
14
|
createReusableBlock,
|
15
15
|
visitSiteEditor,
|
16
|
+
enterEditMode,
|
16
17
|
deleteAllTemplates,
|
17
18
|
} from '@wordpress/e2e-test-utils';
|
18
19
|
|
@@ -265,6 +266,8 @@ describe( 'Multi-entity save flow', () => {
|
|
265
266
|
postType: 'wp_template',
|
266
267
|
} );
|
267
268
|
|
269
|
+
await enterEditMode();
|
270
|
+
|
268
271
|
// Select the header template part via list view.
|
269
272
|
await page.click( '.edit-site-header-edit-mode__list-view-toggle' );
|
270
273
|
const headerTemplatePartListViewButton = await page.waitForXPath(
|
@@ -302,6 +305,8 @@ describe( 'Multi-entity save flow', () => {
|
|
302
305
|
postType: 'wp_template',
|
303
306
|
} );
|
304
307
|
|
308
|
+
await enterEditMode();
|
309
|
+
|
305
310
|
// Insert a paragraph at the bottom.
|
306
311
|
await insertBlock( 'Paragraph' );
|
307
312
|
|
@@ -8,6 +8,7 @@ import {
|
|
8
8
|
selectBlockByClientId,
|
9
9
|
insertBlock,
|
10
10
|
visitSiteEditor,
|
11
|
+
enterEditMode,
|
11
12
|
} from '@wordpress/e2e-test-utils';
|
12
13
|
|
13
14
|
async function toggleSidebar() {
|
@@ -49,6 +50,7 @@ describe( 'Settings sidebar', () => {
|
|
49
50
|
} );
|
50
51
|
beforeEach( async () => {
|
51
52
|
await visitSiteEditor();
|
53
|
+
await enterEditMode();
|
52
54
|
} );
|
53
55
|
|
54
56
|
describe( 'Template tab', () => {
|
@@ -68,6 +70,7 @@ describe( 'Settings sidebar', () => {
|
|
68
70
|
postId: 'emptytheme//singular',
|
69
71
|
postType: 'wp_template',
|
70
72
|
} );
|
73
|
+
await enterEditMode();
|
71
74
|
const templateCardAfterNavigation = await getTemplateCard();
|
72
75
|
|
73
76
|
expect( templateCardBeforeNavigation ).toMatchObject( {
|
@@ -12,6 +12,7 @@ import {
|
|
12
12
|
deleteAllTemplates,
|
13
13
|
activateTheme,
|
14
14
|
visitSiteEditor,
|
15
|
+
enterEditMode,
|
15
16
|
clickOnMoreMenuItem,
|
16
17
|
} from '@wordpress/e2e-test-utils';
|
17
18
|
|
@@ -41,6 +42,7 @@ describe( 'Site Editor Templates Export', () => {
|
|
41
42
|
|
42
43
|
beforeEach( async () => {
|
43
44
|
await visitSiteEditor();
|
45
|
+
await enterEditMode();
|
44
46
|
} );
|
45
47
|
|
46
48
|
it( 'clicking export should download emptytheme.zip file', async () => {
|
@@ -1,309 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import {
|
5
|
-
insertBlock,
|
6
|
-
createNewPost,
|
7
|
-
publishPost,
|
8
|
-
deleteAllTemplates,
|
9
|
-
activateTheme,
|
10
|
-
canvas,
|
11
|
-
openDocumentSettingsSidebar,
|
12
|
-
pressKeyWithModifier,
|
13
|
-
selectBlockByClientId,
|
14
|
-
visitSiteEditor,
|
15
|
-
clickSiteEditorMenuItem,
|
16
|
-
navigateSiteEditorBackToRoot,
|
17
|
-
openSiteEditorNavigationPanel,
|
18
|
-
siteEditorNavigateSequence,
|
19
|
-
} from '@wordpress/e2e-test-utils';
|
20
|
-
|
21
|
-
const clickTemplateItem = async ( menus, itemName ) => {
|
22
|
-
await openSiteEditorNavigationPanel();
|
23
|
-
await navigateSiteEditorBackToRoot();
|
24
|
-
await siteEditorNavigateSequence( menus );
|
25
|
-
await clickSiteEditorMenuItem( itemName );
|
26
|
-
};
|
27
|
-
|
28
|
-
const createTemplatePart = async (
|
29
|
-
templatePartName = 'test-template-part',
|
30
|
-
isNested = false
|
31
|
-
) => {
|
32
|
-
// Create new template part.
|
33
|
-
await insertBlock( 'Template Part' );
|
34
|
-
const [ createNewButton ] = await page.$x(
|
35
|
-
'//button[contains(text(), "New template part")]'
|
36
|
-
);
|
37
|
-
await createNewButton.click();
|
38
|
-
await page.waitForSelector(
|
39
|
-
isNested
|
40
|
-
? '.wp-block-template-part .wp-block-template-part.block-editor-block-list__layout'
|
41
|
-
: '.wp-block-template-part.block-editor-block-list__layout'
|
42
|
-
);
|
43
|
-
await openDocumentSettingsSidebar();
|
44
|
-
|
45
|
-
const advancedPanelXPath = `//div[contains(@class,"interface-interface-skeleton__sidebar")]//button[@class="components-button components-panel__body-toggle"][contains(text(),"Advanced")]`;
|
46
|
-
const advancedPanel = await page.waitForXPath( advancedPanelXPath );
|
47
|
-
await advancedPanel.click();
|
48
|
-
|
49
|
-
const nameInputXPath = `${ advancedPanelXPath }/ancestor::div[contains(@class, "components-panel__body")]//div[contains(@class,"components-base-control__field")]//label[contains(text(), "Title")]/following-sibling::input`;
|
50
|
-
const nameInput = await page.waitForXPath( nameInputXPath );
|
51
|
-
await nameInput.click();
|
52
|
-
|
53
|
-
// Select all of the text in the title field.
|
54
|
-
await pressKeyWithModifier( 'primary', 'a' );
|
55
|
-
|
56
|
-
// Give the reusable block a title.
|
57
|
-
await page.keyboard.type( templatePartName );
|
58
|
-
};
|
59
|
-
|
60
|
-
const editTemplatePart = async ( textToAdd, isNested = false ) => {
|
61
|
-
await page.click(
|
62
|
-
`${
|
63
|
-
isNested
|
64
|
-
? '.wp-block-template-part .wp-block-template-part'
|
65
|
-
: '.wp-block-template-part'
|
66
|
-
} .block-editor-button-block-appender`
|
67
|
-
);
|
68
|
-
await page.click( '.editor-block-list-item-paragraph' );
|
69
|
-
for ( const text of textToAdd ) {
|
70
|
-
await page.keyboard.type( text );
|
71
|
-
await page.keyboard.press( 'Enter' );
|
72
|
-
}
|
73
|
-
};
|
74
|
-
|
75
|
-
const saveAllEntities = async () => {
|
76
|
-
if ( await openEntitySavePanel() ) {
|
77
|
-
await page.click( 'button.editor-entities-saved-states__save-button' );
|
78
|
-
}
|
79
|
-
};
|
80
|
-
|
81
|
-
const openEntitySavePanel = async () => {
|
82
|
-
// Open the entity save panel if it is not already open.
|
83
|
-
try {
|
84
|
-
await page.waitForSelector( '.entities-saved-states__panel', {
|
85
|
-
timeout: 500,
|
86
|
-
} );
|
87
|
-
} catch {
|
88
|
-
try {
|
89
|
-
await page.click(
|
90
|
-
'.edit-site-save-button__button[aria-disabled=false]',
|
91
|
-
{ timeout: 500 }
|
92
|
-
);
|
93
|
-
} catch {
|
94
|
-
try {
|
95
|
-
await page.click(
|
96
|
-
'.editor-post-publish-button__button.has-changes-dot',
|
97
|
-
{ timeout: 500 }
|
98
|
-
);
|
99
|
-
} catch {
|
100
|
-
return false; // Not dirty because the button is disabled.
|
101
|
-
}
|
102
|
-
}
|
103
|
-
await page.waitForSelector( '.entities-saved-states__panel' );
|
104
|
-
}
|
105
|
-
// If we made it this far, the panel is opened.
|
106
|
-
|
107
|
-
return true;
|
108
|
-
};
|
109
|
-
|
110
|
-
const isEntityDirty = async ( name ) => {
|
111
|
-
const isOpen = await openEntitySavePanel();
|
112
|
-
if ( ! isOpen ) {
|
113
|
-
return false;
|
114
|
-
}
|
115
|
-
try {
|
116
|
-
await page.waitForXPath(
|
117
|
-
`//label[@class="components-checkbox-control__label"]//strong[contains(text(),"${ name }")]`,
|
118
|
-
{ timeout: 1000 }
|
119
|
-
);
|
120
|
-
return true;
|
121
|
-
} catch {}
|
122
|
-
return false;
|
123
|
-
};
|
124
|
-
|
125
|
-
const removeErrorMocks = () => {
|
126
|
-
// TODO: Add back console mocks when
|
127
|
-
// https://github.com/WordPress/gutenberg/issues/17355 is fixed.
|
128
|
-
/* eslint-disable no-console */
|
129
|
-
console.warn.mockReset();
|
130
|
-
console.error.mockReset();
|
131
|
-
console.info.mockReset();
|
132
|
-
/* eslint-enable no-console */
|
133
|
-
};
|
134
|
-
|
135
|
-
describe( 'Multi-entity editor states', () => {
|
136
|
-
beforeAll( async () => {
|
137
|
-
await activateTheme( 'emptytheme' );
|
138
|
-
await deleteAllTemplates( 'wp_template' );
|
139
|
-
await deleteAllTemplates( 'wp_template_part' );
|
140
|
-
} );
|
141
|
-
|
142
|
-
afterAll( async () => {
|
143
|
-
await activateTheme( 'twentytwentyone' );
|
144
|
-
} );
|
145
|
-
|
146
|
-
it( 'should not display any dirty entities when loading the site editor', async () => {
|
147
|
-
await visitSiteEditor();
|
148
|
-
expect( await openEntitySavePanel() ).toBe( false );
|
149
|
-
} );
|
150
|
-
|
151
|
-
// Skip reason: This should be rewritten to use other methods to switching to different templates.
|
152
|
-
it.skip( 'should not dirty an entity by switching to it in the template dropdown', async () => {
|
153
|
-
await visitSiteEditor( {
|
154
|
-
postId: 'emptytheme//header',
|
155
|
-
postType: 'wp_template_part',
|
156
|
-
} );
|
157
|
-
await page.waitForFunction( () =>
|
158
|
-
Array.from( window.frames ).find(
|
159
|
-
( { name } ) => name === 'editor-canvas'
|
160
|
-
)
|
161
|
-
);
|
162
|
-
|
163
|
-
// Wait for blocks to load.
|
164
|
-
await canvas().waitForSelector( '.wp-block' );
|
165
|
-
expect( await isEntityDirty( 'header' ) ).toBe( false );
|
166
|
-
expect( await isEntityDirty( 'Index' ) ).toBe( false );
|
167
|
-
|
168
|
-
// Switch back and make sure it is still clean.
|
169
|
-
await clickTemplateItem( 'Templates', 'Index' );
|
170
|
-
await page.waitForFunction( () =>
|
171
|
-
Array.from( window.frames ).find(
|
172
|
-
( { name } ) => name === 'editor-canvas'
|
173
|
-
)
|
174
|
-
);
|
175
|
-
await canvas().waitForSelector( '.wp-block' );
|
176
|
-
expect( await isEntityDirty( 'header' ) ).toBe( false );
|
177
|
-
expect( await isEntityDirty( 'Index' ) ).toBe( false );
|
178
|
-
|
179
|
-
removeErrorMocks();
|
180
|
-
} );
|
181
|
-
|
182
|
-
describe( 'Multi-entity edit', () => {
|
183
|
-
const templatePartName = 'Test Template Part Name Edit';
|
184
|
-
const nestedTPName = 'Test Nested Template Part Name Edit';
|
185
|
-
const templateName = 'Custom Template';
|
186
|
-
|
187
|
-
beforeAll( async () => {
|
188
|
-
await deleteAllTemplates( 'wp_template' );
|
189
|
-
await deleteAllTemplates( 'wp_template_part' );
|
190
|
-
await createNewPost( {
|
191
|
-
postType: 'wp_template',
|
192
|
-
title: templateName,
|
193
|
-
} );
|
194
|
-
await publishPost();
|
195
|
-
await createTemplatePart( templatePartName );
|
196
|
-
await editTemplatePart( [
|
197
|
-
'Default template part test text.',
|
198
|
-
'Second paragraph test.',
|
199
|
-
] );
|
200
|
-
await createTemplatePart( nestedTPName, true );
|
201
|
-
await editTemplatePart(
|
202
|
-
[ 'Nested Template Part Text.', 'Second Nested test.' ],
|
203
|
-
true
|
204
|
-
);
|
205
|
-
await saveAllEntities();
|
206
|
-
await visitSiteEditor();
|
207
|
-
|
208
|
-
// Wait for site editor to load.
|
209
|
-
await canvas().waitForSelector(
|
210
|
-
'.wp-block-template-part.block-editor-block-list__layout'
|
211
|
-
);
|
212
|
-
|
213
|
-
// Our custom template shows up in the "Templates > General" menu; let's use it.
|
214
|
-
await clickTemplateItem(
|
215
|
-
[ 'Templates', 'General templates' ],
|
216
|
-
templateName
|
217
|
-
);
|
218
|
-
await page.waitForXPath(
|
219
|
-
`//h1[contains(@class, "edit-site-document-actions__title") and contains(text(), '${ templateName }')]`
|
220
|
-
);
|
221
|
-
|
222
|
-
removeErrorMocks();
|
223
|
-
} );
|
224
|
-
|
225
|
-
const saveAndWaitResponse = async () => {
|
226
|
-
await Promise.all( [
|
227
|
-
saveAllEntities(),
|
228
|
-
|
229
|
-
// Wait for the save request and the subsequent query to be
|
230
|
-
// fulfilled - both are requests made to /index.php route.
|
231
|
-
// Without that, clicked elements can lose focus sometimes
|
232
|
-
// when the response is received.
|
233
|
-
page.waitForResponse( ( response ) => {
|
234
|
-
return (
|
235
|
-
response.url().includes( 'index.php' ) &&
|
236
|
-
response.request().method() === 'POST'
|
237
|
-
);
|
238
|
-
} ),
|
239
|
-
|
240
|
-
page.waitForResponse( ( response ) => {
|
241
|
-
return (
|
242
|
-
response.url().includes( 'index.php' ) &&
|
243
|
-
response.request().method() === 'GET'
|
244
|
-
);
|
245
|
-
} ),
|
246
|
-
] );
|
247
|
-
removeErrorMocks();
|
248
|
-
};
|
249
|
-
|
250
|
-
it.skip( 'should only dirty the parent entity when editing the parent', async () => {
|
251
|
-
// Clear selection so that the block is not added to the template part.
|
252
|
-
await insertBlock( 'Paragraph' );
|
253
|
-
|
254
|
-
// Add changes to the main parent entity.
|
255
|
-
await page.keyboard.type( 'Test.' );
|
256
|
-
|
257
|
-
expect( await isEntityDirty( templateName ) ).toBe( true );
|
258
|
-
expect( await isEntityDirty( templatePartName ) ).toBe( false );
|
259
|
-
expect( await isEntityDirty( nestedTPName ) ).toBe( false );
|
260
|
-
await saveAndWaitResponse();
|
261
|
-
} );
|
262
|
-
|
263
|
-
it.skip( 'should only dirty the child when editing the child', async () => {
|
264
|
-
// Select parent TP to unlock selecting content.
|
265
|
-
await canvas().click( '.wp-block-template-part' );
|
266
|
-
await canvas().click(
|
267
|
-
'.wp-block-template-part .wp-block[data-type="core/paragraph"]'
|
268
|
-
);
|
269
|
-
await page.keyboard.type( 'Some more test words!' );
|
270
|
-
|
271
|
-
expect( await isEntityDirty( templateName ) ).toBe( false );
|
272
|
-
expect( await isEntityDirty( templatePartName ) ).toBe( true );
|
273
|
-
expect( await isEntityDirty( nestedTPName ) ).toBe( false );
|
274
|
-
await saveAndWaitResponse();
|
275
|
-
} );
|
276
|
-
|
277
|
-
it.skip( 'should only dirty the nested entity when editing the nested entity', async () => {
|
278
|
-
// Select parent TP to unlock selecting child.
|
279
|
-
await canvas().click( '.wp-block-template-part' );
|
280
|
-
// Select child TP to unlock selecting content.
|
281
|
-
await canvas().click(
|
282
|
-
'.wp-block-template-part .wp-block-template-part'
|
283
|
-
);
|
284
|
-
await canvas().click(
|
285
|
-
'.wp-block-template-part .wp-block-template-part .wp-block[data-type="core/paragraph"]'
|
286
|
-
);
|
287
|
-
await page.keyboard.type( 'Nested test words!' );
|
288
|
-
|
289
|
-
expect( await isEntityDirty( templateName ) ).toBe( false );
|
290
|
-
expect( await isEntityDirty( templatePartName ) ).toBe( false );
|
291
|
-
expect( await isEntityDirty( nestedTPName ) ).toBe( true );
|
292
|
-
await saveAndWaitResponse();
|
293
|
-
} );
|
294
|
-
|
295
|
-
it.skip( 'should not allow selecting template part content without parent selected', async () => {
|
296
|
-
// Unselect blocks.
|
297
|
-
await selectBlockByClientId();
|
298
|
-
// Try to select a child block of a template part.
|
299
|
-
await canvas().click(
|
300
|
-
'.wp-block-template-part .wp-block-template-part .wp-block[data-type="core/paragraph"]'
|
301
|
-
);
|
302
|
-
|
303
|
-
const selectedBlock = await page.evaluate( () => {
|
304
|
-
return wp.data.select( 'core/block-editor' ).getSelectedBlock();
|
305
|
-
} );
|
306
|
-
expect( selectedBlock?.name ).toBe( 'core/template-part' );
|
307
|
-
} );
|
308
|
-
} );
|
309
|
-
} );
|