@wordpress/e2e-tests 3.1.1 → 4.0.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 +6 -0
- package/README.md +2 -0
- package/config/flaky-tests-reporter.js +1 -0
- package/package.json +8 -6
- package/specs/editor/blocks/__snapshots__/buttons.test.js.snap +8 -0
- package/specs/editor/blocks/__snapshots__/navigation.test.js.snap +2 -2
- package/specs/editor/blocks/__snapshots__/separator.test.js.snap +1 -1
- package/specs/editor/blocks/buttons.test.js +10 -0
- package/specs/editor/blocks/columns.test.js +3 -3
- package/specs/editor/blocks/gallery.test.js +36 -6
- package/specs/editor/blocks/heading.test.js +1 -1
- package/specs/editor/blocks/navigation.test.js +370 -72
- package/specs/editor/plugins/annotations.test.js +63 -67
- package/specs/editor/various/__snapshots__/block-deletion.test.js.snap +20 -12
- package/specs/editor/various/__snapshots__/block-editor-keyboard-shortcuts.test.js.snap +26 -0
- package/specs/editor/various/__snapshots__/block-hierarchy-navigation.test.js.snap +1 -1
- package/specs/editor/various/__snapshots__/multi-block-selection.test.js.snap +122 -6
- package/specs/editor/various/__snapshots__/writing-flow.test.js.snap +6 -6
- package/specs/editor/various/autosave.test.js +3 -3
- package/specs/editor/various/block-deletion.test.js +1 -0
- package/specs/editor/various/block-editor-keyboard-shortcuts.test.js +3 -5
- package/specs/editor/various/block-hierarchy-navigation.test.js +10 -16
- package/specs/editor/various/block-locking.test.js +120 -0
- package/specs/editor/various/keyboard-navigable-blocks.test.js +23 -0
- package/specs/editor/various/list-view.test.js +139 -7
- package/specs/editor/various/multi-block-selection.test.js +153 -9
- package/specs/editor/various/post-editor-template-mode.test.js +1 -1
- package/specs/editor/various/toolbar-roving-tabindex.test.js +10 -4
- package/specs/editor/various/writing-flow.test.js +10 -5
- package/specs/experiments/blocks/comments-query.test.js +131 -0
- package/specs/experiments/navigation-editor.test.js +126 -121
- package/specs/performance/post-editor.test.js +4 -6
- package/specs/site-editor/iframe-rendering-mode.test.js +31 -0
- package/specs/site-editor/site-editor-export.test.js +2 -2
- package/specs/site-editor/style-variations.test.js +9 -7
- package/specs/site-editor/template-part.test.js +3 -1
- package/specs/editor/various/__snapshots__/copy-cut-paste-whole-blocks.test.js.snap +0 -125
- package/specs/editor/various/copy-cut-paste-whole-blocks.test.js +0 -187
- package/specs/editor/various/new-post.test.js +0 -99
- package/specs/widgets/customizing-widgets.test.js +0 -913
@@ -1,187 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import {
|
5
|
-
clickBlockAppender,
|
6
|
-
createNewPost,
|
7
|
-
pressKeyWithModifier,
|
8
|
-
getEditedPostContent,
|
9
|
-
insertBlock,
|
10
|
-
} from '@wordpress/e2e-test-utils';
|
11
|
-
|
12
|
-
describe( 'Copy/cut/paste of whole blocks', () => {
|
13
|
-
beforeEach( async () => {
|
14
|
-
await createNewPost();
|
15
|
-
} );
|
16
|
-
|
17
|
-
it( 'should copy and paste individual blocks', async () => {
|
18
|
-
await clickBlockAppender();
|
19
|
-
await page.keyboard.type(
|
20
|
-
'Here is a unique string so we can test copying.'
|
21
|
-
);
|
22
|
-
await page.keyboard.press( 'Enter' );
|
23
|
-
await page.keyboard.type( '2' );
|
24
|
-
await page.keyboard.press( 'ArrowUp' );
|
25
|
-
|
26
|
-
await pressKeyWithModifier( 'primary', 'c' );
|
27
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
28
|
-
|
29
|
-
await page.keyboard.press( 'ArrowDown' );
|
30
|
-
await pressKeyWithModifier( 'primary', 'v' );
|
31
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
32
|
-
} );
|
33
|
-
|
34
|
-
it( 'should copy blocks when non textual elements are focused (image, spacer)', async () => {
|
35
|
-
await insertBlock( 'Spacer' );
|
36
|
-
// At this point the spacer wrapper should be focused.
|
37
|
-
await pressKeyWithModifier( 'primary', 'c' );
|
38
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
39
|
-
|
40
|
-
await clickBlockAppender();
|
41
|
-
await pressKeyWithModifier( 'primary', 'v' );
|
42
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
43
|
-
} );
|
44
|
-
|
45
|
-
it( 'should cut and paste individual blocks', async () => {
|
46
|
-
await clickBlockAppender();
|
47
|
-
await page.keyboard.type( 'Yet another unique string.' );
|
48
|
-
await page.keyboard.press( 'Enter' );
|
49
|
-
await page.keyboard.type( '2' );
|
50
|
-
await page.keyboard.press( 'ArrowUp' );
|
51
|
-
|
52
|
-
await pressKeyWithModifier( 'primary', 'x' );
|
53
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
54
|
-
|
55
|
-
await page.keyboard.press( 'Tab' );
|
56
|
-
await page.keyboard.press( 'ArrowDown' );
|
57
|
-
await pressKeyWithModifier( 'primary', 'v' );
|
58
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
59
|
-
} );
|
60
|
-
|
61
|
-
it( 'should respect inline copy when text is selected', async () => {
|
62
|
-
await clickBlockAppender();
|
63
|
-
await page.keyboard.type( 'First block' );
|
64
|
-
await page.keyboard.press( 'Enter' );
|
65
|
-
await page.keyboard.type( 'Second block' );
|
66
|
-
await page.keyboard.press( 'ArrowUp' );
|
67
|
-
await pressKeyWithModifier( 'shift', 'ArrowLeft' );
|
68
|
-
await pressKeyWithModifier( 'shift', 'ArrowLeft' );
|
69
|
-
|
70
|
-
await pressKeyWithModifier( 'primary', 'c' );
|
71
|
-
await page.keyboard.press( 'ArrowRight' );
|
72
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
73
|
-
|
74
|
-
await page.keyboard.press( 'Enter' );
|
75
|
-
await pressKeyWithModifier( 'primary', 'v' );
|
76
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
77
|
-
} );
|
78
|
-
|
79
|
-
it( 'should respect inline copy in places like input fields and textareas', async () => {
|
80
|
-
await insertBlock( 'Shortcode' );
|
81
|
-
await page.keyboard.type( '[my-shortcode]' );
|
82
|
-
await pressKeyWithModifier( 'shift', 'ArrowLeft' );
|
83
|
-
await pressKeyWithModifier( 'shift', 'ArrowLeft' );
|
84
|
-
|
85
|
-
await pressKeyWithModifier( 'primary', 'c' );
|
86
|
-
await page.keyboard.press( 'ArrowRight' );
|
87
|
-
await page.keyboard.press( 'ArrowRight' );
|
88
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
89
|
-
|
90
|
-
await insertBlock( 'Paragraph' );
|
91
|
-
await page.keyboard.type( 'Pasted: ' );
|
92
|
-
await pressKeyWithModifier( 'primary', 'v' );
|
93
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
94
|
-
} );
|
95
|
-
|
96
|
-
it( 'should handle paste events once', async () => {
|
97
|
-
// Add group block with paragraph.
|
98
|
-
await insertBlock( 'Group' );
|
99
|
-
await page.click( '.block-editor-button-block-appender' );
|
100
|
-
await page.click( '.editor-block-list-item-paragraph' );
|
101
|
-
await page.keyboard.type( 'P' );
|
102
|
-
await page.keyboard.press( 'ArrowLeft' );
|
103
|
-
await page.keyboard.press( 'ArrowLeft' );
|
104
|
-
// Cut group.
|
105
|
-
await pressKeyWithModifier( 'primary', 'x' );
|
106
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
107
|
-
|
108
|
-
await page.keyboard.press( 'Enter' );
|
109
|
-
|
110
|
-
await page.evaluate( () => {
|
111
|
-
window.e2eTestPasteOnce = [];
|
112
|
-
let oldBlocks = wp.data.select( 'core/block-editor' ).getBlocks();
|
113
|
-
wp.data.subscribe( () => {
|
114
|
-
const blocks = wp.data
|
115
|
-
.select( 'core/block-editor' )
|
116
|
-
.getBlocks();
|
117
|
-
if ( blocks !== oldBlocks ) {
|
118
|
-
window.e2eTestPasteOnce.push(
|
119
|
-
blocks.map( ( { clientId, name } ) => ( {
|
120
|
-
clientId,
|
121
|
-
name,
|
122
|
-
} ) )
|
123
|
-
);
|
124
|
-
}
|
125
|
-
oldBlocks = blocks;
|
126
|
-
} );
|
127
|
-
} );
|
128
|
-
|
129
|
-
// Paste.
|
130
|
-
await pressKeyWithModifier( 'primary', 'v' );
|
131
|
-
|
132
|
-
// Blocks should only be modified once, not twice with new clientIds on a single paste action.
|
133
|
-
const blocksUpdated = await page.evaluate(
|
134
|
-
() => window.e2eTestPasteOnce
|
135
|
-
);
|
136
|
-
|
137
|
-
expect( blocksUpdated.length ).toEqual( 1 );
|
138
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
139
|
-
} );
|
140
|
-
|
141
|
-
it( 'can copy group onto non textual element (image, spacer)', async () => {
|
142
|
-
// Add group block with paragraph.
|
143
|
-
await insertBlock( 'Group' );
|
144
|
-
await page.click( '.block-editor-button-block-appender' );
|
145
|
-
await page.click( '.editor-block-list-item-paragraph' );
|
146
|
-
await page.keyboard.type( 'P' );
|
147
|
-
await page.keyboard.press( 'ArrowLeft' );
|
148
|
-
await page.keyboard.press( 'ArrowLeft' );
|
149
|
-
// Cut group.
|
150
|
-
await pressKeyWithModifier( 'primary', 'x' );
|
151
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
152
|
-
|
153
|
-
await page.keyboard.press( 'Enter' );
|
154
|
-
|
155
|
-
// Insert a non textual element (a spacer)
|
156
|
-
await insertBlock( 'Spacer' );
|
157
|
-
// Spacer is focused.
|
158
|
-
await page.evaluate( () => {
|
159
|
-
window.e2eTestPasteOnce = [];
|
160
|
-
let oldBlocks = wp.data.select( 'core/block-editor' ).getBlocks();
|
161
|
-
wp.data.subscribe( () => {
|
162
|
-
const blocks = wp.data
|
163
|
-
.select( 'core/block-editor' )
|
164
|
-
.getBlocks();
|
165
|
-
if ( blocks !== oldBlocks ) {
|
166
|
-
window.e2eTestPasteOnce.push(
|
167
|
-
blocks.map( ( { clientId, name } ) => ( {
|
168
|
-
clientId,
|
169
|
-
name,
|
170
|
-
} ) )
|
171
|
-
);
|
172
|
-
}
|
173
|
-
oldBlocks = blocks;
|
174
|
-
} );
|
175
|
-
} );
|
176
|
-
|
177
|
-
await pressKeyWithModifier( 'primary', 'v' );
|
178
|
-
|
179
|
-
// Paste should be handled on non-textual elements and only handled once.
|
180
|
-
const blocksUpdated = await page.evaluate(
|
181
|
-
() => window.e2eTestPasteOnce
|
182
|
-
);
|
183
|
-
|
184
|
-
expect( blocksUpdated.length ).toEqual( 1 );
|
185
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
186
|
-
} );
|
187
|
-
} );
|
@@ -1,99 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import {
|
5
|
-
activatePlugin,
|
6
|
-
createNewPost,
|
7
|
-
deactivatePlugin,
|
8
|
-
} from '@wordpress/e2e-test-utils';
|
9
|
-
|
10
|
-
describe( 'new editor state', () => {
|
11
|
-
beforeAll( async () => {
|
12
|
-
await activatePlugin( 'gutenberg-test-plugin-post-formats-support' );
|
13
|
-
} );
|
14
|
-
|
15
|
-
beforeEach( async () => {
|
16
|
-
await createNewPost();
|
17
|
-
} );
|
18
|
-
|
19
|
-
afterAll( async () => {
|
20
|
-
await deactivatePlugin( 'gutenberg-test-plugin-post-formats-support' );
|
21
|
-
} );
|
22
|
-
|
23
|
-
it( 'should show the New Post page in Gutenberg', async () => {
|
24
|
-
expect( page.url() ).toEqual(
|
25
|
-
expect.stringContaining( 'post-new.php' )
|
26
|
-
);
|
27
|
-
// Should display the blank title.
|
28
|
-
const title = await page.$( '[aria-label="Add title"]' );
|
29
|
-
expect( title ).not.toBeNull();
|
30
|
-
// Trim padding non-breaking space.
|
31
|
-
expect(
|
32
|
-
await title.evaluate( ( el ) => el.textContent.trim() )
|
33
|
-
).toBeFalsy();
|
34
|
-
// Should display the Preview button.
|
35
|
-
const postPreviewButton = await page.$(
|
36
|
-
'.editor-post-preview.components-button'
|
37
|
-
);
|
38
|
-
expect( postPreviewButton ).not.toBeNull();
|
39
|
-
// Should display the Post Formats UI.
|
40
|
-
const postFormatsUi = await page.$( '.editor-post-format' );
|
41
|
-
expect( postFormatsUi ).not.toBeNull();
|
42
|
-
} );
|
43
|
-
|
44
|
-
it( 'should have no history', async () => {
|
45
|
-
const undoButton = await page.$(
|
46
|
-
'.editor-history__undo[aria-disabled="false"]'
|
47
|
-
);
|
48
|
-
const redoButton = await page.$(
|
49
|
-
'.editor-history__redo[aria-disabled="false"]'
|
50
|
-
);
|
51
|
-
|
52
|
-
expect( undoButton ).toBeNull();
|
53
|
-
expect( redoButton ).toBeNull();
|
54
|
-
} );
|
55
|
-
|
56
|
-
it( 'should focus the title if the title is empty', async () => {
|
57
|
-
const activeElementClasses = await page.evaluate( () => {
|
58
|
-
return Object.values( document.activeElement.classList );
|
59
|
-
} );
|
60
|
-
const activeElementTagName = await page.evaluate( () => {
|
61
|
-
return document.activeElement.tagName.toLowerCase();
|
62
|
-
} );
|
63
|
-
|
64
|
-
expect( activeElementClasses ).toContain( 'editor-post-title__input' );
|
65
|
-
expect( activeElementTagName ).toEqual( 'h1' );
|
66
|
-
} );
|
67
|
-
|
68
|
-
it( 'should not focus the title if the title exists', async () => {
|
69
|
-
// Enter a title for this post.
|
70
|
-
await page.type( '.editor-post-title__input', 'Here is the title' );
|
71
|
-
// Save the post as a draft.
|
72
|
-
await page.click( '.editor-post-save-draft' );
|
73
|
-
await page.waitForSelector( '.editor-post-saved-state.is-saved' );
|
74
|
-
// Reload the browser so a post is loaded with a title.
|
75
|
-
await page.reload();
|
76
|
-
await page.waitForSelector( '.edit-post-layout' );
|
77
|
-
|
78
|
-
const activeElementClasses = await page.evaluate( () => {
|
79
|
-
return Object.values( document.activeElement.classList );
|
80
|
-
} );
|
81
|
-
const activeElementTagName = await page.evaluate( () => {
|
82
|
-
return document.activeElement.tagName.toLowerCase();
|
83
|
-
} );
|
84
|
-
|
85
|
-
expect( activeElementClasses ).not.toContain(
|
86
|
-
'editor-post-title__input'
|
87
|
-
);
|
88
|
-
// The document `body` should be the `activeElement`, because nothing is
|
89
|
-
// focused by default when a post already has a title.
|
90
|
-
expect( activeElementTagName ).toEqual( 'body' );
|
91
|
-
} );
|
92
|
-
|
93
|
-
it( 'should be saveable with sufficient initial edits', async () => {
|
94
|
-
await createNewPost( { title: 'Here is the title' } );
|
95
|
-
|
96
|
-
// Verify saveable by presence of the Save Draft button.
|
97
|
-
await page.$( 'button.editor-post-save-draft' );
|
98
|
-
} );
|
99
|
-
} );
|