@wordpress/e2e-tests 3.0.5 → 3.0.8
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/package.json +4 -4
- package/specs/editor/blocks/__snapshots__/heading.test.js.snap +8 -8
- package/specs/editor/blocks/__snapshots__/quote.test.js.snap +10 -10
- package/specs/editor/blocks/image.test.js +4 -3
- package/specs/editor/blocks/navigation.test.js +134 -14
- package/specs/editor/plugins/block-directory-add.test.js +15 -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/list-view.test.js +95 -0
- package/specs/editor/various/multi-block-selection.test.js +84 -0
- package/specs/editor/various/post-editor-template-mode.test.js +182 -5
- package/specs/editor/various/post-visibility.test.js +1 -1
- package/specs/editor/various/switch-to-draft.test.js +254 -0
- package/specs/editor/various/writing-flow.test.js +65 -0
- package/specs/performance/site-editor.test.js +5 -6
- package/specs/site-editor/document-settings.test.js +3 -3
- package/specs/site-editor/multi-entity-editing.test.js +5 -5
- package/specs/site-editor/multi-entity-saving.test.js +4 -3
- 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 +18 -18
- package/specs/site-editor/template-revert.test.js +12 -22
- package/specs/widgets/customizing-widgets.test.js +4 -0
@@ -10,6 +10,7 @@ import {
|
|
10
10
|
clickBlockToolbarButton,
|
11
11
|
clickButton,
|
12
12
|
clickMenuItem,
|
13
|
+
openListView,
|
13
14
|
saveDraft,
|
14
15
|
transformBlockTo,
|
15
16
|
} from '@wordpress/e2e-test-utils';
|
@@ -747,4 +748,87 @@ describe( 'Multi-block selection', () => {
|
|
747
748
|
} );
|
748
749
|
expect( selectedText ).toEqual( 'Post title' );
|
749
750
|
} );
|
751
|
+
|
752
|
+
it( 'should multi-select in the ListView component with shift + click', async () => {
|
753
|
+
// Create four blocks.
|
754
|
+
await clickBlockAppender();
|
755
|
+
await page.keyboard.type( '1' );
|
756
|
+
await page.keyboard.press( 'Enter' );
|
757
|
+
await page.keyboard.type( '2' );
|
758
|
+
await page.keyboard.press( 'Enter' );
|
759
|
+
await page.keyboard.type( '3' );
|
760
|
+
await page.keyboard.press( 'Enter' );
|
761
|
+
await page.keyboard.type( '4' );
|
762
|
+
|
763
|
+
// Open up the list view, and get a reference to each of the list items.
|
764
|
+
await openListView();
|
765
|
+
const navButtons = await page.$$(
|
766
|
+
'.block-editor-list-view-block-select-button'
|
767
|
+
);
|
768
|
+
|
769
|
+
// Clicking on the second list item should result in the second block being selected.
|
770
|
+
await navButtons[ 1 ].click();
|
771
|
+
expect( await getSelectedFlatIndices() ).toEqual( 2 );
|
772
|
+
|
773
|
+
// Shift clicking the fourth list item should result in blocks 2 through 4 being selected.
|
774
|
+
await page.keyboard.down( 'Shift' );
|
775
|
+
await navButtons[ 3 ].click();
|
776
|
+
expect( await getSelectedFlatIndices() ).toEqual( [ 2, 3, 4 ] );
|
777
|
+
|
778
|
+
// With the shift key still held down, clicking the first block should result in
|
779
|
+
// the first two blocks being selected.
|
780
|
+
await navButtons[ 0 ].click();
|
781
|
+
expect( await getSelectedFlatIndices() ).toEqual( [ 1, 2 ] );
|
782
|
+
|
783
|
+
// With the shift key up, clicking the fourth block should result in only that block
|
784
|
+
// being selected.
|
785
|
+
await page.keyboard.up( 'Shift' );
|
786
|
+
await navButtons[ 3 ].click();
|
787
|
+
expect( await getSelectedFlatIndices() ).toEqual( 4 );
|
788
|
+
} );
|
789
|
+
|
790
|
+
it( 'should multi-select in the ListView component with shift + up and down keys', async () => {
|
791
|
+
// Create four blocks.
|
792
|
+
await clickBlockAppender();
|
793
|
+
await page.keyboard.type( '1' );
|
794
|
+
await page.keyboard.press( 'Enter' );
|
795
|
+
await page.keyboard.type( '2' );
|
796
|
+
await page.keyboard.press( 'Enter' );
|
797
|
+
await page.keyboard.type( '3' );
|
798
|
+
await page.keyboard.press( 'Enter' );
|
799
|
+
await page.keyboard.type( '4' );
|
800
|
+
|
801
|
+
// Open up the list view. The fourth block button will be focused.
|
802
|
+
await openListView();
|
803
|
+
|
804
|
+
// Press Up twice to focus over the second block.
|
805
|
+
await pressKeyTimes( 'ArrowUp', 2 );
|
806
|
+
|
807
|
+
// Shift + press Down to select the 2nd and 3rd blocks.
|
808
|
+
await page.keyboard.down( 'Shift' );
|
809
|
+
await page.keyboard.press( 'ArrowDown' );
|
810
|
+
expect( await getSelectedFlatIndices() ).toEqual( [ 2, 3 ] );
|
811
|
+
|
812
|
+
// Press Down once more to also select the 4th block.
|
813
|
+
await page.keyboard.press( 'ArrowDown' );
|
814
|
+
expect( await getSelectedFlatIndices() ).toEqual( [ 2, 3, 4 ] );
|
815
|
+
|
816
|
+
// Press Up three times to adjust the selection to only include the first two blocks.
|
817
|
+
await pressKeyTimes( 'ArrowUp', 3 );
|
818
|
+
expect( await getSelectedFlatIndices() ).toEqual( [ 1, 2 ] );
|
819
|
+
|
820
|
+
// Raise the shift key
|
821
|
+
await page.keyboard.up( 'Shift' );
|
822
|
+
|
823
|
+
// Navigate to the bottom of the list of blocks.
|
824
|
+
await pressKeyTimes( 'ArrowDown', 3 );
|
825
|
+
|
826
|
+
// Shift + press UP to select the 3rd and 4th blocks.
|
827
|
+
// This tests that shift selecting blocks by keyboard that are not adjacent
|
828
|
+
// to an existing selection resets the selection.
|
829
|
+
await page.keyboard.down( 'Shift' );
|
830
|
+
await page.keyboard.press( 'ArrowUp' );
|
831
|
+
await page.keyboard.up( 'Shift' );
|
832
|
+
expect( await getSelectedFlatIndices() ).toEqual( [ 3, 4 ] );
|
833
|
+
} );
|
750
834
|
} );
|
@@ -6,11 +6,12 @@ import {
|
|
6
6
|
createNewPost,
|
7
7
|
insertBlock,
|
8
8
|
saveDraft,
|
9
|
-
trashAllPosts,
|
10
9
|
openPreviewPage,
|
11
10
|
openDocumentSettingsSidebar,
|
12
11
|
activatePlugin,
|
13
12
|
deactivatePlugin,
|
13
|
+
deleteAllTemplates,
|
14
|
+
setBrowserViewport,
|
14
15
|
} from '@wordpress/e2e-test-utils';
|
15
16
|
|
16
17
|
const openSidebarPanelWithTitle = async ( title ) => {
|
@@ -56,7 +57,7 @@ const switchToTemplateMode = async () => {
|
|
56
57
|
|
57
58
|
// Check that we switched properly to edit mode.
|
58
59
|
await page.waitForXPath(
|
59
|
-
'//*[
|
60
|
+
'//*[text()="Editing template. Changes made here affect all posts and pages that use the template."]'
|
60
61
|
);
|
61
62
|
const title = await page.$eval(
|
62
63
|
'.edit-post-template-top-area',
|
@@ -92,8 +93,8 @@ const createNewTemplate = async ( templateName ) => {
|
|
92
93
|
describe( 'Post Editor Template mode', () => {
|
93
94
|
beforeAll( async () => {
|
94
95
|
await activatePlugin( 'gutenberg-test-block-templates' );
|
95
|
-
await
|
96
|
-
await
|
96
|
+
await deleteAllTemplates( 'wp_template' );
|
97
|
+
await deleteAllTemplates( 'wp_template_part' );
|
97
98
|
} );
|
98
99
|
|
99
100
|
afterAll( async () => {
|
@@ -119,7 +120,6 @@ describe( 'Post Editor Template mode', () => {
|
|
119
120
|
// there's a template resolution bug forcing us to do so.
|
120
121
|
await saveDraft();
|
121
122
|
await page.reload();
|
122
|
-
|
123
123
|
await switchToTemplateMode();
|
124
124
|
|
125
125
|
// Edit the template
|
@@ -197,3 +197,180 @@ describe( 'Post Editor Template mode', () => {
|
|
197
197
|
expect( content ).toMatchSnapshot();
|
198
198
|
} );
|
199
199
|
} );
|
200
|
+
|
201
|
+
describe( 'Delete Post Template Confirmation Dialog', () => {
|
202
|
+
beforeAll( async () => {
|
203
|
+
await activatePlugin( 'gutenberg-test-block-templates' );
|
204
|
+
await deleteAllTemplates( 'wp_template' );
|
205
|
+
await deleteAllTemplates( 'wp_template_part' );
|
206
|
+
await activateTheme( 'twentytwentyone' );
|
207
|
+
await createNewPost();
|
208
|
+
// Create a random post.
|
209
|
+
await page.type( '.editor-post-title__input', 'Just an FSE Post' );
|
210
|
+
await page.keyboard.press( 'Enter' );
|
211
|
+
await page.keyboard.type( 'Hello World' );
|
212
|
+
|
213
|
+
// Save the post
|
214
|
+
// Saving shouldn't be necessary but unfortunately,
|
215
|
+
// there's a template resolution bug forcing us to do so.
|
216
|
+
await saveDraft();
|
217
|
+
await page.reload();
|
218
|
+
// Unselect the blocks.
|
219
|
+
await page.evaluate( () => {
|
220
|
+
wp.data.dispatch( 'core/block-editor' ).clearSelectedBlock();
|
221
|
+
} );
|
222
|
+
} );
|
223
|
+
|
224
|
+
afterAll( async () => {
|
225
|
+
await activateTheme( 'twentytwentyone' );
|
226
|
+
await deactivatePlugin( 'gutenberg-test-block-templates' );
|
227
|
+
} );
|
228
|
+
|
229
|
+
[ 'large', 'small' ].forEach( ( viewport ) => {
|
230
|
+
it( `should retain template if deletion is canceled when the viewport is ${ viewport }`, async () => {
|
231
|
+
await setBrowserViewport( viewport );
|
232
|
+
|
233
|
+
const isWelcomeGuideActive = await page.evaluate( () =>
|
234
|
+
wp.data
|
235
|
+
.select( 'core/edit-post' )
|
236
|
+
.isFeatureActive( 'welcomeGuide' )
|
237
|
+
);
|
238
|
+
if ( isWelcomeGuideActive === true ) {
|
239
|
+
await page.evaluate( () =>
|
240
|
+
wp.data
|
241
|
+
.dispatch( 'core/edit-post' )
|
242
|
+
.toggleFeature( 'welcomeGuide' )
|
243
|
+
);
|
244
|
+
await page.reload();
|
245
|
+
await page.waitForSelector( '.edit-post-layout' );
|
246
|
+
}
|
247
|
+
if ( viewport === 'small' ) {
|
248
|
+
await page.waitForXPath( '//button[@aria-label="Settings"]' );
|
249
|
+
await openDocumentSettingsSidebar();
|
250
|
+
}
|
251
|
+
const templateTitle = `${ viewport } Viewport Deletion Test`;
|
252
|
+
|
253
|
+
await createNewTemplate( templateTitle );
|
254
|
+
// Edit the template
|
255
|
+
if ( viewport === 'small' ) {
|
256
|
+
await page.waitForXPath( `//h2[text()="${ templateTitle }"]` );
|
257
|
+
const closeDocumentSettingsButton = await page.waitForXPath(
|
258
|
+
'//button[@aria-label="Close settings"]'
|
259
|
+
);
|
260
|
+
await closeDocumentSettingsButton.click();
|
261
|
+
}
|
262
|
+
await insertBlock( 'Paragraph' );
|
263
|
+
await page.keyboard.type(
|
264
|
+
'Just a random paragraph added to the template'
|
265
|
+
);
|
266
|
+
|
267
|
+
// Save changes
|
268
|
+
const publishButton = await page.waitForXPath(
|
269
|
+
`//button[contains(text(), 'Publish')]`
|
270
|
+
);
|
271
|
+
await publishButton.click();
|
272
|
+
const saveButton = await page.waitForXPath(
|
273
|
+
`//div[contains(@class, "entities-saved-states__panel-header")]/button[contains(text(), 'Save')]`
|
274
|
+
);
|
275
|
+
await saveButton.click();
|
276
|
+
// Avoid publishing the post
|
277
|
+
// Select the cancel button via parent div's class, because the text `Cancel` is used on another button as well
|
278
|
+
const cancelButton = await page.waitForXPath(
|
279
|
+
`//div[contains(@class,"editor-post-publish-panel__header-cancel-button")]/button[not(@disabled)]`
|
280
|
+
);
|
281
|
+
await cancelButton.click();
|
282
|
+
|
283
|
+
const templateDropdown = await page.waitForXPath(
|
284
|
+
`//button[contains(text(), '${ templateTitle }')]`
|
285
|
+
);
|
286
|
+
await templateDropdown.click();
|
287
|
+
const deleteTemplateButton = await page.waitForXPath(
|
288
|
+
'//button[@role="menuitem"][@aria-label="Delete template"]'
|
289
|
+
);
|
290
|
+
await deleteTemplateButton.click();
|
291
|
+
|
292
|
+
await page.waitForXPath(
|
293
|
+
`//*[text()="Are you sure you want to delete the ${ templateTitle } template? It may be used by other pages or posts."]`
|
294
|
+
);
|
295
|
+
const dialogCancelButton = await page.waitForXPath(
|
296
|
+
'//*[@role="dialog"][not(@id="wp-link-wrap")]//button[text()="Cancel"]'
|
297
|
+
);
|
298
|
+
await dialogCancelButton.click();
|
299
|
+
|
300
|
+
const exitTemplateModeButton = await page.waitForXPath(
|
301
|
+
'//button[text()="Back"]'
|
302
|
+
);
|
303
|
+
await exitTemplateModeButton.click();
|
304
|
+
|
305
|
+
await page.waitForXPath(
|
306
|
+
'//button[@aria-label="Settings"][@aria-expanded="false"]'
|
307
|
+
);
|
308
|
+
await openDocumentSettingsSidebar();
|
309
|
+
|
310
|
+
const element = await page.waitForXPath(
|
311
|
+
'//h2/button[contains(text(), "Template")]/../..//select'
|
312
|
+
);
|
313
|
+
const value = await element.getProperty( 'value' );
|
314
|
+
const currentTemplateSlug = await value.jsonValue();
|
315
|
+
|
316
|
+
expect( currentTemplateSlug ).toBe(
|
317
|
+
`wp-custom-template-${ viewport }-viewport-deletion-test`
|
318
|
+
);
|
319
|
+
} );
|
320
|
+
|
321
|
+
it( `should delete template if deletion is confirmed when the viewport is ${ viewport }`, async () => {
|
322
|
+
const templateTitle = `${ viewport } Viewport Deletion Test`;
|
323
|
+
|
324
|
+
await setBrowserViewport( viewport );
|
325
|
+
|
326
|
+
await switchToTemplateMode();
|
327
|
+
if ( viewport === 'small' ) {
|
328
|
+
const closeDocumentSettingsButton = await page.waitForXPath(
|
329
|
+
'//div[contains(@class,"interface-complementary-area-header__small")]/button[@aria-label="Close settings"]'
|
330
|
+
);
|
331
|
+
await closeDocumentSettingsButton.click();
|
332
|
+
}
|
333
|
+
|
334
|
+
const templateDropdown = await page.waitForXPath(
|
335
|
+
`//button[contains(text(), '${ templateTitle }')]`
|
336
|
+
);
|
337
|
+
await templateDropdown.click();
|
338
|
+
|
339
|
+
const deleteTemplateButton = await page.waitForXPath(
|
340
|
+
'//button[@role="menuitem"][@aria-label="Delete template"]'
|
341
|
+
);
|
342
|
+
await deleteTemplateButton.click();
|
343
|
+
|
344
|
+
await page.waitForXPath(
|
345
|
+
`//*[text()="Are you sure you want to delete the ${ templateTitle } template? It may be used by other pages or posts."]`
|
346
|
+
);
|
347
|
+
const dialogConfirmButton = await page.waitForXPath(
|
348
|
+
'//*[@role="dialog"][not(@id="wp-link-wrap")]//button[text()="OK"]'
|
349
|
+
);
|
350
|
+
|
351
|
+
await dialogConfirmButton.click();
|
352
|
+
|
353
|
+
// Saving isn't technically necessary, but for themes without any specified templates,
|
354
|
+
// the removal of the Templates dropdown is delayed. A save and reload allows for this
|
355
|
+
// delay and prevents flakiness
|
356
|
+
await saveDraft();
|
357
|
+
await page.reload();
|
358
|
+
|
359
|
+
const optionElementHandlers = await page.$x(
|
360
|
+
'//h2/button[contains(text(), "Template")]/../..//select/option'
|
361
|
+
);
|
362
|
+
const availableTemplates = [];
|
363
|
+
for ( const elem of optionElementHandlers ) {
|
364
|
+
const elemName = await elem.getProperty( 'textContent' );
|
365
|
+
const templateName = await elemName.jsonValue();
|
366
|
+
availableTemplates.push( templateName );
|
367
|
+
}
|
368
|
+
|
369
|
+
expect(
|
370
|
+
availableTemplates.includes(
|
371
|
+
`${ viewport } Viewport Deletion Test`
|
372
|
+
)
|
373
|
+
).toBe( false );
|
374
|
+
} );
|
375
|
+
} );
|
376
|
+
} );
|
@@ -96,7 +96,7 @@ describe( 'Post visibility', () => {
|
|
96
96
|
);
|
97
97
|
await (
|
98
98
|
await page.$x(
|
99
|
-
'
|
99
|
+
'//*[@role="application"][@aria-label="Calendar"]//td[@role="button"]/*[text() = "15"]'
|
100
100
|
)
|
101
101
|
)[ 0 ].click();
|
102
102
|
|
@@ -0,0 +1,254 @@
|
|
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( '//td[@role="button"]/*[text() = "15"]' )
|
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
|
+
} );
|
@@ -437,6 +437,44 @@ describe( 'Writing Flow', () => {
|
|
437
437
|
expect( await getEditedPostContent() ).toMatchSnapshot();
|
438
438
|
} );
|
439
439
|
|
440
|
+
it( 'should merge and then split paragraphs', async () => {
|
441
|
+
await page.keyboard.press( 'Enter' );
|
442
|
+
await page.keyboard.type( 'abc' );
|
443
|
+
await page.keyboard.press( 'Enter' );
|
444
|
+
await page.keyboard.type( '123' );
|
445
|
+
await page.keyboard.press( 'ArrowUp' );
|
446
|
+
await page.keyboard.press( 'Delete' );
|
447
|
+
await page.keyboard.press( 'Enter' );
|
448
|
+
|
449
|
+
expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
|
450
|
+
"<!-- wp:paragraph -->
|
451
|
+
<p>abc</p>
|
452
|
+
<!-- /wp:paragraph -->
|
453
|
+
|
454
|
+
<!-- wp:paragraph -->
|
455
|
+
<p>123</p>
|
456
|
+
<!-- /wp:paragraph -->"
|
457
|
+
` );
|
458
|
+
} );
|
459
|
+
|
460
|
+
it( 'should merge and then soft line break', async () => {
|
461
|
+
await page.keyboard.press( 'Enter' );
|
462
|
+
await page.keyboard.type( '1' );
|
463
|
+
await page.keyboard.press( 'Enter' );
|
464
|
+
await page.keyboard.type( '2' );
|
465
|
+
await page.keyboard.press( 'ArrowUp' );
|
466
|
+
await page.keyboard.press( 'Delete' );
|
467
|
+
await page.keyboard.down( 'Shift' );
|
468
|
+
await page.keyboard.press( 'Enter' );
|
469
|
+
await page.keyboard.up( 'Shift' );
|
470
|
+
|
471
|
+
expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
|
472
|
+
"<!-- wp:paragraph -->
|
473
|
+
<p>1<br>2</p>
|
474
|
+
<!-- /wp:paragraph -->"
|
475
|
+
` );
|
476
|
+
} );
|
477
|
+
|
440
478
|
it( 'should merge forwards', async () => {
|
441
479
|
await page.keyboard.press( 'Enter' );
|
442
480
|
await page.keyboard.type( '1' );
|
@@ -449,6 +487,33 @@ describe( 'Writing Flow', () => {
|
|
449
487
|
expect( await getEditedPostContent() ).toMatchSnapshot();
|
450
488
|
} );
|
451
489
|
|
490
|
+
it( 'should merge forwards properly on multiple triggers', async () => {
|
491
|
+
await page.keyboard.press( 'Enter' );
|
492
|
+
await page.keyboard.type( '1' );
|
493
|
+
await page.keyboard.press( 'Enter' );
|
494
|
+
await page.keyboard.type( '2' );
|
495
|
+
await page.keyboard.press( 'Enter' );
|
496
|
+
await page.keyboard.type( '3' );
|
497
|
+
await pressKeyTimes( 'ArrowUp', 2 );
|
498
|
+
await pressKeyTimes( 'Delete', 2 );
|
499
|
+
expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
|
500
|
+
"<!-- wp:paragraph -->
|
501
|
+
<p>1</p>
|
502
|
+
<!-- /wp:paragraph -->
|
503
|
+
|
504
|
+
<!-- wp:paragraph -->
|
505
|
+
<p>3</p>
|
506
|
+
<!-- /wp:paragraph -->"
|
507
|
+
` );
|
508
|
+
await page.keyboard.press( 'Delete' );
|
509
|
+
|
510
|
+
expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
|
511
|
+
"<!-- wp:paragraph -->
|
512
|
+
<p>13</p>
|
513
|
+
<!-- /wp:paragraph -->"
|
514
|
+
` );
|
515
|
+
} );
|
516
|
+
|
452
517
|
it( 'should preserve horizontal position when navigating vertically between blocks', async () => {
|
453
518
|
await page.keyboard.press( 'Enter' );
|
454
519
|
await page.keyboard.type( 'abc' );
|
@@ -8,13 +8,13 @@ import { writeFileSync } from 'fs';
|
|
8
8
|
* WordPress dependencies
|
9
9
|
*/
|
10
10
|
import {
|
11
|
-
trashAllPosts,
|
12
11
|
activateTheme,
|
13
12
|
canvas,
|
14
13
|
createNewPost,
|
15
14
|
visitSiteEditor,
|
16
15
|
saveDraft,
|
17
16
|
insertBlock,
|
17
|
+
deleteAllTemplates,
|
18
18
|
} from '@wordpress/e2e-test-utils';
|
19
19
|
|
20
20
|
/**
|
@@ -32,13 +32,12 @@ jest.setTimeout( 1000000 );
|
|
32
32
|
describe( 'Site Editor Performance', () => {
|
33
33
|
beforeAll( async () => {
|
34
34
|
await activateTheme( 'emptytheme' );
|
35
|
-
await
|
36
|
-
await
|
37
|
-
await trashAllPosts( 'wp_template_part' );
|
35
|
+
await deleteAllTemplates( 'wp_template' );
|
36
|
+
await deleteAllTemplates( 'wp_template_part' );
|
38
37
|
} );
|
39
38
|
afterAll( async () => {
|
40
|
-
await
|
41
|
-
await
|
39
|
+
await deleteAllTemplates( 'wp_template' );
|
40
|
+
await deleteAllTemplates( 'wp_template_part' );
|
42
41
|
await activateTheme( 'twentytwentyone' );
|
43
42
|
} );
|
44
43
|
|