-
Notifications
You must be signed in to change notification settings - Fork 4.3k
/
Copy pathpost-editor.spec.js
720 lines (610 loc) · 30.7 KB
/
post-editor.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
/* eslint-disable playwright/no-conditional-in-test, playwright/expect-expect */
/**
* WordPress dependencies
*/
import { test, Metrics } from '@wordpress/e2e-test-utils-playwright';
/**
* Internal dependencies
*/
import { PerfUtils } from '../fixtures';
import { sum } from '../utils.js';
// See https://github.com/WordPress/gutenberg/issues/51383#issuecomment-1613460429
const BROWSER_IDLE_WAIT = 1000;
const results = {
serverResponse: [],
firstPaint: [],
domContentLoaded: [],
loaded: [],
firstContentfulPaint: [],
firstBlock: [],
type: [],
typeWithoutInspector: [],
typeWithTopToolbar: [],
typeContainer: [],
focus: [],
listViewOpen: [],
inserterOpen: [],
inserterHover: [],
inserterSearch: [],
loadPatterns: [],
};
test.describe( 'Post Editor Performance', () => {
test.use( {
perfUtils: async ( { page }, use ) => {
await use( new PerfUtils( { page } ) );
},
metrics: async ( { page }, use ) => {
await use( new Metrics( { page } ) );
},
} );
test.afterAll( async ( {}, testInfo ) => {
await testInfo.attach( 'results', {
body: JSON.stringify( results, null, 2 ),
contentType: 'application/json',
} );
} );
test.describe( 'Loading', () => {
let draftId = null;
test( 'Setup the test post', async ( { admin, perfUtils } ) => {
await admin.createNewPost();
await perfUtils.loadBlocksForLargePost();
draftId = await perfUtils.saveDraft();
} );
const samples = 10;
const throwaway = 1;
const iterations = samples + throwaway;
for ( let i = 1; i <= iterations; i++ ) {
test( `Run the test (${ i } of ${ iterations })`, async ( {
admin,
perfUtils,
metrics,
} ) => {
// Open the test draft.
await admin.editPost( draftId );
const canvas = await perfUtils.getCanvas();
// Wait for the first block.
await canvas.locator( '.wp-block' ).first().waitFor();
// Get the durations.
const loadingDurations = await metrics.getLoadingDurations();
// Save the results.
if ( i > throwaway ) {
Object.entries( loadingDurations ).forEach(
( [ metric, duration ] ) => {
if ( metric === 'timeSinceResponseEnd' ) {
results.firstBlock.push( duration );
} else {
results[ metric ].push( duration );
}
}
);
const serverTiming = await metrics.getServerTiming();
for ( const [ key, value ] of Object.entries(
serverTiming
) ) {
results[ key ] ??= [];
results[ key ].push( value );
}
}
} );
}
} );
async function type( target, metrics, key ) {
// The first character typed triggers a longer time (isTyping change).
// It can impact the stability of the metric, so we exclude it. It
// probably deserves a dedicated metric itself, though.
const samples = 10;
const throwaway = 1;
const iterations = samples + throwaway;
// Start tracing.
await metrics.startTracing();
// Type the testing sequence into the empty paragraph.
await target.type( 'x'.repeat( iterations ), {
delay: BROWSER_IDLE_WAIT,
// The extended timeout is needed because the typing is very slow
// and the `delay` value itself does not extend it.
timeout: iterations * BROWSER_IDLE_WAIT * 2, // 2x the total time to be safe.
} );
// Stop tracing.
await metrics.stopTracing();
// Get the durations.
const [ keyDownEvents, keyPressEvents, keyUpEvents ] =
metrics.getTypingEventDurations();
// Save the results.
for ( let i = throwaway; i < iterations; i++ ) {
results[ key ].push(
keyDownEvents[ i ] + keyPressEvents[ i ] + keyUpEvents[ i ]
);
}
}
test.describe( 'Typing', () => {
let draftId = null;
test( 'Setup the test post', async ( { admin, perfUtils, editor } ) => {
await admin.createNewPost();
await perfUtils.loadBlocksForLargePost();
await editor.insertBlock( { name: 'core/paragraph' } );
draftId = await perfUtils.saveDraft();
} );
test( 'Run the test', async ( { admin, perfUtils, metrics } ) => {
await admin.editPost( draftId );
await perfUtils.disableAutosave();
const canvas = await perfUtils.getCanvas();
const paragraph = canvas.getByRole( 'document', {
name: /Empty block/i,
} );
await type( paragraph, metrics, 'type' );
} );
} );
test.describe( 'Typing (without inspector)', () => {
let draftId = null;
test( 'Setup the test post', async ( { admin, perfUtils, editor } ) => {
await admin.createNewPost();
await perfUtils.loadBlocksForLargePost();
await editor.insertBlock( { name: 'core/paragraph' } );
draftId = await perfUtils.saveDraft();
} );
test( 'Run the test', async ( {
admin,
perfUtils,
metrics,
page,
editor,
} ) => {
await admin.editPost( draftId );
await perfUtils.disableAutosave();
const toggleButton = page
.getByRole( 'region', { name: 'Editor settings' } )
.getByRole( 'button', { name: 'Close Settings' } );
await toggleButton.click();
const canvas = await perfUtils.getCanvas();
const paragraph = canvas.getByRole( 'document', {
name: /Empty block/i,
} );
await type( paragraph, metrics, 'typeWithoutInspector' );
// Open the inspector again.
await editor.openDocumentSettingsSidebar();
} );
} );
test.describe( 'Typing (with top toolbar)', () => {
let draftId = null;
test( 'Setup the test post', async ( { admin, perfUtils, editor } ) => {
await admin.createNewPost();
await perfUtils.loadBlocksForLargePost();
await editor.insertBlock( { name: 'core/paragraph' } );
draftId = await perfUtils.saveDraft();
} );
test( 'Run the test', async ( {
admin,
perfUtils,
metrics,
editor,
} ) => {
await admin.editPost( draftId );
await perfUtils.disableAutosave();
// Enable fixed toolbar.
await editor.setIsFixedToolbar( true );
const canvas = await perfUtils.getCanvas();
const paragraph = canvas.getByRole( 'document', {
name: /Empty block/i,
} );
await type( paragraph, metrics, 'typeWithTopToolbar' );
// Disabled fixed toolbar. Default state.
await editor.setIsFixedToolbar( false );
} );
} );
test.describe( 'Typing within containers', () => {
let draftId = null;
test( 'Set up the test post', async ( { admin, perfUtils } ) => {
await admin.createNewPost();
await perfUtils.loadBlocksForSmallPostWithContainers();
draftId = await perfUtils.saveDraft();
} );
test( 'Run the test', async ( { admin, perfUtils, metrics } ) => {
await admin.editPost( draftId );
await perfUtils.disableAutosave();
const canvas = await perfUtils.getCanvas();
// Select the block where we type in.
const firstParagraph = canvas
.getByRole( 'document', {
name: /Paragraph block|Block: Paragraph/,
} )
.first();
await firstParagraph.click();
await type( firstParagraph, metrics, 'typeContainer' );
} );
} );
test.describe( 'Selecting blocks', () => {
let draftId = null;
test( 'Set up the test post', async ( { admin, perfUtils } ) => {
await admin.createNewPost();
await perfUtils.load1000Paragraphs();
draftId = await perfUtils.saveDraft();
} );
test( 'Run the test', async ( { admin, page, perfUtils, metrics } ) => {
await admin.editPost( draftId );
await perfUtils.disableAutosave();
const canvas = await perfUtils.getCanvas();
const paragraphs = canvas.getByRole( 'document', {
name: /Empty block/i,
} );
const samples = 10;
const throwaway = 1;
const iterations = samples + throwaway;
for ( let i = 1; i <= iterations; i++ ) {
// Wait for the browser to be idle before starting the monitoring.
// eslint-disable-next-line no-restricted-syntax, playwright/no-wait-for-timeout
await page.waitForTimeout( BROWSER_IDLE_WAIT );
// Start tracing.
await metrics.startTracing();
// Click the next paragraph.
await paragraphs.nth( i ).click();
// Stop tracing.
await metrics.stopTracing();
// Get the durations.
const allDurations = metrics.getSelectionEventDurations();
// Save the results.
if ( i > throwaway ) {
results.focus.push(
allDurations.reduce( ( acc, eventDurations ) => {
return acc + sum( eventDurations );
}, 0 )
);
}
}
} );
} );
test.describe( 'Opening persistent List View', () => {
let draftId = null;
test( 'Set up the test page', async ( { admin, perfUtils } ) => {
await admin.createNewPost();
await perfUtils.load1000Paragraphs();
draftId = await perfUtils.saveDraft();
} );
test( 'Run the test', async ( { page, admin, perfUtils, metrics } ) => {
await admin.editPost( draftId );
await perfUtils.disableAutosave();
const listViewToggle = page.getByRole( 'button', {
name: 'Document Overview',
} );
const samples = 10;
const throwaway = 1;
const iterations = samples + throwaway;
for ( let i = 1; i <= iterations; i++ ) {
// Wait for the browser to be idle before starting the monitoring.
// eslint-disable-next-line no-restricted-syntax, playwright/no-wait-for-timeout
await page.waitForTimeout( BROWSER_IDLE_WAIT );
// Start tracing.
await metrics.startTracing();
// Open List View.
await listViewToggle.click();
await perfUtils.expectExpandedState( listViewToggle, 'true' );
// Stop tracing.
await metrics.stopTracing();
// Get the durations.
const [ mouseClickEvents ] = metrics.getClickEventDurations();
// Save the results.
if ( i > throwaway ) {
results.listViewOpen.push( mouseClickEvents[ 0 ] );
}
// Close List View
await listViewToggle.click();
await perfUtils.expectExpandedState( listViewToggle, 'false' );
}
} );
} );
test.describe( 'Opening Inserter', () => {
let draftId = null;
test( 'Set up the test page', async ( { admin, perfUtils } ) => {
await admin.createNewPost();
await perfUtils.load1000Paragraphs();
draftId = await perfUtils.saveDraft();
} );
test( 'Run the test', async ( { page, admin, perfUtils, metrics } ) => {
// Go to the test page.
await admin.editPost( draftId );
await perfUtils.disableAutosave();
const globalInserterToggle = page
.getByRole( 'region', { name: 'Editor top bar' } )
.getByRole( 'button', {
name: 'Block Inserter',
} );
const samples = 10;
const throwaway = 1;
const iterations = samples + throwaway;
for ( let i = 1; i <= iterations; i++ ) {
// Wait for the browser to be idle before starting the monitoring.
// eslint-disable-next-line no-restricted-syntax, playwright/no-wait-for-timeout
await page.waitForTimeout( BROWSER_IDLE_WAIT );
// Start tracing.
await metrics.startTracing();
// Open Inserter.
await globalInserterToggle.click();
await perfUtils.expectExpandedState(
globalInserterToggle,
'true'
);
// Stop tracing.
await metrics.stopTracing();
// Get the durations.
const [ mouseClickEvents ] = metrics.getClickEventDurations();
// Save the results.
if ( i > throwaway ) {
results.inserterOpen.push( mouseClickEvents[ 0 ] );
}
// Close Inserter.
await globalInserterToggle.click();
await perfUtils.expectExpandedState(
globalInserterToggle,
'false'
);
}
} );
} );
test.describe( 'Searching Inserter', () => {
let draftId = null;
test( 'Set up the test page', async ( { admin, perfUtils } ) => {
await admin.createNewPost();
await perfUtils.load1000Paragraphs();
draftId = await perfUtils.saveDraft();
} );
test( 'Run the test', async ( { page, admin, perfUtils, metrics } ) => {
// Go to the test page.
await admin.editPost( draftId );
await perfUtils.disableAutosave();
const globalInserterToggle = page
.getByRole( 'region', { name: 'Editor top bar' } )
.getByRole( 'button', {
name: 'Block Inserter',
} );
// Open Inserter.
await globalInserterToggle.click();
await page.getByRole( 'searchbox' ).click();
await perfUtils.expectExpandedState( globalInserterToggle, 'true' );
const samples = 10;
const throwaway = 1;
const iterations = samples + throwaway;
for ( let i = 1; i <= iterations; i++ ) {
// Wait for the browser to be idle before starting the monitoring.
// eslint-disable-next-line no-restricted-syntax, playwright/no-wait-for-timeout
await page.waitForTimeout( BROWSER_IDLE_WAIT );
// Start tracing.
await metrics.startTracing();
// Type to trigger search.
await page.keyboard.type( 'p' );
// Stop tracing.
await metrics.stopTracing();
// Get the durations.
const [ keyDownEvents, keyPressEvents, keyUpEvents ] =
metrics.getTypingEventDurations();
// Save the results.
if ( i > throwaway ) {
results.inserterSearch.push(
keyDownEvents[ 0 ] +
keyPressEvents[ 0 ] +
keyUpEvents[ 0 ]
);
}
await page.keyboard.press( 'Backspace' );
}
} );
} );
test.describe( 'Hovering Inserter items', () => {
let draftId = null;
test( 'Set up the test page', async ( { admin, perfUtils } ) => {
await admin.createNewPost();
await perfUtils.load1000Paragraphs();
draftId = await perfUtils.saveDraft();
} );
test( 'Run the test', async ( { page, admin, perfUtils, metrics } ) => {
// Go to the test page.
await admin.editPost( draftId );
await perfUtils.disableAutosave();
const globalInserterToggle = page
.getByRole( 'region', { name: 'Editor top bar' } )
.getByRole( 'button', {
name: 'Block Inserter',
} );
const paragraphBlockItem = page.locator(
'.block-editor-inserter__menu .editor-block-list-item-paragraph'
);
const headingBlockItem = page.locator(
'.block-editor-inserter__menu .editor-block-list-item-heading'
);
// Open Inserter.
await globalInserterToggle.click();
await perfUtils.expectExpandedState( globalInserterToggle, 'true' );
const samples = 10;
const throwaway = 1;
const iterations = samples + throwaway;
for ( let i = 1; i <= iterations; i++ ) {
// Wait for the browser to be idle before starting the monitoring.
// eslint-disable-next-line no-restricted-syntax, playwright/no-wait-for-timeout
await page.waitForTimeout( BROWSER_IDLE_WAIT );
// Start tracing.
await metrics.startTracing();
// Hover Inserter items.
await paragraphBlockItem.hover();
await headingBlockItem.hover();
// Stop tracing.
await metrics.stopTracing();
// Get the durations.
const [ mouseOverEvents, mouseOutEvents ] =
metrics.getHoverEventDurations();
// Save the results.
if ( i > throwaway ) {
for ( let k = 0; k < mouseOverEvents.length; k++ ) {
results.inserterHover.push(
mouseOverEvents[ k ] + mouseOutEvents[ k ]
);
}
}
}
} );
} );
test.describe( 'Loading Patterns', () => {
test( 'Run the test', async ( { page, admin, perfUtils } ) => {
await admin.createNewPost();
await perfUtils.disableAutosave();
const globalInserterToggle = page
.getByRole( 'region', { name: 'Editor top bar' } )
.getByRole( 'button', {
name: 'Block Inserter',
} );
const testPatterns = [
{
name: 'core/query-standard-posts',
title: 'Standard',
content:
'<!-- wp:query {"query":{"perPage":3,"pages":0,"offset":0,"postType":"post","order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"","inherit":false}} -->\n\t\t\t\t\t<div class="wp-block-query">\n\t\t\t\t\t<!-- wp:post-template -->\n\t\t\t\t\t<!-- wp:post-title {"isLink":true} /-->\n\t\t\t\t\t<!-- wp:post-featured-image {"isLink":true,"align":"wide"} /-->\n\t\t\t\t\t<!-- wp:post-excerpt /-->\n\t\t\t\t\t<!-- wp:separator -->\n\t\t\t\t\t<hr class="wp-block-separator"/>\n\t\t\t\t\t<!-- /wp:separator -->\n\t\t\t\t\t<!-- wp:post-date /-->\n\t\t\t\t\t<!-- /wp:post-template -->\n\t\t\t\t\t</div>\n\t\t\t\t\t<!-- /wp:query -->',
categories: [ 'test' ],
blockTypes: [ 'core/query' ],
source: 'core',
},
{
name: 'core/query-medium-posts',
title: 'Image at left',
content:
'<!-- wp:query {"query":{"perPage":3,"pages":0,"offset":0,"postType":"post","order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"","inherit":false}} -->\n\t\t\t\t\t<div class="wp-block-query">\n\t\t\t\t\t<!-- wp:post-template -->\n\t\t\t\t\t<!-- wp:columns {"align":"wide"} -->\n\t\t\t\t\t<div class="wp-block-columns alignwide"><!-- wp:column {"width":"66.66%"} -->\n\t\t\t\t\t<div class="wp-block-column" style="flex-basis:66.66%"><!-- wp:post-featured-image {"isLink":true} /--></div>\n\t\t\t\t\t<!-- /wp:column -->\n\t\t\t\t\t<!-- wp:column {"width":"33.33%"} -->\n\t\t\t\t\t<div class="wp-block-column" style="flex-basis:33.33%"><!-- wp:post-title {"isLink":true} /-->\n\t\t\t\t\t<!-- wp:post-excerpt /--></div>\n\t\t\t\t\t<!-- /wp:column --></div>\n\t\t\t\t\t<!-- /wp:columns -->\n\t\t\t\t\t<!-- /wp:post-template -->\n\t\t\t\t\t</div>\n\t\t\t\t\t<!-- /wp:query -->',
categories: [ 'test' ],
blockTypes: [ 'core/query' ],
source: 'core',
},
{
name: 'core/query-small-posts',
title: 'Small image and title',
content:
'<!-- wp:query {"query":{"perPage":3,"pages":0,"offset":0,"postType":"post","order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"","inherit":false}} -->\n\t\t\t\t\t<div class="wp-block-query">\n\t\t\t\t\t<!-- wp:post-template -->\n\t\t\t\t\t<!-- wp:columns {"verticalAlignment":"center"} -->\n\t\t\t\t\t<div class="wp-block-columns are-vertically-aligned-center"><!-- wp:column {"verticalAlignment":"center","width":"25%"} -->\n\t\t\t\t\t<div class="wp-block-column is-vertically-aligned-center" style="flex-basis:25%"><!-- wp:post-featured-image {"isLink":true} /--></div>\n\t\t\t\t\t<!-- /wp:column -->\n\t\t\t\t\t<!-- wp:column {"verticalAlignment":"center","width":"75%"} -->\n\t\t\t\t\t<div class="wp-block-column is-vertically-aligned-center" style="flex-basis:75%"><!-- wp:post-title {"isLink":true} /--></div>\n\t\t\t\t\t<!-- /wp:column --></div>\n\t\t\t\t\t<!-- /wp:columns -->\n\t\t\t\t\t<!-- /wp:post-template -->\n\t\t\t\t\t</div>\n\t\t\t\t\t<!-- /wp:query -->',
categories: [ 'test' ],
blockTypes: [ 'core/query' ],
source: 'core',
},
{
name: 'core/query-grid-posts',
title: 'Grid',
content:
'<!-- wp:query {"query":{"perPage":6,"pages":0,"offset":0,"postType":"post","order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"exclude","inherit":false},"displayLayout":{"type":"flex","columns":3}} -->\n\t\t\t\t\t<div class="wp-block-query">\n\t\t\t\t\t<!-- wp:post-template -->\n\t\t\t\t\t<!-- wp:group {"style":{"spacing":{"padding":{"top":"30px","right":"30px","bottom":"30px","left":"30px"}}},"layout":{"inherit":false}} -->\n\t\t\t\t\t<div class="wp-block-group" style="padding-top:30px;padding-right:30px;padding-bottom:30px;padding-left:30px"><!-- wp:post-title {"isLink":true} /-->\n\t\t\t\t\t<!-- wp:post-excerpt /-->\n\t\t\t\t\t<!-- wp:post-date /--></div>\n\t\t\t\t\t<!-- /wp:group -->\n\t\t\t\t\t<!-- /wp:post-template -->\n\t\t\t\t\t</div>\n\t\t\t\t\t<!-- /wp:query -->',
categories: [ 'test' ],
blockTypes: [ 'core/query' ],
source: 'core',
},
{
name: 'core/query-large-title-posts',
title: 'Large title',
content:
'<!-- wp:group {"align":"full","style":{"spacing":{"padding":{"top":"100px","right":"100px","bottom":"100px","left":"100px"}},"color":{"text":"#ffffff","background":"#000000"}}} -->\n\t\t\t\t\t<div class="wp-block-group alignfull has-text-color has-background" style="background-color:#000000;color:#ffffff;padding-top:100px;padding-right:100px;padding-bottom:100px;padding-left:100px"><!-- wp:query {"query":{"perPage":3,"pages":0,"offset":0,"postType":"post","order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"","inherit":false}} -->\n\t\t\t\t\t<div class="wp-block-query"><!-- wp:post-template -->\n\t\t\t\t\t<!-- wp:separator {"customColor":"#ffffff","align":"wide","className":"is-style-wide"} -->\n\t\t\t\t\t<hr class="wp-block-separator alignwide has-text-color has-background is-style-wide" style="background-color:#ffffff;color:#ffffff"/>\n\t\t\t\t\t<!-- /wp:separator -->\n\n\t\t\t\t\t<!-- wp:columns {"verticalAlignment":"center","align":"wide"} -->\n\t\t\t\t\t<div class="wp-block-columns alignwide are-vertically-aligned-center"><!-- wp:column {"verticalAlignment":"center","width":"20%"} -->\n\t\t\t\t\t<div class="wp-block-column is-vertically-aligned-center" style="flex-basis:20%"><!-- wp:post-date {"style":{"color":{"text":"#ffffff"}},"fontSize":"extra-small"} /--></div>\n\t\t\t\t\t<!-- /wp:column -->\n\n\t\t\t\t\t<!-- wp:column {"verticalAlignment":"center","width":"80%"} -->\n\t\t\t\t\t<div class="wp-block-column is-vertically-aligned-center" style="flex-basis:80%"><!-- wp:post-title {"isLink":true,"style":{"typography":{"fontSize":"72px","lineHeight":"1.1"},"color":{"text":"#ffffff","link":"#ffffff"}}} /--></div>\n\t\t\t\t\t<!-- /wp:column --></div>\n\t\t\t\t\t<!-- /wp:columns -->\n\t\t\t\t\t<!-- /wp:post-template --></div>\n\t\t\t\t\t<!-- /wp:query --></div>\n\t\t\t\t\t<!-- /wp:group -->',
categories: [ 'test' ],
blockTypes: [ 'core/query' ],
source: 'core',
},
{
name: 'core/query-offset-posts',
title: 'Offset',
content:
'<!-- wp:group {"style":{"spacing":{"padding":{"top":"30px","right":"30px","bottom":"30px","left":"30px"}}},"layout":{"inherit":false}} -->\n\t\t\t\t\t<div class="wp-block-group" style="padding-top:30px;padding-right:30px;padding-bottom:30px;padding-left:30px"><!-- wp:columns -->\n\t\t\t\t\t<div class="wp-block-columns"><!-- wp:column {"width":"50%"} -->\n\t\t\t\t\t<div class="wp-block-column" style="flex-basis:50%"><!-- wp:query {"query":{"perPage":2,"pages":0,"offset":0,"postType":"post","order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"exclude","inherit":false},"displayLayout":{"type":"list"}} -->\n\t\t\t\t\t<div class="wp-block-query"><!-- wp:post-template -->\n\t\t\t\t\t<!-- wp:post-featured-image /-->\n\t\t\t\t\t<!-- wp:post-title /-->\n\t\t\t\t\t<!-- wp:post-date /-->\n\t\t\t\t\t<!-- wp:spacer {"height":200} -->\n\t\t\t\t\t<div style="height:200px" aria-hidden="true" class="wp-block-spacer"></div>\n\t\t\t\t\t<!-- /wp:spacer -->\n\t\t\t\t\t<!-- /wp:post-template --></div>\n\t\t\t\t\t<!-- /wp:query --></div>\n\t\t\t\t\t<!-- /wp:column -->\n\t\t\t\t\t<!-- wp:column {"width":"50%"} -->\n\t\t\t\t\t<div class="wp-block-column" style="flex-basis:50%"><!-- wp:query {"query":{"perPage":2,"pages":0,"offset":2,"postType":"post","order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"exclude","inherit":false},"displayLayout":{"type":"list"}} -->\n\t\t\t\t\t<div class="wp-block-query"><!-- wp:post-template -->\n\t\t\t\t\t<!-- wp:spacer {"height":200} -->\n\t\t\t\t\t<div style="height:200px" aria-hidden="true" class="wp-block-spacer"></div>\n\t\t\t\t\t<!-- /wp:spacer -->\n\t\t\t\t\t<!-- wp:post-featured-image /-->\n\t\t\t\t\t<!-- wp:post-title /-->\n\t\t\t\t\t<!-- wp:post-date /-->\n\t\t\t\t\t<!-- /wp:post-template --></div>\n\t\t\t\t\t<!-- /wp:query --></div>\n\t\t\t\t\t<!-- /wp:column --></div>\n\t\t\t\t\t<!-- /wp:columns --></div>\n\t\t\t\t\t<!-- /wp:group -->',
categories: [ 'test' ],
blockTypes: [ 'core/query' ],
source: 'core',
},
{
name: 'core/social-links-shared-background-color',
title: 'Social links with a shared background color',
content:
'<!-- wp:social-links {"customIconColor":"#ffffff","iconColorValue":"#ffffff","customIconBackgroundColor":"#3962e3","iconBackgroundColorValue":"#3962e3","className":"has-icon-color"} -->\n\t\t\t\t\t\t<ul class="wp-block-social-links has-icon-color has-icon-background-color"><!-- wp:social-link {"url":"https://wordpress.org","service":"wordpress"} /-->\n\t\t\t\t\t\t<!-- wp:social-link {"url":"#","service":"chain"} /-->\n\t\t\t\t\t\t<!-- wp:social-link {"url":"#","service":"mail"} /--></ul>\n\t\t\t\t\t\t<!-- /wp:social-links -->',
viewportWidth: 500,
categories: [ 'test' ],
blockTypes: [ 'core/social-links' ],
source: 'core',
},
{
name: 'core/query-large-title-posts-2',
title: 'Large title 2',
content:
'<!-- wp:group {"align":"full","style":{"spacing":{"padding":{"top":"100px","right":"100px","bottom":"100px","left":"100px"}},"color":{"text":"#ffffff","background":"#000000"}}} -->\n\t\t\t\t\t<div class="wp-block-group alignfull has-text-color has-background" style="background-color:#000000;color:#ffffff;padding-top:100px;padding-right:100px;padding-bottom:100px;padding-left:100px"><!-- wp:query {"query":{"perPage":3,"pages":0,"offset":0,"postType":"post","order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"","inherit":false}} -->\n\t\t\t\t\t<div class="wp-block-query"><!-- wp:post-template -->\n\t\t\t\t\t<!-- wp:separator {"customColor":"#ffffff","align":"wide","className":"is-style-wide"} -->\n\t\t\t\t\t<hr class="wp-block-separator alignwide has-text-color has-background is-style-wide" style="background-color:#ffffff;color:#ffffff"/>\n\t\t\t\t\t<!-- /wp:separator -->\n\n\t\t\t\t\t<!-- wp:columns {"verticalAlignment":"center","align":"wide"} -->\n\t\t\t\t\t<div class="wp-block-columns alignwide are-vertically-aligned-center"><!-- wp:column {"verticalAlignment":"center","width":"20%"} -->\n\t\t\t\t\t<div class="wp-block-column is-vertically-aligned-center" style="flex-basis:20%"><!-- wp:post-date {"style":{"color":{"text":"#ffffff"}},"fontSize":"extra-small"} /--></div>\n\t\t\t\t\t<!-- /wp:column -->\n\n\t\t\t\t\t<!-- wp:column {"verticalAlignment":"center","width":"80%"} -->\n\t\t\t\t\t<div class="wp-block-column is-vertically-aligned-center" style="flex-basis:80%"><!-- wp:post-title {"isLink":true,"style":{"typography":{"fontSize":"72px","lineHeight":"1.1"},"color":{"text":"#ffffff","link":"#ffffff"}}} /--></div>\n\t\t\t\t\t<!-- /wp:column --></div>\n\t\t\t\t\t<!-- /wp:columns -->\n\t\t\t\t\t<!-- /wp:post-template --></div>\n\t\t\t\t\t<!-- /wp:query --></div>\n\t\t\t\t\t<!-- /wp:group -->',
categories: [ 'test' ],
blockTypes: [ 'core/query' ],
source: 'core',
},
{
name: 'core/query-offset-posts-2',
title: 'Offset 2',
content:
'<!-- wp:group {"style":{"spacing":{"padding":{"top":"30px","right":"30px","bottom":"30px","left":"30px"}}},"layout":{"inherit":false}} -->\n\t\t\t\t\t<div class="wp-block-group" style="padding-top:30px;padding-right:30px;padding-bottom:30px;padding-left:30px"><!-- wp:columns -->\n\t\t\t\t\t<div class="wp-block-columns"><!-- wp:column {"width":"50%"} -->\n\t\t\t\t\t<div class="wp-block-column" style="flex-basis:50%"><!-- wp:query {"query":{"perPage":2,"pages":0,"offset":0,"postType":"post","order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"exclude","inherit":false},"displayLayout":{"type":"list"}} -->\n\t\t\t\t\t<div class="wp-block-query"><!-- wp:post-template -->\n\t\t\t\t\t<!-- wp:post-featured-image /-->\n\t\t\t\t\t<!-- wp:post-title /-->\n\t\t\t\t\t<!-- wp:post-date /-->\n\t\t\t\t\t<!-- wp:spacer {"height":200} -->\n\t\t\t\t\t<div style="height:200px" aria-hidden="true" class="wp-block-spacer"></div>\n\t\t\t\t\t<!-- /wp:spacer -->\n\t\t\t\t\t<!-- /wp:post-template --></div>\n\t\t\t\t\t<!-- /wp:query --></div>\n\t\t\t\t\t<!-- /wp:column -->\n\t\t\t\t\t<!-- wp:column {"width":"50%"} -->\n\t\t\t\t\t<div class="wp-block-column" style="flex-basis:50%"><!-- wp:query {"query":{"perPage":2,"pages":0,"offset":2,"postType":"post","order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"exclude","inherit":false},"displayLayout":{"type":"list"}} -->\n\t\t\t\t\t<div class="wp-block-query"><!-- wp:post-template -->\n\t\t\t\t\t<!-- wp:spacer {"height":200} -->\n\t\t\t\t\t<div style="height:200px" aria-hidden="true" class="wp-block-spacer"></div>\n\t\t\t\t\t<!-- /wp:spacer -->\n\t\t\t\t\t<!-- wp:post-featured-image /-->\n\t\t\t\t\t<!-- wp:post-title /-->\n\t\t\t\t\t<!-- wp:post-date /-->\n\t\t\t\t\t<!-- /wp:post-template --></div>\n\t\t\t\t\t<!-- /wp:query --></div>\n\t\t\t\t\t<!-- /wp:column --></div>\n\t\t\t\t\t<!-- /wp:columns --></div>\n\t\t\t\t\t<!-- /wp:group -->',
categories: [ 'test' ],
blockTypes: [ 'core/query' ],
source: 'core',
},
{
name: 'core/social-links-shared-background-color-2',
title: 'Social links with a shared background color 2',
content:
'<!-- wp:social-links {"customIconColor":"#ffffff","iconColorValue":"#ffffff","customIconBackgroundColor":"#3962e3","iconBackgroundColorValue":"#3962e3","className":"has-icon-color"} -->\n\t\t\t\t\t\t<ul class="wp-block-social-links has-icon-color has-icon-background-color"><!-- wp:social-link {"url":"https://wordpress.org","service":"wordpress"} /-->\n\t\t\t\t\t\t<!-- wp:social-link {"url":"#","service":"chain"} /-->\n\t\t\t\t\t\t<!-- wp:social-link {"url":"#","service":"mail"} /--></ul>\n\t\t\t\t\t\t<!-- /wp:social-links -->',
viewportWidth: 500,
categories: [ 'test' ],
blockTypes: [ 'core/social-links' ],
source: 'core',
},
];
await page.evaluate( ( _testPatterns ) => {
const settings = window.wp.data
.select( 'core/editor' )
.getEditorSettings();
window.wp.data.dispatch( 'core/editor' ).updateEditorSettings( {
...settings,
__experimentalAdditionalBlockPatternCategories: [
...settings.__experimentalAdditionalBlockPatternCategories,
{ name: 'test', label: 'Test' },
],
__experimentalAdditionalBlockPatterns: [
...settings.__experimentalAdditionalBlockPatterns,
..._testPatterns,
],
} );
}, testPatterns );
const samples = 10;
const throwaway = 1;
const iterations = samples + throwaway;
for ( let i = 1; i <= iterations; i++ ) {
// Wait for the browser to be idle before starting the monitoring.
// eslint-disable-next-line no-restricted-syntax, playwright/no-wait-for-timeout
await page.waitForTimeout( BROWSER_IDLE_WAIT );
await globalInserterToggle.click();
await perfUtils.expectExpandedState(
globalInserterToggle,
'true'
);
await page.getByRole( 'tab', { name: 'Patterns' } ).click();
const startTime = performance.now();
// This is the WP v6.5 and older locator.
const oldLocator = page.getByRole( 'button', { name: 'Test' } );
// This is the WP v6.6 and newer locator.
const newLocator = page.getByRole( 'tab', { name: 'Test' } );
await oldLocator.or( newLocator ).click();
await Promise.all(
testPatterns.map( async ( pattern ) => {
const canvas = await perfUtils.getCanvas(
page
.getByRole( 'option', {
name: pattern.title,
exact: true,
} )
.getByTitle( 'Editor canvas' )
);
// Wait for the first block.
await canvas.locator( '.wp-block' ).first().waitFor();
} )
);
const endTime = performance.now();
// Save the results.
if ( i > throwaway ) {
results.loadPatterns.push( endTime - startTime );
}
// Close Inserter.
await globalInserterToggle.click();
await perfUtils.expectExpandedState(
globalInserterToggle,
'false'
);
}
} );
} );
} );
/* eslint-enable playwright/no-conditional-in-test, playwright/expect-expect */