@wordpress/e2e-tests 5.4.0 → 5.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 +2 -0
- package/package.json +7 -7
- package/specs/editor/blocks/cover.test.js +1 -1
- package/specs/editor/blocks/navigation.test.js +1 -1
- package/specs/editor/blocks/site-title.test.js +11 -7
- package/specs/editor/various/block-hierarchy-navigation.test.js +1 -1
- package/specs/editor/various/font-size-picker.test.js +1 -1
- package/specs/site-editor/multi-entity-saving.test.js +20 -20
- package/specs/editor/blocks/columns.test.js +0 -31
- package/specs/editor/blocks/gallery.test.js +0 -156
- package/specs/editor/plugins/__snapshots__/templates.test.js.snap +0 -69
- package/specs/editor/plugins/templates.test.js +0 -126
- package/specs/editor/various/__snapshots__/compatibility-classic-editor.test.js.snap +0 -7
- package/specs/editor/various/__snapshots__/splitting-merging.test.js.snap +0 -101
- package/specs/editor/various/compatibility-classic-editor.test.js +0 -38
- package/specs/editor/various/fullscreen-mode.test.js +0 -31
- package/specs/editor/various/new-post-default-content.test.js +0 -52
- package/specs/editor/various/splitting-merging.test.js +0 -303
- package/specs/site-editor/iframe-rendering-mode.test.js +0 -31
- package/specs/site-editor/site-editor-inserter.test.js +0 -33
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@wordpress/e2e-tests",
|
3
|
-
"version": "5.
|
3
|
+
"version": "5.5.0",
|
4
4
|
"description": "End-To-End (E2E) tests for WordPress.",
|
5
5
|
"author": "The WordPress Contributors",
|
6
6
|
"license": "GPL-2.0-or-later",
|
@@ -23,11 +23,11 @@
|
|
23
23
|
"node": ">=14"
|
24
24
|
},
|
25
25
|
"dependencies": {
|
26
|
-
"@wordpress/e2e-test-utils": "^8.
|
27
|
-
"@wordpress/jest-console": "^6.
|
28
|
-
"@wordpress/jest-puppeteer-axe": "^5.
|
29
|
-
"@wordpress/scripts": "^24.
|
30
|
-
"@wordpress/url": "^3.
|
26
|
+
"@wordpress/e2e-test-utils": "^8.5.0",
|
27
|
+
"@wordpress/jest-console": "^6.4.0",
|
28
|
+
"@wordpress/jest-puppeteer-axe": "^5.4.0",
|
29
|
+
"@wordpress/scripts": "^24.5.0",
|
30
|
+
"@wordpress/url": "^3.22.0",
|
31
31
|
"chalk": "^4.0.0",
|
32
32
|
"expect-puppeteer": "^4.4.0",
|
33
33
|
"filenamify": "^4.2.0",
|
@@ -46,5 +46,5 @@
|
|
46
46
|
"publishConfig": {
|
47
47
|
"access": "public"
|
48
48
|
},
|
49
|
-
"gitHead": "
|
49
|
+
"gitHead": "511f4cc1f0138641bc4394bc1cf36e833109c791"
|
50
50
|
}
|
@@ -134,7 +134,7 @@ describe( 'Cover', () => {
|
|
134
134
|
|
135
135
|
const heightInput = (
|
136
136
|
await page.$x(
|
137
|
-
'//div[./label[contains(text(),"Minimum height of cover")]]//input'
|
137
|
+
'//div[./label[contains(text(),"Minimum height of cover")]]/following-sibling::div//input'
|
138
138
|
)
|
139
139
|
)[ 0 ];
|
140
140
|
|
@@ -506,7 +506,7 @@ Expected mock function not to be called but it was called with: ["POST", "http:/
|
|
506
506
|
// outside of the Nav block.
|
507
507
|
await insertBlock( 'Paragraph' );
|
508
508
|
|
509
|
-
//
|
509
|
+
// Acquire fresh reference to block
|
510
510
|
navBlock = await waitForBlock( 'Navigation' );
|
511
511
|
|
512
512
|
// Check Placeholder Preview is visible.
|
@@ -3,13 +3,12 @@
|
|
3
3
|
*/
|
4
4
|
import {
|
5
5
|
createNewPost,
|
6
|
-
createUser,
|
7
|
-
deleteUser,
|
8
6
|
getOption,
|
9
7
|
insertBlock,
|
10
8
|
loginUser,
|
11
9
|
pressKeyWithModifier,
|
12
10
|
setOption,
|
11
|
+
openDocumentSettingsSidebar,
|
13
12
|
} from '@wordpress/e2e-test-utils';
|
14
13
|
|
15
14
|
const saveEntities = async () => {
|
@@ -35,11 +34,9 @@ describe( 'Site Title block', () => {
|
|
35
34
|
const username = 'testuser';
|
36
35
|
beforeAll( async () => {
|
37
36
|
originalSiteTitle = await getOption( 'blogname' );
|
38
|
-
password = await createUser( username, { role: 'editor' } );
|
39
37
|
} );
|
40
38
|
|
41
39
|
afterAll( async () => {
|
42
|
-
await deleteUser( username );
|
43
40
|
await setOption( 'blogname', originalSiteTitle );
|
44
41
|
} );
|
45
42
|
|
@@ -70,11 +67,18 @@ describe( 'Site Title block', () => {
|
|
70
67
|
await createNewPost();
|
71
68
|
await insertBlock( 'Site Title' );
|
72
69
|
|
73
|
-
|
74
|
-
|
70
|
+
await openDocumentSettingsSidebar();
|
71
|
+
|
72
|
+
const [ disableLink ] = await page.$x(
|
73
|
+
"//label[contains(text(), 'Make title link to home')]"
|
74
|
+
);
|
75
|
+
await disableLink.click();
|
76
|
+
|
77
|
+
const siteTitleSelector = '[aria-label="Block: Site Title"] span';
|
78
|
+
await page.waitForSelector( siteTitleSelector );
|
75
79
|
|
76
80
|
const editable = await page.$eval(
|
77
|
-
|
81
|
+
siteTitleSelector,
|
78
82
|
( element ) => element.contentEditable
|
79
83
|
);
|
80
84
|
expect( editable ).toBe( 'inherit' );
|
@@ -119,7 +119,7 @@ describe( 'Navigating the block hierarchy', () => {
|
|
119
119
|
// Navigate to the third column in the columns block.
|
120
120
|
await pressKeyWithModifier( 'ctrl', '`' );
|
121
121
|
await pressKeyWithModifier( 'ctrl', '`' );
|
122
|
-
await pressKeyTimes( 'Tab',
|
122
|
+
await pressKeyTimes( 'Tab', 4 );
|
123
123
|
await pressKeyTimes( 'ArrowDown', 4 );
|
124
124
|
await page.waitForSelector(
|
125
125
|
'.is-highlighted[aria-label="Block: Column (3 of 3)"]'
|
@@ -233,7 +233,7 @@ describe( 'Font Size Picker', () => {
|
|
233
233
|
await page.keyboard.type( 'Paragraph to be made "large"' );
|
234
234
|
|
235
235
|
await clickFontSizeButtonByLabel( 'Large' );
|
236
|
-
const buttonSelector = `${ FONT_SIZE_TOGGLE_GROUP_SELECTOR }//
|
236
|
+
const buttonSelector = `${ FONT_SIZE_TOGGLE_GROUP_SELECTOR }//button[@aria-checked='true']`;
|
237
237
|
const [ activeButton ] = await page.$x( buttonSelector );
|
238
238
|
const activeLabel = await page.evaluate(
|
239
239
|
( element ) => element?.getAttribute( 'aria-label' ),
|
@@ -31,7 +31,7 @@ describe( 'Multi-entity save flow', () => {
|
|
31
31
|
const checkboxInputs = await page.$$( checkboxInputSelector );
|
32
32
|
expect( checkedBoxes.length - checkboxInputs.length ).toBe( 0 );
|
33
33
|
};
|
34
|
-
const
|
34
|
+
const assertExistence = async ( selector, shouldBePresent ) => {
|
35
35
|
const element = await page.$( selector );
|
36
36
|
if ( shouldBePresent ) {
|
37
37
|
expect( element ).not.toBeNull();
|
@@ -102,10 +102,10 @@ describe( 'Multi-entity save flow', () => {
|
|
102
102
|
await assertMultiSaveDisabled();
|
103
103
|
|
104
104
|
// Should only have publish panel a11y button active with only post edited.
|
105
|
-
await
|
106
|
-
await
|
107
|
-
await
|
108
|
-
await
|
105
|
+
await assertExistence( publishA11ySelector, true );
|
106
|
+
await assertExistence( saveA11ySelector, false );
|
107
|
+
await assertExistence( publishPanelSelector, false );
|
108
|
+
await assertExistence( savePanelSelector, false );
|
109
109
|
|
110
110
|
// Add a reusable block and edit it.
|
111
111
|
await createReusableBlock( 'Hi!', 'Test' );
|
@@ -117,10 +117,10 @@ describe( 'Multi-entity save flow', () => {
|
|
117
117
|
await assertMultiSaveEnabled();
|
118
118
|
|
119
119
|
// Should only have save panel a11y button active after child entities edited.
|
120
|
-
await
|
121
|
-
await
|
122
|
-
await
|
123
|
-
await
|
120
|
+
await assertExistence( publishA11ySelector, false );
|
121
|
+
await assertExistence( saveA11ySelector, true );
|
122
|
+
await assertExistence( publishPanelSelector, false );
|
123
|
+
await assertExistence( savePanelSelector, false );
|
124
124
|
|
125
125
|
// Opening panel has boxes checked by default.
|
126
126
|
await page.click( savePostSelector );
|
@@ -128,18 +128,18 @@ describe( 'Multi-entity save flow', () => {
|
|
128
128
|
await assertAllBoxesChecked();
|
129
129
|
|
130
130
|
// Should not show other panels (or their a11y buttons) while save panel opened.
|
131
|
-
await
|
132
|
-
await
|
133
|
-
await
|
131
|
+
await assertExistence( publishA11ySelector, false );
|
132
|
+
await assertExistence( saveA11ySelector, false );
|
133
|
+
await assertExistence( publishPanelSelector, false );
|
134
134
|
|
135
135
|
// Publish panel should open after saving.
|
136
136
|
await page.click( entitiesSaveSelector );
|
137
137
|
await page.waitForSelector( publishPanelSelector );
|
138
138
|
|
139
139
|
// No other panels (or their a11y buttons) should be present with publish panel open.
|
140
|
-
await
|
141
|
-
await
|
142
|
-
await
|
140
|
+
await assertExistence( publishA11ySelector, false );
|
141
|
+
await assertExistence( saveA11ySelector, false );
|
142
|
+
await assertExistence( savePanelSelector, false );
|
143
143
|
|
144
144
|
// Close publish panel.
|
145
145
|
const closePanelButton = await page.waitForSelector(
|
@@ -151,7 +151,7 @@ describe( 'Multi-entity save flow', () => {
|
|
151
151
|
const draftSaved = await page.waitForSelector( draftSavedSelector );
|
152
152
|
expect( draftSaved ).not.toBeNull();
|
153
153
|
await assertMultiSaveDisabled();
|
154
|
-
await
|
154
|
+
await assertExistence( saveA11ySelector, false );
|
155
155
|
|
156
156
|
await publishPost();
|
157
157
|
// Wait for the success notice specifically for the published post.
|
@@ -178,7 +178,7 @@ describe( 'Multi-entity save flow', () => {
|
|
178
178
|
expect( enabledSaveButton ).not.toBeNull();
|
179
179
|
// Verify multi-entity saving not enabled.
|
180
180
|
await assertMultiSaveDisabled();
|
181
|
-
await
|
181
|
+
await assertExistence( saveA11ySelector, false );
|
182
182
|
|
183
183
|
// Update reusable block again.
|
184
184
|
await page.click( 'p[data-type="core/paragraph"]' );
|
@@ -188,7 +188,7 @@ describe( 'Multi-entity save flow', () => {
|
|
188
188
|
|
189
189
|
// Multi-entity saving should be enabled.
|
190
190
|
await assertMultiSaveEnabled();
|
191
|
-
await
|
191
|
+
await assertExistence( saveA11ySelector, true );
|
192
192
|
} );
|
193
193
|
|
194
194
|
it( 'Site blocks should save individually', async () => {
|
@@ -252,7 +252,7 @@ describe( 'Multi-entity save flow', () => {
|
|
252
252
|
await assertAllBoxesChecked();
|
253
253
|
|
254
254
|
// Save a11y button should not be present with save panel open.
|
255
|
-
await
|
255
|
+
await assertExistence( saveA11ySelector, false );
|
256
256
|
|
257
257
|
// Saving should result in items being saved.
|
258
258
|
await page.click( entitiesSaveSelector );
|
@@ -284,7 +284,7 @@ describe( 'Multi-entity save flow', () => {
|
|
284
284
|
expect( enabledButton ).not.toBeNull();
|
285
285
|
|
286
286
|
// Save a11y button should be present.
|
287
|
-
await
|
287
|
+
await assertExistence( saveA11ySelector, true );
|
288
288
|
|
289
289
|
// Save all changes.
|
290
290
|
await saveAllChanges();
|
@@ -1,31 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import {
|
5
|
-
createNewPost,
|
6
|
-
getAllBlockInserterItemTitles,
|
7
|
-
insertBlock,
|
8
|
-
openGlobalBlockInserter,
|
9
|
-
closeGlobalBlockInserter,
|
10
|
-
getListViewBlocks,
|
11
|
-
} from '@wordpress/e2e-test-utils';
|
12
|
-
|
13
|
-
describe( 'Columns', () => {
|
14
|
-
beforeEach( async () => {
|
15
|
-
await createNewPost();
|
16
|
-
} );
|
17
|
-
|
18
|
-
it( 'restricts all blocks inside the columns block', async () => {
|
19
|
-
await insertBlock( 'Columns' );
|
20
|
-
await closeGlobalBlockInserter();
|
21
|
-
await page.click( '[aria-label="Two columns; equal split"]' );
|
22
|
-
await page.click( '.edit-post-header-toolbar__list-view-toggle' );
|
23
|
-
|
24
|
-
const columnBlockMenuItem = (
|
25
|
-
await getListViewBlocks( 'Column' )
|
26
|
-
)[ 0 ];
|
27
|
-
await columnBlockMenuItem.click();
|
28
|
-
await openGlobalBlockInserter();
|
29
|
-
expect( await getAllBlockInserterItemTitles() ).toHaveLength( 1 );
|
30
|
-
} );
|
31
|
-
} );
|
@@ -1,156 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* External dependencies
|
3
|
-
*/
|
4
|
-
import path from 'path';
|
5
|
-
import fs from 'fs';
|
6
|
-
import os from 'os';
|
7
|
-
import { v4 as uuid } from 'uuid';
|
8
|
-
|
9
|
-
/**
|
10
|
-
* WordPress dependencies
|
11
|
-
*/
|
12
|
-
import {
|
13
|
-
insertBlock,
|
14
|
-
getEditedPostContent,
|
15
|
-
createNewPost,
|
16
|
-
clickButton,
|
17
|
-
openListView,
|
18
|
-
getListViewBlocks,
|
19
|
-
clickBlockToolbarButton,
|
20
|
-
} from '@wordpress/e2e-test-utils';
|
21
|
-
|
22
|
-
async function upload( selector ) {
|
23
|
-
await page.waitForSelector( selector );
|
24
|
-
const inputElement = await page.$( selector );
|
25
|
-
const testImagePath = path.join(
|
26
|
-
__dirname,
|
27
|
-
'..',
|
28
|
-
'..',
|
29
|
-
'..',
|
30
|
-
'assets',
|
31
|
-
'10x10_e2e_test_image_z9T8jK.png'
|
32
|
-
);
|
33
|
-
const filename = uuid();
|
34
|
-
const tmpFileName = path.join( os.tmpdir(), filename + '.png' );
|
35
|
-
fs.copyFileSync( testImagePath, tmpFileName );
|
36
|
-
await inputElement.uploadFile( tmpFileName );
|
37
|
-
await page.waitForSelector(
|
38
|
-
`.wp-block-gallery img[src$="${ filename }.png"]`
|
39
|
-
);
|
40
|
-
return filename;
|
41
|
-
}
|
42
|
-
|
43
|
-
describe( 'Gallery', () => {
|
44
|
-
beforeEach( async () => {
|
45
|
-
await createNewPost();
|
46
|
-
} );
|
47
|
-
|
48
|
-
it( 'can be created using uploaded images', async () => {
|
49
|
-
await insertBlock( 'Gallery' );
|
50
|
-
const filename = await upload( '.wp-block-gallery input[type="file"]' );
|
51
|
-
|
52
|
-
const regex = new RegExp(
|
53
|
-
`<!-- wp:gallery {\\"linkTo\\":\\"none\\"} -->\\s*<figure class=\\"wp-block-gallery has-nested-images columns-default is-cropped\\"><!-- wp:image {\\"id\\":\\d+,\\"sizeSlug\\":\\"(?:full|large)\\",\\"linkDestination\\":\\"none\\"} -->\\s*<figure class=\\"wp-block-image (?:size-full|size-large)\\"><img src=\\"[^"]+\/${ filename }\.png\\" alt=\\"\\" class=\\"wp-image-\\d+\\"\/><\/figure>\\s*<!-- \/wp:image --><\/figure>\\s*<!-- \/wp:gallery -->`
|
54
|
-
);
|
55
|
-
expect( await getEditedPostContent() ).toMatch( regex );
|
56
|
-
} );
|
57
|
-
|
58
|
-
it( 'gallery caption can be edited', async () => {
|
59
|
-
const galleryCaption = 'Tested gallery caption';
|
60
|
-
|
61
|
-
await insertBlock( 'Gallery' );
|
62
|
-
await upload( '.wp-block-gallery input[type="file"]' );
|
63
|
-
await page.waitForSelector( '.wp-block-gallery .wp-block-image' );
|
64
|
-
|
65
|
-
// The Gallery needs to be selected from the List view panel due to the
|
66
|
-
// way that Image uploads take and lose focus.
|
67
|
-
await openListView();
|
68
|
-
|
69
|
-
const galleryListLink = ( await getListViewBlocks( 'Gallery' ) )[ 0 ];
|
70
|
-
await galleryListLink.click();
|
71
|
-
|
72
|
-
await page.click( '.wp-block-gallery .blocks-gallery-caption' );
|
73
|
-
|
74
|
-
await page.keyboard.type( galleryCaption );
|
75
|
-
|
76
|
-
expect( await getEditedPostContent() ).toMatch(
|
77
|
-
new RegExp( `<figcaption.*?>${ galleryCaption }</figcaption>` )
|
78
|
-
);
|
79
|
-
} );
|
80
|
-
|
81
|
-
it( "uploaded images' captions can be edited", async () => {
|
82
|
-
await insertBlock( 'Gallery' );
|
83
|
-
await upload( '.wp-block-gallery input[type="file"]' );
|
84
|
-
|
85
|
-
const figureElement = await page.waitForSelector(
|
86
|
-
'.wp-block-gallery .wp-block-image'
|
87
|
-
);
|
88
|
-
|
89
|
-
// Check that the Image is unselected, in which case the figcaption won't be
|
90
|
-
// in the DOM - due the way that the Gallery block handles the upload the latest
|
91
|
-
// image gets selected in order to scroll to the position of it, as in large
|
92
|
-
// galleries the new upload may be off-canvas. After upload the image is unselected
|
93
|
-
// so if we don't check for that it may get unselected again by this flow after we
|
94
|
-
// have re-selected it to edit it.
|
95
|
-
await page.waitForFunction(
|
96
|
-
() => ! document.querySelector( '.wp-block-image figcaption' )
|
97
|
-
);
|
98
|
-
|
99
|
-
// The Image needs to be selected from the List view panel due to the
|
100
|
-
// way that Image uploads take and lose focus.
|
101
|
-
await openListView();
|
102
|
-
|
103
|
-
// Due to collapsed state of ListView nodes Gallery must be expanded to reveal the child blocks.
|
104
|
-
// This xpath selects the anchor node for the block which has a child span which contains the text
|
105
|
-
// label of the block and then selects the expander span for that node.
|
106
|
-
const galleryExpander = await page.waitForXPath(
|
107
|
-
`//a[.//span[text()='Gallery']]/span[contains(@class, 'block-editor-list-view__expander')]`
|
108
|
-
);
|
109
|
-
|
110
|
-
await galleryExpander.click();
|
111
|
-
|
112
|
-
const imageListLink = ( await getListViewBlocks( 'Image' ) )[ 0 ];
|
113
|
-
await imageListLink.click();
|
114
|
-
await clickBlockToolbarButton( 'Caption' );
|
115
|
-
const captionElement = await figureElement.$(
|
116
|
-
'.block-editor-rich-text__editable'
|
117
|
-
);
|
118
|
-
|
119
|
-
await captionElement.click();
|
120
|
-
const caption = 'Tested caption';
|
121
|
-
|
122
|
-
await page.keyboard.type( caption );
|
123
|
-
|
124
|
-
expect( await getEditedPostContent() ).toMatch(
|
125
|
-
new RegExp( `<figcaption.*?>${ caption }</figcaption>` )
|
126
|
-
);
|
127
|
-
} );
|
128
|
-
|
129
|
-
// Disable reason:
|
130
|
-
// This test would be good to enable, but the media modal contains an
|
131
|
-
// invalid role, which is causing Axe tests to fail:
|
132
|
-
// https://core.trac.wordpress.org/ticket/50273
|
133
|
-
//
|
134
|
-
// Attempts to add an Axe exception for the media modal haven't proved
|
135
|
-
// successful:
|
136
|
-
// https://github.com/WordPress/gutenberg/pull/22719
|
137
|
-
//
|
138
|
-
// This test could be re-enabled once the trac ticket is solved.
|
139
|
-
// eslint-disable-next-line jest/no-disabled-tests
|
140
|
-
it.skip( 'when initially added the media library shows the Create Gallery view', async () => {
|
141
|
-
await insertBlock( 'Gallery' );
|
142
|
-
await clickButton( 'Media Library' );
|
143
|
-
await page.waitForSelector( '.media-frame' );
|
144
|
-
const mediaLibraryHeaderText = await page.$eval(
|
145
|
-
'.media-frame-title h1',
|
146
|
-
( element ) => element.textContent
|
147
|
-
);
|
148
|
-
const mediaLibraryButtonText = await page.$eval(
|
149
|
-
'.media-toolbar-primary button',
|
150
|
-
( element ) => element.textContent
|
151
|
-
);
|
152
|
-
|
153
|
-
expect( mediaLibraryHeaderText ).toBe( 'Create Gallery' );
|
154
|
-
expect( mediaLibraryButtonText ).toBe( 'Create a new gallery' );
|
155
|
-
} );
|
156
|
-
} );
|
@@ -1,69 +0,0 @@
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
-
|
3
|
-
exports[`templates Using a CPT with a predefined template Should add a custom post types with a predefined template 1`] = `
|
4
|
-
"<!-- wp:image -->
|
5
|
-
<figure class=\\"wp-block-image\\"><img alt=\\"\\"/></figure>
|
6
|
-
<!-- /wp:image -->
|
7
|
-
|
8
|
-
<!-- wp:paragraph {\\"placeholder\\":\\"Add a book description\\"} -->
|
9
|
-
<p></p>
|
10
|
-
<!-- /wp:paragraph -->
|
11
|
-
|
12
|
-
<!-- wp:quote -->
|
13
|
-
<blockquote class=\\"wp-block-quote\\"><!-- wp:paragraph -->
|
14
|
-
<p></p>
|
15
|
-
<!-- /wp:paragraph --></blockquote>
|
16
|
-
<!-- /wp:quote -->
|
17
|
-
|
18
|
-
<!-- wp:columns -->
|
19
|
-
<div class=\\"wp-block-columns\\"><!-- wp:column -->
|
20
|
-
<div class=\\"wp-block-column\\"><!-- wp:image -->
|
21
|
-
<figure class=\\"wp-block-image\\"><img alt=\\"\\"/></figure>
|
22
|
-
<!-- /wp:image --></div>
|
23
|
-
<!-- /wp:column -->
|
24
|
-
|
25
|
-
<!-- wp:column -->
|
26
|
-
<div class=\\"wp-block-column\\"><!-- wp:paragraph {\\"placeholder\\":\\"Add a inner paragraph\\"} -->
|
27
|
-
<p></p>
|
28
|
-
<!-- /wp:paragraph --></div>
|
29
|
-
<!-- /wp:column --></div>
|
30
|
-
<!-- /wp:columns -->"
|
31
|
-
`;
|
32
|
-
|
33
|
-
exports[`templates Using a CPT with a predefined template Should respect user edits to not re-apply template after save (full delete) 1`] = `""`;
|
34
|
-
|
35
|
-
exports[`templates Using a CPT with a predefined template Should respect user edits to not re-apply template after save (single block removal) 1`] = `
|
36
|
-
"<!-- wp:paragraph {\\"placeholder\\":\\"Add a book description\\"} -->
|
37
|
-
<p></p>
|
38
|
-
<!-- /wp:paragraph -->
|
39
|
-
|
40
|
-
<!-- wp:quote -->
|
41
|
-
<blockquote class=\\"wp-block-quote\\"><!-- wp:paragraph -->
|
42
|
-
<p></p>
|
43
|
-
<!-- /wp:paragraph --></blockquote>
|
44
|
-
<!-- /wp:quote -->
|
45
|
-
|
46
|
-
<!-- wp:columns -->
|
47
|
-
<div class=\\"wp-block-columns\\"><!-- wp:column -->
|
48
|
-
<div class=\\"wp-block-column\\"><!-- wp:image -->
|
49
|
-
<figure class=\\"wp-block-image\\"><img alt=\\"\\"/></figure>
|
50
|
-
<!-- /wp:image --></div>
|
51
|
-
<!-- /wp:column -->
|
52
|
-
|
53
|
-
<!-- wp:column -->
|
54
|
-
<div class=\\"wp-block-column\\"><!-- wp:paragraph {\\"placeholder\\":\\"Add a inner paragraph\\"} -->
|
55
|
-
<p></p>
|
56
|
-
<!-- /wp:paragraph --></div>
|
57
|
-
<!-- /wp:column --></div>
|
58
|
-
<!-- /wp:columns -->"
|
59
|
-
`;
|
60
|
-
|
61
|
-
exports[`templates With default post format assigned should not populate edited post with default block for format 1`] = `""`;
|
62
|
-
|
63
|
-
exports[`templates With default post format assigned should not populate new page with default block for format 1`] = `""`;
|
64
|
-
|
65
|
-
exports[`templates With default post format assigned should populate new post with default block for format 1`] = `
|
66
|
-
"<!-- wp:image -->
|
67
|
-
<figure class=\\"wp-block-image\\"><img alt=\\"\\"/></figure>
|
68
|
-
<!-- /wp:image -->"
|
69
|
-
`;
|
@@ -1,126 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import {
|
5
|
-
activatePlugin,
|
6
|
-
createNewPost,
|
7
|
-
deactivatePlugin,
|
8
|
-
getEditedPostContent,
|
9
|
-
pressKeyWithModifier,
|
10
|
-
saveDraft,
|
11
|
-
switchUserToAdmin,
|
12
|
-
switchUserToTest,
|
13
|
-
visitAdminPage,
|
14
|
-
} from '@wordpress/e2e-test-utils';
|
15
|
-
|
16
|
-
describe( 'templates', () => {
|
17
|
-
describe( 'Using a CPT with a predefined template', () => {
|
18
|
-
beforeAll( async () => {
|
19
|
-
await activatePlugin( 'gutenberg-test-plugin-templates' );
|
20
|
-
} );
|
21
|
-
|
22
|
-
beforeEach( async () => {
|
23
|
-
await createNewPost( { postType: 'book' } );
|
24
|
-
} );
|
25
|
-
|
26
|
-
afterAll( async () => {
|
27
|
-
await deactivatePlugin( 'gutenberg-test-plugin-templates' );
|
28
|
-
} );
|
29
|
-
|
30
|
-
it( 'Should add a custom post types with a predefined template', async () => {
|
31
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
32
|
-
} );
|
33
|
-
|
34
|
-
it( 'Should respect user edits to not re-apply template after save (single block removal)', async () => {
|
35
|
-
// Remove a block from the template to verify that it's not
|
36
|
-
// re-added after saving and reloading the editor.
|
37
|
-
await page.click( '.editor-post-title__input' );
|
38
|
-
await page.keyboard.press( 'ArrowDown' );
|
39
|
-
await page.keyboard.press( 'Backspace' );
|
40
|
-
await saveDraft();
|
41
|
-
await page.reload();
|
42
|
-
await page.waitForSelector( '.edit-post-layout' );
|
43
|
-
|
44
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
45
|
-
} );
|
46
|
-
|
47
|
-
it( 'Should respect user edits to not re-apply template after save (full delete)', async () => {
|
48
|
-
// Remove all blocks from the template to verify that they're not
|
49
|
-
// re-added after saving and reloading the editor.
|
50
|
-
await page.type( '.editor-post-title__input', 'My Empty Book' );
|
51
|
-
await page.keyboard.press( 'ArrowDown' );
|
52
|
-
await pressKeyWithModifier( 'primary', 'A' );
|
53
|
-
await page.keyboard.press( 'Backspace' );
|
54
|
-
await saveDraft();
|
55
|
-
await page.reload();
|
56
|
-
await page.waitForSelector( '.edit-post-layout' );
|
57
|
-
|
58
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
59
|
-
} );
|
60
|
-
} );
|
61
|
-
|
62
|
-
describe( 'With default post format assigned', () => {
|
63
|
-
const STANDARD_FORMAT_VALUE = '0';
|
64
|
-
|
65
|
-
async function setPostFormat( format ) {
|
66
|
-
// To set the post format, we need to be the admin user.
|
67
|
-
await switchUserToAdmin();
|
68
|
-
await visitAdminPage( 'options-writing.php' );
|
69
|
-
await page.select( '#default_post_format', format );
|
70
|
-
await Promise.all( [
|
71
|
-
page.waitForNavigation(),
|
72
|
-
page.click( '#submit' ),
|
73
|
-
] );
|
74
|
-
await switchUserToTest();
|
75
|
-
}
|
76
|
-
|
77
|
-
beforeAll( async () => {
|
78
|
-
await activatePlugin(
|
79
|
-
'gutenberg-test-plugin-post-formats-support'
|
80
|
-
);
|
81
|
-
await setPostFormat( 'image' );
|
82
|
-
} );
|
83
|
-
afterAll( async () => {
|
84
|
-
await setPostFormat( STANDARD_FORMAT_VALUE );
|
85
|
-
await deactivatePlugin(
|
86
|
-
'gutenberg-test-plugin-post-formats-support'
|
87
|
-
);
|
88
|
-
} );
|
89
|
-
|
90
|
-
it( 'should populate new post with default block for format', async () => {
|
91
|
-
await createNewPost();
|
92
|
-
|
93
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
94
|
-
} );
|
95
|
-
|
96
|
-
it( 'should not populate edited post with default block for format', async () => {
|
97
|
-
await createNewPost();
|
98
|
-
|
99
|
-
// Remove the default block template to verify that it's not
|
100
|
-
// re-added after saving and reloading the editor.
|
101
|
-
await page.type( '.editor-post-title__input', 'My Image Format' );
|
102
|
-
await page.click( '.wp-block-image' );
|
103
|
-
await page.keyboard.press( 'Backspace' );
|
104
|
-
await saveDraft();
|
105
|
-
await page.reload();
|
106
|
-
await page.waitForSelector( '.edit-post-layout' );
|
107
|
-
|
108
|
-
// Wait a bit more for getEditedPostContent to be correct.
|
109
|
-
await page.waitForSelector(
|
110
|
-
'.block-editor-default-block-appender__content'
|
111
|
-
);
|
112
|
-
|
113
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
114
|
-
} );
|
115
|
-
|
116
|
-
it( 'should not populate new page with default block for format', async () => {
|
117
|
-
// This test always needs to run as the admin user, because other roles can't create pages.
|
118
|
-
// It can't be skipped, because then it failed because of not testing the snapshot.
|
119
|
-
await switchUserToAdmin();
|
120
|
-
await createNewPost( { postType: 'page' } );
|
121
|
-
|
122
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
123
|
-
await switchUserToTest();
|
124
|
-
} );
|
125
|
-
} );
|
126
|
-
} );
|
@@ -1,101 +0,0 @@
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
-
|
3
|
-
exports[`splitting and merging blocks should delete an empty first line 1`] = `
|
4
|
-
"<!-- wp:paragraph -->
|
5
|
-
<p>First</p>
|
6
|
-
<!-- /wp:paragraph -->
|
7
|
-
|
8
|
-
<!-- wp:paragraph -->
|
9
|
-
<p>Still Second</p>
|
10
|
-
<!-- /wp:paragraph -->"
|
11
|
-
`;
|
12
|
-
|
13
|
-
exports[`splitting and merging blocks should forward delete from an empty paragraph 1`] = `
|
14
|
-
"<!-- wp:paragraph -->
|
15
|
-
<p>Second</p>
|
16
|
-
<!-- /wp:paragraph -->"
|
17
|
-
`;
|
18
|
-
|
19
|
-
exports[`splitting and merging blocks should gracefully handle if placing caret in empty container 1`] = `
|
20
|
-
"<!-- wp:paragraph -->
|
21
|
-
<p><strong>Foo</strong></p>
|
22
|
-
<!-- /wp:paragraph -->
|
23
|
-
|
24
|
-
<!-- wp:paragraph -->
|
25
|
-
<p></p>
|
26
|
-
<!-- /wp:paragraph -->"
|
27
|
-
`;
|
28
|
-
|
29
|
-
exports[`splitting and merging blocks should merge into inline boundary position 1`] = `
|
30
|
-
"<!-- wp:paragraph -->
|
31
|
-
<p>Bar</p>
|
32
|
-
<!-- /wp:paragraph -->"
|
33
|
-
`;
|
34
|
-
|
35
|
-
exports[`splitting and merging blocks should not merge paragraphs if the selection is not collapsed 1`] = `
|
36
|
-
"<!-- wp:paragraph -->
|
37
|
-
<p>Foo</p>
|
38
|
-
<!-- /wp:paragraph -->
|
39
|
-
|
40
|
-
<!-- wp:paragraph -->
|
41
|
-
<p></p>
|
42
|
-
<!-- /wp:paragraph -->"
|
43
|
-
`;
|
44
|
-
|
45
|
-
exports[`splitting and merging blocks should not split with line break in front 1`] = `
|
46
|
-
"<!-- wp:paragraph -->
|
47
|
-
<p>1</p>
|
48
|
-
<!-- /wp:paragraph -->
|
49
|
-
|
50
|
-
<!-- wp:paragraph -->
|
51
|
-
<p>2</p>
|
52
|
-
<!-- /wp:paragraph -->"
|
53
|
-
`;
|
54
|
-
|
55
|
-
exports[`splitting and merging blocks should remove at most one paragraph in forward direction 1`] = `
|
56
|
-
"<!-- wp:paragraph -->
|
57
|
-
<p>First</p>
|
58
|
-
<!-- /wp:paragraph -->
|
59
|
-
|
60
|
-
<!-- wp:paragraph -->
|
61
|
-
<p></p>
|
62
|
-
<!-- /wp:paragraph -->
|
63
|
-
|
64
|
-
<!-- wp:paragraph -->
|
65
|
-
<p>Second</p>
|
66
|
-
<!-- /wp:paragraph -->"
|
67
|
-
`;
|
68
|
-
|
69
|
-
exports[`splitting and merging blocks should remove empty paragraph block on backspace 1`] = `""`;
|
70
|
-
|
71
|
-
exports[`splitting and merging blocks should split and merge paragraph blocks using Enter and Backspace 1`] = `
|
72
|
-
"<!-- wp:paragraph -->
|
73
|
-
<p>First</p>
|
74
|
-
<!-- /wp:paragraph -->
|
75
|
-
|
76
|
-
<!-- wp:paragraph -->
|
77
|
-
<p>Second</p>
|
78
|
-
<!-- /wp:paragraph -->"
|
79
|
-
`;
|
80
|
-
|
81
|
-
exports[`splitting and merging blocks should split and merge paragraph blocks using Enter and Backspace 2`] = `
|
82
|
-
"<!-- wp:paragraph -->
|
83
|
-
<p>FirstBetweenSecond</p>
|
84
|
-
<!-- /wp:paragraph -->"
|
85
|
-
`;
|
86
|
-
|
87
|
-
exports[`splitting and merging blocks should split and merge paragraph blocks using Enter and Backspace 3`] = `
|
88
|
-
"<!-- wp:paragraph -->
|
89
|
-
<p><strong>First</strong></p>
|
90
|
-
<!-- /wp:paragraph -->
|
91
|
-
|
92
|
-
<!-- wp:paragraph -->
|
93
|
-
<p>BeforeSecond:Second</p>
|
94
|
-
<!-- /wp:paragraph -->"
|
95
|
-
`;
|
96
|
-
|
97
|
-
exports[`splitting and merging blocks should undo split in one go 1`] = `
|
98
|
-
"<!-- wp:paragraph -->
|
99
|
-
<p>12</p>
|
100
|
-
<!-- /wp:paragraph -->"
|
101
|
-
`;
|
@@ -1,38 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import {
|
5
|
-
createNewPost,
|
6
|
-
insertBlock,
|
7
|
-
publishPost,
|
8
|
-
} from '@wordpress/e2e-test-utils';
|
9
|
-
|
10
|
-
describe( 'Compatibility with classic editor', () => {
|
11
|
-
beforeEach( async () => {
|
12
|
-
await createNewPost();
|
13
|
-
} );
|
14
|
-
|
15
|
-
it( 'Should not apply autop when rendering blocks', async () => {
|
16
|
-
await insertBlock( 'Custom HTML' );
|
17
|
-
await page.keyboard.type( '<a>' );
|
18
|
-
await page.keyboard.press( 'Enter' );
|
19
|
-
await page.keyboard.type( 'Random Link' );
|
20
|
-
await page.keyboard.press( 'Enter' );
|
21
|
-
await page.keyboard.type( '</a>' );
|
22
|
-
await publishPost();
|
23
|
-
|
24
|
-
// View the post.
|
25
|
-
const viewPostLinks = await page.$x(
|
26
|
-
"//a[contains(text(), 'View Post')]"
|
27
|
-
);
|
28
|
-
await viewPostLinks[ 0 ].click();
|
29
|
-
await page.waitForNavigation();
|
30
|
-
|
31
|
-
// Check the content doesn't contain <p> tags.
|
32
|
-
await page.waitForSelector( '.entry-content' );
|
33
|
-
const content = await page.$eval( '.entry-content', ( element ) =>
|
34
|
-
element.innerHTML.trim()
|
35
|
-
);
|
36
|
-
expect( content ).toMatchSnapshot();
|
37
|
-
} );
|
38
|
-
} );
|
@@ -1,31 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import {
|
5
|
-
createNewPost,
|
6
|
-
clickOnMoreMenuItem,
|
7
|
-
toggleMoreMenu,
|
8
|
-
} from '@wordpress/e2e-test-utils';
|
9
|
-
|
10
|
-
describe( 'Fullscreen Mode', () => {
|
11
|
-
beforeAll( async () => {
|
12
|
-
await createNewPost();
|
13
|
-
} );
|
14
|
-
|
15
|
-
it( 'should open the fullscreen mode from the more menu', async () => {
|
16
|
-
await clickOnMoreMenuItem( 'Fullscreen mode' );
|
17
|
-
await toggleMoreMenu( 'close' );
|
18
|
-
|
19
|
-
const isFullscreenEnabled = await page.$eval( 'body', ( body ) => {
|
20
|
-
return body.classList.contains( 'is-fullscreen-mode' );
|
21
|
-
} );
|
22
|
-
|
23
|
-
expect( isFullscreenEnabled ).toBe( true );
|
24
|
-
|
25
|
-
const fullscreenCloseButton = await page.$(
|
26
|
-
'.edit-post-fullscreen-mode-close'
|
27
|
-
);
|
28
|
-
|
29
|
-
expect( fullscreenCloseButton ).not.toBeNull();
|
30
|
-
} );
|
31
|
-
} );
|
@@ -1,52 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import {
|
5
|
-
activatePlugin,
|
6
|
-
createNewPost,
|
7
|
-
deactivatePlugin,
|
8
|
-
findSidebarPanelToggleButtonWithTitle,
|
9
|
-
getEditedPostContent,
|
10
|
-
openDocumentSettingsSidebar,
|
11
|
-
} from '@wordpress/e2e-test-utils';
|
12
|
-
|
13
|
-
describe( 'new editor filtered state', () => {
|
14
|
-
beforeAll( async () => {
|
15
|
-
await activatePlugin( 'gutenberg-test-plugin-default-post-content' );
|
16
|
-
} );
|
17
|
-
|
18
|
-
beforeEach( async () => {
|
19
|
-
await createNewPost();
|
20
|
-
} );
|
21
|
-
|
22
|
-
afterAll( async () => {
|
23
|
-
await deactivatePlugin( 'gutenberg-test-plugin-default-post-content' );
|
24
|
-
} );
|
25
|
-
|
26
|
-
it( 'should respect default content', async () => {
|
27
|
-
// Get the values that should have their defaults changed.
|
28
|
-
const title = await page.$eval(
|
29
|
-
'.editor-post-title__input',
|
30
|
-
( element ) => element.innerHTML
|
31
|
-
);
|
32
|
-
const content = await getEditedPostContent();
|
33
|
-
|
34
|
-
// open the sidebar, we want to see the excerpt.
|
35
|
-
await openDocumentSettingsSidebar();
|
36
|
-
const excerptButton = await findSidebarPanelToggleButtonWithTitle(
|
37
|
-
'Excerpt'
|
38
|
-
);
|
39
|
-
if ( excerptButton ) {
|
40
|
-
await excerptButton.click( 'button' );
|
41
|
-
}
|
42
|
-
const excerpt = await page.$eval(
|
43
|
-
'.editor-post-excerpt textarea',
|
44
|
-
( element ) => element.innerHTML
|
45
|
-
);
|
46
|
-
|
47
|
-
// Assert they match what the plugin set.
|
48
|
-
expect( title ).toBe( 'My default title' );
|
49
|
-
expect( content ).toBe( 'My default content' );
|
50
|
-
expect( excerpt ).toBe( 'My default excerpt' );
|
51
|
-
} );
|
52
|
-
} );
|
@@ -1,303 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import {
|
5
|
-
createNewPost,
|
6
|
-
insertBlock,
|
7
|
-
isInDefaultBlock,
|
8
|
-
getEditedPostContent,
|
9
|
-
pressKeyTimes,
|
10
|
-
pressKeyWithModifier,
|
11
|
-
} from '@wordpress/e2e-test-utils';
|
12
|
-
|
13
|
-
describe( 'splitting and merging blocks', () => {
|
14
|
-
beforeEach( async () => {
|
15
|
-
await createNewPost();
|
16
|
-
} );
|
17
|
-
|
18
|
-
it( 'should split and merge paragraph blocks using Enter and Backspace', async () => {
|
19
|
-
// Use regular inserter to add paragraph block and text.
|
20
|
-
await insertBlock( 'Paragraph' );
|
21
|
-
await page.keyboard.type( 'FirstSecond' );
|
22
|
-
|
23
|
-
// Move caret between 'First' and 'Second' and press Enter to split
|
24
|
-
// paragraph blocks.
|
25
|
-
await pressKeyTimes( 'ArrowLeft', 6 );
|
26
|
-
await page.keyboard.press( 'Enter' );
|
27
|
-
|
28
|
-
// Assert that there are now two paragraph blocks with correct content.
|
29
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
30
|
-
|
31
|
-
// Press Backspace to merge paragraph blocks.
|
32
|
-
await page.keyboard.press( 'Backspace' );
|
33
|
-
|
34
|
-
// Ensure that caret position is correctly placed at the between point.
|
35
|
-
await page.keyboard.type( 'Between' );
|
36
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
37
|
-
|
38
|
-
await pressKeyTimes( 'Backspace', 7 ); // Delete "Between"
|
39
|
-
|
40
|
-
// Edge case: Without ensuring that the editor still has focus when
|
41
|
-
// restoring a bookmark, the caret may be inadvertently moved back to
|
42
|
-
// an inline boundary after a split occurs.
|
43
|
-
await page.keyboard.press( 'Home' );
|
44
|
-
await page.keyboard.down( 'Shift' );
|
45
|
-
await pressKeyTimes( 'ArrowRight', 5 );
|
46
|
-
await page.keyboard.up( 'Shift' );
|
47
|
-
await pressKeyWithModifier( 'primary', 'b' );
|
48
|
-
// Collapse selection, still within inline boundary.
|
49
|
-
await page.keyboard.press( 'ArrowRight' );
|
50
|
-
await page.keyboard.press( 'Enter' );
|
51
|
-
await page.keyboard.type( 'BeforeSecond:' );
|
52
|
-
|
53
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
54
|
-
} );
|
55
|
-
|
56
|
-
it( 'should merge into inline boundary position', async () => {
|
57
|
-
// Regression Test: Caret should reset to end of inline boundary when
|
58
|
-
// backspacing to delete second paragraph.
|
59
|
-
await insertBlock( 'Paragraph' );
|
60
|
-
await pressKeyWithModifier( 'primary', 'b' );
|
61
|
-
await page.keyboard.type( 'Foo' );
|
62
|
-
await page.keyboard.press( 'Enter' );
|
63
|
-
await page.keyboard.press( 'Backspace' );
|
64
|
-
|
65
|
-
// Replace contents of first paragraph with "Bar".
|
66
|
-
await pressKeyTimes( 'Backspace', 4 );
|
67
|
-
await page.keyboard.type( 'Bar' );
|
68
|
-
|
69
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
70
|
-
} );
|
71
|
-
|
72
|
-
it( 'should delete an empty first line', async () => {
|
73
|
-
// Regression Test: When a paragraph block has line break, and the first
|
74
|
-
// line has no text, pressing backspace at the start of the second line
|
75
|
-
// should remove the first.
|
76
|
-
//
|
77
|
-
// See: https://github.com/WordPress/gutenberg/issues/8388
|
78
|
-
|
79
|
-
// First paragraph.
|
80
|
-
await insertBlock( 'Paragraph' );
|
81
|
-
await page.keyboard.type( 'First' );
|
82
|
-
await page.keyboard.press( 'Enter' );
|
83
|
-
|
84
|
-
// Second paragraph.
|
85
|
-
await page.keyboard.down( 'Shift' );
|
86
|
-
await page.keyboard.press( 'Enter' );
|
87
|
-
await page.keyboard.up( 'Shift' );
|
88
|
-
|
89
|
-
// Delete the soft line break.
|
90
|
-
await page.keyboard.press( 'Backspace' );
|
91
|
-
|
92
|
-
// Typing at this point should occur still within the second paragraph,
|
93
|
-
// while before the regression fix it would have occurred in the first.
|
94
|
-
await page.keyboard.type( 'Still Second' );
|
95
|
-
|
96
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
97
|
-
} );
|
98
|
-
|
99
|
-
it( 'should not merge paragraphs if the selection is not collapsed', async () => {
|
100
|
-
// Regression Test: When all of a paragraph is selected, pressing
|
101
|
-
// backspace should delete the contents, not merge to previous.
|
102
|
-
//
|
103
|
-
// See: https://github.com/WordPress/gutenberg/issues/8268
|
104
|
-
await insertBlock( 'Paragraph' );
|
105
|
-
await page.keyboard.type( 'Foo' );
|
106
|
-
await insertBlock( 'Paragraph' );
|
107
|
-
await page.keyboard.type( 'Bar' );
|
108
|
-
|
109
|
-
// Select text.
|
110
|
-
await page.keyboard.down( 'Shift' );
|
111
|
-
await pressKeyTimes( 'ArrowLeft', 3 );
|
112
|
-
await page.keyboard.up( 'Shift' );
|
113
|
-
|
114
|
-
// Delete selection.
|
115
|
-
await page.keyboard.press( 'Backspace' );
|
116
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
117
|
-
} );
|
118
|
-
|
119
|
-
it( 'should gracefully handle if placing caret in empty container', async () => {
|
120
|
-
// Regression Test: placeCaretAtHorizontalEdge previously did not
|
121
|
-
// account for contentEditables which have no children.
|
122
|
-
//
|
123
|
-
// See: https://github.com/WordPress/gutenberg/issues/8676
|
124
|
-
await insertBlock( 'Paragraph' );
|
125
|
-
await page.keyboard.type( 'Foo' );
|
126
|
-
|
127
|
-
// The regression appeared to only affect paragraphs created while
|
128
|
-
// within an inline boundary.
|
129
|
-
await page.keyboard.down( 'Shift' );
|
130
|
-
await pressKeyTimes( 'ArrowLeft', 3 );
|
131
|
-
await page.keyboard.up( 'Shift' );
|
132
|
-
await pressKeyWithModifier( 'primary', 'b' );
|
133
|
-
await page.keyboard.press( 'ArrowRight' );
|
134
|
-
await page.keyboard.press( 'Enter' );
|
135
|
-
await page.keyboard.press( 'Enter' );
|
136
|
-
|
137
|
-
await page.keyboard.press( 'Backspace' );
|
138
|
-
|
139
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
140
|
-
} );
|
141
|
-
|
142
|
-
it( 'should forward delete from an empty paragraph', async () => {
|
143
|
-
// Regression test: Bogus nodes in a RichText container can interfere
|
144
|
-
// with isHorizontalEdge detection, preventing forward deletion.
|
145
|
-
//
|
146
|
-
// See: https://github.com/WordPress/gutenberg/issues/8731
|
147
|
-
await insertBlock( 'Paragraph' );
|
148
|
-
await page.keyboard.press( 'Enter' );
|
149
|
-
await page.keyboard.type( 'Second' );
|
150
|
-
await page.keyboard.press( 'ArrowUp' );
|
151
|
-
await page.keyboard.press( 'Delete' );
|
152
|
-
|
153
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
154
|
-
} );
|
155
|
-
|
156
|
-
it( 'should remove empty paragraph block on backspace', async () => {
|
157
|
-
// Regression Test: In a sole empty paragraph, pressing backspace
|
158
|
-
// should remove the block.
|
159
|
-
//
|
160
|
-
// See: https://github.com/WordPress/gutenberg/pull/8306
|
161
|
-
await insertBlock( 'Paragraph' );
|
162
|
-
await page.keyboard.press( 'Backspace' );
|
163
|
-
|
164
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
165
|
-
} );
|
166
|
-
|
167
|
-
it( 'should remove at most one paragraph in forward direction', async () => {
|
168
|
-
// Regression Test: A forward delete on empty RichText previously would
|
169
|
-
// destroy two paragraphs on the dual-action of merge & remove.
|
170
|
-
//
|
171
|
-
// See: https://github.com/WordPress/gutenberg/pull/8735
|
172
|
-
await insertBlock( 'Paragraph' );
|
173
|
-
await page.keyboard.type( 'First' );
|
174
|
-
await page.keyboard.press( 'Enter' );
|
175
|
-
await page.keyboard.press( 'Enter' );
|
176
|
-
await page.keyboard.press( 'Enter' );
|
177
|
-
await page.keyboard.type( 'Second' );
|
178
|
-
await page.keyboard.press( 'ArrowUp' );
|
179
|
-
await page.keyboard.press( 'ArrowUp' );
|
180
|
-
await page.keyboard.press( 'Delete' );
|
181
|
-
|
182
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
183
|
-
} );
|
184
|
-
|
185
|
-
it( 'should ensure always a default block', async () => {
|
186
|
-
// Feature: To avoid focus loss, removal of all blocks will result in a
|
187
|
-
// default block insertion at the root. Pressing backspace in a new
|
188
|
-
// paragraph should not effectively allow removal. This is counteracted
|
189
|
-
// with pre-save content processing to save post consisting of only the
|
190
|
-
// unmodified default block as an empty string.
|
191
|
-
//
|
192
|
-
// See: https://github.com/WordPress/gutenberg/issues/9626
|
193
|
-
await insertBlock( 'Paragraph' );
|
194
|
-
await page.keyboard.press( 'Backspace' );
|
195
|
-
|
196
|
-
// There is a default block and post title:
|
197
|
-
expect(
|
198
|
-
await page.$$( '.block-editor-block-list__block' )
|
199
|
-
).toHaveLength( 2 );
|
200
|
-
|
201
|
-
// But the effective saved content is still empty:
|
202
|
-
expect( await getEditedPostContent() ).toBe( '' );
|
203
|
-
|
204
|
-
// And focus is retained:
|
205
|
-
expect( await isInDefaultBlock() ).toBe( true );
|
206
|
-
} );
|
207
|
-
|
208
|
-
it( 'should undo split in one go', async () => {
|
209
|
-
await page.keyboard.press( 'Enter' );
|
210
|
-
await page.keyboard.type( '12' );
|
211
|
-
await page.keyboard.press( 'ArrowLeft' );
|
212
|
-
await page.keyboard.press( 'Enter' );
|
213
|
-
await pressKeyWithModifier( 'primary', 'z' );
|
214
|
-
|
215
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
216
|
-
} );
|
217
|
-
|
218
|
-
it( 'should not split with line break in front', async () => {
|
219
|
-
await page.keyboard.press( 'Enter' );
|
220
|
-
await page.keyboard.type( '1' );
|
221
|
-
await page.keyboard.press( 'Enter' );
|
222
|
-
await pressKeyWithModifier( 'shift', 'Enter' );
|
223
|
-
await page.keyboard.type( '2' );
|
224
|
-
await page.keyboard.press( 'ArrowLeft' );
|
225
|
-
await page.keyboard.press( 'Backspace' );
|
226
|
-
|
227
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
228
|
-
} );
|
229
|
-
|
230
|
-
describe( 'test restore selection when merge produces more than one block', () => {
|
231
|
-
it( 'on forward delete', async () => {
|
232
|
-
await insertBlock( 'Paragraph' );
|
233
|
-
await page.keyboard.type( 'hi' );
|
234
|
-
await insertBlock( 'List' );
|
235
|
-
await page.keyboard.type( 'item 1' );
|
236
|
-
await page.keyboard.press( 'Enter' );
|
237
|
-
await page.keyboard.type( 'item 2' );
|
238
|
-
await pressKeyTimes( 'ArrowUp', 3 );
|
239
|
-
await page.keyboard.press( 'Delete' );
|
240
|
-
expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
|
241
|
-
"<!-- wp:paragraph -->
|
242
|
-
<p>hi</p>
|
243
|
-
<!-- /wp:paragraph -->
|
244
|
-
|
245
|
-
<!-- wp:paragraph -->
|
246
|
-
<p>item 1</p>
|
247
|
-
<!-- /wp:paragraph -->
|
248
|
-
|
249
|
-
<!-- wp:paragraph -->
|
250
|
-
<p>item 2</p>
|
251
|
-
<!-- /wp:paragraph -->"
|
252
|
-
` );
|
253
|
-
await page.keyboard.press( 'Delete' );
|
254
|
-
// Carret should be in the first block and at the proper position.
|
255
|
-
await page.keyboard.type( '-' );
|
256
|
-
expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
|
257
|
-
"<!-- wp:paragraph -->
|
258
|
-
<p>hi-item 1</p>
|
259
|
-
<!-- /wp:paragraph -->
|
260
|
-
|
261
|
-
<!-- wp:paragraph -->
|
262
|
-
<p>item 2</p>
|
263
|
-
<!-- /wp:paragraph -->"
|
264
|
-
` );
|
265
|
-
} );
|
266
|
-
it( 'on backspace', async () => {
|
267
|
-
await insertBlock( 'Paragraph' );
|
268
|
-
await page.keyboard.type( 'hi' );
|
269
|
-
await insertBlock( 'List' );
|
270
|
-
await page.keyboard.type( 'item 1' );
|
271
|
-
await page.keyboard.press( 'Enter' );
|
272
|
-
await page.keyboard.type( 'item 2' );
|
273
|
-
await page.keyboard.press( 'ArrowUp' );
|
274
|
-
await pressKeyTimes( 'ArrowLeft', 6 );
|
275
|
-
await page.keyboard.press( 'Backspace' );
|
276
|
-
expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
|
277
|
-
"<!-- wp:paragraph -->
|
278
|
-
<p>hi</p>
|
279
|
-
<!-- /wp:paragraph -->
|
280
|
-
|
281
|
-
<!-- wp:paragraph -->
|
282
|
-
<p>item 1</p>
|
283
|
-
<!-- /wp:paragraph -->
|
284
|
-
|
285
|
-
<!-- wp:paragraph -->
|
286
|
-
<p>item 2</p>
|
287
|
-
<!-- /wp:paragraph -->"
|
288
|
-
` );
|
289
|
-
await page.keyboard.press( 'Backspace' );
|
290
|
-
// Carret should be in the first block and at the proper position.
|
291
|
-
await page.keyboard.type( '-' );
|
292
|
-
expect( await getEditedPostContent() ).toMatchInlineSnapshot( `
|
293
|
-
"<!-- wp:paragraph -->
|
294
|
-
<p>hi-item 1</p>
|
295
|
-
<!-- /wp:paragraph -->
|
296
|
-
|
297
|
-
<!-- wp:paragraph -->
|
298
|
-
<p>item 2</p>
|
299
|
-
<!-- /wp:paragraph -->"
|
300
|
-
` );
|
301
|
-
} );
|
302
|
-
} );
|
303
|
-
} );
|
@@ -1,31 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import { activateTheme, visitSiteEditor } from '@wordpress/e2e-test-utils';
|
5
|
-
|
6
|
-
describe( 'Site editor iframe rendering mode', () => {
|
7
|
-
beforeAll( async () => {
|
8
|
-
await activateTheme( 'emptytheme' );
|
9
|
-
} );
|
10
|
-
|
11
|
-
afterAll( async () => {
|
12
|
-
await activateTheme( 'twentytwentyone' );
|
13
|
-
} );
|
14
|
-
|
15
|
-
it( 'Should render editor in standards mode.', async () => {
|
16
|
-
await visitSiteEditor( {
|
17
|
-
postId: 'emptytheme//index',
|
18
|
-
postType: 'wp_template',
|
19
|
-
} );
|
20
|
-
|
21
|
-
const compatMode = await page.evaluate(
|
22
|
-
() =>
|
23
|
-
document.querySelector( `iframe[name='editor-canvas']` )
|
24
|
-
.contentDocument.compatMode
|
25
|
-
);
|
26
|
-
|
27
|
-
// CSS1Compat = expected standards mode.
|
28
|
-
// BackCompat = quirks mode.
|
29
|
-
expect( compatMode ).toBe( 'CSS1Compat' );
|
30
|
-
} );
|
31
|
-
} );
|
@@ -1,33 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import {
|
5
|
-
deleteAllTemplates,
|
6
|
-
activateTheme,
|
7
|
-
visitSiteEditor,
|
8
|
-
} from '@wordpress/e2e-test-utils';
|
9
|
-
|
10
|
-
describe( 'Site Editor Inserter', () => {
|
11
|
-
beforeAll( async () => {
|
12
|
-
await activateTheme( 'emptytheme' );
|
13
|
-
await deleteAllTemplates( 'wp_template' );
|
14
|
-
await deleteAllTemplates( 'wp_template_part' );
|
15
|
-
} );
|
16
|
-
afterAll( async () => {
|
17
|
-
await activateTheme( 'twentytwentyone' );
|
18
|
-
} );
|
19
|
-
beforeEach( async () => {
|
20
|
-
await visitSiteEditor();
|
21
|
-
} );
|
22
|
-
|
23
|
-
it( 'inserter toggle button should toggle global inserter', async () => {
|
24
|
-
await page.click( '.edit-site-header-edit-mode__inserter-toggle' );
|
25
|
-
await page.waitForSelector( '.edit-site-editor__inserter-panel', {
|
26
|
-
visible: true,
|
27
|
-
} );
|
28
|
-
await page.click( '.edit-site-header-edit-mode__inserter-toggle' );
|
29
|
-
await page.waitForSelector( '.edit-site-editor__inserter-panel', {
|
30
|
-
hidden: true,
|
31
|
-
} );
|
32
|
-
} );
|
33
|
-
} );
|