@wordpress/e2e-tests 3.0.9 → 3.1.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.
Files changed (63) hide show
  1. package/config/setup-performance-test.js +1 -1
  2. package/config/setup-test-framework.js +1 -1
  3. package/package.json +5 -5
  4. package/specs/editor/blocks/__snapshots__/navigation.test.js.snap +16 -16
  5. package/specs/editor/blocks/classic.test.js +2 -2
  6. package/specs/editor/blocks/cover.test.js +17 -17
  7. package/specs/editor/blocks/list.test.js +1 -1
  8. package/specs/editor/blocks/navigation.test.js +259 -52
  9. package/specs/editor/blocks/table.test.js +1 -1
  10. package/specs/editor/plugins/align-hook.test.js +10 -10
  11. package/specs/editor/plugins/block-context.test.js +1 -1
  12. package/specs/editor/plugins/block-directory-add.test.js +14 -14
  13. package/specs/editor/plugins/custom-post-types.test.js +1 -1
  14. package/specs/editor/plugins/custom-taxonomies.test.js +3 -3
  15. package/specs/editor/plugins/meta-attribute-block.test.js +1 -1
  16. package/specs/editor/plugins/meta-boxes.test.js +3 -3
  17. package/specs/editor/plugins/templates.test.js +1 -1
  18. package/specs/editor/plugins/wp-editor-meta-box.test.js +1 -1
  19. package/specs/editor/various/autosave.test.js +19 -19
  20. package/specs/editor/various/block-deletion.test.js +5 -5
  21. package/specs/editor/various/block-grouping.test.js +29 -12
  22. package/specs/editor/various/block-hierarchy-navigation.test.js +5 -5
  23. package/specs/editor/various/change-detection.test.js +3 -3
  24. package/specs/editor/various/compatibility-classic-editor.test.js +1 -1
  25. package/specs/editor/various/copy-cut-paste-whole-blocks.test.js +7 -7
  26. package/specs/editor/various/datepicker.test.js +1 -1
  27. package/specs/editor/various/duplicating-blocks.test.js +3 -3
  28. package/specs/editor/various/editor-modes.test.js +5 -5
  29. package/specs/editor/various/inserting-blocks.test.js +6 -6
  30. package/specs/editor/various/invalid-block.test.js +4 -4
  31. package/specs/editor/various/is-typing.test.js +8 -8
  32. package/specs/editor/various/keyboard-navigable-blocks.test.js +2 -2
  33. package/specs/editor/various/links.test.js +90 -90
  34. package/specs/editor/various/list-view.test.js +47 -1
  35. package/specs/editor/various/manage-reusable-blocks.test.js +5 -5
  36. package/specs/editor/various/multi-block-selection.test.js +2 -2
  37. package/specs/editor/various/navigable-toolbar.test.js +1 -1
  38. package/specs/editor/various/new-post-default-content.test.js +2 -2
  39. package/specs/editor/various/new-post.test.js +1 -1
  40. package/specs/editor/various/nux.test.js +11 -11
  41. package/specs/editor/various/popovers.test.js +3 -3
  42. package/specs/editor/various/post-editor-template-mode.test.js +12 -11
  43. package/specs/editor/various/preferences.test.js +1 -1
  44. package/specs/editor/various/preview.test.js +8 -4
  45. package/specs/editor/various/publish-button.test.js +2 -2
  46. package/specs/editor/various/publishing.test.js +50 -1
  47. package/specs/editor/various/reusable-blocks.test.js +31 -31
  48. package/specs/editor/various/rich-text.test.js +1 -1
  49. package/specs/editor/various/splitting-merging.test.js +6 -6
  50. package/specs/editor/various/style-variation.test.js +2 -2
  51. package/specs/editor/various/switch-to-draft.test.js +3 -1
  52. package/specs/editor/various/taxonomies.test.js +1 -1
  53. package/specs/editor/various/toolbar-roving-tabindex.test.js +1 -1
  54. package/specs/editor/various/writing-flow.test.js +20 -20
  55. package/specs/experiments/navigation-editor.test.js +168 -3
  56. package/specs/performance/post-editor.test.js +7 -7
  57. package/specs/performance/site-editor.test.js +1 -1
  58. package/specs/site-editor/document-settings.test.js +5 -5
  59. package/specs/site-editor/multi-entity-editing.test.js +1 -1
  60. package/specs/site-editor/multi-entity-saving.test.js +1 -1
  61. package/specs/site-editor/template-part.test.js +9 -8
  62. package/specs/widgets/customizing-widgets.test.js +10 -9
  63. package/specs/widgets/editing-widgets.test.js +8 -7
@@ -84,15 +84,15 @@ async function updateActiveNavigationLink( { url, label, type } ) {
84
84
 
85
85
  // Wait for the autocomplete suggestion item to appear.
86
86
  await page.waitForXPath( suggestionPath );
87
- // Set the suggestion
87
+ // Set the suggestion.
88
88
  const suggestion = await page.waitForXPath( suggestionPath );
89
89
 
90
- // Select it (so we're clicking the right one, even if it's further down the list)
90
+ // Select it (so we're clicking the right one, even if it's further down the list).
91
91
  await suggestion.click();
92
92
  }
93
93
 
94
94
  if ( label ) {
95
- // Wait for rich text editor input to be focused before we start typing the label
95
+ // Wait for rich text editor input to be focused before we start typing the label.
96
96
  await page.waitForSelector( ':focus.rich-text' );
97
97
 
98
98
  // With https://github.com/WordPress/gutenberg/pull/19686, we're auto-selecting the label if the label is URL-ish.
@@ -144,7 +144,7 @@ async function populateNavWithOneItem() {
144
144
  const PLACEHOLDER_ACTIONS_CLASS = 'wp-block-navigation-placeholder__actions';
145
145
  const PLACEHOLDER_ACTIONS_XPATH = `//*[contains(@class, '${ PLACEHOLDER_ACTIONS_CLASS }')]`;
146
146
  const START_EMPTY_XPATH = `${ PLACEHOLDER_ACTIONS_XPATH }//button[text()='Start empty']`;
147
- const SELECT_MENU_XPATH = `${ PLACEHOLDER_ACTIONS_XPATH }//button[text()='Select menu']`;
147
+ const SELECT_MENU_XPATH = `${ PLACEHOLDER_ACTIONS_XPATH }//button[text()='Select Menu']`;
148
148
 
149
149
  /**
150
150
  * Delete all items for the given REST resources using the REST API.
@@ -264,49 +264,246 @@ describe( 'Navigation', () => {
264
264
  await deleteUser( contributorUsername );
265
265
  } );
266
266
 
267
- describe( 'placeholder', () => {
268
- it( 'allows a navigation block to be created from existing menus', async () => {
269
- await createClassicMenu( { name: 'Test Menu 1' } );
270
- await createClassicMenu(
271
- { name: 'Test Menu 2' },
272
- menuItemsFixture
267
+ describe( 'loading states', () => {
268
+ it( 'does not show a loading indicator if there is no ref to a Navigation post', async () => {
269
+ await createNewPost();
270
+ await clickOnMoreMenuItem( 'Code editor' );
271
+ const codeEditorInput = await page.waitForSelector(
272
+ '.editor-post-text-editor'
273
+ );
274
+
275
+ // Simulate block behaviour when loading a page containing an unconfigured Nav block
276
+ // that is not selected.
277
+ await codeEditorInput.click();
278
+ const markup = '<!-- wp:navigation /-->';
279
+ await page.keyboard.type( markup );
280
+ await clickButton( 'Exit code editor' );
281
+
282
+ // Wait for block to render...
283
+ const navBlock = await waitForBlock( 'Navigation' );
284
+
285
+ // Test specifically for the primary loading indicator because a spinner also exists
286
+ // in the hidden Placeholder component when it is loading.
287
+ const loadingSpinner = await navBlock.$(
288
+ '.wp-block-navigation__loading-indicator.components-spinner'
273
289
  );
274
290
 
291
+ // We should not see the loading state if the block has not been configured and is empty.
292
+ expect( loadingSpinner ).toBeNull();
293
+ } );
294
+
295
+ it( 'shows a loading indicator whilst ref resolves to Navigation post items', async () => {
296
+ const testNavId = 1;
297
+
298
+ let resolveNavigationRequest;
299
+
300
+ // Mock the request for the single Navigation post in order to fully
301
+ // control the resolution of the request. This will enable the ability
302
+ // to assert on how the UI responds during the API resolution without
303
+ // relying on variable factors such as network conditions.
304
+ await setUpResponseMocking( [
305
+ {
306
+ match: ( request ) =>
307
+ request.url().includes( `rest_route` ) &&
308
+ request.url().includes( `navigation` ) &&
309
+ request.url().includes( testNavId ),
310
+ onRequestMatch: () => {
311
+ // The Promise simulates a REST API request whose resolultion
312
+ // the test has full control over.
313
+ return new Promise( ( resolve ) => {
314
+ // Assign the resolution function to the var in the
315
+ // upper scope to afford control over resolution.
316
+ resolveNavigationRequest = resolve;
317
+ } );
318
+ },
319
+ },
320
+ ] );
321
+
275
322
  await createNewPost();
276
- await insertBlock( 'Navigation' );
277
- await selectClassicMenu( 'Test Menu 2' );
323
+ await clickOnMoreMenuItem( 'Code editor' );
324
+ const codeEditorInput = await page.waitForSelector(
325
+ '.editor-post-text-editor'
326
+ );
327
+ await codeEditorInput.click();
278
328
 
279
- // Wait for a navigation link block before making assertion.
280
- await page.waitForSelector( '*[aria-label="Block: Custom Link"]' );
281
- expect( await getNavigationMenuRawContent() ).toMatchSnapshot();
329
+ // The ID used in this `ref` is that which we mock in the request
330
+ // above to ensure we can control the resolution of the Navigation post.
331
+ const markup = `<!-- wp:navigation {"ref":${ testNavId }} /-->`;
332
+ await page.keyboard.type( markup );
333
+ await clickButton( 'Exit code editor' );
334
+
335
+ const navBlock = await waitForBlock( 'Navigation' );
336
+
337
+ // Check for the spinner to be present whilst loading.
338
+ await navBlock.waitForSelector( '.components-spinner' );
339
+
340
+ // Resolve the controlled mocked API request.
341
+ resolveNavigationRequest();
282
342
  } );
283
343
 
284
- it( 'creates an empty navigation block when the selected existing menu is also empty', async () => {
285
- await createClassicMenu( { name: 'Test Menu 1' } );
344
+ it( 'shows a loading indicator whilst empty Navigation menu is being created', async () => {
345
+ const testNavId = 1;
346
+
347
+ let resolveNavigationRequest;
348
+
349
+ // Mock the request for the single Navigation post in order to fully
350
+ // control the resolution of the request. This will enable the ability
351
+ // to assert on how the UI responds during the API resolution without
352
+ // relying on variable factors such as network conditions.
353
+ await setUpResponseMocking( [
354
+ {
355
+ match: ( request ) =>
356
+ request.url().includes( `rest_route` ) &&
357
+ request.url().includes( `navigation` ) &&
358
+ request.url().includes( testNavId ),
359
+ onRequestMatch: () => {
360
+ // The Promise simulates a REST API request whose resolultion
361
+ // the test has full control over.
362
+ return new Promise( ( resolve ) => {
363
+ // Assign the resolution function to the var in the
364
+ // upper scope to afford control over resolution.
365
+ resolveNavigationRequest = resolve;
366
+ } );
367
+ },
368
+ },
369
+ ] );
370
+
286
371
  await createNewPost();
287
372
  await insertBlock( 'Navigation' );
288
- await selectClassicMenu( 'Test Menu 1' );
289
373
 
290
- // Wait for the appender so that we know the navigation menu was created.
291
- await page.waitForSelector(
292
- 'nav[aria-label="Block: Navigation"] button[aria-label="Add block"]'
374
+ let navBlock = await waitForBlock( 'Navigation' );
375
+
376
+ // Create empty Navigation block with no items
377
+ const startEmptyButton = await page.waitForXPath(
378
+ START_EMPTY_XPATH
293
379
  );
294
- expect( await getNavigationMenuRawContent() ).toMatchSnapshot();
380
+ await startEmptyButton.click();
381
+
382
+ navBlock = await waitForBlock( 'Navigation' );
383
+
384
+ // Check for the spinner to be present whilst loading.
385
+ await navBlock.waitForSelector( '.components-spinner' );
386
+
387
+ // Resolve the controlled mocked API request.
388
+ resolveNavigationRequest();
295
389
  } );
390
+ } );
296
391
 
297
- it( 'does not display the options to create from pages or menus if there are none', async () => {
298
- await createNewPost();
392
+ describe( 'Placeholder', () => {
393
+ describe( 'placeholder states', () => {
394
+ it( 'shows placeholder on insertion of block', async () => {
395
+ await createNewPost();
396
+ await insertBlock( 'Navigation' );
397
+ await page.waitForXPath( START_EMPTY_XPATH );
398
+ } );
299
399
 
300
- await insertBlock( 'Navigation' );
301
- await page.waitForXPath( START_EMPTY_XPATH );
400
+ it( 'shows placeholder preview when unconfigured block is not selected', async () => {
401
+ await createNewPost();
402
+ await insertBlock( 'Navigation' );
302
403
 
303
- const placeholderActionsLength = await page.$$eval(
304
- `.${ PLACEHOLDER_ACTIONS_CLASS } button`,
305
- ( els ) => els.length
306
- );
404
+ // Check for unconfigured Placeholder state to display
405
+ await page.waitForXPath( START_EMPTY_XPATH );
406
+
407
+ // Deselect the Nav block by inserting a new block at the root level
408
+ // outside of the Nav block.
409
+ await insertBlock( 'Paragraph' );
307
410
 
308
- // Should only be showing "Start empty".
309
- expect( placeholderActionsLength ).toEqual( 1 );
411
+ const navBlock = await waitForBlock( 'Navigation' );
412
+
413
+ // Check Placeholder Preview is visible.
414
+ await navBlock.waitForSelector(
415
+ '.wp-block-navigation-placeholder__preview',
416
+ { visible: true }
417
+ );
418
+
419
+ // Check Placeholder Component itself is not visible.
420
+ await navBlock.waitForSelector(
421
+ '.wp-block-navigation-placeholder__controls',
422
+ { visible: false }
423
+ );
424
+ } );
425
+
426
+ it( 'shows placeholder preview when block with no menu items is not selected', async () => {
427
+ await createNewPost();
428
+ await insertBlock( 'Navigation' );
429
+
430
+ // Create empty Navigation block with no items
431
+ const startEmptyButton = await page.waitForXPath(
432
+ START_EMPTY_XPATH
433
+ );
434
+ await startEmptyButton.click();
435
+
436
+ // Wait for block to resolve
437
+ let navBlock = await waitForBlock( 'Navigation' );
438
+
439
+ // Deselect the Nav block by inserting a new block at the root level
440
+ // outside of the Nav block.
441
+ await insertBlock( 'Paragraph' );
442
+
443
+ // Aquire fresh reference to block
444
+ navBlock = await waitForBlock( 'Navigation' );
445
+
446
+ // Check Placeholder Preview is visible.
447
+ await navBlock.waitForSelector(
448
+ '.wp-block-navigation-placeholder__preview',
449
+ { visible: true }
450
+ );
451
+
452
+ // Check the block's appender is not visible.
453
+ const blockAppender = await navBlock.$(
454
+ '.block-list-appender'
455
+ );
456
+
457
+ expect( blockAppender ).toBeNull();
458
+ } );
459
+ } );
460
+
461
+ describe( 'placeholder actions', () => {
462
+ it( 'allows a navigation block to be created from existing menus', async () => {
463
+ await createClassicMenu( { name: 'Test Menu 1' } );
464
+ await createClassicMenu(
465
+ { name: 'Test Menu 2' },
466
+ menuItemsFixture
467
+ );
468
+
469
+ await createNewPost();
470
+ await insertBlock( 'Navigation' );
471
+ await selectClassicMenu( 'Test Menu 2' );
472
+
473
+ // Wait for a navigation link block before making assertion.
474
+ await page.waitForSelector(
475
+ '*[aria-label="Block: Custom Link"]'
476
+ );
477
+ expect( await getNavigationMenuRawContent() ).toMatchSnapshot();
478
+ } );
479
+
480
+ it( 'creates an empty navigation block when the selected existing menu is also empty', async () => {
481
+ await createClassicMenu( { name: 'Test Menu 1' } );
482
+ await createNewPost();
483
+ await insertBlock( 'Navigation' );
484
+ await selectClassicMenu( 'Test Menu 1' );
485
+
486
+ // Wait for the appender so that we know the navigation menu was created.
487
+ await page.waitForSelector(
488
+ 'nav[aria-label="Block: Navigation"] button[aria-label="Add block"]'
489
+ );
490
+ expect( await getNavigationMenuRawContent() ).toMatchSnapshot();
491
+ } );
492
+
493
+ it( 'does not display the options to create from existing menus if there are no existing menus', async () => {
494
+ await createNewPost();
495
+
496
+ await insertBlock( 'Navigation' );
497
+ await page.waitForXPath( START_EMPTY_XPATH );
498
+
499
+ const placeholderActionsLength = await page.$$eval(
500
+ `.${ PLACEHOLDER_ACTIONS_CLASS } button`,
501
+ ( els ) => els.length
502
+ );
503
+
504
+ // Should only be showing "Start empty".
505
+ expect( placeholderActionsLength ).toEqual( 1 );
506
+ } );
310
507
  } );
311
508
  } );
312
509
 
@@ -316,6 +513,11 @@ describe( 'Navigation', () => {
316
513
  const startEmptyButton = await page.waitForXPath( START_EMPTY_XPATH );
317
514
  await startEmptyButton.click();
318
515
 
516
+ // Await "success" notice.
517
+ await page.waitForXPath(
518
+ '//div[@class="components-snackbar__content"][contains(text(), "Navigation Menu successfully created.")]'
519
+ );
520
+
319
521
  const appender = await page.waitForSelector(
320
522
  '.wp-block-navigation .block-list-appender'
321
523
  );
@@ -340,7 +542,7 @@ describe( 'Navigation', () => {
340
542
  // After adding a new block, search input should be shown immediately.
341
543
  // Verify that Escape would close the popover.
342
544
  // Regression: https://github.com/WordPress/gutenberg/pull/19885
343
- // Wait for URL input to be focused
545
+ // Wait for URL input to be focused.
344
546
  await page.waitForSelector(
345
547
  'input.block-editor-url-input__input:focus'
346
548
  );
@@ -405,7 +607,7 @@ describe( 'Navigation', () => {
405
607
  );
406
608
  await appenderAgain.click();
407
609
 
408
- // Wait for URL input to be focused
610
+ // Wait for URL input to be focused.
409
611
  await page.waitForSelector(
410
612
  'input.block-editor-url-input__input:focus'
411
613
  );
@@ -420,7 +622,7 @@ describe( 'Navigation', () => {
420
622
  expect( isInURLInput ).toBe( true );
421
623
  await page.keyboard.press( 'Escape' );
422
624
 
423
- // Click the link placeholder
625
+ // Click the link placeholder.
424
626
  const placeholder = await page.waitForSelector(
425
627
  '.wp-block-navigation-link__placeholder'
426
628
  );
@@ -584,14 +786,17 @@ describe( 'Navigation', () => {
584
786
  const markup =
585
787
  '<!-- wp:navigation --><!-- wp:page-list /--><!-- /wp:navigation -->';
586
788
  await page.keyboard.type( markup );
789
+
587
790
  await clickButton( 'Exit code editor' );
588
- const navBlock = await page.waitForSelector(
589
- 'nav[aria-label="Block: Navigation"]'
590
- );
591
- // Select the block to convert to a wp_navigation and publish.
592
- // The select menu button shows up when saving is complete.
791
+
792
+ const navBlock = await waitForBlock( 'Navigation' );
793
+
794
+ // Select the block to convert to a wp_navigation.
593
795
  await navBlock.click();
594
- await page.waitForSelector( 'button[aria-label="Select Menu"]' );
796
+
797
+ // The Page List block is rendered within Navigation InnerBlocks when saving is complete.
798
+ await waitForBlock( 'Page List' );
799
+
595
800
  await publishPost();
596
801
 
597
802
  // Check that the wp_navigation post has the page list block.
@@ -624,17 +829,18 @@ describe( 'Navigation', () => {
624
829
  '<!-- wp:navigation --><!-- wp:page-list /--><!-- /wp:navigation -->';
625
830
  await page.keyboard.type( markup );
626
831
  await clickButton( 'Exit code editor' );
627
- const navBlock = await page.waitForSelector(
628
- 'nav[aria-label="Block: Navigation"]'
629
- );
630
832
 
631
- // Select the block to convert to a wp_navigation and publish.
632
- // The select menu button shows up when saving is complete.
833
+ const navBlock = await waitForBlock( 'Navigation' );
834
+
835
+ // Select the block to convert to a wp_navigation.
633
836
  await navBlock.click();
634
- await page.waitForSelector( 'button[aria-label="Select Menu"]' );
837
+
838
+ // The Page List block is rendered within Navigation InnerBlocks when saving is complete.
839
+ await waitForBlock( 'Page List' );
635
840
 
636
841
  // Reset the nav block to create a new entity.
637
842
  await resetNavBlockToInitialState();
843
+
638
844
  const startEmptyButton = await page.waitForXPath(
639
845
  START_EMPTY_XPATH
640
846
  );
@@ -670,7 +876,7 @@ describe( 'Navigation', () => {
670
876
  await page.waitForXPath( NAV_ENTITY_SELECTOR );
671
877
  expect( await page.$x( NAV_ENTITY_SELECTOR ) ).toHaveLength( 1 );
672
878
 
673
- // Publish the post
879
+ // Publish the post.
674
880
  const entitySaveButton = await page.waitForSelector(
675
881
  '.editor-entities-saved-states__save-button'
676
882
  );
@@ -842,7 +1048,7 @@ describe( 'Navigation', () => {
842
1048
  // no URL of label and can be considered unpopulated.
843
1049
  await clickBlockToolbarButton( 'Select Submenu' );
844
1050
 
845
- // Check for non-disabled Convert to Link button
1051
+ // Check for non-disabled Convert to Link button.
846
1052
  const convertToLinkButton = await page.$(
847
1053
  '[aria-label="Block tools"] [aria-label="Convert to Link"]:not([disabled])'
848
1054
  );
@@ -879,9 +1085,10 @@ describe( 'Navigation', () => {
879
1085
 
880
1086
  await insertBlock( 'Navigation' );
881
1087
 
882
- // Select the Navigation post created by the Admin early
1088
+ // Select the Navigation post created by the Admin earlier
883
1089
  // in the test.
884
1090
  const navigationPostCreatedByAdminName = 'Navigation';
1091
+
885
1092
  const dropdown = await page.waitForXPath( SELECT_MENU_XPATH );
886
1093
  await dropdown.click();
887
1094
  const theOption = await page.waitForXPath(
@@ -889,7 +1096,7 @@ describe( 'Navigation', () => {
889
1096
  );
890
1097
  await theOption.click();
891
1098
 
892
- // Make sure the snackbar error shows up
1099
+ // Make sure the snackbar error shows up.
893
1100
  await page.waitForXPath(
894
1101
  `//*[contains(@class, 'components-snackbar__content')][ text()="You do not have permission to edit this Menu. Any changes made will not be saved." ]`
895
1102
  );
@@ -912,7 +1119,7 @@ describe( 'Navigation', () => {
912
1119
  await createNewPost();
913
1120
  await insertBlock( 'Navigation' );
914
1121
 
915
- // Make sure the snackbar error shows up
1122
+ // Make sure the snackbar error shows up.
916
1123
  await page.waitForXPath(
917
1124
  `//*[contains(@class, 'components-snackbar__content')][ text()="${ noticeText }" ]`
918
1125
  );
@@ -131,7 +131,7 @@ describe( 'Table', () => {
131
131
  // Expect the table to have a header, body and footer with written content.
132
132
  expect( await getEditedPostContent() ).toMatchSnapshot();
133
133
 
134
- // Toggle off the switches
134
+ // Toggle off the switches.
135
135
  await headerSwitch[ 0 ].click();
136
136
  await footerSwitch[ 0 ].click();
137
137
 
@@ -94,32 +94,32 @@ const createCorrectlyAppliesAndRemovesAlignmentTest = (
94
94
  it( 'Correctly applies the selected alignment and correctly removes the alignment', async () => {
95
95
  const BUTTON_XPATH = `//button[contains(@class,'components-dropdown-menu__menu-item')]//span[contains(text(), '${ alignLabels[ alignment ] }')]`;
96
96
 
97
- // set the specified alignment.
97
+ // Set the specified alignment.
98
98
  await insertBlock( blockName );
99
99
  await clickBlockToolbarButton( 'Align' );
100
100
  await ( await page.$x( BUTTON_XPATH ) )[ 0 ].click();
101
101
 
102
- // verify the button of the specified alignment is pressed.
102
+ // Verify the button of the specified alignment is pressed.
103
103
  await expectActiveButtonLabelToBe( alignLabels[ alignment ] );
104
104
 
105
105
  let htmlMarkup = await getEditedPostContent();
106
106
 
107
- // verify the markup of the selected alignment was generated.
107
+ // Verify the markup of the selected alignment was generated.
108
108
  expect( htmlMarkup ).toMatchSnapshot();
109
109
 
110
- // verify the markup can be correctly parsed
110
+ // Verify the markup can be correctly parsed.
111
111
  await verifyMarkupIsValid( htmlMarkup );
112
112
 
113
113
  await selectBlockByClientId( ( await getAllBlocks() )[ 0 ].clientId );
114
114
 
115
- // remove the alignment.
115
+ // Remove the alignment.
116
116
  await clickBlockToolbarButton( 'Align' );
117
117
  await ( await page.$x( BUTTON_XPATH ) )[ 0 ].click();
118
118
 
119
- // verify 'none' alignment button is in pressed state.
119
+ // Verify 'none' alignment button is in pressed state.
120
120
  await expectActiveButtonLabelToBe( alignLabels.none );
121
121
 
122
- // verify alignment markup was removed from the block.
122
+ // Verify alignment markup was removed from the block.
123
123
  htmlMarkup = await getEditedPostContent();
124
124
  expect( htmlMarkup ).toMatchSnapshot();
125
125
 
@@ -128,7 +128,7 @@ const createCorrectlyAppliesAndRemovesAlignmentTest = (
128
128
 
129
129
  await selectBlockByClientId( ( await getAllBlocks() )[ 0 ].clientId );
130
130
 
131
- // verify alignment `none` button is in pressed state after parsing the block.
131
+ // Verify alignment `none` button is in pressed state after parsing the block.
132
132
  await expectActiveButtonLabelToBe( alignLabels.none );
133
133
  } );
134
134
  };
@@ -202,7 +202,7 @@ describe( 'Align Hook Works As Expected', () => {
202
202
 
203
203
  it( 'Applies the selected alignment by default', async () => {
204
204
  await insertBlock( BLOCK_NAME );
205
- // verify the correct alignment button is pressed
205
+ // Verify the correct alignment button is pressed.
206
206
  await clickBlockToolbarButton( 'Align' );
207
207
  const selectedAlignmentControls = await page.$x(
208
208
  SELECTED_ALIGNMENT_CONTROL_SELECTOR
@@ -219,7 +219,7 @@ describe( 'Align Hook Works As Expected', () => {
219
219
 
220
220
  it( 'Can remove the default alignment and the align attribute equals none but alignnone class is not applied', async () => {
221
221
  await insertBlock( BLOCK_NAME );
222
- // remove the alignment.
222
+ // Remove the alignment.
223
223
  await clickBlockToolbarButton( 'Align' );
224
224
  const [ selectedAlignmentControl ] = await page.$x(
225
225
  SELECTED_ALIGNMENT_CONTROL_SELECTOR
@@ -77,7 +77,7 @@ describe( 'Block context', () => {
77
77
  );
78
78
  expect( content ).toMatch( /^123,\d+,post$/ );
79
79
 
80
- // Clean up
80
+ // Clean up.
81
81
  await editorPage.bringToFront();
82
82
  await previewPage.close();
83
83
  } );
@@ -12,7 +12,7 @@ import {
12
12
 
13
13
  const BLOCK1_NAME = 'block-directory-test-block/main-block';
14
14
 
15
- // Urls to mock
15
+ // Urls to mock.
16
16
  const SEARCH_URLS = [
17
17
  '/wp/v2/block-directory/search',
18
18
  `rest_route=${ encodeURIComponent( '/wp/v2/block-directory/search' ) }`,
@@ -30,7 +30,7 @@ const INSTALL_URLS = [
30
30
  `rest_route=${ encodeURIComponent( '/wp/v2/plugins' ) }`,
31
31
  ];
32
32
 
33
- // Example Blocks
33
+ // Example Blocks.
34
34
  const MOCK_BLOCK1 = {
35
35
  name: BLOCK1_NAME,
36
36
  title: 'Block Directory Test Block',
@@ -44,7 +44,7 @@ const MOCK_BLOCK1 = {
44
44
  author: 'No Author',
45
45
  icon: 'block-default',
46
46
  assets: [
47
- 'https://fake_url.com/block.js', // we will mock this
47
+ 'https://fake_url.com/block.js', // We will mock this.
48
48
  ],
49
49
  humanized_updated: '5 months ago',
50
50
  links: {},
@@ -82,7 +82,7 @@ const MOCK_BLOCK2 = {
82
82
  id: 'block-directory-test-secondary-block',
83
83
  };
84
84
 
85
- // Block that will be registered
85
+ // Block that will be registered.
86
86
  const block = `( function() {
87
87
  var registerBlockType = wp.blocks.registerBlockType;
88
88
  var el = wp.element.createElement;
@@ -112,26 +112,26 @@ const MOCK_EMPTY_RESPONSES = [
112
112
 
113
113
  const MOCK_BLOCKS_RESPONSES = [
114
114
  {
115
- // Mock response for search with the block
115
+ // Mock response for search with the block.
116
116
  match: ( request ) =>
117
117
  matchUrl( request.url(), SEARCH_URLS ) &&
118
118
  request.method() === 'GET',
119
119
  onRequestMatch: createJSONResponse( [ MOCK_BLOCK1, MOCK_BLOCK2 ] ),
120
120
  },
121
121
  {
122
- // Mock response for block type
122
+ // Mock response for block type.
123
123
  match: ( request ) => matchUrl( request.url(), BLOCK_TYPE_URLS ),
124
124
  onRequestMatch: createJSONResponse( {} ),
125
125
  },
126
126
  {
127
- // Mock response for install
127
+ // Mock response for install.
128
128
  match: ( request ) => matchUrl( request.url(), INSTALL_URLS ),
129
129
  onRequestMatch: createJSONResponse(
130
130
  MOCK_INSTALLED_BLOCK_PLUGIN_DETAILS
131
131
  ),
132
132
  },
133
133
  {
134
- // Mock the response for the js asset once it gets injected
134
+ // Mock the response for the js asset once it gets injected.
135
135
  match: ( request ) => request.url().includes( MOCK_BLOCK1.assets[ 0 ] ),
136
136
  onRequestMatch: createResponse(
137
137
  Buffer.from( block, 'utf8' ),
@@ -171,13 +171,13 @@ describe( 'adding blocks from block directory', () => {
171
171
  } );
172
172
 
173
173
  it( 'Should show an empty state when no plugin is found.', async () => {
174
- // Be super weird so there won't be a matching block installed
174
+ // Be super weird so there won't be a matching block installed.
175
175
  const impossibleBlockName = '@#$@@Dsdsdfw2#$@';
176
176
 
177
- // Return an empty list of plugins
177
+ // Return an empty list of plugins.
178
178
  await setUpResponseMocking( MOCK_EMPTY_RESPONSES );
179
179
 
180
- // Search for the block via the inserter
180
+ // Search for the block via the inserter.
181
181
  await searchForBlock( impossibleBlockName );
182
182
 
183
183
  const selectorContent = await page.evaluate(
@@ -191,15 +191,15 @@ describe( 'adding blocks from block directory', () => {
191
191
  } );
192
192
 
193
193
  it( 'Should be able to add (the first) block.', async () => {
194
- // Setup our mocks
194
+ // Setup our mocks.
195
195
  await setUpResponseMocking( MOCK_BLOCKS_RESPONSES );
196
196
 
197
- // Search for the block via the inserter
197
+ // Search for the block via the inserter.
198
198
  await insertBlockDirectoryBlock( MOCK_BLOCK1.title );
199
199
 
200
200
  await page.waitForSelector( `div[data-type="${ MOCK_BLOCK1.name }"]` );
201
201
 
202
- // The block will auto select and get added, make sure we see it in the content
202
+ // The block will auto select and get added, make sure we see it in the content.
203
203
  expect( await getEditedPostContent() ).toMatchSnapshot();
204
204
  } );
205
205
  } );
@@ -13,7 +13,7 @@ import {
13
13
  const openPageAttributesPanel = async () => {
14
14
  const openButton = await findSidebarPanelWithTitle( 'Page Attributes' );
15
15
 
16
- // Get the classes from the panel
16
+ // Get the classes from the panel.
17
17
  const buttonClassName = await (
18
18
  await openButton.getProperty( 'className' )
19
19
  ).jsonValue();
@@ -29,7 +29,7 @@ describe( 'Custom Taxonomies labels are used', () => {
29
29
  const openButton = await findSidebarPanelWithTitle( 'Model' );
30
30
  expect( openButton ).not.toBeFalsy();
31
31
 
32
- // Get the classes from the panel
32
+ // Get the classes from the panel.
33
33
  const buttonClassName = await (
34
34
  await openButton.getProperty( 'className' )
35
35
  ).jsonValue();
@@ -39,13 +39,13 @@ describe( 'Custom Taxonomies labels are used', () => {
39
39
  await openButton.click();
40
40
  }
41
41
 
42
- // Check the add new button
42
+ // Check the add new button.
43
43
  const labelNew = await page.$x(
44
44
  "//label[@class='components-form-token-field__label' and contains(text(), 'Add New Model')]"
45
45
  );
46
46
  expect( labelNew ).not.toBeFalsy();
47
47
 
48
- // Fill with one entry
48
+ // Fill with one entry.
49
49
  await page.type(
50
50
  'input.components-form-token-field__input',
51
51
  'Model 1'
@@ -62,7 +62,7 @@ describe( 'Block with a meta attribute', () => {
62
62
  // Clicking the input selects the block,
63
63
  // and selecting the block enables the sync data mode
64
64
  // as otherwise the asynchronous re-rendering of unselected blocks
65
- // may cause the input to have not yet been updated for the other blocks
65
+ // may cause the input to have not yet been updated for the other blocks.
66
66
  await input.click();
67
67
  const inputValue = await input.getProperty( 'value' );
68
68
  expect( await inputValue.jsonValue() ).toBe(