@wordpress/e2e-tests 3.0.7 → 3.0.10-next.a55ed9455a.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/config/setup-performance-test.js +1 -1
- package/config/setup-test-framework.js +1 -1
- package/package.json +7 -7
- package/specs/editor/blocks/__snapshots__/heading.test.js.snap +8 -8
- package/specs/editor/blocks/__snapshots__/navigation.test.js.snap +16 -16
- package/specs/editor/blocks/__snapshots__/quote.test.js.snap +10 -10
- package/specs/editor/blocks/classic.test.js +2 -2
- package/specs/editor/blocks/cover.test.js +17 -17
- package/specs/editor/blocks/image.test.js +4 -3
- package/specs/editor/blocks/list.test.js +1 -1
- package/specs/editor/blocks/navigation.test.js +392 -65
- package/specs/editor/blocks/table.test.js +1 -1
- package/specs/editor/plugins/align-hook.test.js +10 -10
- package/specs/editor/plugins/block-context.test.js +1 -1
- package/specs/editor/plugins/block-directory-add.test.js +14 -14
- package/specs/editor/plugins/custom-post-types.test.js +1 -1
- package/specs/editor/plugins/custom-taxonomies.test.js +3 -3
- package/specs/editor/plugins/meta-attribute-block.test.js +1 -1
- package/specs/editor/plugins/meta-boxes.test.js +3 -3
- package/specs/editor/plugins/templates.test.js +1 -1
- package/specs/editor/plugins/wp-editor-meta-box.test.js +1 -1
- 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/autosave.test.js +19 -19
- package/specs/editor/various/block-deletion.test.js +5 -5
- package/specs/editor/various/block-grouping.test.js +29 -12
- package/specs/editor/various/block-hierarchy-navigation.test.js +5 -5
- package/specs/editor/various/change-detection.test.js +3 -3
- package/specs/editor/various/compatibility-classic-editor.test.js +1 -1
- package/specs/editor/various/copy-cut-paste-whole-blocks.test.js +7 -7
- package/specs/editor/various/datepicker.test.js +1 -1
- package/specs/editor/various/duplicating-blocks.test.js +3 -3
- package/specs/editor/various/editor-modes.test.js +5 -5
- package/specs/editor/various/inserting-blocks.test.js +6 -6
- package/specs/editor/various/invalid-block.test.js +4 -4
- package/specs/editor/various/is-typing.test.js +8 -8
- package/specs/editor/various/keyboard-navigable-blocks.test.js +2 -2
- package/specs/editor/various/links.test.js +90 -90
- package/specs/editor/various/list-view.test.js +142 -1
- package/specs/editor/various/manage-reusable-blocks.test.js +5 -5
- package/specs/editor/various/multi-block-selection.test.js +86 -2
- package/specs/editor/various/navigable-toolbar.test.js +1 -1
- package/specs/editor/various/new-post-default-content.test.js +2 -2
- package/specs/editor/various/new-post.test.js +1 -1
- package/specs/editor/various/nux.test.js +11 -11
- package/specs/editor/various/popovers.test.js +3 -3
- package/specs/editor/various/post-editor-template-mode.test.js +189 -11
- package/specs/editor/various/post-visibility.test.js +1 -1
- package/specs/editor/various/preferences.test.js +1 -1
- package/specs/editor/various/preview.test.js +8 -4
- package/specs/editor/various/publish-button.test.js +2 -2
- package/specs/editor/various/publishing.test.js +50 -1
- package/specs/editor/various/reusable-blocks.test.js +31 -31
- package/specs/editor/various/rich-text.test.js +1 -1
- package/specs/editor/various/splitting-merging.test.js +6 -6
- package/specs/editor/various/style-variation.test.js +2 -2
- package/specs/editor/various/switch-to-draft.test.js +256 -0
- package/specs/editor/various/taxonomies.test.js +1 -1
- package/specs/editor/various/toolbar-roving-tabindex.test.js +1 -1
- package/specs/editor/various/writing-flow.test.js +85 -20
- package/specs/experiments/navigation-editor.test.js +168 -3
- package/specs/performance/post-editor.test.js +7 -7
- package/specs/performance/site-editor.test.js +6 -7
- package/specs/site-editor/document-settings.test.js +8 -8
- package/specs/site-editor/multi-entity-editing.test.js +6 -6
- package/specs/site-editor/multi-entity-saving.test.js +5 -4
- package/specs/site-editor/settings-sidebar.test.js +5 -5
- package/specs/site-editor/site-editor-export.test.js +3 -3
- package/specs/site-editor/site-editor-inserter.test.js +3 -3
- package/specs/site-editor/template-part.test.js +27 -26
- package/specs/site-editor/template-revert.test.js +12 -22
- package/specs/widgets/customizing-widgets.test.js +14 -9
- package/specs/widgets/editing-widgets.test.js +8 -7
@@ -9,9 +9,58 @@ import {
|
|
9
9
|
disablePrePublishChecks,
|
10
10
|
arePrePublishChecksEnabled,
|
11
11
|
setBrowserViewport,
|
12
|
+
openPublishPanel,
|
13
|
+
pressKeyWithModifier,
|
12
14
|
} from '@wordpress/e2e-test-utils';
|
13
15
|
|
14
16
|
describe( 'Publishing', () => {
|
17
|
+
describe.each( [ 'post', 'page' ] )(
|
18
|
+
'%s locking prevent saving',
|
19
|
+
( postType ) => {
|
20
|
+
beforeEach( async () => {
|
21
|
+
await createNewPost( postType );
|
22
|
+
} );
|
23
|
+
|
24
|
+
it( `disables the publish button when a ${ postType } is locked`, async () => {
|
25
|
+
await page.type(
|
26
|
+
'.editor-post-title__input',
|
27
|
+
'E2E Test Post lock check publish button'
|
28
|
+
);
|
29
|
+
await page.evaluate( () =>
|
30
|
+
wp.data
|
31
|
+
.dispatch( 'core/editor' )
|
32
|
+
.lockPostSaving( 'futurelock' )
|
33
|
+
);
|
34
|
+
|
35
|
+
await openPublishPanel();
|
36
|
+
|
37
|
+
expect(
|
38
|
+
await page.$(
|
39
|
+
'.editor-post-publish-button[aria-disabled="true"]'
|
40
|
+
)
|
41
|
+
).not.toBeNull();
|
42
|
+
} );
|
43
|
+
|
44
|
+
it( `disables the save shortcut when a ${ postType } is locked`, async () => {
|
45
|
+
await page.type(
|
46
|
+
'.editor-post-title__input',
|
47
|
+
'E2E Test Post check save shortcut'
|
48
|
+
);
|
49
|
+
await page.evaluate( () =>
|
50
|
+
wp.data
|
51
|
+
.dispatch( 'core/editor' )
|
52
|
+
.lockPostSaving( 'futurelock' )
|
53
|
+
);
|
54
|
+
await pressKeyWithModifier( 'primary', 'S' );
|
55
|
+
|
56
|
+
expect( await page.$( '.editor-post-saved-state' ) ).toBeNull();
|
57
|
+
expect(
|
58
|
+
await page.$( '.editor-post-save-draft' )
|
59
|
+
).not.toBeNull();
|
60
|
+
} );
|
61
|
+
}
|
62
|
+
);
|
63
|
+
|
15
64
|
describe.each( [ 'post', 'page' ] )( 'a %s', ( postType ) => {
|
16
65
|
let werePrePublishChecksEnabled;
|
17
66
|
|
@@ -69,7 +118,7 @@ describe( 'Publishing', () => {
|
|
69
118
|
it( `should publish the ${ postType } without opening the post-publish sidebar.`, async () => {
|
70
119
|
await page.type( '.editor-post-title__input', 'E2E Test Post' );
|
71
120
|
|
72
|
-
// The "Publish" button should be shown instead of the "Publish..." toggle
|
121
|
+
// The "Publish" button should be shown instead of the "Publish..." toggle.
|
73
122
|
expect(
|
74
123
|
await page.$( '.editor-post-publish-panel__toggle' )
|
75
124
|
).toBeNull();
|
@@ -26,7 +26,7 @@ const reusableBlockInspectorNameInputSelector =
|
|
26
26
|
const saveAll = async () => {
|
27
27
|
const publishButtonSelector =
|
28
28
|
'.editor-post-publish-button__button.has-changes-dot';
|
29
|
-
// Wait for the Publish button to become enabled in case the editor is autosaving ATM
|
29
|
+
// Wait for the Publish button to become enabled in case the editor is autosaving ATM:.
|
30
30
|
const publishButton = await page.waitForSelector(
|
31
31
|
publishButtonSelector + '[aria-disabled="false"]'
|
32
32
|
);
|
@@ -41,7 +41,7 @@ const saveAll = async () => {
|
|
41
41
|
const saveAllButDontPublish = async () => {
|
42
42
|
await saveAll();
|
43
43
|
|
44
|
-
//
|
44
|
+
// No need to publish the post.
|
45
45
|
const cancelPublish = await page.waitForSelector(
|
46
46
|
'.editor-post-publish-panel__header-cancel-button button'
|
47
47
|
);
|
@@ -49,7 +49,7 @@ const saveAllButDontPublish = async () => {
|
|
49
49
|
};
|
50
50
|
|
51
51
|
const clearAllBlocks = async () => {
|
52
|
-
// Remove all blocks from the post so that we're working with a clean slate
|
52
|
+
// Remove all blocks from the post so that we're working with a clean slate.
|
53
53
|
await page.evaluate( () => {
|
54
54
|
const blocks = wp.data.select( 'core/block-editor' ).getBlocks();
|
55
55
|
const clientIds = blocks.map( ( block ) => block.clientId );
|
@@ -70,10 +70,10 @@ describe( 'Reusable blocks', () => {
|
|
70
70
|
await createReusableBlock( 'Hello there!', 'Greeting block' );
|
71
71
|
await clearAllBlocks();
|
72
72
|
|
73
|
-
// Insert the reusable block we created above
|
73
|
+
// Insert the reusable block we created above.
|
74
74
|
await insertReusableBlock( 'Greeting block' );
|
75
75
|
|
76
|
-
// Change the block's title
|
76
|
+
// Change the block's title.
|
77
77
|
await openDocumentSettingsSidebar();
|
78
78
|
const nameInput = await page.waitForSelector(
|
79
79
|
reusableBlockInspectorNameInputSelector
|
@@ -82,20 +82,20 @@ describe( 'Reusable blocks', () => {
|
|
82
82
|
await pressKeyWithModifier( 'primary', 'a' );
|
83
83
|
await page.keyboard.type( 'Surprised greeting block' );
|
84
84
|
|
85
|
-
// Quickly focus the paragraph block
|
85
|
+
// Quickly focus the paragraph block.
|
86
86
|
await page.click(
|
87
87
|
'.block-editor-block-list__block[data-type="core/block"] p'
|
88
88
|
);
|
89
|
-
await page.keyboard.press( 'Escape' ); // Enter navigation mode
|
90
|
-
await page.keyboard.press( 'Enter' ); // Enter edit mode
|
89
|
+
await page.keyboard.press( 'Escape' ); // Enter navigation mode.
|
90
|
+
await page.keyboard.press( 'Enter' ); // Enter edit mode.
|
91
91
|
|
92
|
-
// Change the block's content
|
92
|
+
// Change the block's content.
|
93
93
|
await page.keyboard.type( 'Oh! ' );
|
94
94
|
|
95
|
-
// Save the reusable block
|
95
|
+
// Save the reusable block.
|
96
96
|
await saveAllButDontPublish();
|
97
97
|
|
98
|
-
// Check that its content is up to date
|
98
|
+
// Check that its content is up to date.
|
99
99
|
const text = await page.$eval(
|
100
100
|
'.block-editor-block-list__block[data-type="core/block"] p',
|
101
101
|
( element ) => element.innerText
|
@@ -104,19 +104,19 @@ describe( 'Reusable blocks', () => {
|
|
104
104
|
|
105
105
|
await clearAllBlocks();
|
106
106
|
|
107
|
-
// Insert the reusable block we edited above
|
107
|
+
// Insert the reusable block we edited above.
|
108
108
|
await insertReusableBlock( 'Surprised greeting block' );
|
109
109
|
|
110
|
-
// Convert block to a regular block
|
110
|
+
// Convert block to a regular block.
|
111
111
|
await clickBlockToolbarButton( 'Convert to regular blocks' );
|
112
112
|
|
113
|
-
// Check that we have a paragraph block on the page
|
113
|
+
// Check that we have a paragraph block on the page.
|
114
114
|
const paragraphBlock = await page.$(
|
115
115
|
'.block-editor-block-list__block[data-type="core/paragraph"]'
|
116
116
|
);
|
117
117
|
expect( paragraphBlock ).not.toBeNull();
|
118
118
|
|
119
|
-
// Check that its content is up to date
|
119
|
+
// Check that its content is up to date.
|
120
120
|
const paragraphContent = await page.$eval(
|
121
121
|
'.block-editor-block-list__block[data-type="core/paragraph"]',
|
122
122
|
( element ) => element.innerText
|
@@ -145,13 +145,13 @@ describe( 'Reusable blocks', () => {
|
|
145
145
|
await page.waitForSelector( 'p[aria-label="Paragraph block"]' );
|
146
146
|
await page.focus( 'p[aria-label="Paragraph block"]' );
|
147
147
|
|
148
|
-
// Change the block's content
|
148
|
+
// Change the block's content.
|
149
149
|
await page.keyboard.type( 'Einen ' );
|
150
150
|
|
151
|
-
// Save the reusable block and update the post
|
151
|
+
// Save the reusable block and update the post.
|
152
152
|
await saveAll();
|
153
153
|
|
154
|
-
// Check that its content is up to date
|
154
|
+
// Check that its content is up to date.
|
155
155
|
const paragraphContent = await page.$eval(
|
156
156
|
'p[aria-label="Paragraph block"]',
|
157
157
|
( element ) => element.innerText
|
@@ -180,21 +180,21 @@ describe( 'Reusable blocks', () => {
|
|
180
180
|
it( 'can be created from multiselection and converted back to regular blocks', async () => {
|
181
181
|
await createNewPost();
|
182
182
|
|
183
|
-
// Insert a Two paragraphs block
|
183
|
+
// Insert a Two paragraphs block.
|
184
184
|
await insertBlock( 'Paragraph' );
|
185
185
|
await page.keyboard.type( 'Hello there!' );
|
186
186
|
await page.keyboard.press( 'Enter' );
|
187
187
|
await page.keyboard.type( 'Second paragraph' );
|
188
188
|
|
189
|
-
// Select all the blocks
|
189
|
+
// Select all the blocks.
|
190
190
|
await pressKeyWithModifier( 'primary', 'a' );
|
191
191
|
await pressKeyWithModifier( 'primary', 'a' );
|
192
192
|
|
193
|
-
// Convert block to a reusable block
|
193
|
+
// Convert block to a reusable block.
|
194
194
|
await clickBlockToolbarButton( 'Options' );
|
195
195
|
await clickMenuItem( 'Add to Reusable blocks' );
|
196
196
|
|
197
|
-
// Set title
|
197
|
+
// Set title.
|
198
198
|
const nameInput = await page.waitForSelector(
|
199
199
|
reusableBlockNameInputSelector
|
200
200
|
);
|
@@ -202,20 +202,20 @@ describe( 'Reusable blocks', () => {
|
|
202
202
|
await page.keyboard.type( 'Multi-selection reusable block' );
|
203
203
|
await page.keyboard.press( 'Enter' );
|
204
204
|
|
205
|
-
// Wait for creation to finish
|
205
|
+
// Wait for creation to finish.
|
206
206
|
await page.waitForXPath(
|
207
207
|
'//*[contains(@class, "components-snackbar")]/*[text()="Reusable block created."]'
|
208
208
|
);
|
209
209
|
|
210
210
|
await clearAllBlocks();
|
211
211
|
|
212
|
-
// Insert the reusable block we edited above
|
212
|
+
// Insert the reusable block we edited above.
|
213
213
|
await insertReusableBlock( 'Multi-selection reusable block' );
|
214
214
|
|
215
|
-
// Convert block to a regular block
|
215
|
+
// Convert block to a regular block.
|
216
216
|
await clickBlockToolbarButton( 'Convert to regular blocks' );
|
217
217
|
|
218
|
-
// Check that we have two paragraph blocks on the page
|
218
|
+
// Check that we have two paragraph blocks on the page.
|
219
219
|
expect( await getEditedPostContent() ).toMatchSnapshot();
|
220
220
|
} );
|
221
221
|
|
@@ -236,25 +236,25 @@ describe( 'Reusable blocks', () => {
|
|
236
236
|
|
237
237
|
await page.waitForNavigation();
|
238
238
|
|
239
|
-
// Click the block to give it focus
|
239
|
+
// Click the block to give it focus.
|
240
240
|
const blockSelector = 'p[data-title="Paragraph"]';
|
241
241
|
await page.waitForSelector( blockSelector );
|
242
242
|
await page.click( blockSelector );
|
243
243
|
|
244
|
-
// Delete the block, leaving the reusable block empty
|
244
|
+
// Delete the block, leaving the reusable block empty.
|
245
245
|
await clickBlockToolbarButton( 'Options' );
|
246
246
|
const deleteButton = await page.waitForXPath(
|
247
247
|
'//button/span[text()="Remove Paragraph"]'
|
248
248
|
);
|
249
249
|
deleteButton.click();
|
250
250
|
|
251
|
-
// Wait for the Update button to become enabled
|
251
|
+
// Wait for the Update button to become enabled.
|
252
252
|
const publishButtonSelector = '.editor-post-publish-button__button';
|
253
253
|
await page.waitForSelector(
|
254
254
|
publishButtonSelector + '[aria-disabled="false"]'
|
255
255
|
);
|
256
256
|
|
257
|
-
// Save the reusable block
|
257
|
+
// Save the reusable block.
|
258
258
|
await page.click( publishButtonSelector );
|
259
259
|
await page.waitForXPath(
|
260
260
|
'//*[contains(@class, "components-snackbar")]/*[text()="Reusable block updated."]'
|
@@ -268,7 +268,7 @@ describe( 'Reusable blocks', () => {
|
|
268
268
|
} );
|
269
269
|
|
270
270
|
it( 'Should show a proper message when the reusable block is missing', async () => {
|
271
|
-
// Insert a non-existant reusable block
|
271
|
+
// Insert a non-existant reusable block.
|
272
272
|
await page.evaluate( () => {
|
273
273
|
const { createBlock } = window.wp.blocks;
|
274
274
|
const { dispatch } = window.wp.data;
|
@@ -16,19 +16,19 @@ describe( 'splitting and merging blocks', () => {
|
|
16
16
|
} );
|
17
17
|
|
18
18
|
it( 'should split and merge paragraph blocks using Enter and Backspace', async () => {
|
19
|
-
// Use regular inserter to add paragraph block and text
|
19
|
+
// Use regular inserter to add paragraph block and text.
|
20
20
|
await insertBlock( 'Paragraph' );
|
21
21
|
await page.keyboard.type( 'FirstSecond' );
|
22
22
|
|
23
23
|
// Move caret between 'First' and 'Second' and press Enter to split
|
24
|
-
// paragraph blocks
|
24
|
+
// paragraph blocks.
|
25
25
|
await pressKeyTimes( 'ArrowLeft', 6 );
|
26
26
|
await page.keyboard.press( 'Enter' );
|
27
27
|
|
28
|
-
// Assert that there are now two paragraph blocks with correct content
|
28
|
+
// Assert that there are now two paragraph blocks with correct content.
|
29
29
|
expect( await getEditedPostContent() ).toMatchSnapshot();
|
30
30
|
|
31
|
-
// Press Backspace to merge paragraph blocks
|
31
|
+
// Press Backspace to merge paragraph blocks.
|
32
32
|
await page.keyboard.press( 'Backspace' );
|
33
33
|
|
34
34
|
// Ensure that caret position is correctly placed at the between point.
|
@@ -76,12 +76,12 @@ describe( 'splitting and merging blocks', () => {
|
|
76
76
|
//
|
77
77
|
// See: https://github.com/WordPress/gutenberg/issues/8388
|
78
78
|
|
79
|
-
// First paragraph
|
79
|
+
// First paragraph.
|
80
80
|
await insertBlock( 'Paragraph' );
|
81
81
|
await page.keyboard.type( 'First' );
|
82
82
|
await page.keyboard.press( 'Enter' );
|
83
83
|
|
84
|
-
// Second paragraph
|
84
|
+
// Second paragraph.
|
85
85
|
await page.keyboard.down( 'Shift' );
|
86
86
|
await page.keyboard.press( 'Enter' );
|
87
87
|
await page.keyboard.up( 'Shift' );
|
@@ -14,7 +14,7 @@ describe( 'adding blocks', () => {
|
|
14
14
|
} );
|
15
15
|
|
16
16
|
it( 'Should switch to the plain style of the quote block', async () => {
|
17
|
-
// Inserting a quote block
|
17
|
+
// Inserting a quote block.
|
18
18
|
await insertBlock( 'Quote' );
|
19
19
|
await page.keyboard.type( 'Quote content' );
|
20
20
|
|
@@ -25,7 +25,7 @@ describe( 'adding blocks', () => {
|
|
25
25
|
);
|
26
26
|
await plainStyleButton.click();
|
27
27
|
|
28
|
-
// Check the content
|
28
|
+
// Check the content.
|
29
29
|
const content = await getEditedPostContent();
|
30
30
|
expect( content ).toMatchInlineSnapshot( `
|
31
31
|
"<!-- wp:quote {\\"className\\":\\"is-style-plain\\"} -->
|
@@ -0,0 +1,256 @@
|
|
1
|
+
/**
|
2
|
+
* WordPress dependencies
|
3
|
+
*/
|
4
|
+
import {
|
5
|
+
createNewPost,
|
6
|
+
openDocumentSettingsSidebar,
|
7
|
+
publishPost,
|
8
|
+
setBrowserViewport,
|
9
|
+
trashAllPosts,
|
10
|
+
} from '@wordpress/e2e-test-utils';
|
11
|
+
|
12
|
+
async function prepTestPost( postType, viewport ) {
|
13
|
+
// Create a post
|
14
|
+
await createNewPost( { postType } );
|
15
|
+
|
16
|
+
await page.type(
|
17
|
+
'.editor-post-title__input',
|
18
|
+
`Switch scheduled ${ postType } to draft`
|
19
|
+
);
|
20
|
+
await page.keyboard.press( 'Enter' );
|
21
|
+
await page.keyboard.type(
|
22
|
+
`This will be a scheduled ${ postType } edited in a ${ viewport } viewport`
|
23
|
+
);
|
24
|
+
|
25
|
+
// Unselect the blocks.
|
26
|
+
await page.evaluate( () => {
|
27
|
+
wp.data.dispatch( 'core/block-editor' ).clearSelectedBlock();
|
28
|
+
} );
|
29
|
+
}
|
30
|
+
|
31
|
+
async function publishTestPost( postType, viewport ) {
|
32
|
+
// Create a post
|
33
|
+
await prepTestPost( postType, viewport );
|
34
|
+
|
35
|
+
// Publish the post
|
36
|
+
await publishPost();
|
37
|
+
|
38
|
+
const publishedSnackBar = await page.waitForXPath(
|
39
|
+
`//*[@aria-label="Dismiss this notice"][@role="button"]/div[contains(text(),"published")]`
|
40
|
+
);
|
41
|
+
|
42
|
+
const snackBarText = await (
|
43
|
+
await publishedSnackBar.getProperty( 'textContent' )
|
44
|
+
).jsonValue();
|
45
|
+
|
46
|
+
expect( snackBarText.toLowerCase() ).toBe(
|
47
|
+
`${ postType } published.view ${ postType }`
|
48
|
+
);
|
49
|
+
|
50
|
+
const closePublishingPanel = await page.waitForXPath(
|
51
|
+
'//button[@aria-label="Close panel"]'
|
52
|
+
);
|
53
|
+
await closePublishingPanel.click();
|
54
|
+
}
|
55
|
+
|
56
|
+
async function scheduleTestPost( postType, viewport ) {
|
57
|
+
// Create a post
|
58
|
+
await prepTestPost( postType, viewport );
|
59
|
+
|
60
|
+
if ( viewport === 'small' ) {
|
61
|
+
await openDocumentSettingsSidebar();
|
62
|
+
}
|
63
|
+
// Set a publish date for the next month.
|
64
|
+
await page.click( '.edit-post-post-schedule__toggle' );
|
65
|
+
await page.click(
|
66
|
+
'div[aria-label="Move forward to switch to the next month."]'
|
67
|
+
);
|
68
|
+
|
69
|
+
await (
|
70
|
+
await page.$x(
|
71
|
+
'//*[@role="application"][@aria-label="Calendar"]//td[@role="button"]/*[text() = "15"]'
|
72
|
+
)
|
73
|
+
)[ 0 ].click();
|
74
|
+
|
75
|
+
await page.click( '.edit-post-post-schedule__toggle' );
|
76
|
+
|
77
|
+
if ( viewport === 'small' ) {
|
78
|
+
const closeDocumentSettingsButton = await page.waitForXPath(
|
79
|
+
'//div[@aria-label="Editor settings"]//button[@aria-label="Close settings"]'
|
80
|
+
);
|
81
|
+
await closeDocumentSettingsButton.click();
|
82
|
+
}
|
83
|
+
|
84
|
+
// Important: target an ellipsis (…) and not three dots (...)
|
85
|
+
const scheduleButton = await page.waitForXPath(
|
86
|
+
'//button[text()="Schedule…"]'
|
87
|
+
);
|
88
|
+
await scheduleButton.click();
|
89
|
+
const secondScheduleButton = await page.waitForXPath(
|
90
|
+
'//button[text()="Schedule"]'
|
91
|
+
);
|
92
|
+
await secondScheduleButton.click();
|
93
|
+
|
94
|
+
const closePublishingPanel = await page.waitForXPath(
|
95
|
+
'//button[@aria-label="Close panel"]'
|
96
|
+
);
|
97
|
+
await closePublishingPanel.click();
|
98
|
+
}
|
99
|
+
|
100
|
+
async function verifyRevertToDraft( postType ) {
|
101
|
+
const revertedSnackBar = await page.waitForXPath(
|
102
|
+
`//*[@aria-label="Dismiss this notice"][@role="button"]/div[contains(text(),"reverted")]`
|
103
|
+
);
|
104
|
+
|
105
|
+
const revertedSnackBarText = await (
|
106
|
+
await revertedSnackBar.getProperty( 'textContent' )
|
107
|
+
).jsonValue();
|
108
|
+
|
109
|
+
expect( revertedSnackBarText.toLowerCase() ).toBe(
|
110
|
+
`${ postType } reverted to draft.`
|
111
|
+
);
|
112
|
+
}
|
113
|
+
|
114
|
+
describe( 'Clicking "Switch to draft" on a published post/page', () => {
|
115
|
+
beforeAll( async () => {
|
116
|
+
await trashAllPosts( 'post' );
|
117
|
+
await trashAllPosts( 'page' );
|
118
|
+
} );
|
119
|
+
afterEach( async () => {
|
120
|
+
await setBrowserViewport( 'large' );
|
121
|
+
} );
|
122
|
+
|
123
|
+
[ 'large', 'small' ].forEach( ( viewport ) => {
|
124
|
+
describe( `in a ${ viewport } viewport`, () => {
|
125
|
+
[ 'post', 'page' ].forEach( ( postType ) => {
|
126
|
+
const buttonText =
|
127
|
+
viewport === 'large' ? 'Switch to draft' : 'Draft';
|
128
|
+
beforeEach( async () => {
|
129
|
+
await setBrowserViewport( viewport );
|
130
|
+
} );
|
131
|
+
|
132
|
+
it( `should leave a published ${ postType } published if canceled`, async () => {
|
133
|
+
publishTestPost( postType, viewport );
|
134
|
+
|
135
|
+
const switchToDraftButton = await page.waitForXPath(
|
136
|
+
`//button[contains(text(), "${ buttonText }")]`
|
137
|
+
);
|
138
|
+
await switchToDraftButton.click();
|
139
|
+
|
140
|
+
// Process the ConfirmDialog
|
141
|
+
await page.waitForXPath(
|
142
|
+
'//*[text()="Are you sure you want to unpublish this post?"]'
|
143
|
+
);
|
144
|
+
const [ cancelButton ] = await page.$x(
|
145
|
+
'//*[@role="dialog"][not(@id="wp-link-wrap")]//button[text()="Cancel"]'
|
146
|
+
);
|
147
|
+
await cancelButton.click();
|
148
|
+
|
149
|
+
const postStatus = await page.evaluate( () => {
|
150
|
+
return wp.data
|
151
|
+
.select( 'core/editor' )
|
152
|
+
.getEditedPostAttribute( 'status' );
|
153
|
+
} );
|
154
|
+
expect( postStatus ).toBe( 'publish' );
|
155
|
+
} );
|
156
|
+
it( `should revert a published ${ postType } to a draft if confirmed`, async () => {
|
157
|
+
// Switch to draft
|
158
|
+
const switchToDraftButton = await page.waitForXPath(
|
159
|
+
`//button[contains(text(), "${ buttonText }")]`
|
160
|
+
);
|
161
|
+
await switchToDraftButton.click();
|
162
|
+
|
163
|
+
// Process the ConfirmDialog
|
164
|
+
await page.waitForXPath(
|
165
|
+
'//*[text()="Are you sure you want to unpublish this post?"]'
|
166
|
+
);
|
167
|
+
const [ confirmButton ] = await page.$x(
|
168
|
+
'//*[@role="dialog"]//button[text()="OK"]'
|
169
|
+
);
|
170
|
+
await confirmButton.click();
|
171
|
+
|
172
|
+
await verifyRevertToDraft( postType );
|
173
|
+
|
174
|
+
const postStatus = await page.evaluate( () => {
|
175
|
+
return wp.data
|
176
|
+
.select( 'core/editor' )
|
177
|
+
.getEditedPostAttribute( 'status' );
|
178
|
+
} );
|
179
|
+
expect( postStatus ).toBe( 'draft' );
|
180
|
+
} );
|
181
|
+
} );
|
182
|
+
} );
|
183
|
+
} );
|
184
|
+
} );
|
185
|
+
describe( 'Clicking "Switch to draft" on a scheduled post/page', () => {
|
186
|
+
beforeAll( async () => {
|
187
|
+
await trashAllPosts( 'post' );
|
188
|
+
await trashAllPosts( 'page' );
|
189
|
+
} );
|
190
|
+
afterEach( async () => {
|
191
|
+
await setBrowserViewport( 'large' );
|
192
|
+
} );
|
193
|
+
|
194
|
+
[ 'large', 'small' ].forEach( ( viewport ) => {
|
195
|
+
describe( `in a ${ viewport } viewport`, () => {
|
196
|
+
[ 'post', 'page' ].forEach( ( postType ) => {
|
197
|
+
const buttonText =
|
198
|
+
viewport === 'large' ? 'Switch to draft' : 'Draft';
|
199
|
+
beforeEach( async () => {
|
200
|
+
await setBrowserViewport( viewport );
|
201
|
+
} );
|
202
|
+
|
203
|
+
it( `should leave a scheduled ${ postType } scheduled if canceled`, async () => {
|
204
|
+
scheduleTestPost( postType, viewport );
|
205
|
+
|
206
|
+
const switchToDraftButton = await page.waitForXPath(
|
207
|
+
`//button[contains(text(), "${ buttonText }")]`
|
208
|
+
);
|
209
|
+
await switchToDraftButton.click();
|
210
|
+
|
211
|
+
// Process the ConfirmDialog
|
212
|
+
await page.waitForXPath(
|
213
|
+
'//*[text()="Are you sure you want to unschedule this post?"]'
|
214
|
+
);
|
215
|
+
const [ cancelButton ] = await page.$x(
|
216
|
+
'//*[@role="dialog"][not(@id="wp-link-wrap")]//button[text()="Cancel"]'
|
217
|
+
);
|
218
|
+
await cancelButton.click();
|
219
|
+
|
220
|
+
// Confirm post is still scheduled
|
221
|
+
const postStatus = await page.evaluate( () => {
|
222
|
+
return wp.data
|
223
|
+
.select( 'core/editor' )
|
224
|
+
.getEditedPostAttribute( 'status' );
|
225
|
+
} );
|
226
|
+
expect( postStatus ).toBe( 'future' );
|
227
|
+
} );
|
228
|
+
it( `should revert a scheduled ${ postType } to a draft if confirmed`, async () => {
|
229
|
+
// Switch to draft
|
230
|
+
const switchToDraftButton = await page.waitForXPath(
|
231
|
+
`//button[contains(text(), "${ buttonText }")]`
|
232
|
+
);
|
233
|
+
await switchToDraftButton.click();
|
234
|
+
|
235
|
+
// Process the ConfirmDialog
|
236
|
+
await page.waitForXPath(
|
237
|
+
'//*[text()="Are you sure you want to unschedule this post?"]'
|
238
|
+
);
|
239
|
+
const [ confirmButton ] = await page.$x(
|
240
|
+
'//*[@role="dialog"]//button[text()="OK"]'
|
241
|
+
);
|
242
|
+
await confirmButton.click();
|
243
|
+
|
244
|
+
await verifyRevertToDraft( postType );
|
245
|
+
|
246
|
+
const postStatus = await page.evaluate( () => {
|
247
|
+
return wp.data
|
248
|
+
.select( 'core/editor' )
|
249
|
+
.getEditedPostAttribute( 'status' );
|
250
|
+
} );
|
251
|
+
expect( postStatus ).toBe( 'draft' );
|
252
|
+
} );
|
253
|
+
} );
|
254
|
+
} );
|
255
|
+
} );
|
256
|
+
} );
|
@@ -200,7 +200,7 @@ describe( 'Taxonomies', () => {
|
|
200
200
|
return;
|
201
201
|
}
|
202
202
|
|
203
|
-
// At the start there are no tag tokens
|
203
|
+
// At the start there are no tag tokens.
|
204
204
|
expect( await page.$$( TAG_TOKEN_SELECTOR ) ).toHaveLength( 0 );
|
205
205
|
|
206
206
|
const tagsPanel = await findSidebarPanelWithTitle( 'Tags' );
|
@@ -98,7 +98,7 @@ describe( 'Toolbar roving tabindex', () => {
|
|
98
98
|
it( 'ensures table block toolbar uses roving tabindex', async () => {
|
99
99
|
await insertBlock( 'Table' );
|
100
100
|
await testBlockToolbarKeyboardNavigation( 'Block: Table', 'Table' );
|
101
|
-
// Move focus to the first toolbar item
|
101
|
+
// Move focus to the first toolbar item.
|
102
102
|
await page.keyboard.press( 'Home' );
|
103
103
|
await expectLabelToHaveFocus( 'Table' );
|
104
104
|
await page.click( '.blocks-table__placeholder-button' );
|