@wordpress/e2e-tests 7.12.0 → 7.13.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/mu-plugins/enable-templates-ui.php +1 -1
- package/mu-plugins/nocache-headers.php +1 -1
- package/package.json +7 -7
- package/plugins/block-context.php +1 -1
- package/plugins/iframed-block.php +2 -2
- package/plugins/iframed-enqueue-block-assets.php +1 -1
- package/plugins/iframed-enqueue-block-editor-settings.php +1 -1
- package/plugins/iframed-inline-styles.php +3 -3
- package/plugins/iframed-masonry-block.php +2 -2
- package/plugins/iframed-multiple-stylesheets.php +2 -2
- package/plugins/inner-blocks-allowed-blocks/index.js +16 -10
- package/plugins/interactive-blocks/router-navigate/block.json +14 -0
- package/plugins/interactive-blocks/router-navigate/render.php +51 -0
- package/plugins/interactive-blocks/router-navigate/view.js +41 -0
- package/plugins/interactive-blocks.php +3 -4
- package/plugins/marquee-function-widget.php +2 -2
- package/specs/editor/plugins/__snapshots__/plugins-api.test.js.snap +2 -2
- package/specs/editor/plugins/annotations.test.js +5 -12
- package/specs/editor/plugins/container-blocks.test.js +1 -1
- package/specs/editor/plugins/custom-taxonomies.test.js +1 -1
- package/specs/editor/plugins/inner-blocks-render-appender.test.js +2 -2
- package/specs/editor/plugins/meta-boxes.test.js +2 -3
- package/specs/editor/various/__snapshots__/{reusable-blocks.test.js.snap → pattern-blocks.test.js.snap} +2 -2
- package/specs/editor/various/change-detection.test.js +1 -1
- package/specs/editor/various/inserting-blocks.test.js +2 -2
- package/specs/editor/various/{reusable-blocks.test.js → pattern-blocks.test.js} +15 -15
- package/specs/site-editor/multi-entity-saving.test.js +2 -3
- package/specs/widgets/editing-widgets.test.js +4 -6
- package/specs/editor/various/__snapshots__/rich-text.test.js.snap +0 -231
- package/specs/editor/various/rich-text.test.js +0 -570
@@ -1,570 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import {
|
5
|
-
createNewPost,
|
6
|
-
getEditedPostContent,
|
7
|
-
insertBlock,
|
8
|
-
clickBlockAppender,
|
9
|
-
pressKeyWithModifier,
|
10
|
-
showBlockToolbar,
|
11
|
-
clickBlockToolbarButton,
|
12
|
-
canvas,
|
13
|
-
} from '@wordpress/e2e-test-utils';
|
14
|
-
|
15
|
-
describe( 'RichText', () => {
|
16
|
-
beforeEach( async () => {
|
17
|
-
await createNewPost();
|
18
|
-
} );
|
19
|
-
|
20
|
-
it( 'should handle change in tag name gracefully', async () => {
|
21
|
-
// Regression test: The heading block changes the tag name of its
|
22
|
-
// RichText element. Historically this has been prone to breakage,
|
23
|
-
// because the Editable component prevents rerenders, so React cannot
|
24
|
-
// update the element by itself.
|
25
|
-
//
|
26
|
-
// See: https://github.com/WordPress/gutenberg/issues/3091
|
27
|
-
await insertBlock( 'Heading' );
|
28
|
-
await page.waitForSelector( '[aria-label="Change level"]' );
|
29
|
-
await page.click( '[aria-label="Change level"]' );
|
30
|
-
await page.click( '[aria-label="Heading 3"]' );
|
31
|
-
|
32
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
33
|
-
} );
|
34
|
-
|
35
|
-
it( 'should apply formatting with primary shortcut', async () => {
|
36
|
-
await clickBlockAppender();
|
37
|
-
await page.keyboard.type( 'test' );
|
38
|
-
await pressKeyWithModifier( 'primary', 'a' );
|
39
|
-
await pressKeyWithModifier( 'primary', 'b' );
|
40
|
-
|
41
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
42
|
-
} );
|
43
|
-
|
44
|
-
it( 'should apply formatting when selection is collapsed', async () => {
|
45
|
-
await clickBlockAppender();
|
46
|
-
await page.keyboard.type( 'Some ' );
|
47
|
-
// All following characters should now be bold.
|
48
|
-
await pressKeyWithModifier( 'primary', 'b' );
|
49
|
-
await page.keyboard.type( 'bold' );
|
50
|
-
// All following characters should no longer be bold.
|
51
|
-
await pressKeyWithModifier( 'primary', 'b' );
|
52
|
-
await page.keyboard.type( '.' );
|
53
|
-
|
54
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
55
|
-
} );
|
56
|
-
|
57
|
-
it( 'should apply multiple formats when selection is collapsed', async () => {
|
58
|
-
await clickBlockAppender();
|
59
|
-
await pressKeyWithModifier( 'primary', 'b' );
|
60
|
-
await pressKeyWithModifier( 'primary', 'i' );
|
61
|
-
await page.keyboard.type( '1' );
|
62
|
-
await pressKeyWithModifier( 'primary', 'i' );
|
63
|
-
await pressKeyWithModifier( 'primary', 'b' );
|
64
|
-
await page.keyboard.type( '.' );
|
65
|
-
|
66
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
67
|
-
} );
|
68
|
-
|
69
|
-
it( 'should not highlight more than one format', async () => {
|
70
|
-
await clickBlockAppender();
|
71
|
-
await pressKeyWithModifier( 'primary', 'b' );
|
72
|
-
await page.keyboard.type( '1' );
|
73
|
-
await pressKeyWithModifier( 'primary', 'b' );
|
74
|
-
await page.keyboard.type( ' 2' );
|
75
|
-
await pressKeyWithModifier( 'shift', 'ArrowLeft' );
|
76
|
-
await pressKeyWithModifier( 'primary', 'b' );
|
77
|
-
|
78
|
-
const count = await canvas().evaluate(
|
79
|
-
() =>
|
80
|
-
document.querySelectorAll( '*[data-rich-text-format-boundary]' )
|
81
|
-
.length
|
82
|
-
);
|
83
|
-
|
84
|
-
expect( count ).toBe( 1 );
|
85
|
-
} );
|
86
|
-
|
87
|
-
it( 'should return focus when pressing formatting button', async () => {
|
88
|
-
await clickBlockAppender();
|
89
|
-
await page.keyboard.type( 'Some ' );
|
90
|
-
await showBlockToolbar();
|
91
|
-
await page.click( '[aria-label="Bold"]' );
|
92
|
-
await page.keyboard.type( 'bold' );
|
93
|
-
await showBlockToolbar();
|
94
|
-
await page.click( '[aria-label="Bold"]' );
|
95
|
-
await page.keyboard.type( '.' );
|
96
|
-
|
97
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
98
|
-
} );
|
99
|
-
|
100
|
-
it( 'should transform backtick to code', async () => {
|
101
|
-
await clickBlockAppender();
|
102
|
-
await page.keyboard.type( 'A `backtick`' );
|
103
|
-
|
104
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
105
|
-
|
106
|
-
await pressKeyWithModifier( 'primary', 'z' );
|
107
|
-
|
108
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
109
|
-
} );
|
110
|
-
|
111
|
-
it( 'should undo backtick transform with backspace', async () => {
|
112
|
-
await clickBlockAppender();
|
113
|
-
await page.keyboard.type( '`a`' );
|
114
|
-
await page.keyboard.press( 'Backspace' );
|
115
|
-
|
116
|
-
// Expect "`a`" to be restored.
|
117
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
118
|
-
} );
|
119
|
-
|
120
|
-
it( 'should not undo backtick transform with backspace after typing', async () => {
|
121
|
-
await clickBlockAppender();
|
122
|
-
await page.keyboard.type( '`a`' );
|
123
|
-
await page.keyboard.type( 'b' );
|
124
|
-
await page.keyboard.press( 'Backspace' );
|
125
|
-
await page.keyboard.press( 'Backspace' );
|
126
|
-
|
127
|
-
// Expect "a" to be deleted.
|
128
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
129
|
-
} );
|
130
|
-
|
131
|
-
it( 'should not undo backtick transform with backspace after selection change', async () => {
|
132
|
-
await clickBlockAppender();
|
133
|
-
await page.keyboard.type( '`a`' );
|
134
|
-
await page.evaluate( () => new Promise( window.requestIdleCallback ) );
|
135
|
-
// Move inside format boundary.
|
136
|
-
await page.keyboard.press( 'ArrowLeft' );
|
137
|
-
await page.keyboard.press( 'ArrowLeft' );
|
138
|
-
await page.keyboard.press( 'ArrowRight' );
|
139
|
-
await page.keyboard.press( 'Backspace' );
|
140
|
-
|
141
|
-
// Expect "a" to be deleted.
|
142
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
143
|
-
} );
|
144
|
-
|
145
|
-
it( 'should not format text after code backtick', async () => {
|
146
|
-
await clickBlockAppender();
|
147
|
-
await page.keyboard.type( 'A `backtick` and more.' );
|
148
|
-
|
149
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
150
|
-
} );
|
151
|
-
|
152
|
-
it( 'should transform when typing backtick over selection', async () => {
|
153
|
-
await clickBlockAppender();
|
154
|
-
await page.keyboard.type( 'A selection test.' );
|
155
|
-
await page.keyboard.press( 'Home' );
|
156
|
-
await page.keyboard.press( 'ArrowRight' );
|
157
|
-
await page.keyboard.press( 'ArrowRight' );
|
158
|
-
await pressKeyWithModifier( 'shiftAlt', 'ArrowRight' );
|
159
|
-
await page.keyboard.type( '`' );
|
160
|
-
|
161
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
162
|
-
|
163
|
-
// Should undo the transform.
|
164
|
-
await pressKeyWithModifier( 'primary', 'z' );
|
165
|
-
|
166
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
167
|
-
} );
|
168
|
-
|
169
|
-
it( 'should only mutate text data on input', async () => {
|
170
|
-
await clickBlockAppender();
|
171
|
-
await page.keyboard.type( '1' );
|
172
|
-
await pressKeyWithModifier( 'primary', 'b' );
|
173
|
-
await page.keyboard.type( '2' );
|
174
|
-
await pressKeyWithModifier( 'primary', 'b' );
|
175
|
-
await page.keyboard.type( '3' );
|
176
|
-
|
177
|
-
await canvas().evaluate( () => {
|
178
|
-
let called;
|
179
|
-
const { body } = document;
|
180
|
-
const config = {
|
181
|
-
attributes: true,
|
182
|
-
childList: true,
|
183
|
-
characterData: true,
|
184
|
-
subtree: true,
|
185
|
-
};
|
186
|
-
|
187
|
-
const mutationObserver = new MutationObserver( ( records ) => {
|
188
|
-
if ( called || records.length > 1 ) {
|
189
|
-
throw new Error( 'Typing should only mutate once.' );
|
190
|
-
}
|
191
|
-
|
192
|
-
records.forEach( ( record ) => {
|
193
|
-
if ( record.type !== 'characterData' ) {
|
194
|
-
throw new Error(
|
195
|
-
`Typing mutated more than character data: ${ record.type }`
|
196
|
-
);
|
197
|
-
}
|
198
|
-
} );
|
199
|
-
|
200
|
-
called = true;
|
201
|
-
} );
|
202
|
-
|
203
|
-
mutationObserver.observe( body, config );
|
204
|
-
|
205
|
-
window.unsubscribes = [ () => mutationObserver.disconnect() ];
|
206
|
-
|
207
|
-
document.addEventListener(
|
208
|
-
'selectionchange',
|
209
|
-
() => {
|
210
|
-
function throwMultipleSelectionChange() {
|
211
|
-
throw new Error(
|
212
|
-
'Typing should only emit one selection change event.'
|
213
|
-
);
|
214
|
-
}
|
215
|
-
|
216
|
-
document.addEventListener(
|
217
|
-
'selectionchange',
|
218
|
-
throwMultipleSelectionChange,
|
219
|
-
{
|
220
|
-
once: true,
|
221
|
-
}
|
222
|
-
);
|
223
|
-
|
224
|
-
window.unsubscribes.push( () => {
|
225
|
-
document.removeEventListener(
|
226
|
-
'selectionchange',
|
227
|
-
throwMultipleSelectionChange
|
228
|
-
);
|
229
|
-
} );
|
230
|
-
},
|
231
|
-
{ once: true }
|
232
|
-
);
|
233
|
-
} );
|
234
|
-
|
235
|
-
await page.keyboard.type( '4' );
|
236
|
-
|
237
|
-
await canvas().evaluate( () => {
|
238
|
-
// The selection change event should be called once. If there's only
|
239
|
-
// one item in `window.unsubscribes`, it means that only one
|
240
|
-
// function is present to disconnect the `mutationObserver`.
|
241
|
-
if ( window.unsubscribes.length === 1 ) {
|
242
|
-
throw new Error(
|
243
|
-
'The selection change event listener was never called.'
|
244
|
-
);
|
245
|
-
}
|
246
|
-
|
247
|
-
window.unsubscribes.forEach( ( unsubscribe ) => unsubscribe() );
|
248
|
-
} );
|
249
|
-
|
250
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
251
|
-
} );
|
252
|
-
|
253
|
-
it( 'should not lose selection direction', async () => {
|
254
|
-
await clickBlockAppender();
|
255
|
-
await pressKeyWithModifier( 'primary', 'b' );
|
256
|
-
await page.keyboard.type( '1' );
|
257
|
-
await pressKeyWithModifier( 'primary', 'b' );
|
258
|
-
await page.keyboard.type( '23' );
|
259
|
-
await page.keyboard.press( 'ArrowLeft' );
|
260
|
-
await page.keyboard.down( 'Shift' );
|
261
|
-
await page.keyboard.press( 'ArrowLeft' );
|
262
|
-
await page.keyboard.press( 'ArrowLeft' );
|
263
|
-
await page.keyboard.press( 'ArrowRight' );
|
264
|
-
await page.keyboard.press( 'ArrowRight' );
|
265
|
-
await page.keyboard.up( 'Shift' );
|
266
|
-
|
267
|
-
// There should be no selection. The following should insert "-" without
|
268
|
-
// deleting the numbers.
|
269
|
-
await page.keyboard.type( '-' );
|
270
|
-
|
271
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
272
|
-
} );
|
273
|
-
|
274
|
-
it( 'should handle Home and End keys', async () => {
|
275
|
-
await page.keyboard.press( 'Enter' );
|
276
|
-
|
277
|
-
// Wait for rich text editor to load.
|
278
|
-
await canvas().waitForSelector( '.block-editor-rich-text__editable' );
|
279
|
-
|
280
|
-
await pressKeyWithModifier( 'primary', 'b' );
|
281
|
-
await page.keyboard.type( '12' );
|
282
|
-
await pressKeyWithModifier( 'primary', 'b' );
|
283
|
-
|
284
|
-
await page.keyboard.press( 'Home' );
|
285
|
-
await page.keyboard.type( '-' );
|
286
|
-
await page.keyboard.press( 'End' );
|
287
|
-
await page.keyboard.type( '+' );
|
288
|
-
|
289
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
290
|
-
} );
|
291
|
-
|
292
|
-
it( 'should update internal selection after fresh focus', async () => {
|
293
|
-
await page.keyboard.press( 'Enter' );
|
294
|
-
await page.keyboard.type( '1' );
|
295
|
-
await page.keyboard.press( 'Tab' );
|
296
|
-
await pressKeyWithModifier( 'shift', 'Tab' );
|
297
|
-
await pressKeyWithModifier( 'primary', 'b' );
|
298
|
-
await page.keyboard.type( '2' );
|
299
|
-
await pressKeyWithModifier( 'primary', 'b' );
|
300
|
-
|
301
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
302
|
-
} );
|
303
|
-
|
304
|
-
it( 'should keep internal selection after blur', async () => {
|
305
|
-
await page.keyboard.press( 'Enter' );
|
306
|
-
await page.keyboard.type( '1' );
|
307
|
-
// Simulate moving focus to a different app, then moving focus back,
|
308
|
-
// without selection being changed.
|
309
|
-
await canvas().evaluate( () => {
|
310
|
-
const activeElement = document.activeElement;
|
311
|
-
activeElement.blur();
|
312
|
-
activeElement.focus();
|
313
|
-
} );
|
314
|
-
// Wait for the next animation frame, see the focus event listener in
|
315
|
-
// RichText.
|
316
|
-
await page.evaluate(
|
317
|
-
() => new Promise( window.requestAnimationFrame )
|
318
|
-
);
|
319
|
-
await pressKeyWithModifier( 'primary', 'b' );
|
320
|
-
await page.keyboard.type( '2' );
|
321
|
-
await pressKeyWithModifier( 'primary', 'b' );
|
322
|
-
|
323
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
324
|
-
} );
|
325
|
-
|
326
|
-
it( 'should split rich text on paste', async () => {
|
327
|
-
await clickBlockAppender();
|
328
|
-
await page.keyboard.type( '1' );
|
329
|
-
await page.keyboard.press( 'Enter' );
|
330
|
-
await page.keyboard.type( '2' );
|
331
|
-
await pressKeyWithModifier( 'primary', 'a' );
|
332
|
-
await pressKeyWithModifier( 'primary', 'a' );
|
333
|
-
await pressKeyWithModifier( 'primary', 'x' );
|
334
|
-
await page.keyboard.type( 'ab' );
|
335
|
-
await page.keyboard.press( 'ArrowLeft' );
|
336
|
-
await pressKeyWithModifier( 'primary', 'v' );
|
337
|
-
|
338
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
339
|
-
} );
|
340
|
-
|
341
|
-
it( 'should not split rich text on inline paste', async () => {
|
342
|
-
await clickBlockAppender();
|
343
|
-
await page.keyboard.type( '2' );
|
344
|
-
await pressKeyWithModifier( 'primary', 'a' );
|
345
|
-
await pressKeyWithModifier( 'primary', 'x' );
|
346
|
-
await page.keyboard.type( '13' );
|
347
|
-
await page.keyboard.press( 'ArrowLeft' );
|
348
|
-
await pressKeyWithModifier( 'primary', 'v' );
|
349
|
-
|
350
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
351
|
-
} );
|
352
|
-
|
353
|
-
it( 'should not split rich text on inline paste with formatting', async () => {
|
354
|
-
await clickBlockAppender();
|
355
|
-
await page.keyboard.type( '1' );
|
356
|
-
await pressKeyWithModifier( 'primary', 'b' );
|
357
|
-
await page.keyboard.type( '2' );
|
358
|
-
await pressKeyWithModifier( 'primary', 'b' );
|
359
|
-
await page.keyboard.type( '3' );
|
360
|
-
await pressKeyWithModifier( 'primary', 'a' );
|
361
|
-
await pressKeyWithModifier( 'primary', 'x' );
|
362
|
-
await page.keyboard.type( 'ab' );
|
363
|
-
await page.keyboard.press( 'ArrowLeft' );
|
364
|
-
await pressKeyWithModifier( 'primary', 'v' );
|
365
|
-
|
366
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
367
|
-
} );
|
368
|
-
|
369
|
-
it( 'should make bold after split and merge', async () => {
|
370
|
-
await clickBlockAppender();
|
371
|
-
await page.keyboard.type( '1' );
|
372
|
-
await page.keyboard.press( 'Enter' );
|
373
|
-
await page.keyboard.press( 'Backspace' );
|
374
|
-
await pressKeyWithModifier( 'primary', 'b' );
|
375
|
-
await page.keyboard.type( '2' );
|
376
|
-
|
377
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
378
|
-
} );
|
379
|
-
|
380
|
-
it( 'should apply active formatting for inline paste', async () => {
|
381
|
-
await clickBlockAppender();
|
382
|
-
await pressKeyWithModifier( 'primary', 'b' );
|
383
|
-
await page.keyboard.type( '1' );
|
384
|
-
await page.keyboard.type( '2' );
|
385
|
-
await pressKeyWithModifier( 'primary', 'b' );
|
386
|
-
await page.keyboard.type( '3' );
|
387
|
-
await pressKeyWithModifier( 'shift', 'ArrowLeft' );
|
388
|
-
await pressKeyWithModifier( 'primary', 'c' );
|
389
|
-
await page.keyboard.press( 'ArrowLeft' );
|
390
|
-
await page.keyboard.press( 'ArrowLeft' );
|
391
|
-
await page.keyboard.press( 'ArrowLeft' );
|
392
|
-
await pressKeyWithModifier( 'primary', 'v' );
|
393
|
-
|
394
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
395
|
-
} );
|
396
|
-
|
397
|
-
it( 'should preserve internal formatting', async () => {
|
398
|
-
await clickBlockAppender();
|
399
|
-
|
400
|
-
// Add text and select to color.
|
401
|
-
await page.keyboard.type( '1' );
|
402
|
-
await pressKeyWithModifier( 'primary', 'a' );
|
403
|
-
await clickBlockToolbarButton( 'More' );
|
404
|
-
|
405
|
-
const button = await page.waitForXPath(
|
406
|
-
`//button[text()='Highlight']`
|
407
|
-
);
|
408
|
-
// Clicks may fail if the button is out of view. Assure it is before click.
|
409
|
-
await button.evaluate( ( element ) => element.scrollIntoView() );
|
410
|
-
await button.click();
|
411
|
-
|
412
|
-
// Wait for the popover with "Text" tab to appear.
|
413
|
-
await page.waitForXPath(
|
414
|
-
'//button[@role="tab"][@aria-selected="true"][text()="Text"]'
|
415
|
-
);
|
416
|
-
// Initial focus is on the "Text" tab.
|
417
|
-
// Tab to the "Custom color picker".
|
418
|
-
await page.keyboard.press( 'Tab' );
|
419
|
-
// Tab to black.
|
420
|
-
await page.keyboard.press( 'Tab' );
|
421
|
-
// Select color other than black.
|
422
|
-
await page.keyboard.press( 'Tab' );
|
423
|
-
await page.keyboard.press( 'Enter' );
|
424
|
-
|
425
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
426
|
-
|
427
|
-
// Dismiss color picker popover.
|
428
|
-
await page.keyboard.press( 'Escape' );
|
429
|
-
|
430
|
-
// Navigate to the block.
|
431
|
-
await page.keyboard.press( 'Tab' );
|
432
|
-
|
433
|
-
// Copy the colored text.
|
434
|
-
await pressKeyWithModifier( 'primary', 'c' );
|
435
|
-
|
436
|
-
// Collapse the selection to the end.
|
437
|
-
await page.keyboard.press( 'ArrowRight' );
|
438
|
-
|
439
|
-
// Create a new paragraph.
|
440
|
-
await page.keyboard.press( 'Enter' );
|
441
|
-
|
442
|
-
// Paste the colored text.
|
443
|
-
await pressKeyWithModifier( 'primary', 'v' );
|
444
|
-
|
445
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
446
|
-
} );
|
447
|
-
|
448
|
-
it( 'should paste paragraph contents into list', async () => {
|
449
|
-
await clickBlockAppender();
|
450
|
-
|
451
|
-
// Create two lines of text in a paragraph.
|
452
|
-
await page.keyboard.type( '1' );
|
453
|
-
await pressKeyWithModifier( 'shift', 'Enter' );
|
454
|
-
await page.keyboard.type( '2' );
|
455
|
-
|
456
|
-
// Select all and copy.
|
457
|
-
await pressKeyWithModifier( 'primary', 'a' );
|
458
|
-
await pressKeyWithModifier( 'primary', 'c' );
|
459
|
-
|
460
|
-
// Collapse the selection to the end.
|
461
|
-
await page.keyboard.press( 'ArrowRight' );
|
462
|
-
|
463
|
-
// Create a list.
|
464
|
-
await page.keyboard.press( 'Enter' );
|
465
|
-
await page.keyboard.type( '* ' );
|
466
|
-
|
467
|
-
// Paste paragraph contents.
|
468
|
-
await pressKeyWithModifier( 'primary', 'v' );
|
469
|
-
|
470
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
471
|
-
} );
|
472
|
-
|
473
|
-
it( 'should paste list contents into paragraph', async () => {
|
474
|
-
await clickBlockAppender();
|
475
|
-
|
476
|
-
// Create an indented list of two lines.
|
477
|
-
await page.keyboard.type( '* 1' );
|
478
|
-
await page.keyboard.press( 'Enter' );
|
479
|
-
await page.keyboard.type( ' 2' );
|
480
|
-
|
481
|
-
// Select all text.
|
482
|
-
await pressKeyWithModifier( 'primary', 'a' );
|
483
|
-
// Select the nested list.
|
484
|
-
await pressKeyWithModifier( 'primary', 'a' );
|
485
|
-
// Select the parent list item.
|
486
|
-
await pressKeyWithModifier( 'primary', 'a' );
|
487
|
-
// Select all the parent list item text.
|
488
|
-
await pressKeyWithModifier( 'primary', 'a' );
|
489
|
-
// Select the entire list.
|
490
|
-
await pressKeyWithModifier( 'primary', 'a' );
|
491
|
-
await pressKeyWithModifier( 'primary', 'c' );
|
492
|
-
|
493
|
-
await page.keyboard.press( 'Enter' );
|
494
|
-
|
495
|
-
// Paste paragraph contents.
|
496
|
-
await pressKeyWithModifier( 'primary', 'v' );
|
497
|
-
|
498
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
499
|
-
} );
|
500
|
-
|
501
|
-
it( 'should navigate arround emoji', async () => {
|
502
|
-
await clickBlockAppender();
|
503
|
-
await page.keyboard.type( '🍓' );
|
504
|
-
// Only one press on arrow left should be required to move in front of
|
505
|
-
// the emoji.
|
506
|
-
await page.keyboard.press( 'ArrowLeft' );
|
507
|
-
await page.keyboard.type( '1' );
|
508
|
-
|
509
|
-
// Expect '1🍓'.
|
510
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
511
|
-
} );
|
512
|
-
|
513
|
-
it( 'should run input rules after composition end', async () => {
|
514
|
-
await clickBlockAppender();
|
515
|
-
// Puppeteer doesn't support composition, so emulate it by inserting
|
516
|
-
// text in the DOM directly, setting selection in the right place, and
|
517
|
-
// firing `compositionend`.
|
518
|
-
// See https://github.com/puppeteer/puppeteer/issues/4981.
|
519
|
-
await canvas().evaluate( async () => {
|
520
|
-
document.activeElement.textContent = '`a`';
|
521
|
-
const selection = window.getSelection();
|
522
|
-
// The `selectionchange` and `compositionend` events should run in separate event
|
523
|
-
// loop ticks to process all data store updates in time. Native events would be
|
524
|
-
// scheduled the same way.
|
525
|
-
selection.selectAllChildren( document.activeElement );
|
526
|
-
selection.collapseToEnd();
|
527
|
-
await new Promise( ( r ) => setTimeout( r, 0 ) );
|
528
|
-
document.activeElement.dispatchEvent(
|
529
|
-
new CompositionEvent( 'compositionend' )
|
530
|
-
);
|
531
|
-
} );
|
532
|
-
|
533
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
534
|
-
} );
|
535
|
-
|
536
|
-
it( 'should navigate consecutive format boundaries', async () => {
|
537
|
-
await clickBlockAppender();
|
538
|
-
await pressKeyWithModifier( 'primary', 'b' );
|
539
|
-
await page.keyboard.type( '1' );
|
540
|
-
await pressKeyWithModifier( 'primary', 'b' );
|
541
|
-
await pressKeyWithModifier( 'primary', 'i' );
|
542
|
-
await page.keyboard.type( '2' );
|
543
|
-
await pressKeyWithModifier( 'primary', 'i' );
|
544
|
-
|
545
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
546
|
-
|
547
|
-
// Should move into the second format.
|
548
|
-
await page.keyboard.press( 'ArrowLeft' );
|
549
|
-
// Should move to the start of the second format.
|
550
|
-
await page.keyboard.press( 'ArrowLeft' );
|
551
|
-
// Should move between the first and second format.
|
552
|
-
await page.keyboard.press( 'ArrowLeft' );
|
553
|
-
|
554
|
-
await page.keyboard.type( '-' );
|
555
|
-
|
556
|
-
// Expect: <strong>1</strong>-<em>2</em>
|
557
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
558
|
-
} );
|
559
|
-
|
560
|
-
test( 'should copy/paste heading', async () => {
|
561
|
-
await insertBlock( 'Heading' );
|
562
|
-
await page.keyboard.type( 'Heading' );
|
563
|
-
await pressKeyWithModifier( 'primary', 'a' );
|
564
|
-
await pressKeyWithModifier( 'primary', 'c' );
|
565
|
-
await page.keyboard.press( 'ArrowRight' );
|
566
|
-
await page.keyboard.press( 'Enter' );
|
567
|
-
await pressKeyWithModifier( 'primary', 'v' );
|
568
|
-
expect( await getEditedPostContent() ).toMatchSnapshot();
|
569
|
-
} );
|
570
|
-
} );
|