diff --git a/tests/e2e/config/bootstrap.js b/tests/e2e/config/bootstrap.js index 00a497bf9ac..cebc96972d5 100644 --- a/tests/e2e/config/bootstrap.js +++ b/tests/e2e/config/bootstrap.js @@ -9,8 +9,6 @@ import { get } from 'lodash'; import { activateTheme, clearLocalStorage, - createMenu, - deleteAllMenus, enablePageDialogAccept, installTheme, isOfflineMode, @@ -250,36 +248,6 @@ async function createTestData() { } ); } -/** - * Create test posts so that the WordPress instance has some data. - */ -async function createTestMenus() { - await deleteAllMenus(); - await createMenu( - { - name: 'Test Menu 1', - }, - [ - { - title: 'WordPress.org', - url: 'https://wordpress.org', - menu_order: 1, - }, - { - title: 'Wikipedia.org', - url: 'https://wikipedia.org', - menu_order: 2, - }, - { - title: 'Google', - url: 'https://google.com', - menu_order: 3, - parent: 1, - }, - ], - ); -} - /** * Install themes and plugins needed in tests. */ @@ -309,7 +277,6 @@ beforeAll( async () => { await setupThemesAndPlugins(); await trashAllPosts(); await createTestData(); - await createTestMenus(); await cleanUpSettings(); await page.setDefaultNavigationTimeout( 10000 ); await page.setDefaultTimeout( 10000 ); diff --git a/tests/e2e/specs/core-themes/twentyfifteen.js b/tests/e2e/specs/core-themes/twentyfifteen.js index 88444ecdf50..fb3fd139935 100644 --- a/tests/e2e/specs/core-themes/twentyfifteen.js +++ b/tests/e2e/specs/core-themes/twentyfifteen.js @@ -7,7 +7,7 @@ import { activateTheme, createURL, installTheme, setBrowserViewport, visitAdminP * Internal dependencies */ import { setTemplateMode } from '../../utils/amp-settings-utils'; -import { assignMenuToLocation } from '../../utils/assign-menu-to-location'; +import { assignMenuToLocation, createTestMenu } from '../../utils/nav-menu-utils'; import { DEFAULT_BROWSER_VIEWPORT_SIZE, MOBILE_BROWSER_VIEWPORT_SIZE } from '../../config/bootstrap'; describe( 'Twenty Fifteen theme on AMP', () => { @@ -25,6 +25,7 @@ describe( 'Twenty Fifteen theme on AMP', () => { describe( 'main navigation on mobile', () => { beforeAll( async () => { + await createTestMenu(); await assignMenuToLocation( 'primary' ); } ); diff --git a/tests/e2e/specs/core-themes/twentyfourteen.js b/tests/e2e/specs/core-themes/twentyfourteen.js index b9e7180c0b3..e563fa97592 100644 --- a/tests/e2e/specs/core-themes/twentyfourteen.js +++ b/tests/e2e/specs/core-themes/twentyfourteen.js @@ -7,7 +7,7 @@ import { activateTheme, createURL, installTheme, setBrowserViewport, visitAdminP * Internal dependencies */ import { setTemplateMode } from '../../utils/amp-settings-utils'; -import { assignMenuToLocation } from '../../utils/assign-menu-to-location'; +import { assignMenuToLocation, createTestMenu } from '../../utils/nav-menu-utils'; import { DEFAULT_BROWSER_VIEWPORT_SIZE, MOBILE_BROWSER_VIEWPORT_SIZE } from '../../config/bootstrap'; describe( 'Twenty Fourteen theme on AMP', () => { @@ -25,6 +25,7 @@ describe( 'Twenty Fourteen theme on AMP', () => { describe( 'main navigation on mobile', () => { beforeAll( async () => { + await createTestMenu(); await assignMenuToLocation( 'primary' ); } ); diff --git a/tests/e2e/specs/core-themes/twentynineteen.js b/tests/e2e/specs/core-themes/twentynineteen.js index 9c2b9316897..04ec1d0108b 100644 --- a/tests/e2e/specs/core-themes/twentynineteen.js +++ b/tests/e2e/specs/core-themes/twentynineteen.js @@ -7,7 +7,7 @@ import { activateTheme, createURL, installTheme, setBrowserViewport, visitAdminP * Internal dependencies */ import { setTemplateMode } from '../../utils/amp-settings-utils'; -import { assignMenuToLocation } from '../../utils/assign-menu-to-location'; +import { assignMenuToLocation, createTestMenu } from '../../utils/nav-menu-utils'; import { DEFAULT_BROWSER_VIEWPORT_SIZE, MOBILE_BROWSER_VIEWPORT_SIZE } from '../../config/bootstrap'; describe( 'Twenty Nineteen theme on AMP', () => { @@ -25,6 +25,7 @@ describe( 'Twenty Nineteen theme on AMP', () => { describe( 'main navigation on mobile', () => { beforeAll( async () => { + await createTestMenu(); await assignMenuToLocation( 'menu-1' ); } ); diff --git a/tests/e2e/specs/core-themes/twentyseventeen.js b/tests/e2e/specs/core-themes/twentyseventeen.js index b93777f4404..8dece2e7dd3 100644 --- a/tests/e2e/specs/core-themes/twentyseventeen.js +++ b/tests/e2e/specs/core-themes/twentyseventeen.js @@ -7,7 +7,7 @@ import { activateTheme, createURL, installTheme, setBrowserViewport, visitAdminP * Internal dependencies */ import { setTemplateMode } from '../../utils/amp-settings-utils'; -import { assignMenuToLocation } from '../../utils/assign-menu-to-location'; +import { assignMenuToLocation, createTestMenu } from '../../utils/nav-menu-utils'; import { DEFAULT_BROWSER_VIEWPORT_SIZE, MOBILE_BROWSER_VIEWPORT_SIZE } from '../../config/bootstrap'; describe( 'Twenty Seventeen theme on AMP', () => { @@ -25,6 +25,7 @@ describe( 'Twenty Seventeen theme on AMP', () => { describe( 'main navigation on mobile', () => { beforeAll( async () => { + await createTestMenu(); await assignMenuToLocation( 'top' ); } ); diff --git a/tests/e2e/specs/core-themes/twentysixteen.js b/tests/e2e/specs/core-themes/twentysixteen.js index a3d3df7d4c1..bff8b2cb575 100644 --- a/tests/e2e/specs/core-themes/twentysixteen.js +++ b/tests/e2e/specs/core-themes/twentysixteen.js @@ -7,7 +7,7 @@ import { activateTheme, createURL, installTheme, setBrowserViewport, visitAdminP * Internal dependencies */ import { setTemplateMode } from '../../utils/amp-settings-utils'; -import { assignMenuToLocation } from '../../utils/assign-menu-to-location'; +import { assignMenuToLocation, createTestMenu } from '../../utils/nav-menu-utils'; import { DEFAULT_BROWSER_VIEWPORT_SIZE, MOBILE_BROWSER_VIEWPORT_SIZE } from '../../config/bootstrap'; describe( 'Twenty Sixteen theme on AMP', () => { @@ -25,6 +25,7 @@ describe( 'Twenty Sixteen theme on AMP', () => { describe( 'main navigation on mobile', () => { beforeAll( async () => { + await createTestMenu(); await assignMenuToLocation( 'primary' ); } ); diff --git a/tests/e2e/specs/core-themes/twentythirteen.js b/tests/e2e/specs/core-themes/twentythirteen.js index afdaa884617..e5df09abeaa 100644 --- a/tests/e2e/specs/core-themes/twentythirteen.js +++ b/tests/e2e/specs/core-themes/twentythirteen.js @@ -7,7 +7,7 @@ import { activateTheme, createURL, installTheme, setBrowserViewport, visitAdminP * Internal dependencies */ import { setTemplateMode } from '../../utils/amp-settings-utils'; -import { assignMenuToLocation } from '../../utils/assign-menu-to-location'; +import { assignMenuToLocation, createTestMenu } from '../../utils/nav-menu-utils'; import { DEFAULT_BROWSER_VIEWPORT_SIZE, MOBILE_BROWSER_VIEWPORT_SIZE } from '../../config/bootstrap'; describe( 'Twenty Thirteen theme on AMP', () => { @@ -25,6 +25,7 @@ describe( 'Twenty Thirteen theme on AMP', () => { describe( 'main navigation on mobile', () => { beforeAll( async () => { + await createTestMenu(); await assignMenuToLocation( 'primary' ); } ); diff --git a/tests/e2e/specs/core-themes/twentytwelve.js b/tests/e2e/specs/core-themes/twentytwelve.js index 2fef4e3b422..d599478a871 100644 --- a/tests/e2e/specs/core-themes/twentytwelve.js +++ b/tests/e2e/specs/core-themes/twentytwelve.js @@ -7,7 +7,7 @@ import { activateTheme, createURL, installTheme, setBrowserViewport, visitAdminP * Internal dependencies */ import { setTemplateMode } from '../../utils/amp-settings-utils'; -import { assignMenuToLocation } from '../../utils/assign-menu-to-location'; +import { assignMenuToLocation, createTestMenu } from '../../utils/nav-menu-utils'; import { DEFAULT_BROWSER_VIEWPORT_SIZE, MOBILE_BROWSER_VIEWPORT_SIZE } from '../../config/bootstrap'; describe( 'Twenty Twelve theme on AMP', () => { @@ -25,6 +25,7 @@ describe( 'Twenty Twelve theme on AMP', () => { describe( 'main navigation on mobile', () => { beforeAll( async () => { + await createTestMenu(); await assignMenuToLocation( 'primary' ); } ); diff --git a/tests/e2e/specs/core-themes/twentytwenty.js b/tests/e2e/specs/core-themes/twentytwenty.js index 4da7f801af2..dc13a49b3bf 100644 --- a/tests/e2e/specs/core-themes/twentytwenty.js +++ b/tests/e2e/specs/core-themes/twentytwenty.js @@ -7,7 +7,7 @@ import { activateTheme, createURL, setBrowserViewport, visitAdminPage } from '@w * Internal dependencies */ import { setTemplateMode } from '../../utils/amp-settings-utils'; -import { assignMenuToLocation } from '../../utils/assign-menu-to-location'; +import { assignMenuToLocation, createTestMenu } from '../../utils/nav-menu-utils'; import { DEFAULT_BROWSER_VIEWPORT_SIZE, MOBILE_BROWSER_VIEWPORT_SIZE } from '../../config/bootstrap'; describe( 'Twenty Twenty theme on AMP', () => { @@ -31,6 +31,7 @@ describe( 'Twenty Twenty theme on AMP', () => { describe( 'main navigation', () => { beforeAll( async () => { + await createTestMenu(); await assignMenuToLocation( 'mobile' ); } ); diff --git a/tests/e2e/specs/core-themes/twentytwentyone.js b/tests/e2e/specs/core-themes/twentytwentyone.js index f20ad3640fb..9b51a543a32 100644 --- a/tests/e2e/specs/core-themes/twentytwentyone.js +++ b/tests/e2e/specs/core-themes/twentytwentyone.js @@ -7,7 +7,7 @@ import { activateTheme, createURL, installTheme, setBrowserViewport, visitAdminP * Internal dependencies */ import { setTemplateMode } from '../../utils/amp-settings-utils'; -import { assignMenuToLocation } from '../../utils/assign-menu-to-location'; +import { assignMenuToLocation, createTestMenu } from '../../utils/nav-menu-utils'; import { DEFAULT_BROWSER_VIEWPORT_SIZE, MOBILE_BROWSER_VIEWPORT_SIZE } from '../../config/bootstrap'; describe( 'Twenty Twenty-One theme on AMP', () => { @@ -25,6 +25,7 @@ describe( 'Twenty Twenty-One theme on AMP', () => { describe( 'main navigation on mobile', () => { beforeAll( async () => { + await createTestMenu(); await assignMenuToLocation( 'primary' ); } ); diff --git a/tests/e2e/utils/assign-menu-to-location.js b/tests/e2e/utils/nav-menu-utils.js similarity index 51% rename from tests/e2e/utils/assign-menu-to-location.js rename to tests/e2e/utils/nav-menu-utils.js index 2c44d40d615..d986092fad2 100644 --- a/tests/e2e/utils/assign-menu-to-location.js +++ b/tests/e2e/utils/nav-menu-utils.js @@ -1,7 +1,34 @@ /** * WordPress dependencies */ -import { visitAdminPage } from '@wordpress/e2e-test-utils'; +import { createMenu, deleteAllMenus, visitAdminPage } from '@wordpress/e2e-test-utils'; + +export async function createTestMenu() { + await deleteAllMenus(); + await createMenu( + { + name: 'Test Menu 1', + }, + [ + { + title: 'WordPress.org', + url: 'https://wordpress.org', + menu_order: 1, + }, + { + title: 'Wikipedia.org', + url: 'https://wikipedia.org', + menu_order: 2, + }, + { + title: 'Google', + url: 'https://google.com', + menu_order: 3, + parent: 1, + }, + ], + ); +} export async function assignMenuToLocation( menuLocationName ) { await visitAdminPage( 'nav-menus.php', '' );