@wordpress/e2e-tests 7.5.0 → 7.6.1
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/mu-plugins/nocache-headers.php +21 -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/inner-blocks-allowed-blocks/index.js +17 -58
- package/plugins/inner-blocks-allowed-blocks.php +2 -3
- 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-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 +4 -3
- package/specs/editor/various/block-grouping.test.js +5 -4
- 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 +26 -152
- 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 +39 -25
- package/specs/editor/various/rich-text.test.js +9 -8
- 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/front-end-block-theme.test.js +1 -2
- package/specs/performance/front-end-classic-theme.test.js +1 -1
- package/specs/performance/post-editor.test.js +6 -0
- package/specs/performance/site-editor.test.js +11 -7
- package/specs/site-editor/settings-sidebar.test.js +2 -2
- package/specs/editor/plugins/inner-blocks-allowed-blocks.test.js +0 -96
- package/specs/editor/various/__snapshots__/block-hierarchy-navigation.test.js.snap +0 -63
- package/specs/editor/various/block-hierarchy-navigation.test.js +0 -227
- package/specs/editor/various/navigable-toolbar.test.js +0 -104
@@ -16,12 +16,17 @@ 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 =
|
22
23
|
'.reusable-blocks-menu-items__convert-modal .components-text-control__input';
|
23
24
|
const reusableBlockInspectorNameInputSelector =
|
24
25
|
'.block-editor-block-inspector .components-text-control__input';
|
26
|
+
const syncToggleSelector =
|
27
|
+
'.reusable-blocks-menu-items__convert-modal .components-form-toggle__input';
|
28
|
+
const syncToggleSelectorChecked =
|
29
|
+
'.reusable-blocks-menu-items__convert-modal .components-form-toggle.is-checked';
|
25
30
|
|
26
31
|
const saveAll = async () => {
|
27
32
|
const publishButtonSelector =
|
@@ -83,7 +88,7 @@ describe( 'Reusable blocks', () => {
|
|
83
88
|
await page.keyboard.type( 'Surprised greeting block' );
|
84
89
|
|
85
90
|
// Quickly focus the paragraph block.
|
86
|
-
await
|
91
|
+
await canvas().click(
|
87
92
|
'.block-editor-block-list__block[data-type="core/block"] p'
|
88
93
|
);
|
89
94
|
await page.keyboard.press( 'Escape' ); // Enter navigation mode.
|
@@ -96,7 +101,7 @@ describe( 'Reusable blocks', () => {
|
|
96
101
|
await saveAllButDontPublish();
|
97
102
|
|
98
103
|
// Check that its content is up to date.
|
99
|
-
const text = await
|
104
|
+
const text = await canvas().$eval(
|
100
105
|
'.block-editor-block-list__block[data-type="core/block"] p',
|
101
106
|
( element ) => element.innerText
|
102
107
|
);
|
@@ -111,13 +116,13 @@ describe( 'Reusable blocks', () => {
|
|
111
116
|
await clickBlockToolbarButton( 'Convert to regular block' );
|
112
117
|
|
113
118
|
// Check that we have a paragraph block on the page.
|
114
|
-
const paragraphBlock = await
|
119
|
+
const paragraphBlock = await canvas().$(
|
115
120
|
'.block-editor-block-list__block[data-type="core/paragraph"]'
|
116
121
|
);
|
117
122
|
expect( paragraphBlock ).not.toBeNull();
|
118
123
|
|
119
124
|
// Check that its content is up to date.
|
120
|
-
const paragraphContent = await
|
125
|
+
const paragraphContent = await canvas().$eval(
|
121
126
|
'.block-editor-block-list__block[data-type="core/paragraph"]',
|
122
127
|
( element ) => element.innerText
|
123
128
|
);
|
@@ -132,7 +137,7 @@ describe( 'Reusable blocks', () => {
|
|
132
137
|
);
|
133
138
|
|
134
139
|
// Make sure the reusable block has loaded properly before attempting to publish the post.
|
135
|
-
await
|
140
|
+
await canvas().waitForSelector( 'p[aria-label="Paragraph block"]' );
|
136
141
|
|
137
142
|
await publishPost();
|
138
143
|
|
@@ -142,8 +147,8 @@ describe( 'Reusable blocks', () => {
|
|
142
147
|
await page.waitForSelector( closePublishPanelSelector );
|
143
148
|
await page.click( closePublishPanelSelector );
|
144
149
|
|
145
|
-
await
|
146
|
-
await
|
150
|
+
await canvas().waitForSelector( 'p[aria-label="Paragraph block"]' );
|
151
|
+
await canvas().focus( 'p[aria-label="Paragraph block"]' );
|
147
152
|
|
148
153
|
// Change the block's content.
|
149
154
|
await page.keyboard.type( 'Einen ' );
|
@@ -152,7 +157,7 @@ describe( 'Reusable blocks', () => {
|
|
152
157
|
await saveAll();
|
153
158
|
|
154
159
|
// Check that its content is up to date.
|
155
|
-
const paragraphContent = await
|
160
|
+
const paragraphContent = await canvas().$eval(
|
156
161
|
'p[aria-label="Paragraph block"]',
|
157
162
|
( element ) => element.innerText
|
158
163
|
);
|
@@ -192,7 +197,7 @@ describe( 'Reusable blocks', () => {
|
|
192
197
|
|
193
198
|
// Convert block to a reusable block.
|
194
199
|
await clickBlockToolbarButton( 'Options' );
|
195
|
-
await clickMenuItem( 'Create
|
200
|
+
await clickMenuItem( 'Create pattern' );
|
196
201
|
|
197
202
|
// Set title.
|
198
203
|
const nameInput = await page.waitForSelector(
|
@@ -200,11 +205,14 @@ describe( 'Reusable blocks', () => {
|
|
200
205
|
);
|
201
206
|
await nameInput.click();
|
202
207
|
await page.keyboard.type( 'Multi-selection reusable block' );
|
208
|
+
const syncToggle = await page.waitForSelector( syncToggleSelector );
|
209
|
+
syncToggle.click();
|
210
|
+
await page.waitForSelector( syncToggleSelectorChecked );
|
203
211
|
await page.keyboard.press( 'Enter' );
|
204
212
|
|
205
213
|
// Wait for creation to finish.
|
206
214
|
await page.waitForXPath(
|
207
|
-
'//*[contains(@class, "components-snackbar")]/*[text()="
|
215
|
+
'//*[contains(@class, "components-snackbar")]/*[text()="Synced Pattern created."]'
|
208
216
|
);
|
209
217
|
|
210
218
|
await clearAllBlocks();
|
@@ -235,11 +243,12 @@ describe( 'Reusable blocks', () => {
|
|
235
243
|
await editButton.click();
|
236
244
|
|
237
245
|
await page.waitForNavigation();
|
246
|
+
await page.waitForSelector( 'iframe[name="editor-canvas"]' );
|
238
247
|
|
239
248
|
// Click the block to give it focus.
|
240
249
|
const blockSelector = 'p[data-title="Paragraph"]';
|
241
|
-
await
|
242
|
-
await
|
250
|
+
await canvas().waitForSelector( blockSelector );
|
251
|
+
await canvas().click( blockSelector );
|
243
252
|
|
244
253
|
// Delete the block, leaving the reusable block empty.
|
245
254
|
await clickBlockToolbarButton( 'Options' );
|
@@ -257,7 +266,7 @@ describe( 'Reusable blocks', () => {
|
|
257
266
|
// Save the reusable block.
|
258
267
|
await page.click( publishButtonSelector );
|
259
268
|
await page.waitForXPath(
|
260
|
-
'//*[contains(@class, "components-snackbar")]/*[text()="
|
269
|
+
'//*[contains(@class, "components-snackbar")]/*[text()="Pattern updated."]'
|
261
270
|
);
|
262
271
|
|
263
272
|
await createNewPost();
|
@@ -277,7 +286,7 @@ describe( 'Reusable blocks', () => {
|
|
277
286
|
] );
|
278
287
|
} );
|
279
288
|
|
280
|
-
await
|
289
|
+
await canvas().waitForXPath(
|
281
290
|
'//*[contains(@class, "block-editor-warning")]/*[text()="Block has been deleted or is unavailable."]'
|
282
291
|
);
|
283
292
|
|
@@ -295,15 +304,16 @@ describe( 'Reusable blocks', () => {
|
|
295
304
|
await insertReusableBlock( 'Duplicated reusable block' );
|
296
305
|
await saveDraft();
|
297
306
|
await page.reload();
|
307
|
+
await page.waitForSelector( 'iframe[name="editor-canvas"]' );
|
298
308
|
|
299
309
|
// Wait for the paragraph to be loaded.
|
300
|
-
await
|
310
|
+
await canvas().waitForSelector(
|
301
311
|
'.block-editor-block-list__block[data-type="core/paragraph"]'
|
302
312
|
);
|
303
313
|
// The first click selects the reusable block wrapper.
|
304
314
|
// The second click selects the actual paragraph block.
|
305
|
-
await
|
306
|
-
await
|
315
|
+
await canvas().click( '.wp-block-block' );
|
316
|
+
await canvas().focus(
|
307
317
|
'.block-editor-block-list__block[data-type="core/paragraph"]'
|
308
318
|
);
|
309
319
|
await pressKeyWithModifier( 'primary', 'a' );
|
@@ -333,16 +343,16 @@ describe( 'Reusable blocks', () => {
|
|
333
343
|
|
334
344
|
// Make an edit to the reusable block and assert that there's only a
|
335
345
|
// paragraph in a reusable block.
|
336
|
-
await
|
337
|
-
await
|
346
|
+
await canvas().waitForSelector( 'p[aria-label="Paragraph block"]' );
|
347
|
+
await canvas().click( 'p[aria-label="Paragraph block"]' );
|
338
348
|
await page.keyboard.type( '2' );
|
339
349
|
const selector =
|
340
|
-
'//div[@aria-label="Block:
|
350
|
+
'//div[@aria-label="Block: Pattern"]//p[@aria-label="Paragraph block"][.="12"]';
|
341
351
|
const reusableBlockWithParagraph = await page.$x( selector );
|
342
352
|
expect( reusableBlockWithParagraph ).toBeTruthy();
|
343
353
|
|
344
354
|
// Convert back to regular blocks.
|
345
|
-
await clickBlockToolbarButton( 'Select
|
355
|
+
await clickBlockToolbarButton( 'Select Pattern' );
|
346
356
|
await clickBlockToolbarButton( 'Convert to regular block' );
|
347
357
|
await page.waitForXPath( selector, {
|
348
358
|
hidden: true,
|
@@ -358,9 +368,10 @@ describe( 'Reusable blocks', () => {
|
|
358
368
|
insertBlock( 'Quote' );
|
359
369
|
await saveDraft();
|
360
370
|
await page.reload();
|
371
|
+
await page.waitForSelector( 'iframe[name="editor-canvas"]' );
|
361
372
|
|
362
373
|
// The quote block should have a visible preview in the sidebar for this test to be valid.
|
363
|
-
const quoteBlock = await
|
374
|
+
const quoteBlock = await canvas().waitForSelector(
|
364
375
|
'.block-editor-block-list__block[aria-label="Block: Quote"]'
|
365
376
|
);
|
366
377
|
// Select the quote block.
|
@@ -372,15 +383,18 @@ describe( 'Reusable blocks', () => {
|
|
372
383
|
|
373
384
|
// Convert to reusable.
|
374
385
|
await clickBlockToolbarButton( 'Options' );
|
375
|
-
await clickMenuItem( 'Create
|
386
|
+
await clickMenuItem( 'Create pattern' );
|
376
387
|
const nameInput = await page.waitForSelector(
|
377
388
|
reusableBlockNameInputSelector
|
378
389
|
);
|
379
390
|
await nameInput.click();
|
380
391
|
await page.keyboard.type( 'Block with styles' );
|
392
|
+
const syncToggle = await page.waitForSelector( syncToggleSelector );
|
393
|
+
syncToggle.click();
|
394
|
+
await page.waitForSelector( syncToggleSelectorChecked );
|
381
395
|
await page.keyboard.press( 'Enter' );
|
382
|
-
const reusableBlock = await
|
383
|
-
'.block-editor-block-list__block[aria-label="Block:
|
396
|
+
const reusableBlock = await canvas().waitForSelector(
|
397
|
+
'.block-editor-block-list__block[aria-label="Block: Pattern"]'
|
384
398
|
);
|
385
399
|
expect( reusableBlock ).toBeTruthy();
|
386
400
|
} );
|
@@ -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', () => {
|
@@ -24,8 +25,8 @@ describe( 'RichText', () => {
|
|
24
25
|
//
|
25
26
|
// See: https://github.com/WordPress/gutenberg/issues/3091
|
26
27
|
await insertBlock( 'Heading' );
|
27
|
-
await page.waitForSelector( '[aria-label="Change
|
28
|
-
await page.click( '[aria-label="Change
|
28
|
+
await page.waitForSelector( '[aria-label="Change level"]' );
|
29
|
+
await page.click( '[aria-label="Change level"]' );
|
29
30
|
await page.click( '[aria-label="Heading 3"]' );
|
30
31
|
|
31
32
|
expect( await getEditedPostContent() ).toMatchSnapshot();
|
@@ -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();
|
@@ -16,13 +16,12 @@ describe( 'Front End Performance', () => {
|
|
16
16
|
};
|
17
17
|
|
18
18
|
beforeAll( async () => {
|
19
|
-
await activateTheme( 'twentytwentythree' );
|
19
|
+
await activateTheme( 'gutenberg-test-themes/twentytwentythree' );
|
20
20
|
await logout();
|
21
21
|
} );
|
22
22
|
|
23
23
|
afterAll( async () => {
|
24
24
|
saveResultsFile( __filename, results );
|
25
|
-
await activateTheme( 'twentytwentyone' );
|
26
25
|
} );
|
27
26
|
|
28
27
|
it( 'Report TTFB, LCP, and LCP-TTFB', async () => {
|
@@ -7,6 +7,7 @@ import path from 'path';
|
|
7
7
|
* WordPress dependencies
|
8
8
|
*/
|
9
9
|
import {
|
10
|
+
activateTheme,
|
10
11
|
createNewPost,
|
11
12
|
saveDraft,
|
12
13
|
insertBlock,
|
@@ -83,6 +84,11 @@ describe( 'Post Editor Performance', () => {
|
|
83
84
|
|
84
85
|
let traceResults;
|
85
86
|
|
87
|
+
beforeAll( async () => {
|
88
|
+
// See https://github.com/WordPress/gutenberg/pull/50905/files#r1209014677;
|
89
|
+
await activateTheme( 'gutenberg-test-themes/twentytwentyone' );
|
90
|
+
} );
|
91
|
+
|
86
92
|
afterAll( async () => {
|
87
93
|
saveResultsFile( __filename, results );
|
88
94
|
deleteFile( traceFilePath );
|
@@ -87,7 +87,6 @@ describe( 'Site Editor Performance', () => {
|
|
87
87
|
saveResultsFile( __filename, results );
|
88
88
|
await deleteAllTemplates( 'wp_template' );
|
89
89
|
await deleteAllTemplates( 'wp_template_part' );
|
90
|
-
await activateTheme( 'twentytwentyone' );
|
91
90
|
} );
|
92
91
|
|
93
92
|
// Number of loading measurements to take.
|
@@ -142,16 +141,21 @@ describe( 'Site Editor Performance', () => {
|
|
142
141
|
postType: 'page',
|
143
142
|
} );
|
144
143
|
|
145
|
-
// Wait for the first
|
146
|
-
|
147
|
-
'//p[contains(text(), "Lorem ipsum dolor sit amet")]'
|
148
|
-
);
|
144
|
+
// Wait for the first block to be ready.
|
145
|
+
await canvas().waitForSelector( '.wp-block' );
|
149
146
|
|
150
147
|
// Get inside the post content.
|
151
148
|
await enterEditMode();
|
152
149
|
|
153
|
-
//
|
154
|
-
await
|
150
|
+
// Select the post content block wrapper.
|
151
|
+
await canvas().click( '.wp-block-post-content' );
|
152
|
+
|
153
|
+
// Select the first paragraph in the post content block.
|
154
|
+
const firstParagraph = await canvas().waitForXPath(
|
155
|
+
'//p[contains(text(), "Lorem ipsum dolor sit amet")]'
|
156
|
+
);
|
157
|
+
await firstParagraph.click();
|
158
|
+
|
155
159
|
await insertBlock( 'Paragraph' );
|
156
160
|
|
157
161
|
// 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
|
};
|