@wordpress/e2e-tests 4.9.1 → 5.0.1-next.957ca95e4c.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -1
- package/README.md +1 -1
- package/assets/large-post.html +364 -182
- package/package.json +8 -8
- package/specs/editor/blocks/__snapshots__/navigation.test.js.snap +2 -2
- package/specs/editor/blocks/__snapshots__/quote.test.js.snap +5 -1
- package/specs/editor/blocks/navigation.test.js +392 -154
- package/specs/editor/blocks/quote.test.js +4 -1
- package/specs/editor/plugins/__snapshots__/cpt-locking.test.js.snap +5 -3
- package/specs/editor/plugins/inner-blocks-allowed-blocks.test.js +3 -0
- package/specs/editor/various/__snapshots__/block-deletion.test.js.snap +3 -1
- package/specs/editor/various/__snapshots__/block-grouping.test.js.snap +5 -5
- package/specs/editor/various/__snapshots__/block-hierarchy-navigation.test.js.snap +1 -1
- package/specs/editor/various/__snapshots__/draggable-block.test.js.snap +22 -2
- package/specs/editor/various/__snapshots__/inserting-blocks.test.js.snap +1 -1
- package/specs/editor/various/__snapshots__/keep-styles-on-block-transforms.test.js.snap +1 -7
- package/specs/editor/various/__snapshots__/multi-block-selection.test.js.snap +34 -6
- package/specs/editor/various/__snapshots__/rich-text.test.js.snap +19 -5
- package/specs/editor/various/__snapshots__/writing-flow.test.js.snap +3 -11
- package/specs/editor/various/block-grouping.test.js +2 -2
- package/specs/editor/various/block-switcher.test.js +11 -3
- package/specs/editor/various/draggable-block.test.js +83 -14
- package/specs/editor/various/inserting-blocks.test.js +4 -0
- package/specs/editor/various/keep-styles-on-block-transforms.test.js +0 -17
- package/specs/editor/various/multi-block-selection.test.js +36 -5
- package/specs/editor/various/post-visibility.test.js +2 -4
- package/specs/editor/various/rich-text.test.js +9 -6
- package/specs/editor/various/scheduling.test.js +2 -6
- package/specs/editor/various/splitting-merging.test.js +7 -2
- package/specs/editor/various/switch-to-draft.test.js +2 -4
- package/specs/editor/various/toolbar-roving-tabindex.test.js +2 -1
- package/specs/editor/various/writing-flow.test.js +8 -4
- package/specs/performance/post-editor.test.js +3 -3
- package/specs/site-editor/global-styles-sidebar.test.js +2 -1
- package/specs/editor/plugins/register-block-type-hooks.test.js +0 -32
- package/specs/editor/plugins/wp-editor-meta-box.test.js +0 -58
- package/specs/editor/various/__snapshots__/duplicating-blocks.test.js.snap +0 -21
- package/specs/editor/various/duplicating-blocks.test.js +0 -47
@@ -154,7 +154,7 @@ async function updateActiveNavigationLink( { url, label, type } ) {
|
|
154
154
|
);
|
155
155
|
await input.type( url );
|
156
156
|
|
157
|
-
const suggestionPath = `//button[contains(@class, 'block-editor-link-control__search-item') and contains(@class, '${ typeClasses[ type ] }')
|
157
|
+
const suggestionPath = `//button[contains(@class, 'block-editor-link-control__search-item') and contains(@class, '${ typeClasses[ type ] }') and contains(., "${ url }")]`;
|
158
158
|
|
159
159
|
// Wait for the autocomplete suggestion item to appear.
|
160
160
|
await page.waitForXPath( suggestionPath );
|
@@ -186,12 +186,13 @@ async function updateActiveNavigationLink( { url, label, type } ) {
|
|
186
186
|
}
|
187
187
|
|
188
188
|
async function selectClassicMenu( optionText ) {
|
189
|
-
const
|
190
|
-
"
|
189
|
+
const navigationSelector = await page.waitForXPath(
|
190
|
+
"//button[text()='Select Menu']"
|
191
191
|
);
|
192
|
-
await
|
192
|
+
await navigationSelector.click();
|
193
|
+
|
193
194
|
const theOption = await page.waitForXPath(
|
194
|
-
|
195
|
+
'//button[contains(., "' + optionText + '")]'
|
195
196
|
);
|
196
197
|
await theOption.click();
|
197
198
|
|
@@ -201,24 +202,6 @@ async function selectClassicMenu( optionText ) {
|
|
201
202
|
);
|
202
203
|
}
|
203
204
|
|
204
|
-
async function populateNavWithOneItem() {
|
205
|
-
// Add a Link block first.
|
206
|
-
const appender = await page.waitForSelector(
|
207
|
-
'.wp-block-navigation .block-list-appender'
|
208
|
-
);
|
209
|
-
await appender.click();
|
210
|
-
// Add a link to the Link block.
|
211
|
-
await updateActiveNavigationLink( {
|
212
|
-
url: 'https://wordpress.org',
|
213
|
-
label: 'WP',
|
214
|
-
type: 'url',
|
215
|
-
} );
|
216
|
-
}
|
217
|
-
|
218
|
-
const PLACEHOLDER_ACTIONS_CLASS = 'wp-block-navigation-placeholder__actions';
|
219
|
-
const PLACEHOLDER_ACTIONS_XPATH = `//*[contains(@class, '${ PLACEHOLDER_ACTIONS_CLASS }')]`;
|
220
|
-
const START_EMPTY_XPATH = `${ PLACEHOLDER_ACTIONS_XPATH }//button[text()='Start empty']`;
|
221
|
-
|
222
205
|
/**
|
223
206
|
* Delete all items for the given REST resources using the REST API.
|
224
207
|
*
|
@@ -246,17 +229,6 @@ async function deleteAll( endpoints ) {
|
|
246
229
|
}
|
247
230
|
}
|
248
231
|
|
249
|
-
async function resetNavBlockToInitialState() {
|
250
|
-
const selectMenuDropdown = await page.waitForSelector(
|
251
|
-
'[aria-label="Select Menu"]'
|
252
|
-
);
|
253
|
-
await selectMenuDropdown.click();
|
254
|
-
const newMenuButton = await page.waitForXPath(
|
255
|
-
'//span[text()="Create new menu"]'
|
256
|
-
);
|
257
|
-
newMenuButton.click();
|
258
|
-
}
|
259
|
-
|
260
232
|
/**
|
261
233
|
* Replace unique ids in nav block content, since these won't be consistent
|
262
234
|
* between test runs.
|
@@ -306,8 +278,9 @@ async function waitForBlock( blockName ) {
|
|
306
278
|
}
|
307
279
|
|
308
280
|
// Disable reason - these tests are to be re-written.
|
281
|
+
// Skipped temporarily due to issues with GH actions: https://wordpress.slack.com/archives/C02QB2JS7/p1661331673166269.
|
309
282
|
// eslint-disable-next-line jest/no-disabled-tests
|
310
|
-
describe( 'Navigation', () => {
|
283
|
+
describe.skip( 'Navigation', () => {
|
311
284
|
const contributorUsername = `contributoruser_${ ++uniqueId }`;
|
312
285
|
let contributorPassword;
|
313
286
|
|
@@ -355,7 +328,8 @@ describe( 'Navigation', () => {
|
|
355
328
|
// Insert an empty block to trigger resolution of Nav Menu items.
|
356
329
|
await insertBlock( 'Navigation' );
|
357
330
|
await waitForBlock( 'Navigation' );
|
358
|
-
|
331
|
+
|
332
|
+
await page.waitForXPath( "//button[text()='Select Menu']" );
|
359
333
|
|
360
334
|
// Now we have Nav Menu items resolved. Continue to assert.
|
361
335
|
await clickOnMoreMenuItem( 'Code editor' );
|
@@ -475,15 +449,18 @@ Expected mock function not to be called but it was called with: ["POST", "http:/
|
|
475
449
|
await createNewPost();
|
476
450
|
await insertBlock( 'Navigation' );
|
477
451
|
|
478
|
-
|
452
|
+
const navBlock = await waitForBlock( 'Navigation' );
|
479
453
|
|
480
454
|
// Create empty Navigation block with no items
|
481
|
-
const
|
482
|
-
|
455
|
+
const navigationSelector = await page.waitForXPath(
|
456
|
+
"//button[text()='Select Menu']"
|
483
457
|
);
|
484
|
-
await
|
458
|
+
await navigationSelector.click();
|
485
459
|
|
486
|
-
|
460
|
+
const createNewMenuButton = await page.waitForXPath(
|
461
|
+
'//button[contains(., "Create new menu")]'
|
462
|
+
);
|
463
|
+
await createNewMenuButton.click();
|
487
464
|
|
488
465
|
// Check for the spinner to be present whilst loading.
|
489
466
|
await navBlock.waitForSelector( '.components-spinner' );
|
@@ -496,48 +473,26 @@ Expected mock function not to be called but it was called with: ["POST", "http:/
|
|
496
473
|
} );
|
497
474
|
|
498
475
|
describe( 'Placeholder', () => {
|
499
|
-
describe( '
|
500
|
-
it( 'shows
|
476
|
+
describe( 'fallback states', () => {
|
477
|
+
it( 'shows page list on insertion of block', async () => {
|
501
478
|
await createNewPost();
|
502
479
|
await insertBlock( 'Navigation' );
|
503
|
-
await
|
480
|
+
await waitForBlock( 'Page List' );
|
504
481
|
} );
|
505
482
|
|
506
|
-
it( 'shows placeholder preview when
|
483
|
+
it( 'shows placeholder preview when block with no menu items is not selected', async () => {
|
507
484
|
await createNewPost();
|
508
485
|
await insertBlock( 'Navigation' );
|
509
486
|
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
// Deselect the Nav block by inserting a new block at the root level
|
514
|
-
// outside of the Nav block.
|
515
|
-
await insertBlock( 'Paragraph' );
|
516
|
-
|
517
|
-
const navBlock = await waitForBlock( 'Navigation' );
|
518
|
-
|
519
|
-
// Check Placeholder Preview is visible.
|
520
|
-
await navBlock.waitForSelector(
|
521
|
-
'.wp-block-navigation-placeholder__preview',
|
522
|
-
{ visible: true }
|
487
|
+
const navigationSelector = await page.waitForXPath(
|
488
|
+
"//button[text()='Select Menu']"
|
523
489
|
);
|
490
|
+
await navigationSelector.click();
|
524
491
|
|
525
|
-
|
526
|
-
|
527
|
-
'.wp-block-navigation-placeholder__controls',
|
528
|
-
{ visible: false }
|
529
|
-
);
|
530
|
-
} );
|
531
|
-
|
532
|
-
it( 'shows placeholder preview when block with no menu items is not selected', async () => {
|
533
|
-
await createNewPost();
|
534
|
-
await insertBlock( 'Navigation' );
|
535
|
-
|
536
|
-
// Create empty Navigation block with no items
|
537
|
-
const startEmptyButton = await page.waitForXPath(
|
538
|
-
START_EMPTY_XPATH
|
492
|
+
const createNewMenuButton = await page.waitForXPath(
|
493
|
+
'//button[contains(., "Create new menu")]'
|
539
494
|
);
|
540
|
-
await
|
495
|
+
await createNewMenuButton.click();
|
541
496
|
|
542
497
|
// Wait for Navigation creation to complete.
|
543
498
|
await page.waitForXPath(
|
@@ -569,7 +524,7 @@ Expected mock function not to be called but it was called with: ["POST", "http:/
|
|
569
524
|
} );
|
570
525
|
} );
|
571
526
|
|
572
|
-
describe( '
|
527
|
+
describe( 'menu selector actions', () => {
|
573
528
|
it( 'allows a navigation block to be created from existing menus', async () => {
|
574
529
|
await createClassicMenu( { name: 'Test Menu 1' } );
|
575
530
|
await createClassicMenu(
|
@@ -594,6 +549,8 @@ Expected mock function not to be called but it was called with: ["POST", "http:/
|
|
594
549
|
await insertBlock( 'Navigation' );
|
595
550
|
await selectClassicMenu( 'Test Menu 1' );
|
596
551
|
|
552
|
+
await page.waitForNetworkIdle();
|
553
|
+
|
597
554
|
// Wait for the appender so that we know the navigation menu was created.
|
598
555
|
await page.waitForSelector(
|
599
556
|
'nav[aria-label="Block: Navigation"] button[aria-label="Add block"]'
|
@@ -605,14 +562,24 @@ Expected mock function not to be called but it was called with: ["POST", "http:/
|
|
605
562
|
await createNewPost();
|
606
563
|
|
607
564
|
await insertBlock( 'Navigation' );
|
608
|
-
|
565
|
+
|
566
|
+
const navigationSelector = await page.waitForXPath(
|
567
|
+
"//button[text()='Select Menu']"
|
568
|
+
);
|
569
|
+
await navigationSelector.click();
|
570
|
+
|
571
|
+
await page.waitForXPath(
|
572
|
+
'//button[contains(., "Create new menu")]'
|
573
|
+
);
|
574
|
+
|
575
|
+
await page.waitForSelector( '.components-menu-group' );
|
609
576
|
|
610
577
|
const placeholderActionsLength = await page.$$eval(
|
611
|
-
|
578
|
+
'.components-menu-group',
|
612
579
|
( els ) => els.length
|
613
580
|
);
|
614
581
|
|
615
|
-
// Should only be showing "
|
582
|
+
// Should only be showing "Create new menu".
|
616
583
|
expect( placeholderActionsLength ).toEqual( 1 );
|
617
584
|
} );
|
618
585
|
} );
|
@@ -621,8 +588,20 @@ Expected mock function not to be called but it was called with: ["POST", "http:/
|
|
621
588
|
it( 'allows an empty navigation block to be created and manually populated using a mixture of internal and external links', async () => {
|
622
589
|
await createNewPost();
|
623
590
|
await insertBlock( 'Navigation' );
|
624
|
-
|
625
|
-
await
|
591
|
+
|
592
|
+
await showBlockToolbar();
|
593
|
+
|
594
|
+
const navigationSelector = await page.waitForXPath(
|
595
|
+
"//button[text()='Select Menu']"
|
596
|
+
);
|
597
|
+
await navigationSelector.click();
|
598
|
+
|
599
|
+
const createNewMenuButton = await page.waitForXPath(
|
600
|
+
'//button[contains(., "Create new menu")]'
|
601
|
+
);
|
602
|
+
await createNewMenuButton.click();
|
603
|
+
|
604
|
+
await page.waitForNetworkIdle();
|
626
605
|
|
627
606
|
// Await "success" notice.
|
628
607
|
await page.waitForXPath(
|
@@ -630,7 +609,7 @@ Expected mock function not to be called but it was called with: ["POST", "http:/
|
|
630
609
|
);
|
631
610
|
|
632
611
|
const appender = await page.waitForSelector(
|
633
|
-
'.wp-block-navigation .block-
|
612
|
+
'.wp-block-navigation .block-editor-button-block-appender'
|
634
613
|
);
|
635
614
|
await appender.click();
|
636
615
|
|
@@ -696,11 +675,25 @@ Expected mock function not to be called but it was called with: ["POST", "http:/
|
|
696
675
|
it( 'encodes URL when create block if needed', async () => {
|
697
676
|
await createNewPost();
|
698
677
|
await insertBlock( 'Navigation' );
|
699
|
-
const
|
700
|
-
|
678
|
+
const navigationSelector = await page.waitForXPath(
|
679
|
+
"//button[text()='Select Menu']"
|
680
|
+
);
|
681
|
+
await navigationSelector.click();
|
682
|
+
|
683
|
+
const createNewMenuButton = await page.waitForXPath(
|
684
|
+
'//button[contains(., "Create new menu")]'
|
685
|
+
);
|
686
|
+
await createNewMenuButton.click();
|
687
|
+
|
688
|
+
await page.waitForNetworkIdle();
|
689
|
+
|
690
|
+
// Await "success" notice.
|
691
|
+
await page.waitForXPath(
|
692
|
+
'//div[@class="components-snackbar__content"][contains(text(), "Navigation Menu successfully created.")]'
|
693
|
+
);
|
701
694
|
|
702
695
|
const appender = await page.waitForSelector(
|
703
|
-
'.wp-block-navigation .block-
|
696
|
+
'.wp-block-navigation .block-editor-button-block-appender'
|
704
697
|
);
|
705
698
|
await appender.click();
|
706
699
|
|
@@ -762,10 +755,26 @@ Expected mock function not to be called but it was called with: ["POST", "http:/
|
|
762
755
|
it( 'allows pages to be created from the navigation block and their links added to menu', async () => {
|
763
756
|
await createNewPost();
|
764
757
|
await insertBlock( 'Navigation' );
|
765
|
-
|
766
|
-
await
|
758
|
+
|
759
|
+
const navigationSelector = await page.waitForXPath(
|
760
|
+
"//button[text()='Select Menu']"
|
761
|
+
);
|
762
|
+
await navigationSelector.click();
|
763
|
+
|
764
|
+
const createNewMenuButton = await page.waitForXPath(
|
765
|
+
'//button[contains(., "Create new menu")]'
|
766
|
+
);
|
767
|
+
await createNewMenuButton.click();
|
768
|
+
|
769
|
+
await page.waitForNetworkIdle();
|
770
|
+
|
771
|
+
// Await "success" notice.
|
772
|
+
await page.waitForXPath(
|
773
|
+
'//div[@class="components-snackbar__content"][contains(text(), "Navigation Menu successfully created.")]'
|
774
|
+
);
|
775
|
+
|
767
776
|
const appender = await page.waitForSelector(
|
768
|
-
'.wp-block-navigation .block-
|
777
|
+
'.wp-block-navigation .block-editor-button-block-appender'
|
769
778
|
);
|
770
779
|
await appender.click();
|
771
780
|
|
@@ -811,10 +820,26 @@ Expected mock function not to be called but it was called with: ["POST", "http:/
|
|
811
820
|
it( 'correctly decodes special characters in the created Page title for display', async () => {
|
812
821
|
await createNewPost();
|
813
822
|
await insertBlock( 'Navigation' );
|
814
|
-
|
815
|
-
await
|
823
|
+
|
824
|
+
const navigationSelector = await page.waitForXPath(
|
825
|
+
"//button[text()='Select Menu']"
|
826
|
+
);
|
827
|
+
await navigationSelector.click();
|
828
|
+
|
829
|
+
const createNewMenuButton = await page.waitForXPath(
|
830
|
+
'//button[contains(., "Create new menu")]'
|
831
|
+
);
|
832
|
+
await createNewMenuButton.click();
|
833
|
+
|
834
|
+
await page.waitForNetworkIdle();
|
835
|
+
|
836
|
+
// Await "success" notice.
|
837
|
+
await page.waitForXPath(
|
838
|
+
'//div[@class="components-snackbar__content"][contains(text(), "Navigation Menu successfully created.")]'
|
839
|
+
);
|
840
|
+
|
816
841
|
const appender = await page.waitForSelector(
|
817
|
-
'.wp-block-navigation .block-
|
842
|
+
'.wp-block-navigation .block-editor-button-block-appender'
|
818
843
|
);
|
819
844
|
await appender.click();
|
820
845
|
|
@@ -904,11 +929,26 @@ Expected mock function not to be called but it was called with: ["POST", "http:/
|
|
904
929
|
it( 'Shows the quick inserter when the block contains non-navigation specific blocks', async () => {
|
905
930
|
await createNewPost();
|
906
931
|
await insertBlock( 'Navigation' );
|
907
|
-
|
908
|
-
await
|
932
|
+
|
933
|
+
const navigationSelector = await page.waitForXPath(
|
934
|
+
"//button[text()='Select Menu']"
|
935
|
+
);
|
936
|
+
await navigationSelector.click();
|
937
|
+
|
938
|
+
const createNewMenuButton = await page.waitForXPath(
|
939
|
+
'//button[contains(., "Create new menu")]'
|
940
|
+
);
|
941
|
+
await createNewMenuButton.click();
|
942
|
+
|
943
|
+
await page.waitForNetworkIdle();
|
944
|
+
|
945
|
+
// Await "success" notice.
|
946
|
+
await page.waitForXPath(
|
947
|
+
'//div[@class="components-snackbar__content"][contains(text(), "Navigation Menu successfully created.")]'
|
948
|
+
);
|
909
949
|
|
910
950
|
const appender = await page.waitForSelector(
|
911
|
-
'.wp-block-navigation .block-
|
951
|
+
'.wp-block-navigation .block-editor-button-block-appender'
|
912
952
|
);
|
913
953
|
await appender.click();
|
914
954
|
|
@@ -949,13 +989,27 @@ Expected mock function not to be called but it was called with: ["POST", "http:/
|
|
949
989
|
|
950
990
|
const navBlock = await waitForBlock( 'Navigation' );
|
951
991
|
|
952
|
-
|
953
|
-
|
954
|
-
START_EMPTY_XPATH
|
992
|
+
const navigationSelector = await page.waitForXPath(
|
993
|
+
"//button[text()='Select Menu']"
|
955
994
|
);
|
956
|
-
await
|
995
|
+
await navigationSelector.click();
|
957
996
|
|
958
|
-
await
|
997
|
+
const createNewMenuButton = await page.waitForXPath(
|
998
|
+
'//button[contains(., "Create new menu")]'
|
999
|
+
);
|
1000
|
+
await createNewMenuButton.click();
|
1001
|
+
|
1002
|
+
await page.waitForNetworkIdle();
|
1003
|
+
|
1004
|
+
// Await "success" notice.
|
1005
|
+
await page.waitForXPath(
|
1006
|
+
'//div[@class="components-snackbar__content"][contains(text(), "Navigation Menu successfully created.")]'
|
1007
|
+
);
|
1008
|
+
|
1009
|
+
const appender = await page.waitForSelector(
|
1010
|
+
'.wp-block-navigation .block-editor-button-block-appender'
|
1011
|
+
);
|
1012
|
+
await appender.click();
|
959
1013
|
|
960
1014
|
await clickOnMoreMenuItem( 'Code editor' );
|
961
1015
|
const codeEditorInput = await page.waitForSelector(
|
@@ -1083,11 +1137,27 @@ Expected mock function not to be called but it was called with: ["POST", "http:/
|
|
1083
1137
|
await createNewPost();
|
1084
1138
|
await insertBlock( 'Navigation' );
|
1085
1139
|
|
1086
|
-
const
|
1087
|
-
|
1140
|
+
const navigationSelector = await page.waitForXPath(
|
1141
|
+
"//button[text()='Select Menu']"
|
1142
|
+
);
|
1143
|
+
await navigationSelector.click();
|
1144
|
+
|
1145
|
+
const createNewMenuButton = await page.waitForXPath(
|
1146
|
+
'//button[contains(., "Create new menu")]'
|
1147
|
+
);
|
1148
|
+
await createNewMenuButton.click();
|
1149
|
+
|
1150
|
+
await page.waitForNetworkIdle();
|
1151
|
+
|
1152
|
+
// Await "success" notice.
|
1153
|
+
await page.waitForXPath(
|
1154
|
+
'//div[@class="components-snackbar__content"][contains(text(), "Navigation Menu successfully created.")]'
|
1155
|
+
);
|
1156
|
+
|
1157
|
+
const appender = await page.waitForSelector(
|
1158
|
+
'.wp-block-navigation .block-editor-button-block-appender'
|
1088
1159
|
);
|
1089
|
-
await
|
1090
|
-
await populateNavWithOneItem();
|
1160
|
+
await appender.click();
|
1091
1161
|
|
1092
1162
|
// Confirm that the menu entity was updated.
|
1093
1163
|
const publishPanelButton = await page.waitForSelector(
|
@@ -1117,13 +1187,27 @@ Expected mock function not to be called but it was called with: ["POST", "http:/
|
|
1117
1187
|
// await page.click( 'nav[aria-label="Block: Navigation"]' );
|
1118
1188
|
await forceSelectNavigationBlock();
|
1119
1189
|
|
1120
|
-
await
|
1190
|
+
const newNavigationSelector = await page.waitForXPath(
|
1191
|
+
"//button[text()='Select Menu']"
|
1192
|
+
);
|
1193
|
+
await newNavigationSelector.click();
|
1121
1194
|
|
1122
|
-
const
|
1123
|
-
|
1195
|
+
const newCreateNewMenuButton = await page.waitForXPath(
|
1196
|
+
'//button[contains(., "Create new menu")]'
|
1124
1197
|
);
|
1125
|
-
await
|
1126
|
-
|
1198
|
+
await newCreateNewMenuButton.click();
|
1199
|
+
|
1200
|
+
await page.waitForNetworkIdle();
|
1201
|
+
|
1202
|
+
// Await "success" notice.
|
1203
|
+
await page.waitForXPath(
|
1204
|
+
'//div[@class="components-snackbar__content"][contains(text(), "Navigation Menu successfully created.")]'
|
1205
|
+
);
|
1206
|
+
|
1207
|
+
const newAppender = await page.waitForSelector(
|
1208
|
+
'.wp-block-navigation .block-editor-button-block-appender'
|
1209
|
+
);
|
1210
|
+
await newAppender.click();
|
1127
1211
|
|
1128
1212
|
// Confirm that only the last menu entity was updated.
|
1129
1213
|
const publishPanelButton2 = await page.waitForSelector(
|
@@ -1139,11 +1223,26 @@ Expected mock function not to be called but it was called with: ["POST", "http:/
|
|
1139
1223
|
it( 'applies accessible label to block element', async () => {
|
1140
1224
|
await createNewPost();
|
1141
1225
|
await insertBlock( 'Navigation' );
|
1142
|
-
|
1143
|
-
await
|
1226
|
+
|
1227
|
+
const navigationSelector = await page.waitForXPath(
|
1228
|
+
"//button[text()='Select Menu']"
|
1229
|
+
);
|
1230
|
+
await navigationSelector.click();
|
1231
|
+
|
1232
|
+
const createNewMenuButton = await page.waitForXPath(
|
1233
|
+
'//button[contains(., "Create new menu")]'
|
1234
|
+
);
|
1235
|
+
await createNewMenuButton.click();
|
1236
|
+
|
1237
|
+
await page.waitForNetworkIdle();
|
1238
|
+
|
1239
|
+
// Await "success" notice.
|
1240
|
+
await page.waitForXPath(
|
1241
|
+
'//div[@class="components-snackbar__content"][contains(text(), "Navigation Menu successfully created.")]'
|
1242
|
+
);
|
1144
1243
|
|
1145
1244
|
const appender = await page.waitForSelector(
|
1146
|
-
'.wp-block-navigation .block-
|
1245
|
+
'.wp-block-navigation .block-editor-button-block-appender'
|
1147
1246
|
);
|
1148
1247
|
await appender.click();
|
1149
1248
|
|
@@ -1189,8 +1288,43 @@ Expected mock function not to be called but it was called with: ["POST", "http:/
|
|
1189
1288
|
it( 'loads the frontend script only once even when multiple navigation blocks are present', async () => {
|
1190
1289
|
await createNewPost();
|
1191
1290
|
await insertBlock( 'Navigation' );
|
1291
|
+
|
1292
|
+
const navigationSelector = await page.waitForXPath(
|
1293
|
+
"//button[text()='Select Menu']"
|
1294
|
+
);
|
1295
|
+
await navigationSelector.click();
|
1296
|
+
|
1297
|
+
const createNewMenuButton = await page.waitForXPath(
|
1298
|
+
'//button[contains(., "Create new menu")]'
|
1299
|
+
);
|
1300
|
+
await createNewMenuButton.click();
|
1301
|
+
|
1302
|
+
await page.waitForNetworkIdle();
|
1303
|
+
|
1304
|
+
// Await "success" notice.
|
1305
|
+
await page.waitForXPath(
|
1306
|
+
'//div[@class="components-snackbar__content"][contains(text(), "Navigation Menu successfully created.")]'
|
1307
|
+
);
|
1308
|
+
|
1192
1309
|
await insertBlock( 'Navigation' );
|
1193
1310
|
|
1311
|
+
const newNavigationSelector = await page.waitForXPath(
|
1312
|
+
"//button[text()='Select Menu']"
|
1313
|
+
);
|
1314
|
+
await newNavigationSelector.click();
|
1315
|
+
|
1316
|
+
const newCreateNewMenuButton = await page.waitForXPath(
|
1317
|
+
'//button[contains(., "Create new menu")]'
|
1318
|
+
);
|
1319
|
+
await newCreateNewMenuButton.click();
|
1320
|
+
|
1321
|
+
await page.waitForNetworkIdle();
|
1322
|
+
|
1323
|
+
// Await "success" notice.
|
1324
|
+
await page.waitForXPath(
|
1325
|
+
'//div[@class="components-snackbar__content"][contains(text(), "Navigation Menu successfully created.")]'
|
1326
|
+
);
|
1327
|
+
|
1194
1328
|
const previewPage = await openPreviewPage();
|
1195
1329
|
await previewPage.bringToFront();
|
1196
1330
|
await previewPage.waitForNetworkIdle();
|
@@ -1212,13 +1346,27 @@ Expected mock function not to be called but it was called with: ["POST", "http:/
|
|
1212
1346
|
await createNewPost();
|
1213
1347
|
await insertBlock( 'Navigation' );
|
1214
1348
|
|
1215
|
-
const
|
1216
|
-
|
1349
|
+
const navigationSelector = await page.waitForXPath(
|
1350
|
+
"//button[text()='Select Menu']"
|
1217
1351
|
);
|
1352
|
+
await navigationSelector.click();
|
1218
1353
|
|
1219
|
-
await
|
1354
|
+
const createNewMenuButton = await page.waitForXPath(
|
1355
|
+
'//button[contains(., "Create new menu")]'
|
1356
|
+
);
|
1357
|
+
await createNewMenuButton.click();
|
1220
1358
|
|
1221
|
-
await
|
1359
|
+
await page.waitForNetworkIdle();
|
1360
|
+
|
1361
|
+
// Await "success" notice.
|
1362
|
+
await page.waitForXPath(
|
1363
|
+
'//div[@class="components-snackbar__content"][contains(text(), "Navigation Menu successfully created.")]'
|
1364
|
+
);
|
1365
|
+
|
1366
|
+
const appender = await page.waitForSelector(
|
1367
|
+
'.wp-block-navigation .block-editor-button-block-appender'
|
1368
|
+
);
|
1369
|
+
await appender.click();
|
1222
1370
|
|
1223
1371
|
await clickBlockToolbarButton( 'Add submenu' );
|
1224
1372
|
|
@@ -1237,24 +1385,44 @@ Expected mock function not to be called but it was called with: ["POST", "http:/
|
|
1237
1385
|
await createNewPost();
|
1238
1386
|
await insertBlock( 'Navigation' );
|
1239
1387
|
|
1240
|
-
const
|
1241
|
-
|
1388
|
+
const navigationSelector = await page.waitForXPath(
|
1389
|
+
"//button[text()='Select Menu']"
|
1390
|
+
);
|
1391
|
+
await navigationSelector.click();
|
1392
|
+
|
1393
|
+
const createNewMenuButton = await page.waitForXPath(
|
1394
|
+
'//button[contains(., "Create new menu")]'
|
1242
1395
|
);
|
1396
|
+
await createNewMenuButton.click();
|
1243
1397
|
|
1244
|
-
await
|
1398
|
+
await page.waitForNetworkIdle();
|
1245
1399
|
|
1246
|
-
|
1400
|
+
// Await "success" notice.
|
1401
|
+
await page.waitForXPath(
|
1402
|
+
'//div[@class="components-snackbar__content"][contains(text(), "Navigation Menu successfully created.")]'
|
1403
|
+
);
|
1404
|
+
|
1405
|
+
const appender = await page.waitForSelector(
|
1406
|
+
'.wp-block-navigation .block-editor-button-block-appender'
|
1407
|
+
);
|
1408
|
+
await appender.click();
|
1409
|
+
|
1410
|
+
await updateActiveNavigationLink( {
|
1411
|
+
url: 'https://make.wordpress.org/core/',
|
1412
|
+
label: 'Menu item #1',
|
1413
|
+
type: 'url',
|
1414
|
+
} );
|
1247
1415
|
|
1248
1416
|
await clickBlockToolbarButton( 'Add submenu' );
|
1249
1417
|
|
1250
1418
|
await waitForBlock( 'Submenu' );
|
1251
1419
|
|
1252
1420
|
// Add a Link block first.
|
1253
|
-
const
|
1421
|
+
const SubAppender = await page.waitForSelector(
|
1254
1422
|
'[aria-label="Block: Submenu"] [aria-label="Add block"]'
|
1255
1423
|
);
|
1256
1424
|
|
1257
|
-
await
|
1425
|
+
await SubAppender.click();
|
1258
1426
|
|
1259
1427
|
await updateActiveNavigationLink( {
|
1260
1428
|
url: 'https://make.wordpress.org/core/',
|
@@ -1265,11 +1433,12 @@ Expected mock function not to be called but it was called with: ["POST", "http:/
|
|
1265
1433
|
await clickBlockToolbarButton( 'Select Submenu' );
|
1266
1434
|
|
1267
1435
|
// Check button exists but is in disabled state.
|
1268
|
-
const disabledConvertToLinkButton = await page
|
1269
|
-
'[aria-label="Block tools"] [aria-label="Convert to Link"][disabled]'
|
1436
|
+
const disabledConvertToLinkButton = await page.$$eval(
|
1437
|
+
'[aria-label="Block tools"] [aria-label="Convert to Link"][disabled]',
|
1438
|
+
( els ) => els.length
|
1270
1439
|
);
|
1271
1440
|
|
1272
|
-
expect( disabledConvertToLinkButton ).
|
1441
|
+
expect( disabledConvertToLinkButton ).toEqual( 1 );
|
1273
1442
|
} );
|
1274
1443
|
|
1275
1444
|
it( 'shows button to convert submenu to link when submenu is populated with a single incomplete link item', async () => {
|
@@ -1279,24 +1448,41 @@ Expected mock function not to be called but it was called with: ["POST", "http:/
|
|
1279
1448
|
await createNewPost();
|
1280
1449
|
await insertBlock( 'Navigation' );
|
1281
1450
|
|
1282
|
-
|
1283
|
-
|
1451
|
+
await clickBlockToolbarButton( 'Select Menu' );
|
1452
|
+
|
1453
|
+
const createNewMenuButton = await page.waitForXPath(
|
1454
|
+
'//button[contains(., "Create new menu")]'
|
1284
1455
|
);
|
1456
|
+
await createNewMenuButton.click();
|
1285
1457
|
|
1286
|
-
await
|
1458
|
+
await page.waitForNetworkIdle();
|
1287
1459
|
|
1288
|
-
|
1460
|
+
// Await "success" notice.
|
1461
|
+
await page.waitForXPath(
|
1462
|
+
'//div[@class="components-snackbar__content"][contains(text(), "Navigation Menu successfully created.")]'
|
1463
|
+
);
|
1464
|
+
|
1465
|
+
const appender = await page.waitForSelector(
|
1466
|
+
'.wp-block-navigation .block-editor-button-block-appender'
|
1467
|
+
);
|
1468
|
+
await appender.click();
|
1469
|
+
|
1470
|
+
await updateActiveNavigationLink( {
|
1471
|
+
url: 'https://make.wordpress.org/core/',
|
1472
|
+
label: 'Menu item #1',
|
1473
|
+
type: 'url',
|
1474
|
+
} );
|
1289
1475
|
|
1290
1476
|
await clickBlockToolbarButton( 'Add submenu' );
|
1291
1477
|
|
1292
1478
|
await waitForBlock( 'Submenu' );
|
1293
1479
|
|
1294
1480
|
// Add a Link block first.
|
1295
|
-
const
|
1481
|
+
const subAppender = await page.waitForSelector(
|
1296
1482
|
'[aria-label="Block: Submenu"] [aria-label="Add block"]'
|
1297
1483
|
);
|
1298
1484
|
|
1299
|
-
await
|
1485
|
+
await subAppender.click();
|
1300
1486
|
|
1301
1487
|
// Here we intentionally do not populate the inserted Navigation Link block.
|
1302
1488
|
// Rather we immediaely click away leaving the link in a state where it has
|
@@ -1393,7 +1579,52 @@ Expected mock function not to be called but it was called with: ["POST", "http:/
|
|
1393
1579
|
expect( linkText ).toBe( 'WordPress' );
|
1394
1580
|
} );
|
1395
1581
|
|
1396
|
-
it( 'does not automatically use first Navigation Menu if
|
1582
|
+
it( 'does not automatically use the first Navigation Menu if uncontrolled inner blocks are present', async () => {
|
1583
|
+
const pageTitle = 'A Test Page';
|
1584
|
+
|
1585
|
+
await createNavigationMenu( {
|
1586
|
+
title: 'Example Navigation',
|
1587
|
+
content:
|
1588
|
+
'<!-- wp:navigation-link {"label":"First Nav Menu Item","type":"custom","url":"http://www.wordpress.org/","kind":"custom","isTopLevelLink":true} /-->',
|
1589
|
+
} );
|
1590
|
+
|
1591
|
+
await rest( {
|
1592
|
+
method: 'POST',
|
1593
|
+
path: `/wp/v2/pages/`,
|
1594
|
+
data: {
|
1595
|
+
status: 'publish',
|
1596
|
+
title: pageTitle,
|
1597
|
+
content: 'Hello world',
|
1598
|
+
},
|
1599
|
+
} );
|
1600
|
+
|
1601
|
+
await createNewPost();
|
1602
|
+
|
1603
|
+
await clickOnMoreMenuItem( 'Code editor' );
|
1604
|
+
|
1605
|
+
const codeEditorInput = await page.waitForSelector(
|
1606
|
+
'.editor-post-text-editor'
|
1607
|
+
);
|
1608
|
+
await codeEditorInput.click();
|
1609
|
+
|
1610
|
+
const markup =
|
1611
|
+
'<!-- wp:navigation --><!-- wp:page-list /--><!-- /wp:navigation -->';
|
1612
|
+
await page.keyboard.type( markup );
|
1613
|
+
await clickButton( 'Exit code editor' );
|
1614
|
+
|
1615
|
+
await waitForBlock( 'Navigation' );
|
1616
|
+
|
1617
|
+
const hasUncontrolledInnerBlocks = await page.evaluate( () => {
|
1618
|
+
const blocks = wp.data
|
1619
|
+
.select( 'core/block-editor' )
|
1620
|
+
.getBlocks();
|
1621
|
+
return !! blocks[ 0 ]?.innerBlocks?.length;
|
1622
|
+
} );
|
1623
|
+
|
1624
|
+
expect( hasUncontrolledInnerBlocks ).toBe( true );
|
1625
|
+
} );
|
1626
|
+
|
1627
|
+
it( 'automatically uses most recent Navigation Menu if more than one exists', async () => {
|
1397
1628
|
await createNavigationMenu( {
|
1398
1629
|
title: 'Example Navigation',
|
1399
1630
|
content:
|
@@ -1412,7 +1643,14 @@ Expected mock function not to be called but it was called with: ["POST", "http:/
|
|
1412
1643
|
|
1413
1644
|
await waitForBlock( 'Navigation' );
|
1414
1645
|
|
1415
|
-
await page.waitForXPath(
|
1646
|
+
const navigationSelector = await page.waitForXPath(
|
1647
|
+
"//button[text()='Select Menu']"
|
1648
|
+
);
|
1649
|
+
await navigationSelector.click();
|
1650
|
+
|
1651
|
+
await page.waitForXPath(
|
1652
|
+
'//button[@aria-checked="true"][contains(., "Second Example Navigation")]'
|
1653
|
+
);
|
1416
1654
|
} );
|
1417
1655
|
|
1418
1656
|
it( 'allows users to manually create new empty menu when block has automatically selected the first available Navigation Menu', async () => {
|
@@ -1426,35 +1664,35 @@ Expected mock function not to be called but it was called with: ["POST", "http:/
|
|
1426
1664
|
|
1427
1665
|
await insertBlock( 'Navigation' );
|
1428
1666
|
|
1429
|
-
await
|
1430
|
-
|
1431
|
-
|
1432
|
-
|
1433
|
-
// Reset the nav block to create a new entity.
|
1434
|
-
await resetNavBlockToInitialState();
|
1667
|
+
const navigationSelector = await page.waitForXPath(
|
1668
|
+
"//button[text()='Select Menu']"
|
1669
|
+
);
|
1670
|
+
await navigationSelector.click();
|
1435
1671
|
|
1436
|
-
const
|
1437
|
-
|
1672
|
+
const createNewMenuButton = await page.waitForXPath(
|
1673
|
+
'//button[contains(., "Create new menu")]'
|
1438
1674
|
);
|
1439
|
-
await
|
1675
|
+
await createNewMenuButton.click();
|
1676
|
+
|
1677
|
+
await page.waitForNetworkIdle();
|
1440
1678
|
|
1441
|
-
//
|
1679
|
+
// Await "success" notice.
|
1442
1680
|
await page.waitForXPath(
|
1443
|
-
'
|
1681
|
+
'//div[@class="components-snackbar__content"][contains(text(), "Navigation Menu successfully created.")]'
|
1444
1682
|
);
|
1445
1683
|
} );
|
1446
1684
|
|
1447
1685
|
it( 'should always focus select menu button after item selection', async () => {
|
1448
1686
|
// Create some navigation menus to work with.
|
1449
1687
|
await createNavigationMenu( {
|
1450
|
-
title: '
|
1688
|
+
title: 'First navigation',
|
1451
1689
|
content:
|
1452
|
-
'<!-- wp:navigation-link {"label":"WordPress","type":"custom","url":"http://www.wordpress.org/","kind":"custom","isTopLevelLink":true} /-->',
|
1690
|
+
'<!-- wp:navigation-link {"label":"WordPress Example Navigation","type":"custom","url":"http://www.wordpress.org/","kind":"custom","isTopLevelLink":true} /-->',
|
1453
1691
|
} );
|
1454
1692
|
await createNavigationMenu( {
|
1455
|
-
title: 'Second
|
1693
|
+
title: 'Second Navigation',
|
1456
1694
|
content:
|
1457
|
-
'<!-- wp:navigation-link {"label":"WordPress","type":"custom","url":"http://www.wordpress.org/","kind":"custom","isTopLevelLink":true} /-->',
|
1695
|
+
'<!-- wp:navigation-link {"label":"WordPress Second Example Navigation","type":"custom","url":"http://www.wordpress.org/","kind":"custom","isTopLevelLink":true} /-->',
|
1458
1696
|
} );
|
1459
1697
|
|
1460
1698
|
// Create new post.
|
@@ -1463,22 +1701,22 @@ Expected mock function not to be called but it was called with: ["POST", "http:/
|
|
1463
1701
|
// Insert new block and wait for the insert to complete.
|
1464
1702
|
await insertBlock( 'Navigation' );
|
1465
1703
|
await waitForBlock( 'Navigation' );
|
1466
|
-
await page.waitForXPath( START_EMPTY_XPATH );
|
1467
1704
|
|
1468
|
-
|
1469
|
-
|
1470
|
-
'[aria-label="Select Menu"]'
|
1705
|
+
const navigationSelector = await page.waitForXPath(
|
1706
|
+
"//button[text()='Select Menu']"
|
1471
1707
|
);
|
1472
|
-
await
|
1473
|
-
|
1474
|
-
|
1708
|
+
await navigationSelector.click();
|
1709
|
+
|
1710
|
+
const theOption = await page.waitForXPath(
|
1711
|
+
"//button[@aria-checked='false'][contains(., 'First navigation')]"
|
1475
1712
|
);
|
1476
|
-
await
|
1713
|
+
await theOption.click();
|
1477
1714
|
|
1478
1715
|
// Once the options are closed, does select menu button receive focus?
|
1479
|
-
const selectMenuDropdown2 = await page
|
1716
|
+
const selectMenuDropdown2 = await page.$(
|
1480
1717
|
'[aria-label="Select Menu"]'
|
1481
1718
|
);
|
1719
|
+
|
1482
1720
|
await expect( selectMenuDropdown2 ).toHaveFocus();
|
1483
1721
|
} );
|
1484
1722
|
} );
|