@wordpress/e2e-tests 5.4.0 → 5.6.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.
@@ -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
- } );