@wordpress/e2e-tests 7.5.0 → 7.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.
- package/CHANGELOG.md +2 -0
- package/config/setup-test-framework.js +9 -0
- package/package.json +7 -7
- package/plugins/block-context.php +1 -1
- package/plugins/iframed-block/block.json +1 -1
- package/plugins/iframed-block.php +2 -2
- package/plugins/iframed-enqueue-block-assets.php +1 -1
- package/plugins/iframed-inline-styles/block.json +1 -1
- package/plugins/iframed-inline-styles/editor.js +1 -1
- package/plugins/iframed-inline-styles.php +3 -3
- package/plugins/iframed-masonry-block/block.json +1 -1
- package/plugins/iframed-masonry-block/editor.js +1 -1
- package/plugins/iframed-masonry-block.php +2 -2
- package/plugins/iframed-multiple-stylesheets/block.json +1 -1
- package/plugins/iframed-multiple-stylesheets/editor.js +1 -1
- package/plugins/iframed-multiple-stylesheets.php +2 -2
- package/plugins/marquee-function-widget.php +2 -2
- package/specs/editor/blocks/post-title.test.js +5 -4
- package/specs/editor/blocks/site-title.test.js +3 -2
- package/specs/editor/plugins/annotations.test.js +17 -9
- package/specs/editor/plugins/block-variations.test.js +6 -5
- package/specs/editor/plugins/cpt-locking.test.js +15 -12
- package/specs/editor/plugins/iframed-inline-styles.test.js +6 -2
- package/specs/editor/plugins/iframed-masonry-block.test.js +1 -1
- package/specs/editor/plugins/iframed-multiple-block-stylesheets.test.js +1 -1
- package/specs/editor/plugins/inner-blocks-allowed-blocks.test.js +7 -6
- package/specs/editor/plugins/inner-blocks-prioritized-inserter-blocks.test.js +2 -1
- package/specs/editor/various/__snapshots__/links.test.js.snap +0 -24
- package/specs/editor/various/adding-inline-tokens.test.js +0 -1
- package/specs/editor/various/autosave.test.js +2 -1
- package/specs/editor/various/block-editor-keyboard-shortcuts.test.js +3 -2
- package/specs/editor/various/block-grouping.test.js +5 -4
- package/specs/editor/various/block-hierarchy-navigation.test.js +12 -9
- package/specs/editor/various/change-detection.test.js +20 -19
- package/specs/editor/various/editor-modes.test.js +7 -6
- package/specs/editor/various/embedding.test.js +21 -15
- package/specs/editor/various/inserting-blocks.test.js +19 -14
- package/specs/editor/various/invalid-block.test.js +4 -6
- package/specs/editor/various/keyboard-navigable-blocks.test.js +16 -17
- package/specs/editor/various/links.test.js +22 -154
- package/specs/editor/various/navigable-toolbar.test.js +14 -14
- package/specs/editor/various/nux.test.js +6 -2
- package/specs/editor/various/publish-button.test.js +3 -2
- package/specs/editor/various/publish-panel.test.js +4 -3
- package/specs/editor/various/publishing.test.js +9 -5
- package/specs/editor/various/reusable-blocks.test.js +22 -18
- package/specs/editor/various/rich-text.test.js +7 -6
- package/specs/editor/various/sidebar-permalink.test.js +4 -3
- package/specs/editor/various/taxonomies.test.js +4 -3
- package/specs/editor/various/typewriter.test.js +68 -50
- package/specs/performance/site-editor.test.js +2 -1
- package/specs/site-editor/settings-sidebar.test.js +2 -2
@@ -11,6 +11,7 @@ import {
|
|
11
11
|
setBrowserViewport,
|
12
12
|
openPublishPanel,
|
13
13
|
pressKeyWithModifier,
|
14
|
+
canvas,
|
14
15
|
} from '@wordpress/e2e-test-utils';
|
15
16
|
|
16
17
|
describe( 'Publishing', () => {
|
@@ -22,7 +23,7 @@ describe( 'Publishing', () => {
|
|
22
23
|
} );
|
23
24
|
|
24
25
|
it( `disables the publish button when a ${ postType } is locked`, async () => {
|
25
|
-
await
|
26
|
+
await canvas().type(
|
26
27
|
'.editor-post-title__input',
|
27
28
|
'E2E Test Post lock check publish button'
|
28
29
|
);
|
@@ -42,7 +43,7 @@ describe( 'Publishing', () => {
|
|
42
43
|
} );
|
43
44
|
|
44
45
|
it( `disables the save shortcut when a ${ postType } is locked`, async () => {
|
45
|
-
await
|
46
|
+
await canvas().type(
|
46
47
|
'.editor-post-title__input',
|
47
48
|
'E2E Test Post check save shortcut'
|
48
49
|
);
|
@@ -79,7 +80,7 @@ describe( 'Publishing', () => {
|
|
79
80
|
} );
|
80
81
|
|
81
82
|
it( `should publish the ${ postType } and close the panel once we start editing again.`, async () => {
|
82
|
-
await
|
83
|
+
await canvas().type( '.editor-post-title__input', 'E2E Test Post' );
|
83
84
|
|
84
85
|
await publishPost();
|
85
86
|
|
@@ -89,7 +90,7 @@ describe( 'Publishing', () => {
|
|
89
90
|
).not.toBeNull();
|
90
91
|
|
91
92
|
// Start editing again.
|
92
|
-
await
|
93
|
+
await canvas().type( '.editor-post-title__input', ' (Updated)' );
|
93
94
|
|
94
95
|
// The post-publishing panel is not visible anymore.
|
95
96
|
expect( await page.$( '.editor-post-publish-panel' ) ).toBeNull();
|
@@ -117,7 +118,10 @@ describe( 'Publishing', () => {
|
|
117
118
|
} );
|
118
119
|
|
119
120
|
it( `should publish the ${ postType } without opening the post-publish sidebar.`, async () => {
|
120
|
-
await
|
121
|
+
await canvas().type(
|
122
|
+
'.editor-post-title__input',
|
123
|
+
'E2E Test Post'
|
124
|
+
);
|
121
125
|
|
122
126
|
// The "Publish" button should be shown instead of the "Publish..." toggle.
|
123
127
|
expect(
|
@@ -16,6 +16,7 @@ import {
|
|
16
16
|
saveDraft,
|
17
17
|
createReusableBlock,
|
18
18
|
publishPost,
|
19
|
+
canvas,
|
19
20
|
} from '@wordpress/e2e-test-utils';
|
20
21
|
|
21
22
|
const reusableBlockNameInputSelector =
|
@@ -83,7 +84,7 @@ describe( 'Reusable blocks', () => {
|
|
83
84
|
await page.keyboard.type( 'Surprised greeting block' );
|
84
85
|
|
85
86
|
// Quickly focus the paragraph block.
|
86
|
-
await
|
87
|
+
await canvas().click(
|
87
88
|
'.block-editor-block-list__block[data-type="core/block"] p'
|
88
89
|
);
|
89
90
|
await page.keyboard.press( 'Escape' ); // Enter navigation mode.
|
@@ -96,7 +97,7 @@ describe( 'Reusable blocks', () => {
|
|
96
97
|
await saveAllButDontPublish();
|
97
98
|
|
98
99
|
// Check that its content is up to date.
|
99
|
-
const text = await
|
100
|
+
const text = await canvas().$eval(
|
100
101
|
'.block-editor-block-list__block[data-type="core/block"] p',
|
101
102
|
( element ) => element.innerText
|
102
103
|
);
|
@@ -111,13 +112,13 @@ describe( 'Reusable blocks', () => {
|
|
111
112
|
await clickBlockToolbarButton( 'Convert to regular block' );
|
112
113
|
|
113
114
|
// Check that we have a paragraph block on the page.
|
114
|
-
const paragraphBlock = await
|
115
|
+
const paragraphBlock = await canvas().$(
|
115
116
|
'.block-editor-block-list__block[data-type="core/paragraph"]'
|
116
117
|
);
|
117
118
|
expect( paragraphBlock ).not.toBeNull();
|
118
119
|
|
119
120
|
// Check that its content is up to date.
|
120
|
-
const paragraphContent = await
|
121
|
+
const paragraphContent = await canvas().$eval(
|
121
122
|
'.block-editor-block-list__block[data-type="core/paragraph"]',
|
122
123
|
( element ) => element.innerText
|
123
124
|
);
|
@@ -132,7 +133,7 @@ describe( 'Reusable blocks', () => {
|
|
132
133
|
);
|
133
134
|
|
134
135
|
// Make sure the reusable block has loaded properly before attempting to publish the post.
|
135
|
-
await
|
136
|
+
await canvas().waitForSelector( 'p[aria-label="Paragraph block"]' );
|
136
137
|
|
137
138
|
await publishPost();
|
138
139
|
|
@@ -142,8 +143,8 @@ describe( 'Reusable blocks', () => {
|
|
142
143
|
await page.waitForSelector( closePublishPanelSelector );
|
143
144
|
await page.click( closePublishPanelSelector );
|
144
145
|
|
145
|
-
await
|
146
|
-
await
|
146
|
+
await canvas().waitForSelector( 'p[aria-label="Paragraph block"]' );
|
147
|
+
await canvas().focus( 'p[aria-label="Paragraph block"]' );
|
147
148
|
|
148
149
|
// Change the block's content.
|
149
150
|
await page.keyboard.type( 'Einen ' );
|
@@ -152,7 +153,7 @@ describe( 'Reusable blocks', () => {
|
|
152
153
|
await saveAll();
|
153
154
|
|
154
155
|
// Check that its content is up to date.
|
155
|
-
const paragraphContent = await
|
156
|
+
const paragraphContent = await canvas().$eval(
|
156
157
|
'p[aria-label="Paragraph block"]',
|
157
158
|
( element ) => element.innerText
|
158
159
|
);
|
@@ -235,11 +236,12 @@ describe( 'Reusable blocks', () => {
|
|
235
236
|
await editButton.click();
|
236
237
|
|
237
238
|
await page.waitForNavigation();
|
239
|
+
await page.waitForSelector( 'iframe[name="editor-canvas"]' );
|
238
240
|
|
239
241
|
// Click the block to give it focus.
|
240
242
|
const blockSelector = 'p[data-title="Paragraph"]';
|
241
|
-
await
|
242
|
-
await
|
243
|
+
await canvas().waitForSelector( blockSelector );
|
244
|
+
await canvas().click( blockSelector );
|
243
245
|
|
244
246
|
// Delete the block, leaving the reusable block empty.
|
245
247
|
await clickBlockToolbarButton( 'Options' );
|
@@ -277,7 +279,7 @@ describe( 'Reusable blocks', () => {
|
|
277
279
|
] );
|
278
280
|
} );
|
279
281
|
|
280
|
-
await
|
282
|
+
await canvas().waitForXPath(
|
281
283
|
'//*[contains(@class, "block-editor-warning")]/*[text()="Block has been deleted or is unavailable."]'
|
282
284
|
);
|
283
285
|
|
@@ -295,15 +297,16 @@ describe( 'Reusable blocks', () => {
|
|
295
297
|
await insertReusableBlock( 'Duplicated reusable block' );
|
296
298
|
await saveDraft();
|
297
299
|
await page.reload();
|
300
|
+
await page.waitForSelector( 'iframe[name="editor-canvas"]' );
|
298
301
|
|
299
302
|
// Wait for the paragraph to be loaded.
|
300
|
-
await
|
303
|
+
await canvas().waitForSelector(
|
301
304
|
'.block-editor-block-list__block[data-type="core/paragraph"]'
|
302
305
|
);
|
303
306
|
// The first click selects the reusable block wrapper.
|
304
307
|
// The second click selects the actual paragraph block.
|
305
|
-
await
|
306
|
-
await
|
308
|
+
await canvas().click( '.wp-block-block' );
|
309
|
+
await canvas().focus(
|
307
310
|
'.block-editor-block-list__block[data-type="core/paragraph"]'
|
308
311
|
);
|
309
312
|
await pressKeyWithModifier( 'primary', 'a' );
|
@@ -333,8 +336,8 @@ describe( 'Reusable blocks', () => {
|
|
333
336
|
|
334
337
|
// Make an edit to the reusable block and assert that there's only a
|
335
338
|
// paragraph in a reusable block.
|
336
|
-
await
|
337
|
-
await
|
339
|
+
await canvas().waitForSelector( 'p[aria-label="Paragraph block"]' );
|
340
|
+
await canvas().click( 'p[aria-label="Paragraph block"]' );
|
338
341
|
await page.keyboard.type( '2' );
|
339
342
|
const selector =
|
340
343
|
'//div[@aria-label="Block: Reusable block"]//p[@aria-label="Paragraph block"][.="12"]';
|
@@ -358,9 +361,10 @@ describe( 'Reusable blocks', () => {
|
|
358
361
|
insertBlock( 'Quote' );
|
359
362
|
await saveDraft();
|
360
363
|
await page.reload();
|
364
|
+
await page.waitForSelector( 'iframe[name="editor-canvas"]' );
|
361
365
|
|
362
366
|
// The quote block should have a visible preview in the sidebar for this test to be valid.
|
363
|
-
const quoteBlock = await
|
367
|
+
const quoteBlock = await canvas().waitForSelector(
|
364
368
|
'.block-editor-block-list__block[aria-label="Block: Quote"]'
|
365
369
|
);
|
366
370
|
// Select the quote block.
|
@@ -379,7 +383,7 @@ describe( 'Reusable blocks', () => {
|
|
379
383
|
await nameInput.click();
|
380
384
|
await page.keyboard.type( 'Block with styles' );
|
381
385
|
await page.keyboard.press( 'Enter' );
|
382
|
-
const reusableBlock = await
|
386
|
+
const reusableBlock = await canvas().waitForSelector(
|
383
387
|
'.block-editor-block-list__block[aria-label="Block: Reusable block"]'
|
384
388
|
);
|
385
389
|
expect( reusableBlock ).toBeTruthy();
|
@@ -9,6 +9,7 @@ import {
|
|
9
9
|
pressKeyWithModifier,
|
10
10
|
showBlockToolbar,
|
11
11
|
clickBlockToolbarButton,
|
12
|
+
canvas,
|
12
13
|
} from '@wordpress/e2e-test-utils';
|
13
14
|
|
14
15
|
describe( 'RichText', () => {
|
@@ -74,7 +75,7 @@ describe( 'RichText', () => {
|
|
74
75
|
await pressKeyWithModifier( 'shift', 'ArrowLeft' );
|
75
76
|
await pressKeyWithModifier( 'primary', 'b' );
|
76
77
|
|
77
|
-
const count = await
|
78
|
+
const count = await canvas().evaluate(
|
78
79
|
() =>
|
79
80
|
document.querySelectorAll( '*[data-rich-text-format-boundary]' )
|
80
81
|
.length
|
@@ -173,7 +174,7 @@ describe( 'RichText', () => {
|
|
173
174
|
await pressKeyWithModifier( 'primary', 'b' );
|
174
175
|
await page.keyboard.type( '3' );
|
175
176
|
|
176
|
-
await
|
177
|
+
await canvas().evaluate( () => {
|
177
178
|
let called;
|
178
179
|
const { body } = document;
|
179
180
|
const config = {
|
@@ -233,7 +234,7 @@ describe( 'RichText', () => {
|
|
233
234
|
|
234
235
|
await page.keyboard.type( '4' );
|
235
236
|
|
236
|
-
await
|
237
|
+
await canvas().evaluate( () => {
|
237
238
|
// The selection change event should be called once. If there's only
|
238
239
|
// one item in `window.unsubscribes`, it means that only one
|
239
240
|
// function is present to disconnect the `mutationObserver`.
|
@@ -274,7 +275,7 @@ describe( 'RichText', () => {
|
|
274
275
|
await page.keyboard.press( 'Enter' );
|
275
276
|
|
276
277
|
// Wait for rich text editor to load.
|
277
|
-
await
|
278
|
+
await canvas().waitForSelector( '.block-editor-rich-text__editable' );
|
278
279
|
|
279
280
|
await pressKeyWithModifier( 'primary', 'b' );
|
280
281
|
await page.keyboard.type( '12' );
|
@@ -305,7 +306,7 @@ describe( 'RichText', () => {
|
|
305
306
|
await page.keyboard.type( '1' );
|
306
307
|
// Simulate moving focus to a different app, then moving focus back,
|
307
308
|
// without selection being changed.
|
308
|
-
await
|
309
|
+
await canvas().evaluate( () => {
|
309
310
|
const activeElement = document.activeElement;
|
310
311
|
activeElement.blur();
|
311
312
|
activeElement.focus();
|
@@ -515,7 +516,7 @@ describe( 'RichText', () => {
|
|
515
516
|
// text in the DOM directly, setting selection in the right place, and
|
516
517
|
// firing `compositionend`.
|
517
518
|
// See https://github.com/puppeteer/puppeteer/issues/4981.
|
518
|
-
await
|
519
|
+
await canvas().evaluate( async () => {
|
519
520
|
document.activeElement.textContent = '`a`';
|
520
521
|
const selection = window.getSelection();
|
521
522
|
// The `selectionchange` and `compositionend` events should run in separate event
|
@@ -6,6 +6,7 @@ import {
|
|
6
6
|
createNewPost,
|
7
7
|
deactivatePlugin,
|
8
8
|
publishPost,
|
9
|
+
canvas,
|
9
10
|
} from '@wordpress/e2e-test-utils';
|
10
11
|
|
11
12
|
const urlButtonSelector = '*[aria-label^="Change URL"]';
|
@@ -28,7 +29,7 @@ describe( 'Sidebar Permalink', () => {
|
|
28
29
|
await page.keyboard.type( 'aaaaa' );
|
29
30
|
await publishPost();
|
30
31
|
// Start editing again.
|
31
|
-
await
|
32
|
+
await canvas().type( '.editor-post-title__input', ' (Updated)' );
|
32
33
|
expect( await page.$( urlButtonSelector ) ).toBeNull();
|
33
34
|
} );
|
34
35
|
|
@@ -37,7 +38,7 @@ describe( 'Sidebar Permalink', () => {
|
|
37
38
|
await page.keyboard.type( 'aaaaa' );
|
38
39
|
await publishPost();
|
39
40
|
// Start editing again.
|
40
|
-
await
|
41
|
+
await canvas().type( '.editor-post-title__input', ' (Updated)' );
|
41
42
|
expect( await page.$( urlButtonSelector ) ).toBeNull();
|
42
43
|
} );
|
43
44
|
|
@@ -46,7 +47,7 @@ describe( 'Sidebar Permalink', () => {
|
|
46
47
|
await page.keyboard.type( 'aaaaa' );
|
47
48
|
await publishPost();
|
48
49
|
// Start editing again.
|
49
|
-
await
|
50
|
+
await canvas( 0 ).type( '.editor-post-title__input', ' (Updated)' );
|
50
51
|
expect( await page.$( urlButtonSelector ) ).not.toBeNull();
|
51
52
|
} );
|
52
53
|
} );
|
@@ -6,6 +6,7 @@ import {
|
|
6
6
|
findSidebarPanelWithTitle,
|
7
7
|
openDocumentSettingsSidebar,
|
8
8
|
publishPost,
|
9
|
+
canvas,
|
9
10
|
} from '@wordpress/e2e-test-utils';
|
10
11
|
|
11
12
|
/**
|
@@ -113,7 +114,7 @@ describe( 'Taxonomies', () => {
|
|
113
114
|
expect( selectedCategories[ 0 ] ).toEqual( 'z rand category 1' );
|
114
115
|
|
115
116
|
// Type something in the title so we can publish the post.
|
116
|
-
await
|
117
|
+
await canvas().type( '.editor-post-title__input', 'Hello World' );
|
117
118
|
|
118
119
|
// Publish the post.
|
119
120
|
await publishPost();
|
@@ -171,7 +172,7 @@ describe( 'Taxonomies', () => {
|
|
171
172
|
expect( tags[ 0 ] ).toEqual( tagName );
|
172
173
|
|
173
174
|
// Type something in the title so we can publish the post.
|
174
|
-
await
|
175
|
+
await canvas().type( '.editor-post-title__input', 'Hello World' );
|
175
176
|
|
176
177
|
// Publish the post.
|
177
178
|
await publishPost();
|
@@ -230,7 +231,7 @@ describe( 'Taxonomies', () => {
|
|
230
231
|
expect( tags[ 0 ] ).toEqual( tagName );
|
231
232
|
|
232
233
|
// Type something in the title so we can publish the post.
|
233
|
-
await
|
234
|
+
await canvas().type( '.editor-post-title__input', 'Hello World' );
|
234
235
|
|
235
236
|
// Publish the post.
|
236
237
|
await publishPost();
|
@@ -9,7 +9,12 @@ describe( 'TypeWriter', () => {
|
|
9
9
|
} );
|
10
10
|
|
11
11
|
const getCaretPosition = async () =>
|
12
|
-
await page.evaluate(
|
12
|
+
await page.evaluate(
|
13
|
+
() =>
|
14
|
+
wp.dom.computeCaretRect(
|
15
|
+
document.activeElement?.contentWindow ?? window
|
16
|
+
).y
|
17
|
+
);
|
13
18
|
|
14
19
|
// Allow the scroll position to be 1px off.
|
15
20
|
const BUFFER = 1;
|
@@ -33,11 +38,13 @@ describe( 'TypeWriter', () => {
|
|
33
38
|
|
34
39
|
// Create blocks until the typewriter effect kicks in.
|
35
40
|
while (
|
36
|
-
await page.evaluate(
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
+
await page.evaluate( () => {
|
42
|
+
const { activeElement } =
|
43
|
+
document.activeElement?.contentDocument ?? document;
|
44
|
+
return (
|
45
|
+
wp.dom.getScrollContainer( activeElement ).scrollTop === 0
|
46
|
+
);
|
47
|
+
} )
|
41
48
|
) {
|
42
49
|
await page.keyboard.press( 'Enter' );
|
43
50
|
}
|
@@ -51,14 +58,14 @@ describe( 'TypeWriter', () => {
|
|
51
58
|
|
52
59
|
// Type until the text wraps.
|
53
60
|
while (
|
54
|
-
await page.evaluate(
|
55
|
-
|
56
|
-
document.activeElement
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
)
|
61
|
+
await page.evaluate( () => {
|
62
|
+
const { activeElement } =
|
63
|
+
document.activeElement?.contentDocument ?? document;
|
64
|
+
return (
|
65
|
+
activeElement.clientHeight <=
|
66
|
+
parseInt( getComputedStyle( activeElement ).lineHeight, 10 )
|
67
|
+
);
|
68
|
+
} )
|
62
69
|
) {
|
63
70
|
await page.keyboard.type( 'a' );
|
64
71
|
}
|
@@ -93,32 +100,35 @@ describe( 'TypeWriter', () => {
|
|
93
100
|
// Create zero or more blocks until there is a scrollable container.
|
94
101
|
// No blocks should be created if there's already a scrollbar.
|
95
102
|
while (
|
96
|
-
await page.evaluate(
|
97
|
-
|
98
|
-
|
103
|
+
await page.evaluate( () => {
|
104
|
+
const { activeElement } =
|
105
|
+
document.activeElement?.contentDocument ?? document;
|
106
|
+
const scrollContainer =
|
107
|
+
wp.dom.getScrollContainer( activeElement );
|
108
|
+
return (
|
109
|
+
scrollContainer.scrollHeight ===
|
110
|
+
scrollContainer.clientHeight
|
111
|
+
);
|
112
|
+
} )
|
99
113
|
) {
|
100
114
|
await page.keyboard.press( 'Enter' );
|
101
115
|
}
|
102
116
|
|
103
|
-
const scrollPosition = await page.evaluate(
|
104
|
-
|
105
|
-
|
117
|
+
const scrollPosition = await page.evaluate( () => {
|
118
|
+
const { activeElement } =
|
119
|
+
document.activeElement?.contentDocument ?? document;
|
120
|
+
return wp.dom.getScrollContainer( activeElement ).scrollTop;
|
121
|
+
} );
|
106
122
|
// Expect scrollbar to be at the top.
|
107
123
|
expect( scrollPosition ).toBe( 0 );
|
108
124
|
|
109
125
|
// Move the mouse to the scroll container, and scroll down
|
110
126
|
// a small amount to trigger the typewriter mode.
|
111
|
-
|
112
|
-
const
|
113
|
-
|
127
|
+
await page.evaluate( () => {
|
128
|
+
const { activeElement } =
|
129
|
+
document.activeElement?.contentDocument ?? document;
|
130
|
+
wp.dom.getScrollContainer( activeElement ).scrollTop += 2;
|
114
131
|
} );
|
115
|
-
await page.mouse.move( ...mouseMovePosition );
|
116
|
-
await page.mouse.wheel( { deltaY: 2 } );
|
117
|
-
await page.waitForFunction(
|
118
|
-
() =>
|
119
|
-
wp.dom.getScrollContainer( document.activeElement )
|
120
|
-
.scrollTop === 2
|
121
|
-
);
|
122
132
|
// Wait for the caret rectangle to be recalculated.
|
123
133
|
await page.evaluate(
|
124
134
|
() => new Promise( window.requestAnimationFrame )
|
@@ -128,12 +138,12 @@ describe( 'TypeWriter', () => {
|
|
128
138
|
// coordinates should be the same.
|
129
139
|
const initialPosition = await getCaretPosition();
|
130
140
|
await page.keyboard.press( 'Enter' );
|
131
|
-
await page.waitForFunction(
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
);
|
141
|
+
await page.waitForFunction( () => {
|
142
|
+
const { activeElement } =
|
143
|
+
document.activeElement?.contentDocument ?? document;
|
144
|
+
// Wait for the Typewriter to scroll down past the initial position.
|
145
|
+
return wp.dom.getScrollContainer( activeElement ).scrollTop > 2;
|
146
|
+
} );
|
137
147
|
expect( await getDiff( initialPosition ) ).toBe( 0 );
|
138
148
|
} );
|
139
149
|
|
@@ -164,9 +174,11 @@ describe( 'TypeWriter', () => {
|
|
164
174
|
|
165
175
|
// Create blocks until there is a scrollable container.
|
166
176
|
while (
|
167
|
-
await page.evaluate(
|
168
|
-
|
169
|
-
|
177
|
+
await page.evaluate( () => {
|
178
|
+
const { activeElement } =
|
179
|
+
document.activeElement?.contentDocument ?? document;
|
180
|
+
return ! wp.dom.getScrollContainer( activeElement );
|
181
|
+
} )
|
170
182
|
) {
|
171
183
|
await page.keyboard.press( 'Enter' );
|
172
184
|
}
|
@@ -176,11 +188,13 @@ describe( 'TypeWriter', () => {
|
|
176
188
|
// Create blocks until the typewriter effect kicks in, create at
|
177
189
|
// least 10 blocks to properly test the .
|
178
190
|
while (
|
179
|
-
( await page.evaluate(
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
191
|
+
( await page.evaluate( () => {
|
192
|
+
const { activeElement } =
|
193
|
+
document.activeElement?.contentDocument ?? document;
|
194
|
+
return (
|
195
|
+
wp.dom.getScrollContainer( activeElement ).scrollTop === 0
|
196
|
+
);
|
197
|
+
} ) ) ||
|
184
198
|
count < 10
|
185
199
|
) {
|
186
200
|
await page.keyboard.press( 'Enter' );
|
@@ -190,9 +204,11 @@ describe( 'TypeWriter', () => {
|
|
190
204
|
// Scroll the active element to the very bottom of the scroll container,
|
191
205
|
// then scroll up, so the caret is partially hidden.
|
192
206
|
await page.evaluate( () => {
|
193
|
-
|
194
|
-
|
195
|
-
|
207
|
+
const { activeElement } =
|
208
|
+
document.activeElement?.contentDocument ?? document;
|
209
|
+
activeElement.scrollIntoView( false );
|
210
|
+
wp.dom.getScrollContainer( activeElement ).scrollTop -=
|
211
|
+
activeElement.offsetHeight + 10;
|
196
212
|
} );
|
197
213
|
|
198
214
|
const bottomPostition = await getCaretPosition();
|
@@ -220,9 +236,11 @@ describe( 'TypeWriter', () => {
|
|
220
236
|
// Scroll the active element to the very top of the scroll container,
|
221
237
|
// then scroll down, so the caret is partially hidden.
|
222
238
|
await page.evaluate( () => {
|
223
|
-
|
224
|
-
|
225
|
-
|
239
|
+
const { activeElement } =
|
240
|
+
document.activeElement?.contentDocument ?? document;
|
241
|
+
activeElement.scrollIntoView();
|
242
|
+
wp.dom.getScrollContainer( activeElement ).scrollTop +=
|
243
|
+
activeElement.offsetHeight + 10;
|
226
244
|
} );
|
227
245
|
|
228
246
|
const topPostition = await getCaretPosition();
|
@@ -151,7 +151,8 @@ describe( 'Site Editor Performance', () => {
|
|
151
151
|
await enterEditMode();
|
152
152
|
|
153
153
|
// Insert a new paragraph right under the first one.
|
154
|
-
await firstParagraph.
|
154
|
+
await firstParagraph.click(); // Once to select the block overlay.
|
155
|
+
await firstParagraph.click(); // Once again to select the paragraph.
|
155
156
|
await insertBlock( 'Paragraph' );
|
156
157
|
|
157
158
|
// Start tracing.
|
@@ -27,11 +27,11 @@ async function getActiveTabLabel() {
|
|
27
27
|
async function getTemplateCard() {
|
28
28
|
return {
|
29
29
|
title: await page.$eval(
|
30
|
-
'.edit-site-
|
30
|
+
'.edit-site-sidebar-card__title',
|
31
31
|
( element ) => element.innerText
|
32
32
|
),
|
33
33
|
description: await page.$eval(
|
34
|
-
'.edit-site-
|
34
|
+
'.edit-site-sidebar-card__description',
|
35
35
|
( element ) => element.innerText
|
36
36
|
),
|
37
37
|
};
|