@wordpress/e2e-tests 3.0.2 → 3.0.6
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/README.md +31 -19
- package/config/is-gutenberg-plugin.js +6 -0
- package/jest.config.js +1 -1
- package/jest.performance.config.js +1 -1
- package/mu-plugins/enable-templates-ui.php +24 -0
- package/package.json +7 -7
- package/plugins/plugins-api/error-boundary.js +11 -0
- package/plugins/plugins-error-boundary.php +27 -0
- package/specs/editor/blocks/__snapshots__/image.test.js.snap +6 -6
- package/specs/editor/blocks/__snapshots__/navigation.test.js.snap +0 -2
- package/specs/editor/blocks/cover.test.js +7 -3
- package/specs/editor/blocks/gallery.test.js +6 -1
- package/specs/editor/blocks/heading.test.js +1 -11
- package/specs/editor/blocks/navigation.test.js +0 -50
- package/specs/editor/plugins/__snapshots__/plugins-api.test.js.snap +2 -2
- package/specs/editor/plugins/block-directory-add.test.js +15 -1
- package/specs/editor/plugins/block-variations.test.js +2 -2
- package/specs/editor/plugins/plugins-api.test.js +30 -0
- package/specs/editor/plugins/templates.test.js +1 -7
- package/specs/editor/various/__snapshots__/inserting-blocks.test.js.snap +1 -1
- package/specs/editor/various/__snapshots__/keep-styles-on-block-transforms.test.js.snap +35 -0
- package/specs/editor/various/fullscreen-mode.test.js +1 -1
- package/specs/editor/various/keep-styles-on-block-transforms.test.js +81 -0
- package/specs/editor/various/post-visibility.test.js +54 -0
- package/specs/editor/various/style-variation.test.js +9 -5
- package/specs/performance/site-editor.test.js +2 -3
- package/specs/site-editor/document-settings.test.js +8 -10
- package/specs/site-editor/multi-entity-editing.test.js +12 -14
- package/specs/site-editor/multi-entity-saving.test.js +3 -9
- package/specs/site-editor/settings-sidebar.test.js +3 -8
- package/specs/site-editor/site-editor-export.test.js +8 -9
- package/specs/site-editor/site-editor-inserter.test.js +6 -8
- package/specs/site-editor/style-variations.test.js +211 -0
- package/specs/site-editor/template-part.test.js +5 -10
- package/specs/site-editor/template-revert.test.js +18 -28
- package/themes/style-variations/block-templates/index.html +11 -0
- package/themes/style-variations/index.php +0 -0
- package/themes/style-variations/style.css +15 -0
- package/themes/style-variations/styles/pink.json +33 -0
- package/themes/style-variations/styles/yellow.json +12 -0
- package/themes/style-variations/theme.json +8 -0
- package/config/gutenberg-phase.js +0 -9
- package/specs/editor/various/__snapshots__/style-variation.test.js.snap +0 -7
- package/specs/site-editor/utils.js +0 -153
@@ -9,13 +9,9 @@ import {
|
|
9
9
|
selectBlockByClientId,
|
10
10
|
clickBlockToolbarButton,
|
11
11
|
canvas,
|
12
|
+
visitSiteEditor,
|
12
13
|
} from '@wordpress/e2e-test-utils';
|
13
14
|
|
14
|
-
/**
|
15
|
-
* Internal dependencies
|
16
|
-
*/
|
17
|
-
import { siteEditor } from './utils';
|
18
|
-
|
19
15
|
const templatePartNameInput =
|
20
16
|
'.edit-site-create-template-part-modal .components-text-control__input';
|
21
17
|
|
@@ -33,13 +29,12 @@ describe( 'Template Part', () => {
|
|
33
29
|
|
34
30
|
describe( 'Template part block', () => {
|
35
31
|
beforeEach( async () => {
|
36
|
-
await
|
37
|
-
await siteEditor.disableWelcomeGuide();
|
32
|
+
await visitSiteEditor();
|
38
33
|
} );
|
39
34
|
|
40
35
|
async function navigateToHeader() {
|
41
36
|
// Switch to editing the header template part.
|
42
|
-
await
|
37
|
+
await visitSiteEditor( {
|
43
38
|
postId: 'emptytheme//header',
|
44
39
|
postType: 'wp_template_part',
|
45
40
|
} );
|
@@ -60,7 +55,7 @@ describe( 'Template Part', () => {
|
|
60
55
|
);
|
61
56
|
|
62
57
|
// Switch back to the Index template.
|
63
|
-
await
|
58
|
+
await visitSiteEditor( {
|
64
59
|
postId: 'emptytheme//index',
|
65
60
|
postType: 'wp_template',
|
66
61
|
} );
|
@@ -314,7 +309,7 @@ describe( 'Template Part', () => {
|
|
314
309
|
await page.click( entitiesSaveSelector );
|
315
310
|
|
316
311
|
// Reload the page so as the new template part is available in the existing template parts.
|
317
|
-
await
|
312
|
+
await visitSiteEditor();
|
318
313
|
siteEditorCanvas = canvas();
|
319
314
|
await awaitHeaderLoad();
|
320
315
|
// Try to insert the template part we created.
|
@@ -8,20 +8,11 @@ import {
|
|
8
8
|
switchUserToAdmin,
|
9
9
|
switchUserToTest,
|
10
10
|
visitAdminPage,
|
11
|
+
visitSiteEditor,
|
12
|
+
getCurrentSiteEditorContent,
|
11
13
|
} from '@wordpress/e2e-test-utils';
|
12
14
|
import { addQueryArgs } from '@wordpress/url';
|
13
15
|
|
14
|
-
/**
|
15
|
-
* Internal dependencies
|
16
|
-
*/
|
17
|
-
import { siteEditor } from './utils';
|
18
|
-
|
19
|
-
const {
|
20
|
-
visit: visitSiteEditor,
|
21
|
-
getEditedPostContent,
|
22
|
-
disableWelcomeGuide,
|
23
|
-
} = siteEditor;
|
24
|
-
|
25
16
|
const assertSaveButtonIsDisabled = async () =>
|
26
17
|
page.waitForSelector(
|
27
18
|
'.edit-site-save-button__button[aria-disabled="true"]'
|
@@ -105,7 +96,6 @@ describe( 'Template Revert', () => {
|
|
105
96
|
beforeEach( async () => {
|
106
97
|
await trashAllPosts( 'wp_template' );
|
107
98
|
await visitSiteEditor();
|
108
|
-
await disableWelcomeGuide();
|
109
99
|
} );
|
110
100
|
|
111
101
|
it( 'should delete the template after saving the reverted template', async () => {
|
@@ -118,19 +108,19 @@ describe( 'Template Revert', () => {
|
|
118
108
|
} );
|
119
109
|
|
120
110
|
it( 'should show the original content after revert', async () => {
|
121
|
-
const contentBefore = await
|
111
|
+
const contentBefore = await getCurrentSiteEditorContent();
|
122
112
|
|
123
113
|
await addDummyText();
|
124
114
|
await save();
|
125
115
|
await revertTemplate();
|
126
116
|
await save();
|
127
117
|
|
128
|
-
const contentAfter = await
|
118
|
+
const contentAfter = await getCurrentSiteEditorContent();
|
129
119
|
expect( contentBefore ).toBe( contentAfter );
|
130
120
|
} );
|
131
121
|
|
132
122
|
it( 'should show the original content after revert and page reload', async () => {
|
133
|
-
const contentBefore = await
|
123
|
+
const contentBefore = await getCurrentSiteEditorContent();
|
134
124
|
|
135
125
|
await addDummyText();
|
136
126
|
await save();
|
@@ -138,38 +128,38 @@ describe( 'Template Revert', () => {
|
|
138
128
|
await save();
|
139
129
|
await visitSiteEditor();
|
140
130
|
|
141
|
-
const contentAfter = await
|
131
|
+
const contentAfter = await getCurrentSiteEditorContent();
|
142
132
|
expect( contentBefore ).toBe( contentAfter );
|
143
133
|
} );
|
144
134
|
|
145
135
|
it( 'should show the edited content after revert and clicking undo in the header toolbar', async () => {
|
146
136
|
await addDummyText();
|
147
137
|
await save();
|
148
|
-
const contentBefore = await
|
138
|
+
const contentBefore = await getCurrentSiteEditorContent();
|
149
139
|
|
150
140
|
await revertTemplate();
|
151
141
|
await save();
|
152
142
|
await undoRevertInHeaderToolbar();
|
153
143
|
|
154
|
-
const contentAfter = await
|
144
|
+
const contentAfter = await getCurrentSiteEditorContent();
|
155
145
|
expect( contentBefore ).toBe( contentAfter );
|
156
146
|
} );
|
157
147
|
|
158
148
|
it( 'should show the edited content after revert and clicking undo in the notice', async () => {
|
159
149
|
await addDummyText();
|
160
150
|
await save();
|
161
|
-
const contentBefore = await
|
151
|
+
const contentBefore = await getCurrentSiteEditorContent();
|
162
152
|
|
163
153
|
await revertTemplate();
|
164
154
|
await save();
|
165
155
|
await undoRevertInNotice();
|
166
156
|
|
167
|
-
const contentAfter = await
|
157
|
+
const contentAfter = await getCurrentSiteEditorContent();
|
168
158
|
expect( contentBefore ).toBe( contentAfter );
|
169
159
|
} );
|
170
160
|
|
171
161
|
it( 'should show the original content after revert, clicking undo then redo in the header toolbar', async () => {
|
172
|
-
const contentBefore = await
|
162
|
+
const contentBefore = await getCurrentSiteEditorContent();
|
173
163
|
|
174
164
|
await addDummyText();
|
175
165
|
await save();
|
@@ -178,12 +168,12 @@ describe( 'Template Revert', () => {
|
|
178
168
|
await undoRevertInHeaderToolbar();
|
179
169
|
await clickRedoInHeaderToolbar();
|
180
170
|
|
181
|
-
const contentAfter = await
|
171
|
+
const contentAfter = await getCurrentSiteEditorContent();
|
182
172
|
expect( contentBefore ).toBe( contentAfter );
|
183
173
|
} );
|
184
174
|
|
185
175
|
it( 'should show the original content after revert, clicking undo in the notice then undo in the header toolbar', async () => {
|
186
|
-
const contentBefore = await
|
176
|
+
const contentBefore = await getCurrentSiteEditorContent();
|
187
177
|
|
188
178
|
await addDummyText();
|
189
179
|
await save();
|
@@ -192,14 +182,14 @@ describe( 'Template Revert', () => {
|
|
192
182
|
await undoRevertInNotice();
|
193
183
|
await undoRevertInHeaderToolbar();
|
194
184
|
|
195
|
-
const contentAfter = await
|
185
|
+
const contentAfter = await getCurrentSiteEditorContent();
|
196
186
|
expect( contentBefore ).toBe( contentAfter );
|
197
187
|
} );
|
198
188
|
|
199
189
|
it( 'should show the edited content after revert, clicking undo in the header toolbar, save and reload', async () => {
|
200
190
|
await addDummyText();
|
201
191
|
await save();
|
202
|
-
const contentBefore = await
|
192
|
+
const contentBefore = await getCurrentSiteEditorContent();
|
203
193
|
|
204
194
|
await revertTemplate();
|
205
195
|
await save();
|
@@ -208,14 +198,14 @@ describe( 'Template Revert', () => {
|
|
208
198
|
await assertSaveButtonIsDisabled();
|
209
199
|
await visitSiteEditor();
|
210
200
|
|
211
|
-
const contentAfter = await
|
201
|
+
const contentAfter = await getCurrentSiteEditorContent();
|
212
202
|
expect( contentBefore ).toBe( contentAfter );
|
213
203
|
} );
|
214
204
|
|
215
205
|
it( 'should show the edited content after revert, clicking undo in the notice and reload', async () => {
|
216
206
|
await addDummyText();
|
217
207
|
await save();
|
218
|
-
const contentBefore = await
|
208
|
+
const contentBefore = await getCurrentSiteEditorContent();
|
219
209
|
|
220
210
|
await revertTemplate();
|
221
211
|
await save();
|
@@ -223,7 +213,7 @@ describe( 'Template Revert', () => {
|
|
223
213
|
await save();
|
224
214
|
await visitSiteEditor();
|
225
215
|
|
226
|
-
const contentAfter = await
|
216
|
+
const contentAfter = await getCurrentSiteEditorContent();
|
227
217
|
expect( contentBefore ).toBe( contentAfter );
|
228
218
|
} );
|
229
219
|
} );
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<!-- wp:query {"queryId":1,"query":{"offset":0,"postType":"post","order":"desc","orderBy":"date","author":"","search":"","sticky":""}} -->
|
2
|
+
<div class="wp-block-query">
|
3
|
+
<!-- wp:post-template -->
|
4
|
+
<!-- wp:post-title {"isLink":true} /-->
|
5
|
+
<!-- wp:post-excerpt /-->
|
6
|
+
<!-- /wp:post-template -->
|
7
|
+
</div>
|
8
|
+
<!-- /wp:query -->
|
9
|
+
<!-- wp:paragraph -->
|
10
|
+
<p>My awesome paragraph</p>
|
11
|
+
<!-- /wp:paragraph -->
|
File without changes
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
Theme Name: Style variations
|
3
|
+
Theme URI: https://github.com/wordpress/theme-experiments/
|
4
|
+
Author: the WordPress team
|
5
|
+
Description: Style variations test theme.
|
6
|
+
Requires at least: 5.3
|
7
|
+
Tested up to: 5.5
|
8
|
+
Requires PHP: 5.6
|
9
|
+
Version: 1.0
|
10
|
+
License: GNU General Public License v2 or later
|
11
|
+
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12
|
+
Text Domain: style-variations
|
13
|
+
Style variations WordPress Theme, (C) 2021 WordPress.org
|
14
|
+
Style variations is distributed under the terms of the GNU GPL.
|
15
|
+
*/
|
@@ -0,0 +1,33 @@
|
|
1
|
+
{
|
2
|
+
"version": 2,
|
3
|
+
"settings": {
|
4
|
+
"color": {
|
5
|
+
"palette": [
|
6
|
+
{
|
7
|
+
"slug": "foreground",
|
8
|
+
"color": "#4a074a",
|
9
|
+
"name": "Foreground"
|
10
|
+
},
|
11
|
+
{
|
12
|
+
"slug": "background",
|
13
|
+
"color": "#ca69d3",
|
14
|
+
"name": "Background"
|
15
|
+
},
|
16
|
+
{
|
17
|
+
"slug": "awesome-pink",
|
18
|
+
"color": "#cc00ffc4",
|
19
|
+
"name": "Awesome pink"
|
20
|
+
}
|
21
|
+
]
|
22
|
+
}
|
23
|
+
},
|
24
|
+
"styles": {
|
25
|
+
"color": {
|
26
|
+
"background": "var(--wp--preset--color--background)",
|
27
|
+
"text": "var(--wp--preset--color--foreground)"
|
28
|
+
},
|
29
|
+
"typography": {
|
30
|
+
"fontSize": "var(--wp--preset--font-size--medium)"
|
31
|
+
}
|
32
|
+
}
|
33
|
+
}
|
@@ -1,9 +0,0 @@
|
|
1
|
-
global.process.env = {
|
2
|
-
...global.process.env,
|
3
|
-
// Inject the `GUTENBERG_PHASE` global, used for feature flagging.
|
4
|
-
// eslint-disable-next-line @wordpress/gutenberg-phase
|
5
|
-
GUTENBERG_PHASE: parseInt(
|
6
|
-
process.env.npm_package_config_GUTENBERG_PHASE,
|
7
|
-
10
|
8
|
-
),
|
9
|
-
};
|
@@ -1,7 +0,0 @@
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
-
|
3
|
-
exports[`adding blocks Should switch to the large style of the quote block 1`] = `
|
4
|
-
"<!-- wp:quote {\\"className\\":\\"is-style-large\\"} -->
|
5
|
-
<blockquote class=\\"wp-block-quote is-style-large\\"><p>Quote content</p></blockquote>
|
6
|
-
<!-- /wp:quote -->"
|
7
|
-
`;
|
@@ -1,153 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import { addQueryArgs } from '@wordpress/url';
|
5
|
-
import { visitAdminPage } from '@wordpress/e2e-test-utils';
|
6
|
-
|
7
|
-
export const navigationPanel = {
|
8
|
-
async open() {
|
9
|
-
const isOpen = !! ( await page.$(
|
10
|
-
'.edit-site-navigation-toggle.is-open'
|
11
|
-
) );
|
12
|
-
|
13
|
-
if ( ! isOpen ) {
|
14
|
-
await page.click( '.edit-site-navigation-toggle__button' );
|
15
|
-
await page.waitForSelector( '.edit-site-navigation-panel' );
|
16
|
-
}
|
17
|
-
},
|
18
|
-
|
19
|
-
async close() {
|
20
|
-
const isOpen = !! ( await page.$(
|
21
|
-
'.edit-site-navigation-toggle.is-open'
|
22
|
-
) );
|
23
|
-
|
24
|
-
if ( isOpen ) {
|
25
|
-
await page.click( '.edit-site-navigation-toggle__button' );
|
26
|
-
}
|
27
|
-
},
|
28
|
-
|
29
|
-
async isRoot() {
|
30
|
-
const isBackToDashboardButtonVisible = !! ( await page.$(
|
31
|
-
'.edit-site-navigation-panel .edit-site-navigation-panel__back-to-dashboard'
|
32
|
-
) );
|
33
|
-
|
34
|
-
return isBackToDashboardButtonVisible;
|
35
|
-
},
|
36
|
-
|
37
|
-
async back() {
|
38
|
-
await page.click( '.components-navigation__back-button' );
|
39
|
-
},
|
40
|
-
|
41
|
-
async navigate( menus ) {
|
42
|
-
if ( ! Array.isArray( menus ) ) {
|
43
|
-
menus = [ menus ];
|
44
|
-
}
|
45
|
-
|
46
|
-
for ( const menu of menus ) {
|
47
|
-
( await this.getItemByText( menu ) ).click();
|
48
|
-
}
|
49
|
-
},
|
50
|
-
|
51
|
-
async backToRoot() {
|
52
|
-
while ( ! ( await this.isRoot() ) ) {
|
53
|
-
await this.back();
|
54
|
-
}
|
55
|
-
},
|
56
|
-
|
57
|
-
async getItemByText( text ) {
|
58
|
-
const item = await page.waitForXPath(
|
59
|
-
`//div[contains(@class, "edit-site-navigation-panel")]//button[.//*[text()="${ text }"]]`,
|
60
|
-
{ visible: true }
|
61
|
-
);
|
62
|
-
return item;
|
63
|
-
},
|
64
|
-
|
65
|
-
async clickItemByText( text ) {
|
66
|
-
const item = await this.getItemByText( text );
|
67
|
-
await item.click();
|
68
|
-
},
|
69
|
-
};
|
70
|
-
|
71
|
-
export const siteEditor = {
|
72
|
-
async visit( query ) {
|
73
|
-
query = addQueryArgs( '', {
|
74
|
-
page: 'gutenberg-edit-site',
|
75
|
-
...query,
|
76
|
-
} ).slice( 1 );
|
77
|
-
await visitAdminPage( 'themes.php', query );
|
78
|
-
await page.waitForSelector( '.edit-site-visual-editor iframe' );
|
79
|
-
},
|
80
|
-
|
81
|
-
async toggleMoreMenu() {
|
82
|
-
// eslint-disable-next-line jest/no-standalone-expect
|
83
|
-
await expect( page ).toClick(
|
84
|
-
'.edit-site-more-menu [aria-label="More tools & options"]'
|
85
|
-
);
|
86
|
-
},
|
87
|
-
|
88
|
-
async clickOnMoreMenuItem( buttonLabel ) {
|
89
|
-
await this.toggleMoreMenu();
|
90
|
-
const moreMenuContainerSelector =
|
91
|
-
'//*[contains(concat(" ", @class, " "), " edit-site-more-menu__content ")]';
|
92
|
-
const elementToClick = (
|
93
|
-
await page.$x(
|
94
|
-
`${ moreMenuContainerSelector }//span[contains(concat(" ", @class, " "), " components-menu-item__item ")][contains(text(), "${ buttonLabel }")]`
|
95
|
-
)
|
96
|
-
)[ 0 ];
|
97
|
-
|
98
|
-
await elementToClick.click();
|
99
|
-
},
|
100
|
-
|
101
|
-
async getEditedPostContent() {
|
102
|
-
return page.evaluate( async () => {
|
103
|
-
const postId = window.wp.data
|
104
|
-
.select( 'core/edit-site' )
|
105
|
-
.getEditedPostId();
|
106
|
-
const postType = window.wp.data
|
107
|
-
.select( 'core/edit-site' )
|
108
|
-
.getEditedPostType();
|
109
|
-
const record = window.wp.data
|
110
|
-
.select( 'core' )
|
111
|
-
.getEditedEntityRecord( 'postType', postType, postId );
|
112
|
-
if ( record ) {
|
113
|
-
if ( typeof record.content === 'function' ) {
|
114
|
-
return record.content( record );
|
115
|
-
} else if ( record.blocks ) {
|
116
|
-
return window.wp.blocks.__unstableSerializeAndClean(
|
117
|
-
record.blocks
|
118
|
-
);
|
119
|
-
} else if ( record.content ) {
|
120
|
-
return record.content;
|
121
|
-
}
|
122
|
-
}
|
123
|
-
return '';
|
124
|
-
} );
|
125
|
-
},
|
126
|
-
|
127
|
-
async disableWelcomeGuide() {
|
128
|
-
const isWelcomeGuideActive = await page.evaluate( () =>
|
129
|
-
wp.data.select( 'core/edit-site' ).isFeatureActive( 'welcomeGuide' )
|
130
|
-
);
|
131
|
-
const isWelcomeGuideStyesActive = await page.evaluate( () =>
|
132
|
-
wp.data
|
133
|
-
.select( 'core/edit-site' )
|
134
|
-
.isFeatureActive( 'welcomeGuideStyles' )
|
135
|
-
);
|
136
|
-
|
137
|
-
if ( isWelcomeGuideActive ) {
|
138
|
-
await page.evaluate( () =>
|
139
|
-
wp.data
|
140
|
-
.dispatch( 'core/edit-site' )
|
141
|
-
.toggleFeature( 'welcomeGuide' )
|
142
|
-
);
|
143
|
-
}
|
144
|
-
|
145
|
-
if ( isWelcomeGuideStyesActive ) {
|
146
|
-
await page.evaluate( () =>
|
147
|
-
wp.data
|
148
|
-
.dispatch( 'core/edit-site' )
|
149
|
-
.toggleFeature( 'welcomeGuideStyles' )
|
150
|
-
);
|
151
|
-
}
|
152
|
-
},
|
153
|
-
};
|