@wordpress/e2e-tests 2.5.7 → 2.5.8

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.7",
3
+ "version": "2.5.8",
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": "ca22e8852fcc91889510e417bdaa180ad60f8dac"
46
+ "gitHead": "6d3bd917064b4b194677233ee426f5988fa441b9"
47
47
  }
@@ -784,4 +784,92 @@ describe.skip( 'Navigation', () => {
784
784
 
785
785
  expect( isScriptLoaded ).toBe( true );
786
786
  } );
787
+
788
+ describe( 'Creating and restarting', () => {
789
+ async function populateNavWithOneItem() {
790
+ // Add a Link block first.
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.
833
+ await insertBlock( 'Navigation' );
834
+
835
+ // Create an empty nav block.
836
+ await createEmptyNavBlock();
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"])'
842
+ );
843
+ await page.click( '.editor-post-publish-panel__toggle' );
844
+
845
+ const NAV_ENTITY_SELECTOR =
846
+ '//div[@class="entities-saved-states__panel"]//label//strong[contains(text(), "Navigation")]';
847
+ await page.waitForXPath( NAV_ENTITY_SELECTOR );
848
+ expect( await page.$x( NAV_ENTITY_SELECTOR ) ).toHaveLength( 1 );
849
+
850
+ // Publish the post
851
+ await page.click( '.editor-entities-saved-states__save-button' );
852
+ await page.waitForSelector( '.editor-post-publish-button' );
853
+ await page.click( '.editor-post-publish-button' );
854
+
855
+ // A success notice should show up
856
+ await page.waitForSelector( '.components-snackbar' );
857
+
858
+ // Now try inserting another Link block via the quick inserter.
859
+ await page.focus( '.wp-block-navigation' );
860
+
861
+ await resetNavBlockToInitialState();
862
+ await createEmptyNavBlock();
863
+ await populateNavWithOneItem();
864
+
865
+ // Let's confirm that only the last menu entity was updated.
866
+ await page.waitForSelector(
867
+ '.editor-post-publish-button__button:not([aria-disabled="true"])'
868
+ );
869
+ await page.click( '.editor-post-publish-button__button' );
870
+
871
+ await page.waitForXPath( NAV_ENTITY_SELECTOR );
872
+ expect( await page.$x( NAV_ENTITY_SELECTOR ) ).toHaveLength( 1 );
873
+ } );
874
+ } );
787
875
  } );