@wordpress/e2e-tests 4.9.2 → 5.0.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 +394 -154
- package/specs/editor/blocks/quote.test.js +4 -1
- package/specs/editor/plugins/__snapshots__/cpt-locking.test.js.snap +2 -2
- 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 -1
- package/specs/editor/various/__snapshots__/multi-block-selection.test.js.snap +9 -5
- package/specs/editor/various/block-grouping.test.js +2 -2
- package/specs/editor/various/draggable-block.test.js +83 -14
- package/specs/editor/various/multi-block-selection.test.js +28 -5
- package/specs/editor/various/post-visibility.test.js +2 -4
- package/specs/editor/various/scheduling.test.js +2 -6
- package/specs/editor/various/switch-to-draft.test.js +2 -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/wp-editor-meta-box.test.js +0 -58
@@ -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.
|
@@ -355,7 +327,8 @@ describe( 'Navigation', () => {
|
|
355
327
|
// Insert an empty block to trigger resolution of Nav Menu items.
|
356
328
|
await insertBlock( 'Navigation' );
|
357
329
|
await waitForBlock( 'Navigation' );
|
358
|
-
|
330
|
+
|
331
|
+
await page.waitForXPath( "//button[text()='Select Menu']" );
|
359
332
|
|
360
333
|
// Now we have Nav Menu items resolved. Continue to assert.
|
361
334
|
await clickOnMoreMenuItem( 'Code editor' );
|
@@ -475,15 +448,18 @@ Expected mock function not to be called but it was called with: ["POST", "http:/
|
|
475
448
|
await createNewPost();
|
476
449
|
await insertBlock( 'Navigation' );
|
477
450
|
|
478
|
-
|
451
|
+
const navBlock = await waitForBlock( 'Navigation' );
|
479
452
|
|
480
453
|
// Create empty Navigation block with no items
|
481
|
-
const
|
482
|
-
|
454
|
+
const navigationSelector = await page.waitForXPath(
|
455
|
+
"//button[text()='Select Menu']"
|
483
456
|
);
|
484
|
-
await
|
457
|
+
await navigationSelector.click();
|
485
458
|
|
486
|
-
|
459
|
+
const createNewMenuButton = await page.waitForXPath(
|
460
|
+
'//button[contains(., "Create new menu")]'
|
461
|
+
);
|
462
|
+
await createNewMenuButton.click();
|
487
463
|
|
488
464
|
// Check for the spinner to be present whilst loading.
|
489
465
|
await navBlock.waitForSelector( '.components-spinner' );
|
@@ -496,48 +472,26 @@ Expected mock function not to be called but it was called with: ["POST", "http:/
|
|
496
472
|
} );
|
497
473
|
|
498
474
|
describe( 'Placeholder', () => {
|
499
|
-
describe( '
|
500
|
-
it( 'shows
|
475
|
+
describe( 'fallback states', () => {
|
476
|
+
it( 'shows page list on insertion of block', async () => {
|
501
477
|
await createNewPost();
|
502
478
|
await insertBlock( 'Navigation' );
|
503
|
-
await
|
479
|
+
await waitForBlock( 'Page List' );
|
504
480
|
} );
|
505
481
|
|
506
|
-
it( 'shows placeholder preview when
|
482
|
+
it( 'shows placeholder preview when block with no menu items is not selected', async () => {
|
507
483
|
await createNewPost();
|
508
484
|
await insertBlock( 'Navigation' );
|
509
485
|
|
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 }
|
486
|
+
const navigationSelector = await page.waitForXPath(
|
487
|
+
"//button[text()='Select Menu']"
|
523
488
|
);
|
489
|
+
await navigationSelector.click();
|
524
490
|
|
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
|
491
|
+
const createNewMenuButton = await page.waitForXPath(
|
492
|
+
'//button[contains(., "Create new menu")]'
|
539
493
|
);
|
540
|
-
await
|
494
|
+
await createNewMenuButton.click();
|
541
495
|
|
542
496
|
// Wait for Navigation creation to complete.
|
543
497
|
await page.waitForXPath(
|
@@ -569,7 +523,7 @@ Expected mock function not to be called but it was called with: ["POST", "http:/
|
|
569
523
|
} );
|
570
524
|
} );
|
571
525
|
|
572
|
-
describe( '
|
526
|
+
describe( 'menu selector actions', () => {
|
573
527
|
it( 'allows a navigation block to be created from existing menus', async () => {
|
574
528
|
await createClassicMenu( { name: 'Test Menu 1' } );
|
575
529
|
await createClassicMenu(
|
@@ -594,6 +548,8 @@ Expected mock function not to be called but it was called with: ["POST", "http:/
|
|
594
548
|
await insertBlock( 'Navigation' );
|
595
549
|
await selectClassicMenu( 'Test Menu 1' );
|
596
550
|
|
551
|
+
await page.waitForNetworkIdle();
|
552
|
+
|
597
553
|
// Wait for the appender so that we know the navigation menu was created.
|
598
554
|
await page.waitForSelector(
|
599
555
|
'nav[aria-label="Block: Navigation"] button[aria-label="Add block"]'
|
@@ -605,14 +561,24 @@ Expected mock function not to be called but it was called with: ["POST", "http:/
|
|
605
561
|
await createNewPost();
|
606
562
|
|
607
563
|
await insertBlock( 'Navigation' );
|
608
|
-
|
564
|
+
|
565
|
+
const navigationSelector = await page.waitForXPath(
|
566
|
+
"//button[text()='Select Menu']"
|
567
|
+
);
|
568
|
+
await navigationSelector.click();
|
569
|
+
|
570
|
+
await page.waitForXPath(
|
571
|
+
'//button[contains(., "Create new menu")]'
|
572
|
+
);
|
573
|
+
|
574
|
+
await page.waitForSelector( '.components-menu-group' );
|
609
575
|
|
610
576
|
const placeholderActionsLength = await page.$$eval(
|
611
|
-
|
577
|
+
'.components-menu-group',
|
612
578
|
( els ) => els.length
|
613
579
|
);
|
614
580
|
|
615
|
-
// Should only be showing "
|
581
|
+
// Should only be showing "Create new menu".
|
616
582
|
expect( placeholderActionsLength ).toEqual( 1 );
|
617
583
|
} );
|
618
584
|
} );
|
@@ -621,8 +587,20 @@ Expected mock function not to be called but it was called with: ["POST", "http:/
|
|
621
587
|
it( 'allows an empty navigation block to be created and manually populated using a mixture of internal and external links', async () => {
|
622
588
|
await createNewPost();
|
623
589
|
await insertBlock( 'Navigation' );
|
624
|
-
|
625
|
-
await
|
590
|
+
|
591
|
+
await showBlockToolbar();
|
592
|
+
|
593
|
+
const navigationSelector = await page.waitForXPath(
|
594
|
+
"//button[text()='Select Menu']"
|
595
|
+
);
|
596
|
+
await navigationSelector.click();
|
597
|
+
|
598
|
+
const createNewMenuButton = await page.waitForXPath(
|
599
|
+
'//button[contains(., "Create new menu")]'
|
600
|
+
);
|
601
|
+
await createNewMenuButton.click();
|
602
|
+
|
603
|
+
await page.waitForNetworkIdle();
|
626
604
|
|
627
605
|
// Await "success" notice.
|
628
606
|
await page.waitForXPath(
|
@@ -630,7 +608,7 @@ Expected mock function not to be called but it was called with: ["POST", "http:/
|
|
630
608
|
);
|
631
609
|
|
632
610
|
const appender = await page.waitForSelector(
|
633
|
-
'.wp-block-navigation .block-
|
611
|
+
'.wp-block-navigation .block-editor-button-block-appender'
|
634
612
|
);
|
635
613
|
await appender.click();
|
636
614
|
|
@@ -696,11 +674,25 @@ Expected mock function not to be called but it was called with: ["POST", "http:/
|
|
696
674
|
it( 'encodes URL when create block if needed', async () => {
|
697
675
|
await createNewPost();
|
698
676
|
await insertBlock( 'Navigation' );
|
699
|
-
const
|
700
|
-
|
677
|
+
const navigationSelector = await page.waitForXPath(
|
678
|
+
"//button[text()='Select Menu']"
|
679
|
+
);
|
680
|
+
await navigationSelector.click();
|
681
|
+
|
682
|
+
const createNewMenuButton = await page.waitForXPath(
|
683
|
+
'//button[contains(., "Create new menu")]'
|
684
|
+
);
|
685
|
+
await createNewMenuButton.click();
|
686
|
+
|
687
|
+
await page.waitForNetworkIdle();
|
688
|
+
|
689
|
+
// Await "success" notice.
|
690
|
+
await page.waitForXPath(
|
691
|
+
'//div[@class="components-snackbar__content"][contains(text(), "Navigation Menu successfully created.")]'
|
692
|
+
);
|
701
693
|
|
702
694
|
const appender = await page.waitForSelector(
|
703
|
-
'.wp-block-navigation .block-
|
695
|
+
'.wp-block-navigation .block-editor-button-block-appender'
|
704
696
|
);
|
705
697
|
await appender.click();
|
706
698
|
|
@@ -762,10 +754,26 @@ Expected mock function not to be called but it was called with: ["POST", "http:/
|
|
762
754
|
it( 'allows pages to be created from the navigation block and their links added to menu', async () => {
|
763
755
|
await createNewPost();
|
764
756
|
await insertBlock( 'Navigation' );
|
765
|
-
|
766
|
-
await
|
757
|
+
|
758
|
+
const navigationSelector = await page.waitForXPath(
|
759
|
+
"//button[text()='Select Menu']"
|
760
|
+
);
|
761
|
+
await navigationSelector.click();
|
762
|
+
|
763
|
+
const createNewMenuButton = await page.waitForXPath(
|
764
|
+
'//button[contains(., "Create new menu")]'
|
765
|
+
);
|
766
|
+
await createNewMenuButton.click();
|
767
|
+
|
768
|
+
await page.waitForNetworkIdle();
|
769
|
+
|
770
|
+
// Await "success" notice.
|
771
|
+
await page.waitForXPath(
|
772
|
+
'//div[@class="components-snackbar__content"][contains(text(), "Navigation Menu successfully created.")]'
|
773
|
+
);
|
774
|
+
|
767
775
|
const appender = await page.waitForSelector(
|
768
|
-
'.wp-block-navigation .block-
|
776
|
+
'.wp-block-navigation .block-editor-button-block-appender'
|
769
777
|
);
|
770
778
|
await appender.click();
|
771
779
|
|
@@ -811,10 +819,26 @@ Expected mock function not to be called but it was called with: ["POST", "http:/
|
|
811
819
|
it( 'correctly decodes special characters in the created Page title for display', async () => {
|
812
820
|
await createNewPost();
|
813
821
|
await insertBlock( 'Navigation' );
|
814
|
-
|
815
|
-
await
|
822
|
+
|
823
|
+
const navigationSelector = await page.waitForXPath(
|
824
|
+
"//button[text()='Select Menu']"
|
825
|
+
);
|
826
|
+
await navigationSelector.click();
|
827
|
+
|
828
|
+
const createNewMenuButton = await page.waitForXPath(
|
829
|
+
'//button[contains(., "Create new menu")]'
|
830
|
+
);
|
831
|
+
await createNewMenuButton.click();
|
832
|
+
|
833
|
+
await page.waitForNetworkIdle();
|
834
|
+
|
835
|
+
// Await "success" notice.
|
836
|
+
await page.waitForXPath(
|
837
|
+
'//div[@class="components-snackbar__content"][contains(text(), "Navigation Menu successfully created.")]'
|
838
|
+
);
|
839
|
+
|
816
840
|
const appender = await page.waitForSelector(
|
817
|
-
'.wp-block-navigation .block-
|
841
|
+
'.wp-block-navigation .block-editor-button-block-appender'
|
818
842
|
);
|
819
843
|
await appender.click();
|
820
844
|
|
@@ -904,11 +928,26 @@ Expected mock function not to be called but it was called with: ["POST", "http:/
|
|
904
928
|
it( 'Shows the quick inserter when the block contains non-navigation specific blocks', async () => {
|
905
929
|
await createNewPost();
|
906
930
|
await insertBlock( 'Navigation' );
|
907
|
-
|
908
|
-
await
|
931
|
+
|
932
|
+
const navigationSelector = await page.waitForXPath(
|
933
|
+
"//button[text()='Select Menu']"
|
934
|
+
);
|
935
|
+
await navigationSelector.click();
|
936
|
+
|
937
|
+
const createNewMenuButton = await page.waitForXPath(
|
938
|
+
'//button[contains(., "Create new menu")]'
|
939
|
+
);
|
940
|
+
await createNewMenuButton.click();
|
941
|
+
|
942
|
+
await page.waitForNetworkIdle();
|
943
|
+
|
944
|
+
// Await "success" notice.
|
945
|
+
await page.waitForXPath(
|
946
|
+
'//div[@class="components-snackbar__content"][contains(text(), "Navigation Menu successfully created.")]'
|
947
|
+
);
|
909
948
|
|
910
949
|
const appender = await page.waitForSelector(
|
911
|
-
'.wp-block-navigation .block-
|
950
|
+
'.wp-block-navigation .block-editor-button-block-appender'
|
912
951
|
);
|
913
952
|
await appender.click();
|
914
953
|
|
@@ -949,13 +988,27 @@ Expected mock function not to be called but it was called with: ["POST", "http:/
|
|
949
988
|
|
950
989
|
const navBlock = await waitForBlock( 'Navigation' );
|
951
990
|
|
952
|
-
|
953
|
-
|
954
|
-
START_EMPTY_XPATH
|
991
|
+
const navigationSelector = await page.waitForXPath(
|
992
|
+
"//button[text()='Select Menu']"
|
955
993
|
);
|
956
|
-
await
|
994
|
+
await navigationSelector.click();
|
957
995
|
|
958
|
-
await
|
996
|
+
const createNewMenuButton = await page.waitForXPath(
|
997
|
+
'//button[contains(., "Create new menu")]'
|
998
|
+
);
|
999
|
+
await createNewMenuButton.click();
|
1000
|
+
|
1001
|
+
await page.waitForNetworkIdle();
|
1002
|
+
|
1003
|
+
// Await "success" notice.
|
1004
|
+
await page.waitForXPath(
|
1005
|
+
'//div[@class="components-snackbar__content"][contains(text(), "Navigation Menu successfully created.")]'
|
1006
|
+
);
|
1007
|
+
|
1008
|
+
const appender = await page.waitForSelector(
|
1009
|
+
'.wp-block-navigation .block-editor-button-block-appender'
|
1010
|
+
);
|
1011
|
+
await appender.click();
|
959
1012
|
|
960
1013
|
await clickOnMoreMenuItem( 'Code editor' );
|
961
1014
|
const codeEditorInput = await page.waitForSelector(
|
@@ -1083,11 +1136,27 @@ Expected mock function not to be called but it was called with: ["POST", "http:/
|
|
1083
1136
|
await createNewPost();
|
1084
1137
|
await insertBlock( 'Navigation' );
|
1085
1138
|
|
1086
|
-
const
|
1087
|
-
|
1139
|
+
const navigationSelector = await page.waitForXPath(
|
1140
|
+
"//button[text()='Select Menu']"
|
1141
|
+
);
|
1142
|
+
await navigationSelector.click();
|
1143
|
+
|
1144
|
+
const createNewMenuButton = await page.waitForXPath(
|
1145
|
+
'//button[contains(., "Create new menu")]'
|
1146
|
+
);
|
1147
|
+
await createNewMenuButton.click();
|
1148
|
+
|
1149
|
+
await page.waitForNetworkIdle();
|
1150
|
+
|
1151
|
+
// Await "success" notice.
|
1152
|
+
await page.waitForXPath(
|
1153
|
+
'//div[@class="components-snackbar__content"][contains(text(), "Navigation Menu successfully created.")]'
|
1154
|
+
);
|
1155
|
+
|
1156
|
+
const appender = await page.waitForSelector(
|
1157
|
+
'.wp-block-navigation .block-editor-button-block-appender'
|
1088
1158
|
);
|
1089
|
-
await
|
1090
|
-
await populateNavWithOneItem();
|
1159
|
+
await appender.click();
|
1091
1160
|
|
1092
1161
|
// Confirm that the menu entity was updated.
|
1093
1162
|
const publishPanelButton = await page.waitForSelector(
|
@@ -1117,13 +1186,27 @@ Expected mock function not to be called but it was called with: ["POST", "http:/
|
|
1117
1186
|
// await page.click( 'nav[aria-label="Block: Navigation"]' );
|
1118
1187
|
await forceSelectNavigationBlock();
|
1119
1188
|
|
1120
|
-
await
|
1189
|
+
const newNavigationSelector = await page.waitForXPath(
|
1190
|
+
"//button[text()='Select Menu']"
|
1191
|
+
);
|
1192
|
+
await newNavigationSelector.click();
|
1121
1193
|
|
1122
|
-
const
|
1123
|
-
|
1194
|
+
const newCreateNewMenuButton = await page.waitForXPath(
|
1195
|
+
'//button[contains(., "Create new menu")]'
|
1124
1196
|
);
|
1125
|
-
await
|
1126
|
-
|
1197
|
+
await newCreateNewMenuButton.click();
|
1198
|
+
|
1199
|
+
await page.waitForNetworkIdle();
|
1200
|
+
|
1201
|
+
// Await "success" notice.
|
1202
|
+
await page.waitForXPath(
|
1203
|
+
'//div[@class="components-snackbar__content"][contains(text(), "Navigation Menu successfully created.")]'
|
1204
|
+
);
|
1205
|
+
|
1206
|
+
const newAppender = await page.waitForSelector(
|
1207
|
+
'.wp-block-navigation .block-editor-button-block-appender'
|
1208
|
+
);
|
1209
|
+
await newAppender.click();
|
1127
1210
|
|
1128
1211
|
// Confirm that only the last menu entity was updated.
|
1129
1212
|
const publishPanelButton2 = await page.waitForSelector(
|
@@ -1139,11 +1222,26 @@ Expected mock function not to be called but it was called with: ["POST", "http:/
|
|
1139
1222
|
it( 'applies accessible label to block element', async () => {
|
1140
1223
|
await createNewPost();
|
1141
1224
|
await insertBlock( 'Navigation' );
|
1142
|
-
|
1143
|
-
await
|
1225
|
+
|
1226
|
+
const navigationSelector = await page.waitForXPath(
|
1227
|
+
"//button[text()='Select Menu']"
|
1228
|
+
);
|
1229
|
+
await navigationSelector.click();
|
1230
|
+
|
1231
|
+
const createNewMenuButton = await page.waitForXPath(
|
1232
|
+
'//button[contains(., "Create new menu")]'
|
1233
|
+
);
|
1234
|
+
await createNewMenuButton.click();
|
1235
|
+
|
1236
|
+
await page.waitForNetworkIdle();
|
1237
|
+
|
1238
|
+
// Await "success" notice.
|
1239
|
+
await page.waitForXPath(
|
1240
|
+
'//div[@class="components-snackbar__content"][contains(text(), "Navigation Menu successfully created.")]'
|
1241
|
+
);
|
1144
1242
|
|
1145
1243
|
const appender = await page.waitForSelector(
|
1146
|
-
'.wp-block-navigation .block-
|
1244
|
+
'.wp-block-navigation .block-editor-button-block-appender'
|
1147
1245
|
);
|
1148
1246
|
await appender.click();
|
1149
1247
|
|
@@ -1189,8 +1287,43 @@ Expected mock function not to be called but it was called with: ["POST", "http:/
|
|
1189
1287
|
it( 'loads the frontend script only once even when multiple navigation blocks are present', async () => {
|
1190
1288
|
await createNewPost();
|
1191
1289
|
await insertBlock( 'Navigation' );
|
1290
|
+
|
1291
|
+
const navigationSelector = await page.waitForXPath(
|
1292
|
+
"//button[text()='Select Menu']"
|
1293
|
+
);
|
1294
|
+
await navigationSelector.click();
|
1295
|
+
|
1296
|
+
const createNewMenuButton = await page.waitForXPath(
|
1297
|
+
'//button[contains(., "Create new menu")]'
|
1298
|
+
);
|
1299
|
+
await createNewMenuButton.click();
|
1300
|
+
|
1301
|
+
await page.waitForNetworkIdle();
|
1302
|
+
|
1303
|
+
// Await "success" notice.
|
1304
|
+
await page.waitForXPath(
|
1305
|
+
'//div[@class="components-snackbar__content"][contains(text(), "Navigation Menu successfully created.")]'
|
1306
|
+
);
|
1307
|
+
|
1192
1308
|
await insertBlock( 'Navigation' );
|
1193
1309
|
|
1310
|
+
const newNavigationSelector = await page.waitForXPath(
|
1311
|
+
"//button[text()='Select Menu']"
|
1312
|
+
);
|
1313
|
+
await newNavigationSelector.click();
|
1314
|
+
|
1315
|
+
const newCreateNewMenuButton = await page.waitForXPath(
|
1316
|
+
'//button[contains(., "Create new menu")]'
|
1317
|
+
);
|
1318
|
+
await newCreateNewMenuButton.click();
|
1319
|
+
|
1320
|
+
await page.waitForNetworkIdle();
|
1321
|
+
|
1322
|
+
// Await "success" notice.
|
1323
|
+
await page.waitForXPath(
|
1324
|
+
'//div[@class="components-snackbar__content"][contains(text(), "Navigation Menu successfully created.")]'
|
1325
|
+
);
|
1326
|
+
|
1194
1327
|
const previewPage = await openPreviewPage();
|
1195
1328
|
await previewPage.bringToFront();
|
1196
1329
|
await previewPage.waitForNetworkIdle();
|
@@ -1212,13 +1345,27 @@ Expected mock function not to be called but it was called with: ["POST", "http:/
|
|
1212
1345
|
await createNewPost();
|
1213
1346
|
await insertBlock( 'Navigation' );
|
1214
1347
|
|
1215
|
-
const
|
1216
|
-
|
1348
|
+
const navigationSelector = await page.waitForXPath(
|
1349
|
+
"//button[text()='Select Menu']"
|
1217
1350
|
);
|
1351
|
+
await navigationSelector.click();
|
1352
|
+
|
1353
|
+
const createNewMenuButton = await page.waitForXPath(
|
1354
|
+
'//button[contains(., "Create new menu")]'
|
1355
|
+
);
|
1356
|
+
await createNewMenuButton.click();
|
1357
|
+
|
1358
|
+
await page.waitForNetworkIdle();
|
1218
1359
|
|
1219
|
-
|
1360
|
+
// Await "success" notice.
|
1361
|
+
await page.waitForXPath(
|
1362
|
+
'//div[@class="components-snackbar__content"][contains(text(), "Navigation Menu successfully created.")]'
|
1363
|
+
);
|
1220
1364
|
|
1221
|
-
await
|
1365
|
+
const appender = await page.waitForSelector(
|
1366
|
+
'.wp-block-navigation .block-editor-button-block-appender'
|
1367
|
+
);
|
1368
|
+
await appender.click();
|
1222
1369
|
|
1223
1370
|
await clickBlockToolbarButton( 'Add submenu' );
|
1224
1371
|
|
@@ -1237,24 +1384,44 @@ Expected mock function not to be called but it was called with: ["POST", "http:/
|
|
1237
1384
|
await createNewPost();
|
1238
1385
|
await insertBlock( 'Navigation' );
|
1239
1386
|
|
1240
|
-
const
|
1241
|
-
|
1387
|
+
const navigationSelector = await page.waitForXPath(
|
1388
|
+
"//button[text()='Select Menu']"
|
1389
|
+
);
|
1390
|
+
await navigationSelector.click();
|
1391
|
+
|
1392
|
+
const createNewMenuButton = await page.waitForXPath(
|
1393
|
+
'//button[contains(., "Create new menu")]'
|
1242
1394
|
);
|
1395
|
+
await createNewMenuButton.click();
|
1396
|
+
|
1397
|
+
await page.waitForNetworkIdle();
|
1243
1398
|
|
1244
|
-
|
1399
|
+
// Await "success" notice.
|
1400
|
+
await page.waitForXPath(
|
1401
|
+
'//div[@class="components-snackbar__content"][contains(text(), "Navigation Menu successfully created.")]'
|
1402
|
+
);
|
1245
1403
|
|
1246
|
-
await
|
1404
|
+
const appender = await page.waitForSelector(
|
1405
|
+
'.wp-block-navigation .block-editor-button-block-appender'
|
1406
|
+
);
|
1407
|
+
await appender.click();
|
1408
|
+
|
1409
|
+
await updateActiveNavigationLink( {
|
1410
|
+
url: 'https://make.wordpress.org/core/',
|
1411
|
+
label: 'Menu item #1',
|
1412
|
+
type: 'url',
|
1413
|
+
} );
|
1247
1414
|
|
1248
1415
|
await clickBlockToolbarButton( 'Add submenu' );
|
1249
1416
|
|
1250
1417
|
await waitForBlock( 'Submenu' );
|
1251
1418
|
|
1252
1419
|
// Add a Link block first.
|
1253
|
-
const
|
1420
|
+
const SubAppender = await page.waitForSelector(
|
1254
1421
|
'[aria-label="Block: Submenu"] [aria-label="Add block"]'
|
1255
1422
|
);
|
1256
1423
|
|
1257
|
-
await
|
1424
|
+
await SubAppender.click();
|
1258
1425
|
|
1259
1426
|
await updateActiveNavigationLink( {
|
1260
1427
|
url: 'https://make.wordpress.org/core/',
|
@@ -1265,11 +1432,12 @@ Expected mock function not to be called but it was called with: ["POST", "http:/
|
|
1265
1432
|
await clickBlockToolbarButton( 'Select Submenu' );
|
1266
1433
|
|
1267
1434
|
// Check button exists but is in disabled state.
|
1268
|
-
const disabledConvertToLinkButton = await page
|
1269
|
-
'[aria-label="Block tools"] [aria-label="Convert to Link"][disabled]'
|
1435
|
+
const disabledConvertToLinkButton = await page.$$eval(
|
1436
|
+
'[aria-label="Block tools"] [aria-label="Convert to Link"][disabled]',
|
1437
|
+
( els ) => els.length
|
1270
1438
|
);
|
1271
1439
|
|
1272
|
-
expect( disabledConvertToLinkButton ).
|
1440
|
+
expect( disabledConvertToLinkButton ).toEqual( 1 );
|
1273
1441
|
} );
|
1274
1442
|
|
1275
1443
|
it( 'shows button to convert submenu to link when submenu is populated with a single incomplete link item', async () => {
|
@@ -1279,24 +1447,41 @@ Expected mock function not to be called but it was called with: ["POST", "http:/
|
|
1279
1447
|
await createNewPost();
|
1280
1448
|
await insertBlock( 'Navigation' );
|
1281
1449
|
|
1282
|
-
|
1283
|
-
|
1450
|
+
await clickBlockToolbarButton( 'Select Menu' );
|
1451
|
+
|
1452
|
+
const createNewMenuButton = await page.waitForXPath(
|
1453
|
+
'//button[contains(., "Create new menu")]'
|
1284
1454
|
);
|
1455
|
+
await createNewMenuButton.click();
|
1285
1456
|
|
1286
|
-
await
|
1457
|
+
await page.waitForNetworkIdle();
|
1287
1458
|
|
1288
|
-
|
1459
|
+
// Await "success" notice.
|
1460
|
+
await page.waitForXPath(
|
1461
|
+
'//div[@class="components-snackbar__content"][contains(text(), "Navigation Menu successfully created.")]'
|
1462
|
+
);
|
1463
|
+
|
1464
|
+
const appender = await page.waitForSelector(
|
1465
|
+
'.wp-block-navigation .block-editor-button-block-appender'
|
1466
|
+
);
|
1467
|
+
await appender.click();
|
1468
|
+
|
1469
|
+
await updateActiveNavigationLink( {
|
1470
|
+
url: 'https://make.wordpress.org/core/',
|
1471
|
+
label: 'Menu item #1',
|
1472
|
+
type: 'url',
|
1473
|
+
} );
|
1289
1474
|
|
1290
1475
|
await clickBlockToolbarButton( 'Add submenu' );
|
1291
1476
|
|
1292
1477
|
await waitForBlock( 'Submenu' );
|
1293
1478
|
|
1294
1479
|
// Add a Link block first.
|
1295
|
-
const
|
1480
|
+
const subAppender = await page.waitForSelector(
|
1296
1481
|
'[aria-label="Block: Submenu"] [aria-label="Add block"]'
|
1297
1482
|
);
|
1298
1483
|
|
1299
|
-
await
|
1484
|
+
await subAppender.click();
|
1300
1485
|
|
1301
1486
|
// Here we intentionally do not populate the inserted Navigation Link block.
|
1302
1487
|
// Rather we immediaely click away leaving the link in a state where it has
|
@@ -1393,7 +1578,52 @@ Expected mock function not to be called but it was called with: ["POST", "http:/
|
|
1393
1578
|
expect( linkText ).toBe( 'WordPress' );
|
1394
1579
|
} );
|
1395
1580
|
|
1396
|
-
it( 'does not automatically use first Navigation Menu if
|
1581
|
+
it( 'does not automatically use the first Navigation Menu if uncontrolled inner blocks are present', async () => {
|
1582
|
+
const pageTitle = 'A Test Page';
|
1583
|
+
|
1584
|
+
await createNavigationMenu( {
|
1585
|
+
title: 'Example Navigation',
|
1586
|
+
content:
|
1587
|
+
'<!-- wp:navigation-link {"label":"First Nav Menu Item","type":"custom","url":"http://www.wordpress.org/","kind":"custom","isTopLevelLink":true} /-->',
|
1588
|
+
} );
|
1589
|
+
|
1590
|
+
await rest( {
|
1591
|
+
method: 'POST',
|
1592
|
+
path: `/wp/v2/pages/`,
|
1593
|
+
data: {
|
1594
|
+
status: 'publish',
|
1595
|
+
title: pageTitle,
|
1596
|
+
content: 'Hello world',
|
1597
|
+
},
|
1598
|
+
} );
|
1599
|
+
|
1600
|
+
await createNewPost();
|
1601
|
+
|
1602
|
+
await clickOnMoreMenuItem( 'Code editor' );
|
1603
|
+
|
1604
|
+
const codeEditorInput = await page.waitForSelector(
|
1605
|
+
'.editor-post-text-editor'
|
1606
|
+
);
|
1607
|
+
await codeEditorInput.click();
|
1608
|
+
|
1609
|
+
const markup =
|
1610
|
+
'<!-- wp:navigation --><!-- wp:page-list /--><!-- /wp:navigation -->';
|
1611
|
+
await page.keyboard.type( markup );
|
1612
|
+
await clickButton( 'Exit code editor' );
|
1613
|
+
|
1614
|
+
await waitForBlock( 'Navigation' );
|
1615
|
+
|
1616
|
+
const hasUncontrolledInnerBlocks = await page.evaluate( () => {
|
1617
|
+
const blocks = wp.data
|
1618
|
+
.select( 'core/block-editor' )
|
1619
|
+
.getBlocks();
|
1620
|
+
return !! blocks[ 0 ]?.innerBlocks?.length;
|
1621
|
+
} );
|
1622
|
+
|
1623
|
+
expect( hasUncontrolledInnerBlocks ).toBe( true );
|
1624
|
+
} );
|
1625
|
+
|
1626
|
+
it( 'automatically uses most recent Navigation Menu if more than one exists', async () => {
|
1397
1627
|
await createNavigationMenu( {
|
1398
1628
|
title: 'Example Navigation',
|
1399
1629
|
content:
|
@@ -1412,7 +1642,14 @@ Expected mock function not to be called but it was called with: ["POST", "http:/
|
|
1412
1642
|
|
1413
1643
|
await waitForBlock( 'Navigation' );
|
1414
1644
|
|
1415
|
-
await page.waitForXPath(
|
1645
|
+
const navigationSelector = await page.waitForXPath(
|
1646
|
+
"//button[text()='Select Menu']"
|
1647
|
+
);
|
1648
|
+
await navigationSelector.click();
|
1649
|
+
|
1650
|
+
await page.waitForXPath(
|
1651
|
+
'//button[@aria-checked="true"][contains(., "Second Example Navigation")]'
|
1652
|
+
);
|
1416
1653
|
} );
|
1417
1654
|
|
1418
1655
|
it( 'allows users to manually create new empty menu when block has automatically selected the first available Navigation Menu', async () => {
|
@@ -1426,35 +1663,38 @@ Expected mock function not to be called but it was called with: ["POST", "http:/
|
|
1426
1663
|
|
1427
1664
|
await insertBlock( 'Navigation' );
|
1428
1665
|
|
1429
|
-
await
|
1430
|
-
|
1431
|
-
|
1432
|
-
|
1433
|
-
// Reset the nav block to create a new entity.
|
1434
|
-
await resetNavBlockToInitialState();
|
1666
|
+
const navigationSelector = await page.waitForXPath(
|
1667
|
+
"//button[text()='Select Menu']"
|
1668
|
+
);
|
1669
|
+
await navigationSelector.click();
|
1435
1670
|
|
1436
|
-
const
|
1437
|
-
|
1671
|
+
const createNewMenuButton = await page.waitForXPath(
|
1672
|
+
'//button[contains(., "Create new menu")]'
|
1438
1673
|
);
|
1439
|
-
await
|
1674
|
+
await createNewMenuButton.click();
|
1440
1675
|
|
1441
|
-
|
1676
|
+
await page.waitForNetworkIdle();
|
1677
|
+
|
1678
|
+
// Await "success" notice.
|
1442
1679
|
await page.waitForXPath(
|
1443
|
-
'
|
1680
|
+
'//div[@class="components-snackbar__content"][contains(text(), "Navigation Menu successfully created.")]'
|
1444
1681
|
);
|
1445
1682
|
} );
|
1446
1683
|
|
1447
|
-
|
1684
|
+
// Skip reason: running it in interactive works but selecting and
|
1685
|
+
// checking for focus consistently fails in the test.
|
1686
|
+
// eslint-disable-next-line jest/no-disabled-tests
|
1687
|
+
it.skip( 'should always focus select menu button after item selection', async () => {
|
1448
1688
|
// Create some navigation menus to work with.
|
1449
1689
|
await createNavigationMenu( {
|
1450
|
-
title: '
|
1690
|
+
title: 'First navigation',
|
1451
1691
|
content:
|
1452
|
-
'<!-- wp:navigation-link {"label":"WordPress","type":"custom","url":"http://www.wordpress.org/","kind":"custom","isTopLevelLink":true} /-->',
|
1692
|
+
'<!-- wp:navigation-link {"label":"WordPress Example Navigation","type":"custom","url":"http://www.wordpress.org/","kind":"custom","isTopLevelLink":true} /-->',
|
1453
1693
|
} );
|
1454
1694
|
await createNavigationMenu( {
|
1455
|
-
title: 'Second
|
1695
|
+
title: 'Second Navigation',
|
1456
1696
|
content:
|
1457
|
-
'<!-- wp:navigation-link {"label":"WordPress","type":"custom","url":"http://www.wordpress.org/","kind":"custom","isTopLevelLink":true} /-->',
|
1697
|
+
'<!-- wp:navigation-link {"label":"WordPress Second Example Navigation","type":"custom","url":"http://www.wordpress.org/","kind":"custom","isTopLevelLink":true} /-->',
|
1458
1698
|
} );
|
1459
1699
|
|
1460
1700
|
// Create new post.
|
@@ -1463,22 +1703,22 @@ Expected mock function not to be called but it was called with: ["POST", "http:/
|
|
1463
1703
|
// Insert new block and wait for the insert to complete.
|
1464
1704
|
await insertBlock( 'Navigation' );
|
1465
1705
|
await waitForBlock( 'Navigation' );
|
1466
|
-
await page.waitForXPath( START_EMPTY_XPATH );
|
1467
1706
|
|
1468
|
-
|
1469
|
-
|
1470
|
-
'[aria-label="Select Menu"]'
|
1707
|
+
const navigationSelector = await page.waitForXPath(
|
1708
|
+
"//button[text()='Select Menu']"
|
1471
1709
|
);
|
1472
|
-
await
|
1473
|
-
|
1474
|
-
|
1710
|
+
await navigationSelector.click();
|
1711
|
+
|
1712
|
+
const theOption = await page.waitForXPath(
|
1713
|
+
"//button[@aria-checked='false'][contains(., 'First navigation')]"
|
1475
1714
|
);
|
1476
|
-
|
1715
|
+
theOption.click();
|
1477
1716
|
|
1478
1717
|
// Once the options are closed, does select menu button receive focus?
|
1479
|
-
const selectMenuDropdown2 = await page
|
1718
|
+
const selectMenuDropdown2 = await page.$(
|
1480
1719
|
'[aria-label="Select Menu"]'
|
1481
1720
|
);
|
1721
|
+
|
1482
1722
|
await expect( selectMenuDropdown2 ).toHaveFocus();
|
1483
1723
|
} );
|
1484
1724
|
} );
|