@wordpress/e2e-tests 6.3.5 → 6.5.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 +4 -0
- package/config/setup-performance-test.js +14 -7
- package/jest.config.js +4 -0
- package/package.json +7 -7
- package/specs/editor/blocks/pullquote.test.js +3 -3
- package/specs/editor/plugins/__snapshots__/align-hook.test.js.snap +11 -11
- package/specs/editor/plugins/__snapshots__/container-blocks.test.js.snap +14 -14
- package/specs/editor/plugins/__snapshots__/cpt-locking.test.js.snap +29 -29
- package/specs/editor/plugins/__snapshots__/iframed-inline-styles.test.js.snap +1 -1
- package/specs/editor/plugins/__snapshots__/iframed-masonry-block.test.js.snap +1 -1
- package/specs/editor/plugins/__snapshots__/inner-blocks-render-appender.test.js.snap +5 -5
- package/specs/editor/plugins/__snapshots__/plugins-api.test.js.snap +2 -2
- package/specs/editor/various/__snapshots__/adding-patterns.test.js.snap +4 -4
- package/specs/editor/various/__snapshots__/block-grouping.test.js.snap +21 -21
- package/specs/editor/various/__snapshots__/block-hierarchy-navigation.test.js.snap +12 -12
- package/specs/editor/various/__snapshots__/embedding.test.js.snap +19 -19
- package/specs/editor/various/__snapshots__/inserting-blocks.test.js.snap +8 -8
- package/specs/editor/various/__snapshots__/keep-styles-on-block-transforms.test.js.snap +11 -11
- package/specs/editor/various/__snapshots__/links.test.js.snap +9 -9
- package/specs/editor/various/__snapshots__/multi-block-selection.test.js.snap +17 -17
- package/specs/editor/various/__snapshots__/rich-text.test.js.snap +5 -5
- package/specs/editor/various/block-grouping.test.js +3 -3
- package/specs/editor/various/format-library/__snapshots__/text-color.test.js.snap +1 -1
- package/specs/editor/various/links.test.js +50 -16
- package/specs/editor/various/multi-block-selection.test.js +2 -2
- package/specs/performance/front-end-block-theme.test.js +48 -12
- package/specs/performance/front-end-classic-theme.test.js +50 -13
- package/specs/performance/post-editor.test.js +45 -28
- package/specs/performance/site-editor.test.js +69 -42
- package/specs/performance/utils.js +12 -1
- package/specs/widgets/editing-widgets.test.js +20 -15
- package/specs/editor/blocks/__snapshots__/heading.test.js.snap +0 -51
- package/specs/editor/blocks/__snapshots__/navigation.test.js.snap +0 -47
- package/specs/editor/blocks/heading.test.js +0 -113
- package/specs/editor/blocks/navigation.test.js +0 -1723
- package/specs/editor/blocks/query.test.js +0 -66
- package/specs/editor/various/__snapshots__/block-deletion.test.js.snap +0 -111
- package/specs/editor/various/__snapshots__/list-view.test.js.snap +0 -15
- package/specs/editor/various/block-deletion.test.js +0 -209
- package/specs/editor/various/list-view.test.js +0 -330
- package/specs/editor/various/switch-to-draft.test.js +0 -254
@@ -1,330 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import {
|
5
|
-
createNewPost,
|
6
|
-
insertBlock,
|
7
|
-
getEditedPostContent,
|
8
|
-
openListView,
|
9
|
-
pressKeyWithModifier,
|
10
|
-
pressKeyTimes,
|
11
|
-
} from '@wordpress/e2e-test-utils';
|
12
|
-
|
13
|
-
async function dragAndDrop( draggableElement, targetElement, offsetY ) {
|
14
|
-
const draggablePoint = await draggableElement.clickablePoint();
|
15
|
-
const targetClickablePoint = await targetElement.clickablePoint();
|
16
|
-
const targetPoint = {
|
17
|
-
x: targetClickablePoint.x,
|
18
|
-
y: targetClickablePoint.y + offsetY,
|
19
|
-
};
|
20
|
-
|
21
|
-
return await page.mouse.dragAndDrop( draggablePoint, targetPoint );
|
22
|
-
}
|
23
|
-
|
24
|
-
async function getBlockListLeafNodes() {
|
25
|
-
return await page.$$( '.block-editor-list-view-leaf' );
|
26
|
-
}
|
27
|
-
|
28
|
-
describe( 'List view', () => {
|
29
|
-
beforeAll( async () => {
|
30
|
-
await page.setDragInterception( true );
|
31
|
-
} );
|
32
|
-
|
33
|
-
beforeEach( async () => {
|
34
|
-
await createNewPost();
|
35
|
-
} );
|
36
|
-
|
37
|
-
afterAll( async () => {
|
38
|
-
await page.setDragInterception( false );
|
39
|
-
} );
|
40
|
-
|
41
|
-
it( 'allows a user to drag a block to a new sibling position', async () => {
|
42
|
-
// Insert some blocks of different types.
|
43
|
-
await insertBlock( 'Heading' );
|
44
|
-
await insertBlock( 'Image' );
|
45
|
-
await insertBlock( 'Paragraph' );
|
46
|
-
|
47
|
-
// Open list view.
|
48
|
-
await pressKeyWithModifier( 'access', 'o' );
|
49
|
-
|
50
|
-
const paragraphBlock = await page.waitForXPath(
|
51
|
-
'//a[contains(., "Paragraph")][@draggable="true"]'
|
52
|
-
);
|
53
|
-
|
54
|
-
// Drag above the heading block.
|
55
|
-
const headingBlock = await page.waitForXPath(
|
56
|
-
'//a[contains(., "Heading")][@draggable="true"]'
|
57
|
-
);
|
58
|
-
|
59
|
-
await dragAndDrop( paragraphBlock, headingBlock, -5 );
|
60
|
-
|
61
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
62
|
-
} );
|
63
|
-
|
64
|
-
// Check for regressions of https://github.com/WordPress/gutenberg/issues/38763.
|
65
|
-
it( 'shows the correct amount of blocks after a block is removed in the canvas', async () => {
|
66
|
-
// Insert some blocks of different types.
|
67
|
-
await insertBlock( 'Image' );
|
68
|
-
await insertBlock( 'Heading' );
|
69
|
-
await insertBlock( 'Paragraph' );
|
70
|
-
|
71
|
-
// Open list view.
|
72
|
-
await pressKeyWithModifier( 'access', 'o' );
|
73
|
-
|
74
|
-
// The last inserted paragraph block should be selected in List View.
|
75
|
-
await page.waitForSelector(
|
76
|
-
'.block-editor-list-view-block__contents-cell[aria-selected="true"][aria-label^="Paragraph"]'
|
77
|
-
);
|
78
|
-
|
79
|
-
// Go to the image block in list view.
|
80
|
-
await pressKeyTimes( 'ArrowUp', 2 );
|
81
|
-
const listViewImageBlock = await page.waitForXPath(
|
82
|
-
'//a[contains(., "Image")]'
|
83
|
-
);
|
84
|
-
await expect( listViewImageBlock ).toHaveFocus();
|
85
|
-
|
86
|
-
// Select the image block in the canvas.
|
87
|
-
await page.keyboard.press( 'Enter' );
|
88
|
-
|
89
|
-
const uploadButton = await page.waitForXPath(
|
90
|
-
'//button[contains( text(), "Upload" ) ]'
|
91
|
-
);
|
92
|
-
await expect( uploadButton ).toHaveFocus();
|
93
|
-
|
94
|
-
// Delete the image block in the canvas.
|
95
|
-
await page.keyboard.press( 'ArrowUp' );
|
96
|
-
await page.keyboard.press( 'Backspace' );
|
97
|
-
|
98
|
-
// List view should have two rows.
|
99
|
-
const listViewRows = await page.$$( 'tr.block-editor-list-view-leaf' );
|
100
|
-
expect( listViewRows ).toHaveLength( 2 );
|
101
|
-
|
102
|
-
// The console didn't throw an error as reported in
|
103
|
-
// https://github.com/WordPress/gutenberg/issues/38763.
|
104
|
-
expect( console ).not.toHaveErrored();
|
105
|
-
} );
|
106
|
-
|
107
|
-
// Check for regression of https://github.com/WordPress/gutenberg/issues/39026
|
108
|
-
it( 'should select previous block after removing selected one', async () => {
|
109
|
-
// Insert some blocks of different types.
|
110
|
-
await insertBlock( 'Image' );
|
111
|
-
await insertBlock( 'Heading' );
|
112
|
-
await insertBlock( 'Paragraph' );
|
113
|
-
|
114
|
-
// Open list view.
|
115
|
-
await openListView();
|
116
|
-
|
117
|
-
// The last inserted paragraph block should be selected in List View.
|
118
|
-
await page.waitForSelector(
|
119
|
-
'.block-editor-list-view-block__contents-cell[aria-selected="true"][aria-label^="Paragraph"]'
|
120
|
-
);
|
121
|
-
|
122
|
-
// Paragraph options button.
|
123
|
-
const paragraphOptionsButton = await page.waitForSelector(
|
124
|
-
'tr.block-editor-list-view-leaf:last-child button[aria-label="Options for Paragraph block"]'
|
125
|
-
);
|
126
|
-
|
127
|
-
await paragraphOptionsButton.click();
|
128
|
-
|
129
|
-
const paragraphRemoveButton = await page.waitForXPath(
|
130
|
-
'//button[contains(., "Remove Paragraph")]'
|
131
|
-
);
|
132
|
-
|
133
|
-
// Remove paragraph.
|
134
|
-
await paragraphRemoveButton.click();
|
135
|
-
|
136
|
-
// Heading block should be selected as previous block.
|
137
|
-
await page.waitForSelector(
|
138
|
-
'.block-editor-list-view-block__contents-cell[aria-selected="true"][aria-label^="Heading"]'
|
139
|
-
);
|
140
|
-
} );
|
141
|
-
|
142
|
-
// Check for regression of https://github.com/WordPress/gutenberg/issues/39026
|
143
|
-
it( 'should select next block after removing the very first block', async () => {
|
144
|
-
// Insert some blocks of different types.
|
145
|
-
await insertBlock( 'Image' );
|
146
|
-
await insertBlock( 'Heading' );
|
147
|
-
await insertBlock( 'Paragraph' );
|
148
|
-
|
149
|
-
// Open list view.
|
150
|
-
await openListView();
|
151
|
-
|
152
|
-
// The last inserted paragraph block should be selected in List View.
|
153
|
-
await page.waitForSelector(
|
154
|
-
'.block-editor-list-view-block__contents-cell[aria-selected="true"][aria-label^="Paragraph"]'
|
155
|
-
);
|
156
|
-
|
157
|
-
// Go to the image block in list view.
|
158
|
-
await pressKeyTimes( 'ArrowUp', 2 );
|
159
|
-
await pressKeyTimes( 'Enter', 1 );
|
160
|
-
|
161
|
-
// Image block should have selected.
|
162
|
-
await page.waitForSelector(
|
163
|
-
'.block-editor-list-view-block__contents-cell[aria-selected="true"][aria-label^="Image"]'
|
164
|
-
);
|
165
|
-
|
166
|
-
// Image options dropdown.
|
167
|
-
const imageOptionsButton = await page.waitForSelector(
|
168
|
-
'tr.block-editor-list-view-leaf:first-child button[aria-label="Options for Image block"]'
|
169
|
-
);
|
170
|
-
|
171
|
-
await imageOptionsButton.click();
|
172
|
-
|
173
|
-
const imageRemoveButton = await page.waitForXPath(
|
174
|
-
'//button[contains(., "Remove Image")]'
|
175
|
-
);
|
176
|
-
|
177
|
-
// Remove Image block.
|
178
|
-
await imageRemoveButton.click();
|
179
|
-
|
180
|
-
// Heading block should be selected as next block.
|
181
|
-
await page.waitForSelector(
|
182
|
-
'.block-editor-list-view-block__contents-cell[aria-selected="true"][aria-label^="Heading"]'
|
183
|
-
);
|
184
|
-
} );
|
185
|
-
|
186
|
-
/**
|
187
|
-
* When all the blocks gets removed from the editor, it inserts a default paragraph block;
|
188
|
-
* make sure that paragraph block gets selected after removing blocks from ListView.
|
189
|
-
*/
|
190
|
-
it( 'should select default paragraph block after removing all blocks', async () => {
|
191
|
-
// Insert some blocks of different types.
|
192
|
-
await insertBlock( 'Image' );
|
193
|
-
await insertBlock( 'Heading' );
|
194
|
-
|
195
|
-
// Open list view.
|
196
|
-
await openListView();
|
197
|
-
|
198
|
-
// The last inserted heading block should be selected in List View.
|
199
|
-
const headingBlock = await page.waitForSelector(
|
200
|
-
'.block-editor-list-view-block__contents-cell[aria-selected="true"][aria-label^="Heading"]'
|
201
|
-
);
|
202
|
-
|
203
|
-
await headingBlock.click();
|
204
|
-
|
205
|
-
// Select all two blocks.
|
206
|
-
await pressKeyWithModifier( 'shift', 'ArrowUp' );
|
207
|
-
|
208
|
-
// Both Image and Heading blocks should have selected.
|
209
|
-
await page.waitForSelector(
|
210
|
-
'.block-editor-list-view-block__contents-cell[aria-selected="true"][aria-label^="Heading"]'
|
211
|
-
);
|
212
|
-
await page.waitForSelector(
|
213
|
-
'.block-editor-list-view-block__contents-cell[aria-selected="true"][aria-label^="Image"]'
|
214
|
-
);
|
215
|
-
|
216
|
-
const imageOptionsButton = await page.waitForSelector(
|
217
|
-
'tr.block-editor-list-view-leaf:first-child button[aria-label="Options for Image block"]'
|
218
|
-
);
|
219
|
-
|
220
|
-
// Blocks options dropdown.
|
221
|
-
await imageOptionsButton.click();
|
222
|
-
|
223
|
-
const blocksRemoveButton = await page.waitForXPath(
|
224
|
-
'//button[contains(., "Remove blocks")]'
|
225
|
-
);
|
226
|
-
|
227
|
-
// Remove all blocks.
|
228
|
-
await blocksRemoveButton.click();
|
229
|
-
|
230
|
-
// Newly created default paragraph block should be selected.
|
231
|
-
await page.waitForSelector(
|
232
|
-
'.block-editor-list-view-block__contents-cell[aria-selected="true"][aria-label^="Paragraph"]'
|
233
|
-
);
|
234
|
-
} );
|
235
|
-
|
236
|
-
it( 'should expand nested list items', async () => {
|
237
|
-
// Insert some blocks of different types.
|
238
|
-
await insertBlock( 'Cover' );
|
239
|
-
|
240
|
-
// Click first color option from the block placeholder's color picker to make the inner blocks appear.
|
241
|
-
const colorPickerButton = await page.waitForSelector(
|
242
|
-
'.wp-block-cover__placeholder-background-options .components-circular-option-picker__option-wrapper:first-child button'
|
243
|
-
);
|
244
|
-
await colorPickerButton.click();
|
245
|
-
|
246
|
-
// Open list view.
|
247
|
-
await openListView();
|
248
|
-
|
249
|
-
// Things start off expanded.
|
250
|
-
expect( await getBlockListLeafNodes() ).toHaveLength( 2 );
|
251
|
-
|
252
|
-
const blockListExpanders = await page.$$(
|
253
|
-
'.block-editor-list-view__expander'
|
254
|
-
);
|
255
|
-
|
256
|
-
// Collapse the first block
|
257
|
-
await blockListExpanders[ 0 ].click();
|
258
|
-
|
259
|
-
// Check that we're collapsed
|
260
|
-
expect( await getBlockListLeafNodes() ).toHaveLength( 1 );
|
261
|
-
|
262
|
-
// Focus the cover block. The paragraph is not focussed by default.
|
263
|
-
const coverBlock = await page.waitForSelector( '.wp-block-cover' );
|
264
|
-
|
265
|
-
await coverBlock.focus();
|
266
|
-
|
267
|
-
// Click the cover title placeholder.
|
268
|
-
const coverTitle = await page.waitForSelector(
|
269
|
-
'.wp-block-cover .wp-block-paragraph'
|
270
|
-
);
|
271
|
-
|
272
|
-
await coverTitle.click();
|
273
|
-
|
274
|
-
// The block list should contain two leafs and the second should be selected (and be a paragraph).
|
275
|
-
const selectedElementText = await page.$eval(
|
276
|
-
'.block-editor-list-view-leaf.is-selected .block-editor-list-view-block-contents',
|
277
|
-
( element ) => element.innerText
|
278
|
-
);
|
279
|
-
|
280
|
-
expect( selectedElementText ).toContain( 'Paragraph' );
|
281
|
-
} );
|
282
|
-
|
283
|
-
// Test keyboard Home/End keys.
|
284
|
-
it( 'ensures the Home/End keyboard keys move focus to start/end of list', async () => {
|
285
|
-
// Insert some blocks of different types.
|
286
|
-
await insertBlock( 'Image' );
|
287
|
-
await insertBlock( 'Heading' );
|
288
|
-
await insertBlock( 'Paragraph' );
|
289
|
-
await insertBlock( 'Columns' );
|
290
|
-
await insertBlock( 'Group' );
|
291
|
-
|
292
|
-
// Open list view.
|
293
|
-
await pressKeyWithModifier( 'access', 'o' );
|
294
|
-
|
295
|
-
// The last inserted group block should be selected in list view.
|
296
|
-
await page.waitForSelector(
|
297
|
-
'.block-editor-list-view-block__contents-cell[aria-selected="true"][aria-label^="Group"]'
|
298
|
-
);
|
299
|
-
|
300
|
-
// Press Home to go to the first inserted block (image).
|
301
|
-
await page.keyboard.press( 'Home' );
|
302
|
-
const listViewImageBlock = await page.waitForXPath(
|
303
|
-
'//a[contains(., "Image")]'
|
304
|
-
);
|
305
|
-
await expect( listViewImageBlock ).toHaveFocus();
|
306
|
-
|
307
|
-
// Press End followed by Arrow Up to go to the second to last block (columns).
|
308
|
-
await page.keyboard.press( 'End' );
|
309
|
-
await page.keyboard.press( 'ArrowUp' );
|
310
|
-
const listViewColumnsBlock = await page.waitForXPath(
|
311
|
-
'//a[contains(., "Columns")]'
|
312
|
-
);
|
313
|
-
await expect( listViewColumnsBlock ).toHaveFocus();
|
314
|
-
|
315
|
-
// Try navigating the right column to image block options button via Home key.
|
316
|
-
await page.keyboard.press( 'ArrowRight' );
|
317
|
-
await page.keyboard.press( 'Home' );
|
318
|
-
const listViewImageBlockRight = await page.waitForSelector(
|
319
|
-
'button[aria-label="Options for Image block"]'
|
320
|
-
);
|
321
|
-
await expect( listViewImageBlockRight ).toHaveFocus();
|
322
|
-
|
323
|
-
// Try navigating the right column to group block options button.
|
324
|
-
await page.keyboard.press( 'End' );
|
325
|
-
const listViewGroupBlockRight = await page.waitForSelector(
|
326
|
-
'button[aria-label="Options for Group block"]'
|
327
|
-
);
|
328
|
-
await expect( listViewGroupBlockRight ).toHaveFocus();
|
329
|
-
} );
|
330
|
-
} );
|
@@ -1,254 +0,0 @@
|
|
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( '*[aria-label="View next month"]' );
|
66
|
-
|
67
|
-
await (
|
68
|
-
await page.$x(
|
69
|
-
'//*[@role="application"][@aria-label="Calendar"]//button[text()="15"]'
|
70
|
-
)
|
71
|
-
)[ 0 ].click();
|
72
|
-
|
73
|
-
await page.click( '.edit-post-post-schedule__toggle' );
|
74
|
-
|
75
|
-
if ( viewport === 'small' ) {
|
76
|
-
const closeDocumentSettingsButton = await page.waitForXPath(
|
77
|
-
'//div[@aria-label="Editor settings"]//button[@aria-label="Close settings"]'
|
78
|
-
);
|
79
|
-
await closeDocumentSettingsButton.click();
|
80
|
-
}
|
81
|
-
|
82
|
-
// Important: target an ellipsis (…) and not three dots (...)
|
83
|
-
const scheduleButton = await page.waitForXPath(
|
84
|
-
'//button[text()="Schedule…"]'
|
85
|
-
);
|
86
|
-
await scheduleButton.click();
|
87
|
-
const secondScheduleButton = await page.waitForXPath(
|
88
|
-
'//button[text()="Schedule"]'
|
89
|
-
);
|
90
|
-
await secondScheduleButton.click();
|
91
|
-
|
92
|
-
const closePublishingPanel = await page.waitForXPath(
|
93
|
-
'//button[@aria-label="Close panel"]'
|
94
|
-
);
|
95
|
-
await closePublishingPanel.click();
|
96
|
-
}
|
97
|
-
|
98
|
-
async function verifyRevertToDraft( postType ) {
|
99
|
-
const revertedSnackBar = await page.waitForXPath(
|
100
|
-
`//*[@aria-label="Dismiss this notice"][@role="button"]/div[contains(text(),"reverted")]`
|
101
|
-
);
|
102
|
-
|
103
|
-
const revertedSnackBarText = await (
|
104
|
-
await revertedSnackBar.getProperty( 'textContent' )
|
105
|
-
).jsonValue();
|
106
|
-
|
107
|
-
expect( revertedSnackBarText.toLowerCase() ).toBe(
|
108
|
-
`${ postType } reverted to draft.`
|
109
|
-
);
|
110
|
-
}
|
111
|
-
|
112
|
-
describe( 'Clicking "Switch to draft" on a published post/page', () => {
|
113
|
-
beforeAll( async () => {
|
114
|
-
await trashAllPosts( 'post' );
|
115
|
-
await trashAllPosts( 'page' );
|
116
|
-
} );
|
117
|
-
afterEach( async () => {
|
118
|
-
await setBrowserViewport( 'large' );
|
119
|
-
} );
|
120
|
-
|
121
|
-
[ 'large', 'small' ].forEach( ( viewport ) => {
|
122
|
-
describe( `in a ${ viewport } viewport`, () => {
|
123
|
-
[ 'post', 'page' ].forEach( ( postType ) => {
|
124
|
-
const buttonText =
|
125
|
-
viewport === 'large' ? 'Switch to draft' : 'Draft';
|
126
|
-
beforeEach( async () => {
|
127
|
-
await setBrowserViewport( viewport );
|
128
|
-
} );
|
129
|
-
|
130
|
-
it( `should leave a published ${ postType } published if canceled`, async () => {
|
131
|
-
publishTestPost( postType, viewport );
|
132
|
-
|
133
|
-
const switchToDraftButton = await page.waitForXPath(
|
134
|
-
`//button[contains(text(), "${ buttonText }")]`
|
135
|
-
);
|
136
|
-
await switchToDraftButton.click();
|
137
|
-
|
138
|
-
// Process the ConfirmDialog
|
139
|
-
await page.waitForXPath(
|
140
|
-
'//*[text()="Are you sure you want to unpublish this post?"]'
|
141
|
-
);
|
142
|
-
const [ cancelButton ] = await page.$x(
|
143
|
-
'//*[@role="dialog"][not(@id="wp-link-wrap")]//button[text()="Cancel"]'
|
144
|
-
);
|
145
|
-
await cancelButton.click();
|
146
|
-
|
147
|
-
const postStatus = await page.evaluate( () => {
|
148
|
-
return wp.data
|
149
|
-
.select( 'core/editor' )
|
150
|
-
.getEditedPostAttribute( 'status' );
|
151
|
-
} );
|
152
|
-
expect( postStatus ).toBe( 'publish' );
|
153
|
-
} );
|
154
|
-
it( `should revert a published ${ postType } to a draft if confirmed`, async () => {
|
155
|
-
// Switch to draft
|
156
|
-
const switchToDraftButton = await page.waitForXPath(
|
157
|
-
`//button[contains(text(), "${ buttonText }")]`
|
158
|
-
);
|
159
|
-
await switchToDraftButton.click();
|
160
|
-
|
161
|
-
// Process the ConfirmDialog
|
162
|
-
await page.waitForXPath(
|
163
|
-
'//*[text()="Are you sure you want to unpublish this post?"]'
|
164
|
-
);
|
165
|
-
const [ confirmButton ] = await page.$x(
|
166
|
-
'//*[@role="dialog"]//button[text()="OK"]'
|
167
|
-
);
|
168
|
-
await confirmButton.click();
|
169
|
-
|
170
|
-
await verifyRevertToDraft( postType );
|
171
|
-
|
172
|
-
const postStatus = await page.evaluate( () => {
|
173
|
-
return wp.data
|
174
|
-
.select( 'core/editor' )
|
175
|
-
.getEditedPostAttribute( 'status' );
|
176
|
-
} );
|
177
|
-
expect( postStatus ).toBe( 'draft' );
|
178
|
-
} );
|
179
|
-
} );
|
180
|
-
} );
|
181
|
-
} );
|
182
|
-
} );
|
183
|
-
describe( 'Clicking "Switch to draft" on a scheduled post/page', () => {
|
184
|
-
beforeAll( async () => {
|
185
|
-
await trashAllPosts( 'post' );
|
186
|
-
await trashAllPosts( 'page' );
|
187
|
-
} );
|
188
|
-
afterEach( async () => {
|
189
|
-
await setBrowserViewport( 'large' );
|
190
|
-
} );
|
191
|
-
|
192
|
-
[ 'large', 'small' ].forEach( ( viewport ) => {
|
193
|
-
describe( `in a ${ viewport } viewport`, () => {
|
194
|
-
[ 'post', 'page' ].forEach( ( postType ) => {
|
195
|
-
const buttonText =
|
196
|
-
viewport === 'large' ? 'Switch to draft' : 'Draft';
|
197
|
-
beforeEach( async () => {
|
198
|
-
await setBrowserViewport( viewport );
|
199
|
-
} );
|
200
|
-
|
201
|
-
it( `should leave a scheduled ${ postType } scheduled if canceled`, async () => {
|
202
|
-
scheduleTestPost( postType, viewport );
|
203
|
-
|
204
|
-
const switchToDraftButton = await page.waitForXPath(
|
205
|
-
`//button[contains(text(), "${ buttonText }")]`
|
206
|
-
);
|
207
|
-
await switchToDraftButton.click();
|
208
|
-
|
209
|
-
// Process the ConfirmDialog
|
210
|
-
await page.waitForXPath(
|
211
|
-
'//*[text()="Are you sure you want to unschedule this post?"]'
|
212
|
-
);
|
213
|
-
const [ cancelButton ] = await page.$x(
|
214
|
-
'//*[@role="dialog"][not(@id="wp-link-wrap")]//button[text()="Cancel"]'
|
215
|
-
);
|
216
|
-
await cancelButton.click();
|
217
|
-
|
218
|
-
// Confirm post is still scheduled
|
219
|
-
const postStatus = await page.evaluate( () => {
|
220
|
-
return wp.data
|
221
|
-
.select( 'core/editor' )
|
222
|
-
.getEditedPostAttribute( 'status' );
|
223
|
-
} );
|
224
|
-
expect( postStatus ).toBe( 'future' );
|
225
|
-
} );
|
226
|
-
it( `should revert a scheduled ${ postType } to a draft if confirmed`, async () => {
|
227
|
-
// Switch to draft
|
228
|
-
const switchToDraftButton = await page.waitForXPath(
|
229
|
-
`//button[contains(text(), "${ buttonText }")]`
|
230
|
-
);
|
231
|
-
await switchToDraftButton.click();
|
232
|
-
|
233
|
-
// Process the ConfirmDialog
|
234
|
-
await page.waitForXPath(
|
235
|
-
'//*[text()="Are you sure you want to unschedule this post?"]'
|
236
|
-
);
|
237
|
-
const [ confirmButton ] = await page.$x(
|
238
|
-
'//*[@role="dialog"]//button[text()="OK"]'
|
239
|
-
);
|
240
|
-
await confirmButton.click();
|
241
|
-
|
242
|
-
await verifyRevertToDraft( postType );
|
243
|
-
|
244
|
-
const postStatus = await page.evaluate( () => {
|
245
|
-
return wp.data
|
246
|
-
.select( 'core/editor' )
|
247
|
-
.getEditedPostAttribute( 'status' );
|
248
|
-
} );
|
249
|
-
expect( postStatus ).toBe( 'draft' );
|
250
|
-
} );
|
251
|
-
} );
|
252
|
-
} );
|
253
|
-
} );
|
254
|
-
} );
|