@wordpress/e2e-tests 2.5.12 → 2.5.13
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/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@wordpress/e2e-tests",
|
3
|
-
"version": "2.5.
|
3
|
+
"version": "2.5.13",
|
4
4
|
"description": "End-To-End (E2E) tests for WordPress.",
|
5
5
|
"author": "The WordPress Contributors",
|
6
6
|
"license": "GPL-2.0-or-later",
|
@@ -43,5 +43,5 @@
|
|
43
43
|
"publishConfig": {
|
44
44
|
"access": "public"
|
45
45
|
},
|
46
|
-
"gitHead": "
|
46
|
+
"gitHead": "1081a28b2368fcebd9a14554fbd0e25eb33fbcb6"
|
47
47
|
}
|
@@ -2,6 +2,8 @@
|
|
2
2
|
* WordPress dependencies
|
3
3
|
*/
|
4
4
|
import {
|
5
|
+
clickButton,
|
6
|
+
clickOnMoreMenuItem,
|
5
7
|
createJSONResponse,
|
6
8
|
createNewPost,
|
7
9
|
getEditedPostContent,
|
@@ -187,7 +189,10 @@ async function updateActiveNavigationLink( { url, label, type } ) {
|
|
187
189
|
};
|
188
190
|
|
189
191
|
if ( url ) {
|
190
|
-
await page.
|
192
|
+
const input = await page.waitForSelector(
|
193
|
+
'input[placeholder="Search or type url"]'
|
194
|
+
);
|
195
|
+
await input.type( url );
|
191
196
|
|
192
197
|
const suggestionPath = `//button[contains(@class, 'block-editor-link-control__search-item') and contains(@class, '${ typeClasses[ type ] }')]/span/span[@class='block-editor-link-control__search-item-title']/mark[text()="${ url }"]`;
|
193
198
|
|
@@ -235,6 +240,7 @@ const PLACEHOLDER_ACTIONS_CLASS = 'wp-block-navigation-placeholder__actions';
|
|
235
240
|
const PLACEHOLDER_ACTIONS_XPATH = `//*[contains(@class, '${ PLACEHOLDER_ACTIONS_CLASS }')]`;
|
236
241
|
const START_EMPTY_XPATH = `${ PLACEHOLDER_ACTIONS_XPATH }//button[text()='Start empty']`;
|
237
242
|
const ADD_ALL_PAGES_XPATH = `${ PLACEHOLDER_ACTIONS_XPATH }//button[text()='Add all pages']`;
|
243
|
+
const SELECT_MENU_XPATH = `${ PLACEHOLDER_ACTIONS_XPATH }//button[text()='Select menu']`;
|
238
244
|
|
239
245
|
async function createNavBlockWithAllPages() {
|
240
246
|
const allPagesButton = await page.waitForXPath( ADD_ALL_PAGES_XPATH );
|
@@ -675,6 +681,151 @@ describe.skip( 'Navigation', () => {
|
|
675
681
|
expect( await getEditedPostContent() ).toMatchSnapshot();
|
676
682
|
} );
|
677
683
|
|
684
|
+
it( 'supports navigation blocks that have inner blocks within their markup and converts them to wp_navigation posts', async () => {
|
685
|
+
// Insert 'old-school' inner blocks via the code editor.
|
686
|
+
await createNewPost();
|
687
|
+
await clickOnMoreMenuItem( 'Code editor' );
|
688
|
+
const codeEditorInput = await page.waitForSelector(
|
689
|
+
'.editor-post-text-editor'
|
690
|
+
);
|
691
|
+
await codeEditorInput.click();
|
692
|
+
const markup =
|
693
|
+
'<!-- wp:navigation --><!-- wp:page-list /--><!-- /wp:navigation -->';
|
694
|
+
await page.keyboard.type( markup );
|
695
|
+
await clickButton( 'Exit code editor' );
|
696
|
+
const navBlock = await page.waitForSelector(
|
697
|
+
'nav[aria-label="Block: Navigation"]'
|
698
|
+
);
|
699
|
+
// Select the block to convert to a wp_navigation and publish.
|
700
|
+
// The select menu button shows up when saving is complete.
|
701
|
+
await navBlock.click();
|
702
|
+
await page.waitForSelector( 'button[aria-label="Select Menu"]' );
|
703
|
+
// await publishPost();
|
704
|
+
|
705
|
+
// Check that the wp_navigation post has the page list block.
|
706
|
+
// expect( await getNavigationMenuRawContent() ).toMatchSnapshot();
|
707
|
+
} );
|
708
|
+
|
709
|
+
describe( 'Creating and restarting', () => {
|
710
|
+
const NAV_ENTITY_SELECTOR =
|
711
|
+
'//div[@class="entities-saved-states__panel"]//label//strong[contains(text(), "Navigation")]';
|
712
|
+
|
713
|
+
async function populateNavWithOneItem() {
|
714
|
+
// Add a Link block first.
|
715
|
+
const appender = await page.waitForSelector(
|
716
|
+
'.wp-block-navigation .block-list-appender'
|
717
|
+
);
|
718
|
+
await appender.click();
|
719
|
+
// Add a link to the Link block.
|
720
|
+
await updateActiveNavigationLink( {
|
721
|
+
url: 'https://wordpress.org',
|
722
|
+
label: 'WP',
|
723
|
+
type: 'url',
|
724
|
+
} );
|
725
|
+
}
|
726
|
+
|
727
|
+
async function resetNavBlockToInitialState() {
|
728
|
+
const selectMenuDropdown = await page.waitForSelector(
|
729
|
+
'[aria-label="Select Menu"]'
|
730
|
+
);
|
731
|
+
await selectMenuDropdown.click();
|
732
|
+
const newMenuButton = await page.waitForXPath(
|
733
|
+
'//span[text()="Create new menu"]'
|
734
|
+
);
|
735
|
+
newMenuButton.click();
|
736
|
+
}
|
737
|
+
|
738
|
+
it( 'does not retain uncontrolled inner blocks when creating a new entity', async () => {
|
739
|
+
await createNewPost();
|
740
|
+
await clickOnMoreMenuItem( 'Code editor' );
|
741
|
+
const codeEditorInput = await page.waitForSelector(
|
742
|
+
'.editor-post-text-editor'
|
743
|
+
);
|
744
|
+
await codeEditorInput.click();
|
745
|
+
const markup =
|
746
|
+
'<!-- wp:navigation --><!-- wp:page-list /--><!-- /wp:navigation -->';
|
747
|
+
await page.keyboard.type( markup );
|
748
|
+
await clickButton( 'Exit code editor' );
|
749
|
+
const navBlock = await page.waitForSelector(
|
750
|
+
'nav[aria-label="Block: Navigation"]'
|
751
|
+
);
|
752
|
+
|
753
|
+
// Select the block to convert to a wp_navigation and publish.
|
754
|
+
// The select menu button shows up when saving is complete.
|
755
|
+
await navBlock.click();
|
756
|
+
await page.waitForSelector( 'button[aria-label="Select Menu"]' );
|
757
|
+
|
758
|
+
// Reset the nav block to create a new entity.
|
759
|
+
await resetNavBlockToInitialState();
|
760
|
+
const startEmptyButton = await page.waitForXPath(
|
761
|
+
START_EMPTY_XPATH
|
762
|
+
);
|
763
|
+
await startEmptyButton.click();
|
764
|
+
await populateNavWithOneItem();
|
765
|
+
|
766
|
+
// Confirm that only the last menu entity was updated.
|
767
|
+
const publishPanelButton2 = await page.waitForSelector(
|
768
|
+
'.editor-post-publish-button__button:not([aria-disabled="true"])'
|
769
|
+
);
|
770
|
+
await publishPanelButton2.click();
|
771
|
+
|
772
|
+
await page.waitForXPath( NAV_ENTITY_SELECTOR );
|
773
|
+
expect( await page.$x( NAV_ENTITY_SELECTOR ) ).toHaveLength( 1 );
|
774
|
+
} );
|
775
|
+
|
776
|
+
it( 'only update a single entity currently linked with the block', async () => {
|
777
|
+
await createNewPost();
|
778
|
+
await insertBlock( 'Navigation' );
|
779
|
+
|
780
|
+
const startEmptyButton = await page.waitForXPath(
|
781
|
+
START_EMPTY_XPATH
|
782
|
+
);
|
783
|
+
await startEmptyButton.click();
|
784
|
+
await populateNavWithOneItem();
|
785
|
+
|
786
|
+
// Confirm that the menu entity was updated.
|
787
|
+
const publishPanelButton = await page.waitForSelector(
|
788
|
+
'.editor-post-publish-panel__toggle:not([aria-disabled="true"])'
|
789
|
+
);
|
790
|
+
await publishPanelButton.click();
|
791
|
+
|
792
|
+
await page.waitForXPath( NAV_ENTITY_SELECTOR );
|
793
|
+
expect( await page.$x( NAV_ENTITY_SELECTOR ) ).toHaveLength( 1 );
|
794
|
+
|
795
|
+
// Publish the post
|
796
|
+
const entitySaveButton = await page.waitForSelector(
|
797
|
+
'.editor-entities-saved-states__save-button'
|
798
|
+
);
|
799
|
+
await entitySaveButton.click();
|
800
|
+
const publishButton = await page.waitForSelector(
|
801
|
+
'.editor-post-publish-button:not([aria-disabled="true"])'
|
802
|
+
);
|
803
|
+
await publishButton.click();
|
804
|
+
|
805
|
+
// A success notice should show up.
|
806
|
+
await page.waitForSelector( '.components-snackbar' );
|
807
|
+
|
808
|
+
// Now try inserting another Link block via the quick inserter.
|
809
|
+
await page.click( 'nav[aria-label="Block: Navigation"]' );
|
810
|
+
|
811
|
+
await resetNavBlockToInitialState();
|
812
|
+
const startEmptyButton2 = await page.waitForXPath(
|
813
|
+
START_EMPTY_XPATH
|
814
|
+
);
|
815
|
+
await startEmptyButton2.click();
|
816
|
+
await populateNavWithOneItem();
|
817
|
+
|
818
|
+
// Confirm that only the last menu entity was updated.
|
819
|
+
const publishPanelButton2 = await page.waitForSelector(
|
820
|
+
'.editor-post-publish-button__button:not([aria-disabled="true"])'
|
821
|
+
);
|
822
|
+
await publishPanelButton2.click();
|
823
|
+
|
824
|
+
await page.waitForXPath( NAV_ENTITY_SELECTOR );
|
825
|
+
expect( await page.$x( NAV_ENTITY_SELECTOR ) ).toHaveLength( 1 );
|
826
|
+
} );
|
827
|
+
} );
|
828
|
+
|
678
829
|
// The following tests are unstable, roughly around when https://github.com/WordPress/wordpress-develop/pull/1412
|
679
830
|
// landed. The block manually tests well, so let's skip to unblock other PRs and immediately follow up. cc @vcanales
|
680
831
|
it.skip( 'loads frontend code only if the block is present', async () => {
|
@@ -785,91 +936,51 @@ describe.skip( 'Navigation', () => {
|
|
785
936
|
expect( isScriptLoaded ).toBe( true );
|
786
937
|
} );
|
787
938
|
|
788
|
-
describe( '
|
789
|
-
async
|
790
|
-
|
791
|
-
await page.waitForSelector(
|
792
|
-
'.wp-block-navigation .block-list-appender'
|
793
|
-
);
|
794
|
-
await page.click( '.wp-block-navigation .block-list-appender' );
|
795
|
-
// Add a link to the Link block.
|
796
|
-
await updateActiveNavigationLink( {
|
797
|
-
url: 'https://wordpress.org',
|
798
|
-
label: 'WP',
|
799
|
-
type: 'url',
|
800
|
-
} );
|
801
|
-
}
|
802
|
-
|
803
|
-
async function resetNavBlockToInitialState() {
|
804
|
-
await page.waitForSelector( '[aria-label="Select Menu"]' );
|
805
|
-
await page.click( '[aria-label="Select Menu"]' );
|
806
|
-
|
807
|
-
await page.waitForXPath( '//span[text()="Create new menu"]' );
|
808
|
-
const newMenuButton = await page.$x(
|
809
|
-
'//span[text()="Create new menu"]'
|
810
|
-
);
|
811
|
-
newMenuButton[ 0 ].click();
|
812
|
-
}
|
813
|
-
|
814
|
-
it( 'only update a single entity currently linked with the block', async () => {
|
815
|
-
// Mock the response from the Pages endpoint. This is done so that the pages returned are always
|
816
|
-
// consistent and to test the feature more rigorously than the single default sample page.
|
817
|
-
await mockPagesResponse( [
|
818
|
-
{
|
819
|
-
title: 'Home',
|
820
|
-
slug: 'home',
|
821
|
-
},
|
822
|
-
{
|
823
|
-
title: 'About',
|
824
|
-
slug: 'about',
|
825
|
-
},
|
826
|
-
{
|
827
|
-
title: 'Contact Us',
|
828
|
-
slug: 'contact',
|
829
|
-
},
|
830
|
-
] );
|
831
|
-
|
832
|
-
// Add the navigation block.
|
939
|
+
describe( 'Permission based restrictions', () => {
|
940
|
+
it( 'shows a warning if user does not have permission to edit or update navigation menus', async () => {
|
941
|
+
await createNewPost();
|
833
942
|
await insertBlock( 'Navigation' );
|
834
943
|
|
835
|
-
|
836
|
-
|
837
|
-
await populateNavWithOneItem();
|
838
|
-
|
839
|
-
// Let's confirm that the menu entity was updated.
|
840
|
-
await page.waitForSelector(
|
841
|
-
'.editor-post-publish-panel__toggle:not([aria-disabled="true"])'
|
944
|
+
const startEmptyButton = await page.waitForXPath(
|
945
|
+
START_EMPTY_XPATH
|
842
946
|
);
|
843
|
-
await page.click( '.editor-post-publish-panel__toggle' );
|
844
947
|
|
845
|
-
|
846
|
-
|
847
|
-
await page.waitForXPath( NAV_ENTITY_SELECTOR );
|
848
|
-
expect( await page.$x( NAV_ENTITY_SELECTOR ) ).toHaveLength( 1 );
|
948
|
+
// This creates an empty Navigation post type entity.
|
949
|
+
await startEmptyButton.click();
|
849
950
|
|
850
|
-
//
|
851
|
-
|
852
|
-
await
|
853
|
-
await page.click( '.editor-post-publish-button' );
|
951
|
+
// Publishing the Post ensures the Navigation entity is saved.
|
952
|
+
// The Post itself is irrelevant.
|
953
|
+
// await publishPost();
|
854
954
|
|
855
|
-
//
|
856
|
-
|
955
|
+
// Switch to a Contributor role user - they should not have
|
956
|
+
// permission to update Navigations.
|
957
|
+
// await loginUser( username, contribUserPassword );
|
857
958
|
|
858
|
-
|
859
|
-
await page.focus( '.wp-block-navigation' );
|
959
|
+
await createNewPost();
|
860
960
|
|
861
|
-
await
|
862
|
-
await createEmptyNavBlock();
|
863
|
-
await populateNavWithOneItem();
|
961
|
+
await insertBlock( 'Navigation' );
|
864
962
|
|
865
|
-
//
|
866
|
-
|
867
|
-
|
963
|
+
// Select the Navigation post created by the Admin early
|
964
|
+
// in the test.
|
965
|
+
const navigationPostCreatedByAdminName = 'Navigation';
|
966
|
+
const dropdown = await page.waitForXPath( SELECT_MENU_XPATH );
|
967
|
+
await dropdown.click();
|
968
|
+
const theOption = await page.waitForXPath(
|
969
|
+
`//*[contains(@class, 'components-menu-item__item')][ text()="${ navigationPostCreatedByAdminName }" ]`
|
868
970
|
);
|
869
|
-
await
|
971
|
+
await theOption.click();
|
870
972
|
|
871
|
-
|
872
|
-
|
973
|
+
// Make sure the snackbar error shows up
|
974
|
+
await page.waitForXPath(
|
975
|
+
`//*[contains(@class, 'components-snackbar__content')][ text()="You do not have permission to edit this Menu. Any changes made will not be saved." ]`
|
976
|
+
);
|
977
|
+
|
978
|
+
// Expect a console 403 for request to Navigation Areas for lower permisison users.
|
979
|
+
// This is because reading requires the `edit_theme_options` capability
|
980
|
+
// which the Contributor level user does not have.
|
981
|
+
// See: https://github.com/WordPress/gutenberg/blob/4cedaf0c4abb0aeac4bfd4289d63e9889efe9733/lib/class-wp-rest-block-navigation-areas-controller.php#L81-L91.
|
982
|
+
// Todo: removed once Nav Areas are removed from the Gutenberg Plugin.
|
983
|
+
expect( console ).toHaveErrored();
|
873
984
|
} );
|
874
985
|
} );
|
875
986
|
} );
|
@@ -25,7 +25,7 @@ describe( 'Multi-entity save flow', () => {
|
|
25
25
|
const activatedTemplatePartSelector = `${ templatePartSelector }.block-editor-block-list__layout`;
|
26
26
|
const savePanelSelector = '.entities-saved-states__panel';
|
27
27
|
const closePanelButtonSelector =
|
28
|
-
'.editor-post-publish-panel__header-cancel-button button';
|
28
|
+
'.editor-post-publish-panel__header-cancel-button button:not(:disabled)';
|
29
29
|
const createNewButtonSelector =
|
30
30
|
'//button[contains(text(), "New template part")]';
|
31
31
|
|
@@ -145,7 +145,10 @@ describe( 'Multi-entity save flow', () => {
|
|
145
145
|
await assertExistance( savePanelSelector, false );
|
146
146
|
|
147
147
|
// Close publish panel.
|
148
|
-
await page.
|
148
|
+
const closePanelButton = await page.waitForSelector(
|
149
|
+
closePanelButtonSelector
|
150
|
+
);
|
151
|
+
await closePanelButton.click();
|
149
152
|
|
150
153
|
// Verify saving is disabled.
|
151
154
|
const draftSaved = await page.waitForSelector( draftSavedSelector );
|
@@ -154,13 +157,22 @@ describe( 'Multi-entity save flow', () => {
|
|
154
157
|
await assertExistance( saveA11ySelector, false );
|
155
158
|
|
156
159
|
await publishPost();
|
160
|
+
// Wait for the success notice specifically for the published post.
|
161
|
+
// `publishPost()` has a similar check but it only checks for the
|
162
|
+
// existence of any snackbars. In this case, there's another "Site updated"
|
163
|
+
// notice which will be sufficient for that and thus creating a false-positive.
|
164
|
+
await page.waitForXPath(
|
165
|
+
'//*[@id="a11y-speak-polite"][contains(text(), "Post published")]'
|
166
|
+
);
|
157
167
|
|
158
168
|
// Update the post.
|
159
169
|
await page.click( '.editor-post-title' );
|
160
170
|
await page.keyboard.type( '...more title!' );
|
161
171
|
|
162
172
|
// Verify update button is enabled.
|
163
|
-
const enabledSaveButton = await page
|
173
|
+
const enabledSaveButton = await page.waitForSelector(
|
174
|
+
enabledSavePostSelector
|
175
|
+
);
|
164
176
|
expect( enabledSaveButton ).not.toBeNull();
|
165
177
|
// Verify multi-entity saving not enabled.
|
166
178
|
await assertMultiSaveDisabled();
|