@wordpress/e2e-tests 3.1.0 → 4.0.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.
Files changed (42) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +2 -0
  3. package/config/flaky-tests-reporter.js +1 -0
  4. package/package.json +10 -8
  5. package/specs/editor/blocks/__snapshots__/buttons.test.js.snap +8 -0
  6. package/specs/editor/blocks/__snapshots__/navigation.test.js.snap +2 -2
  7. package/specs/editor/blocks/__snapshots__/separator.test.js.snap +1 -1
  8. package/specs/editor/blocks/buttons.test.js +10 -0
  9. package/specs/editor/blocks/columns.test.js +3 -3
  10. package/specs/editor/blocks/gallery.test.js +36 -6
  11. package/specs/editor/blocks/heading.test.js +1 -1
  12. package/specs/editor/blocks/navigation.test.js +370 -72
  13. package/specs/editor/blocks/query.test.js +13 -3
  14. package/specs/editor/plugins/annotations.test.js +63 -67
  15. package/specs/editor/various/__snapshots__/block-deletion.test.js.snap +20 -12
  16. package/specs/editor/various/__snapshots__/block-editor-keyboard-shortcuts.test.js.snap +26 -0
  17. package/specs/editor/various/__snapshots__/block-hierarchy-navigation.test.js.snap +1 -1
  18. package/specs/editor/various/__snapshots__/multi-block-selection.test.js.snap +122 -6
  19. package/specs/editor/various/__snapshots__/writing-flow.test.js.snap +6 -6
  20. package/specs/editor/various/autosave.test.js +3 -3
  21. package/specs/editor/various/block-deletion.test.js +1 -0
  22. package/specs/editor/various/block-editor-keyboard-shortcuts.test.js +3 -5
  23. package/specs/editor/various/block-hierarchy-navigation.test.js +10 -16
  24. package/specs/editor/various/block-locking.test.js +120 -0
  25. package/specs/editor/various/keyboard-navigable-blocks.test.js +23 -0
  26. package/specs/editor/various/list-view.test.js +139 -7
  27. package/specs/editor/various/multi-block-selection.test.js +153 -9
  28. package/specs/editor/various/post-editor-template-mode.test.js +1 -1
  29. package/specs/editor/various/toolbar-roving-tabindex.test.js +10 -4
  30. package/specs/editor/various/writing-flow.test.js +10 -5
  31. package/specs/experiments/blocks/comments-query.test.js +131 -0
  32. package/specs/experiments/navigation-editor.test.js +126 -121
  33. package/specs/performance/post-editor.test.js +4 -6
  34. package/specs/site-editor/global-styles-sidebar.test.js +42 -0
  35. package/specs/site-editor/iframe-rendering-mode.test.js +31 -0
  36. package/specs/site-editor/site-editor-export.test.js +2 -2
  37. package/specs/site-editor/style-variations.test.js +9 -7
  38. package/specs/site-editor/template-part.test.js +3 -1
  39. package/specs/editor/various/__snapshots__/copy-cut-paste-whole-blocks.test.js.snap +0 -125
  40. package/specs/editor/various/copy-cut-paste-whole-blocks.test.js +0 -187
  41. package/specs/editor/various/new-post.test.js +0 -99
  42. package/specs/widgets/customizing-widgets.test.js +0 -913
@@ -1,913 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import {
5
- __experimentalActivatePlugin as activatePlugin,
6
- activateTheme,
7
- __experimentalDeactivatePlugin as deactivatePlugin,
8
- visitAdminPage,
9
- showBlockToolbar,
10
- clickBlockToolbarButton,
11
- deleteAllWidgets,
12
- createURL,
13
- openTypographyToolsPanelMenu,
14
- } from '@wordpress/e2e-test-utils';
15
-
16
- /**
17
- * External dependencies
18
- */
19
- // eslint-disable-next-line no-restricted-imports
20
- import { find, findAll } from 'puppeteer-testing-library';
21
-
22
- describe( 'Widgets Customizer', () => {
23
- beforeEach( async () => {
24
- await deleteAllWidgets();
25
- await visitAdminPage( 'customize.php' );
26
-
27
- // Disable welcome guide if it is enabled.
28
- const isWelcomeGuideActive = await page.evaluate(
29
- () =>
30
- !! wp.data
31
- .select( 'core/preferences' )
32
- .get( 'core/customize-widgets', 'welcomeGuide' )
33
- );
34
- if ( isWelcomeGuideActive ) {
35
- await page.evaluate( () =>
36
- wp.data
37
- .dispatch( 'core/preferences' )
38
- .toggle( 'core/customize-widgets', 'welcomeGuide' )
39
- );
40
- }
41
- } );
42
-
43
- beforeAll( async () => {
44
- // TODO: Ideally we can bundle our test theme directly in the repo.
45
- await activateTheme( 'twentytwenty' );
46
- await deactivatePlugin(
47
- 'gutenberg-test-plugin-disables-the-css-animations'
48
- );
49
- // Disable the transition timing function to make it "snap".
50
- // We can't disable all the transitions yet because of #32024.
51
- await page.evaluateOnNewDocument( () => {
52
- const style = document.createElement( 'style' );
53
- style.innerHTML = `
54
- * {
55
- transition-timing-function: step-start !important;
56
- animation-timing-function: step-start !important;
57
- }
58
- `;
59
- window.addEventListener( 'DOMContentLoaded', () => {
60
- document.head.appendChild( style );
61
- } );
62
- } );
63
- await activatePlugin( 'gutenberg-test-widgets' );
64
- } );
65
-
66
- afterAll( async () => {
67
- await activatePlugin(
68
- 'gutenberg-test-plugin-disables-the-css-animations'
69
- );
70
- await deactivatePlugin( 'gutenberg-test-widgets' );
71
- await activateTheme( 'twentytwentyone' );
72
- } );
73
-
74
- it( 'should add blocks', async () => {
75
- const widgetsPanel = await find( {
76
- role: 'heading',
77
- name: /Widgets/,
78
- level: 3,
79
- } );
80
- await widgetsPanel.click();
81
-
82
- const footer1Section = await find( {
83
- role: 'heading',
84
- name: /Footer #1/,
85
- level: 3,
86
- } );
87
- await footer1Section.click();
88
-
89
- await addBlock( 'Paragraph' );
90
- await page.keyboard.type( 'First Paragraph' );
91
-
92
- await waitForPreviewIframe();
93
-
94
- await addBlock( 'Heading' );
95
- await page.keyboard.type( 'My Heading' );
96
-
97
- const inlineAddBlockButton = await find( {
98
- role: 'combobox',
99
- name: 'Add block',
100
- haspopup: 'menu',
101
- } );
102
- await inlineAddBlockButton.click();
103
-
104
- const inlineInserterSearchBox = await find( {
105
- role: 'searchbox',
106
- name: 'Search for blocks and patterns',
107
- } );
108
-
109
- await expect( inlineInserterSearchBox ).toHaveFocus();
110
-
111
- await page.keyboard.type( 'Search' );
112
-
113
- const searchOption = await find( {
114
- role: 'option',
115
- name: 'Search',
116
- } );
117
- await searchOption.click();
118
-
119
- const addedSearchBlock = await find( {
120
- role: 'document',
121
- name: 'Block: Search',
122
- } );
123
-
124
- const searchTitle = await find(
125
- {
126
- role: 'textbox',
127
- name: 'Label text',
128
- },
129
- { root: addedSearchBlock }
130
- );
131
- await searchTitle.focus();
132
-
133
- await page.keyboard.type( 'My ' );
134
-
135
- await waitForPreviewIframe();
136
-
137
- const findOptions = {
138
- root: await find( {
139
- name: 'Site Preview',
140
- selector: 'iframe',
141
- } ),
142
- };
143
-
144
- // Expect the paragraph to be found in the preview iframe.
145
- await expect( {
146
- text: 'First Paragraph',
147
- selector: '.widget-content p',
148
- } ).toBeFound( findOptions );
149
-
150
- // Expect the heading to be found in the preview iframe.
151
- await expect( {
152
- role: 'heading',
153
- name: 'My Heading',
154
- selector: '.widget-content *',
155
- } ).toBeFound( findOptions );
156
-
157
- // Expect the search box to be found in the preview iframe.
158
- await expect( {
159
- role: 'searchbox',
160
- name: 'My Search',
161
- selector: '.widget-content *',
162
- } ).toBeFound( findOptions );
163
- } );
164
-
165
- it( 'should open the inspector panel', async () => {
166
- const widgetsPanel = await find( {
167
- role: 'heading',
168
- name: /Widgets/,
169
- level: 3,
170
- } );
171
- await widgetsPanel.click();
172
-
173
- const footer1Section = await find( {
174
- role: 'heading',
175
- name: /Footer #1/,
176
- level: 3,
177
- } );
178
- await footer1Section.click();
179
-
180
- await addBlock( 'Paragraph' );
181
- await page.keyboard.type( 'First Paragraph' );
182
-
183
- await showBlockToolbar();
184
- await clickBlockToolbarButton( 'Options' );
185
- let showMoreSettingsButton = await find( {
186
- role: 'menuitem',
187
- name: 'Show more settings',
188
- } );
189
- await showMoreSettingsButton.click();
190
-
191
- const backButton = await find( {
192
- role: 'button',
193
- name: /Back/,
194
- focused: true,
195
- } );
196
- await expect( backButton ).toHaveFocus();
197
-
198
- // Expect the inspector panel to be found.
199
- let inspectorHeading = await find( {
200
- role: 'heading',
201
- name: 'Customizing ▸ Widgets ▸ Footer #1 Block Settings',
202
- level: 3,
203
- } );
204
-
205
- // Expect the block title to be found.
206
- await expect( {
207
- role: 'heading',
208
- name: 'Paragraph',
209
- level: 2,
210
- } ).toBeFound();
211
-
212
- await backButton.click();
213
-
214
- // Go back to the widgets editor.
215
- await find( {
216
- role: 'heading',
217
- name: 'Customizing ▸ Widgets Footer #1',
218
- level: 3,
219
- } );
220
-
221
- await expect( inspectorHeading ).not.toBeVisible();
222
-
223
- await clickBlockToolbarButton( 'Options' );
224
- showMoreSettingsButton = await find( {
225
- role: 'menuitem',
226
- name: 'Show more settings',
227
- } );
228
- await showMoreSettingsButton.click();
229
-
230
- // Expect the inspector panel to be found.
231
- inspectorHeading = await find( {
232
- role: 'heading',
233
- name: 'Customizing ▸ Widgets ▸ Footer #1 Block Settings',
234
- level: 3,
235
- } );
236
-
237
- // Press Escape to close the inspector panel.
238
- await page.keyboard.press( 'Escape' );
239
-
240
- // Go back to the widgets editor.
241
- await expect( {
242
- role: 'heading',
243
- name: 'Customizing ▸ Widgets Footer #1',
244
- level: 3,
245
- } ).toBeFound();
246
-
247
- await expect( inspectorHeading ).not.toBeVisible();
248
- } );
249
-
250
- it( 'should handle the inserter outer section', async () => {
251
- const widgetsPanel = await find( {
252
- role: 'heading',
253
- name: /Widgets/,
254
- level: 3,
255
- } );
256
- await widgetsPanel.click();
257
-
258
- const footer1Section = await find( {
259
- role: 'heading',
260
- name: /^Footer #1/,
261
- level: 3,
262
- } );
263
- await footer1Section.click();
264
-
265
- // We need to make some changes for the publish settings to appear.
266
- await addBlock( 'Paragraph' );
267
- await page.keyboard.type( 'First Paragraph' );
268
-
269
- await waitForPreviewIframe();
270
-
271
- const documentTools = await find( {
272
- role: 'toolbar',
273
- name: 'Document tools',
274
- } );
275
-
276
- // Open the inserter outer section.
277
- const addBlockButton = await find(
278
- {
279
- role: 'button',
280
- name: 'Add block',
281
- },
282
- { root: documentTools }
283
- );
284
- await addBlockButton.click();
285
-
286
- // Expect the inserter outer section to be found.
287
- await expect( {
288
- role: 'heading',
289
- name: 'Add a block',
290
- level: 2,
291
- } ).toBeFound();
292
-
293
- // Expect to close the inserter outer section when pressing Escape.
294
- await page.keyboard.press( 'Escape' );
295
-
296
- // Open the inserter outer section again.
297
- await addBlockButton.click();
298
-
299
- // Expect the inserter outer section to be found again.
300
- const inserterHeading = await find( {
301
- role: 'heading',
302
- name: 'Add a block',
303
- level: 2,
304
- } );
305
-
306
- // Open the Publish Settings.
307
- const publishSettingsButton = await find( {
308
- role: 'button',
309
- name: 'Publish Settings',
310
- } );
311
- await publishSettingsButton.click();
312
-
313
- // Expect the Publish Settings outer section to be found.
314
- const publishSettings = await find( {
315
- selector: '#sub-accordion-section-publish_settings',
316
- } );
317
-
318
- // Expect the inserter outer section to be closed.
319
- await expect( inserterHeading ).not.toBeVisible();
320
-
321
- // Focus the block and start typing to hide the block toolbar.
322
- // Shouldn't be needed if we automatically hide the toolbar on blur.
323
- const paragraphBlock = await find( {
324
- role: 'document',
325
- name: 'Paragraph block',
326
- } );
327
- await paragraphBlock.focus();
328
- await page.keyboard.type( ' ' );
329
-
330
- // Open the inserter outer section.
331
- await addBlockButton.click();
332
-
333
- await expect( {
334
- role: 'heading',
335
- name: 'Add a block',
336
- level: 2,
337
- } ).toBeFound();
338
-
339
- // Expect the Publish Settings section to be closed.
340
- await expect( publishSettings ).not.toBeVisible();
341
-
342
- // Back to the widget areas panel.
343
- const backButton = await find( {
344
- role: 'button',
345
- name: /Back/,
346
- } );
347
- await backButton.click();
348
-
349
- // Expect the inserter outer section to be closed.
350
- await expect( {
351
- role: 'heading',
352
- name: 'Add a block',
353
- level: 2,
354
- } ).not.toBeFound();
355
- } );
356
-
357
- it( 'should move focus to the block', async () => {
358
- const widgetsPanel = await find( {
359
- role: 'heading',
360
- name: /Widgets/,
361
- level: 3,
362
- } );
363
- await widgetsPanel.click();
364
-
365
- const footer1Section = await find( {
366
- role: 'heading',
367
- name: /^Footer #1/,
368
- level: 3,
369
- } );
370
- await footer1Section.click();
371
-
372
- await addBlock( 'Paragraph' );
373
- await page.keyboard.type( 'First Paragraph' );
374
-
375
- await waitForPreviewIframe();
376
-
377
- await addBlock( 'Heading' );
378
- await page.keyboard.type( 'First Heading' );
379
-
380
- // Navigate back to the parent panel.
381
- const backButton = await find( { role: 'button', name: /Back/ } );
382
- await backButton.click();
383
-
384
- await waitForPreviewIframe();
385
-
386
- const iframe = await find( {
387
- name: 'Site Preview',
388
- selector: 'iframe',
389
- } );
390
-
391
- const paragraphWidget = await find(
392
- {
393
- text: /First Paragraph/,
394
- selector: '.widget',
395
- },
396
- {
397
- root: iframe,
398
- }
399
- );
400
-
401
- const editParagraphWidget = await find(
402
- {
403
- role: 'button',
404
- name: 'Click to edit this widget.',
405
- },
406
- {
407
- root: paragraphWidget,
408
- }
409
- );
410
- await editParagraphWidget.click();
411
-
412
- const firstParagraphBlock = await find( {
413
- role: 'document',
414
- name: 'Paragraph block',
415
- text: 'First Paragraph',
416
- } );
417
- await expect( firstParagraphBlock ).toHaveFocus();
418
-
419
- // Expect to focus on a already focused widget.
420
- await editParagraphWidget.click();
421
- await expect( firstParagraphBlock ).toHaveFocus();
422
-
423
- const headingWidget = await find(
424
- {
425
- text: /First Heading/,
426
- selector: '.widget',
427
- },
428
- {
429
- root: iframe,
430
- }
431
- );
432
-
433
- const editHeadingWidget = await find(
434
- {
435
- role: 'button',
436
- name: 'Click to edit this widget.',
437
- },
438
- {
439
- root: headingWidget,
440
- }
441
- );
442
- await editHeadingWidget.click();
443
-
444
- const headingBlock = await find( {
445
- role: 'document',
446
- name: 'Block: Heading',
447
- text: 'First Heading',
448
- } );
449
- await expect( headingBlock ).toHaveFocus();
450
- } );
451
-
452
- it( 'should clear block selection', async () => {
453
- const widgetsPanel = await find( {
454
- role: 'heading',
455
- name: /Widgets/,
456
- level: 3,
457
- } );
458
- await widgetsPanel.click();
459
-
460
- const footer1Section = await find( {
461
- role: 'heading',
462
- name: /^Footer #1/,
463
- level: 3,
464
- } );
465
- await footer1Section.click();
466
-
467
- const paragraphBlock = await addBlock( 'Paragraph' );
468
- await page.keyboard.type( 'First Paragraph' );
469
- await showBlockToolbar();
470
-
471
- const sectionHeading = await find( {
472
- role: 'heading',
473
- name: 'Customizing ▸ Widgets Footer #1',
474
- level: 3,
475
- } );
476
- await sectionHeading.click();
477
-
478
- // Expect clicking on the section title should clear the selection.
479
- await expect( {
480
- role: 'toolbar',
481
- name: 'Block tools',
482
- } ).not.toBeFound();
483
-
484
- await paragraphBlock.focus();
485
- await showBlockToolbar();
486
-
487
- const preview = await page.$( '#customize-preview' );
488
- await preview.click();
489
-
490
- // Expect clicking on the preview iframe should clear the selection.
491
- await expect( {
492
- role: 'toolbar',
493
- name: 'Block tools',
494
- } ).not.toBeFound();
495
-
496
- await paragraphBlock.focus();
497
- await showBlockToolbar();
498
-
499
- const editorContainer = await page.$(
500
- '#customize-control-sidebars_widgets-sidebar-1'
501
- );
502
- const { x, y, width, height } = await editorContainer.boundingBox();
503
- // Simulate Clicking on the empty space at the end of the editor.
504
- await page.mouse.click( x + width / 2, y + height + 10 );
505
-
506
- // Expect clicking on the empty space at the end of the editor
507
- // should clear the selection.
508
- await expect( {
509
- role: 'toolbar',
510
- name: 'Block tools',
511
- } ).not.toBeFound();
512
- } );
513
-
514
- it( 'should handle legacy widgets', async () => {
515
- const widgetsPanel = await find( {
516
- role: 'heading',
517
- name: /Widgets/,
518
- level: 3,
519
- } );
520
- await widgetsPanel.click();
521
-
522
- const footer1Section = await find( {
523
- role: 'heading',
524
- name: /^Footer #1/,
525
- level: 3,
526
- } );
527
- await footer1Section.click();
528
-
529
- const legacyWidgetBlock = await addBlock( 'Legacy Widget' );
530
- const selectLegacyWidgets = await find( {
531
- role: 'combobox',
532
- name: 'Select a legacy widget to display:',
533
- } );
534
- await selectLegacyWidgets.select( 'test_widget' );
535
-
536
- await expect( {
537
- role: 'heading',
538
- name: 'Test Widget',
539
- level: 3,
540
- } ).toBeFound( { root: legacyWidgetBlock } );
541
-
542
- let titleInput = await find(
543
- {
544
- role: 'textbox',
545
- name: 'Title:',
546
- },
547
- {
548
- root: legacyWidgetBlock,
549
- }
550
- );
551
-
552
- await titleInput.type( 'Hello Title' );
553
-
554
- // Unfocus the current legacy widget.
555
- await page.keyboard.press( 'Tab' );
556
-
557
- // Disable reason: Sometimes the preview just doesn't fully load,
558
- // it's the only way I know for now to ensure that the iframe is ready.
559
- // eslint-disable-next-line no-restricted-syntax
560
- await page.waitForTimeout( 2000 );
561
- await waitForPreviewIframe();
562
-
563
- // Expect the legacy widget to show in the site preview frame.
564
- await expect( {
565
- role: 'heading',
566
- name: 'Hello Title',
567
- } ).toBeFound( {
568
- root: await find( {
569
- name: 'Site Preview',
570
- selector: 'iframe',
571
- } ),
572
- } );
573
-
574
- // Expect the preview in block to show when unfocusing the legacy widget block.
575
- await expect( {
576
- role: 'heading',
577
- name: 'Hello Title',
578
- } ).toBeFound( {
579
- root: await find( {
580
- selector: 'iframe',
581
- name: 'Legacy Widget Preview',
582
- } ),
583
- } );
584
-
585
- await legacyWidgetBlock.focus();
586
- await showBlockToolbar();
587
-
588
- // Testing removing the block.
589
- await clickBlockToolbarButton( 'Options' );
590
- const removeBlockButton = await find( {
591
- role: 'menuitem',
592
- name: /Remove Legacy Widget/,
593
- } );
594
- await removeBlockButton.click();
595
-
596
- // Add it back again using the variant.
597
- const testWidgetBlock = await addBlock( 'Test Widget' );
598
-
599
- titleInput = await find(
600
- {
601
- role: 'textbox',
602
- name: 'Title:',
603
- },
604
- {
605
- root: testWidgetBlock,
606
- }
607
- );
608
-
609
- await titleInput.type( 'Hello again!' );
610
- // Unfocus the current legacy widget.
611
- await page.keyboard.press( 'Tab' );
612
-
613
- // Expect the preview in block to show when unfocusing the legacy widget block.
614
- await expect( {
615
- role: 'heading',
616
- name: 'Hello again!',
617
- } ).toBeFound( {
618
- root: await find( {
619
- selector: 'iframe',
620
- name: 'Legacy Widget Preview',
621
- } ),
622
- } );
623
-
624
- const publishButton = await find( {
625
- role: 'button',
626
- name: 'Publish',
627
- } );
628
- await publishButton.click();
629
-
630
- // Wait for publishing to finish.
631
- await page.waitForResponse( createURL( '/wp-admin/admin-ajax.php' ) );
632
- await expect( publishButton ).toMatchQuery( {
633
- disabled: true,
634
- } );
635
-
636
- await page.goto( createURL( '/' ) );
637
-
638
- // Expect the saved widgets to show on frontend.
639
- await expect( {
640
- role: 'heading',
641
- name: 'Hello again!',
642
- } ).toBeFound();
643
- } );
644
-
645
- it( 'should handle esc key events', async () => {
646
- const widgetsPanel = await find( {
647
- role: 'heading',
648
- name: /Widgets/,
649
- level: 3,
650
- } );
651
- await widgetsPanel.click();
652
-
653
- const footer1Section = await find( {
654
- role: 'heading',
655
- name: /^Footer #1/,
656
- level: 3,
657
- } );
658
- await footer1Section.click();
659
-
660
- const paragraphBlock = await addBlock( 'Paragraph' );
661
- await page.keyboard.type( 'First Paragraph' );
662
- await showBlockToolbar();
663
-
664
- // Open the more menu dropdown in block toolbar.
665
- await clickBlockToolbarButton( 'Options' );
666
- await expect( {
667
- role: 'menu',
668
- name: 'Options',
669
- } ).toBeFound();
670
-
671
- // Expect pressing the Escape key to close the dropdown,
672
- // but not close the editor.
673
- await page.keyboard.press( 'Escape' );
674
- await expect( {
675
- role: 'menu',
676
- name: 'Options',
677
- } ).not.toBeFound();
678
- await expect( paragraphBlock ).toBeVisible();
679
-
680
- await paragraphBlock.focus();
681
-
682
- // Expect pressing the Escape key to enter navigation mode,
683
- // but not close the editor.
684
- await page.keyboard.press( 'Escape' );
685
- await expect( {
686
- text: /^You are currently in navigation mode\./,
687
- selector: '*[aria-live="polite"][aria-relevant="additions text"]',
688
- } ).toBeFound();
689
- await expect( paragraphBlock ).toBeVisible();
690
- } );
691
-
692
- it( 'should move (inner) blocks to another sidebar', async () => {
693
- const widgetsPanel = await find( {
694
- role: 'heading',
695
- name: /Widgets/,
696
- level: 3,
697
- } );
698
- await widgetsPanel.click();
699
-
700
- const footer1Section = await find( {
701
- role: 'heading',
702
- name: /Footer #1/,
703
- level: 3,
704
- } );
705
- await footer1Section.click();
706
-
707
- await addBlock( 'Paragraph' );
708
- await page.keyboard.type( 'First Paragraph' );
709
-
710
- await showBlockToolbar();
711
- await clickBlockToolbarButton( 'Options' );
712
- const groupButton = await find( {
713
- role: 'menuitem',
714
- name: 'Group',
715
- } );
716
- await groupButton.click();
717
-
718
- // Refocus the paragraph block.
719
- const paragraphBlock = await find( {
720
- role: 'document',
721
- name: 'Paragraph block',
722
- value: 'First Paragraph',
723
- } );
724
- await paragraphBlock.focus();
725
- await showBlockToolbar();
726
- await clickBlockToolbarButton( 'Move to widget area' );
727
-
728
- const footer2Option = await find( {
729
- role: 'menuitemradio',
730
- name: 'Footer #2',
731
- } );
732
- await footer2Option.click();
733
-
734
- // Should switch to and expand Footer #2.
735
- await expect( {
736
- role: 'heading',
737
- name: 'Customizing ▸ Widgets Footer #2',
738
- } ).toBeFound();
739
-
740
- // The paragraph block should be moved to the new sidebar and have focus.
741
- const movedParagraphBlockQuery = {
742
- role: 'document',
743
- name: 'Paragraph block',
744
- value: 'First Paragraph',
745
- };
746
- await expect( movedParagraphBlockQuery ).toBeFound();
747
- const movedParagraphBlock = await find( movedParagraphBlockQuery );
748
- await expect( movedParagraphBlock ).toHaveFocus();
749
- } );
750
-
751
- it( 'should not render Block Settings sections', async () => {
752
- // We add Block Settings as a section, but it shouldn't display to
753
- // the user as a section on the main menu. It's simply how we
754
- // integrate the G sidebar inside the customizer.
755
- const findAllBlockSettingsHeader = findAll(
756
- {
757
- role: 'heading',
758
- name: /Block Settings/,
759
- level: 3,
760
- },
761
- { timeout: 0 }
762
- );
763
- await expect( findAllBlockSettingsHeader ).toThrowQueryEmptyError();
764
- } );
765
-
766
- it( 'should stay in block settings after making a change in that area', async () => {
767
- // Open footer block widgets
768
- const widgetsPanel = await find( {
769
- role: 'heading',
770
- name: /Widgets/,
771
- level: 3,
772
- } );
773
- await widgetsPanel.click();
774
-
775
- const footer1Section = await find( {
776
- role: 'heading',
777
- name: /^Footer #1/,
778
- level: 3,
779
- } );
780
- await footer1Section.click();
781
-
782
- // Add a block to make the publish button active.
783
- await addBlock( 'Paragraph' );
784
- await page.keyboard.type( 'First Paragraph' );
785
-
786
- await waitForPreviewIframe();
787
-
788
- // Click Publish.
789
- const publishButton = await find( {
790
- role: 'button',
791
- name: 'Publish',
792
- } );
793
- await publishButton.click();
794
-
795
- // Wait for publishing to finish.
796
- await page.waitForResponse( createURL( '/wp-admin/admin-ajax.php' ) );
797
- await expect( publishButton ).toMatchQuery( {
798
- disabled: true,
799
- } );
800
-
801
- // Select the paragraph block.
802
- const paragraphBlock = await find( {
803
- role: 'document',
804
- name: 'Paragraph block',
805
- } );
806
- await paragraphBlock.focus();
807
-
808
- // Click the three dots button, then click "Show More Settings".
809
- await showBlockToolbar();
810
- await clickBlockToolbarButton( 'Options' );
811
- const showMoreSettingsButton = await find( {
812
- role: 'menuitem',
813
- name: 'Show more settings',
814
- } );
815
- await showMoreSettingsButton.click();
816
-
817
- // Change `drop cap` (Any change made in this section is sufficient; not required to be `drop cap`).
818
- await openTypographyToolsPanelMenu();
819
- await page.click( 'button[aria-label="Show Drop cap"]' );
820
-
821
- const [ dropCapToggle ] = await page.$x(
822
- "//label[contains(text(), 'Drop cap')]"
823
- );
824
- await dropCapToggle.click();
825
-
826
- // Now that we've made a change:
827
- // (1) Publish button should be active
828
- // (2) We should still be in the "Block Settings" area.
829
- await find( {
830
- role: 'button',
831
- name: 'Publish',
832
- } );
833
-
834
- // This fails on 539cea09 and earlier; we get kicked back to the widgets area.
835
- // We expect to stay in block settings.
836
- await find( {
837
- role: 'heading',
838
- name: 'Customizing ▸ Widgets ▸ Footer #1 Block Settings',
839
- level: 3,
840
- } );
841
- } );
842
- } );
843
-
844
- /**
845
- * Wait when there's only one preview iframe.
846
- * There could be a 2 iframes when it's changing from no widgets to
847
- * adding a first widget to the sidebar,
848
- */
849
- async function waitForPreviewIframe() {
850
- await page.waitForFunction(
851
- () =>
852
- document.querySelectorAll( '[name^="customize-preview-"]' )
853
- .length === 1
854
- );
855
- }
856
-
857
- async function addBlock( blockName ) {
858
- const addBlockButton = await find(
859
- {
860
- role: 'button',
861
- name: 'Add block',
862
- },
863
- {
864
- root: await find( {
865
- role: 'toolbar',
866
- name: 'Document tools',
867
- } ),
868
- }
869
- );
870
- await addBlockButton.click();
871
-
872
- const searchBox = await find( {
873
- role: 'searchbox',
874
- name: 'Search for blocks and patterns',
875
- } );
876
-
877
- // Clear the input.
878
- await searchBox.evaluate( ( node ) => {
879
- if ( node.value ) {
880
- node.value = '';
881
- }
882
- } );
883
-
884
- // Click something so that the block toolbar, which sometimes obscures
885
- // buttons in the inserter, goes away.
886
- await searchBox.click();
887
-
888
- await searchBox.type( blockName );
889
-
890
- // TODO - remove this timeout when the test plugin for disabling CSS
891
- // animations in tests works properly.
892
- //
893
- // This waits for the inserter panel animation to finish before
894
- // attempting to insert a block. If the panel is still animating
895
- // puppeteer can click on the wrong block.
896
- //
897
- // eslint-disable-next-line no-restricted-syntax
898
- await page.waitForTimeout( 300 );
899
-
900
- const blockOption = await find( {
901
- role: 'option',
902
- name: blockName,
903
- } );
904
- await blockOption.click();
905
-
906
- const addedBlock = await find( {
907
- role: 'document',
908
- selector: '.is-selected[data-block]',
909
- } );
910
- await addedBlock.focus();
911
-
912
- return addedBlock;
913
- }