diff --git a/packages/e2e-test-utils-playwright/src/admin/create-new-post.js b/packages/e2e-test-utils-playwright/src/admin/create-new-post.js deleted file mode 100644 index 81822e2514a73..0000000000000 --- a/packages/e2e-test-utils-playwright/src/admin/create-new-post.js +++ /dev/null @@ -1,47 +0,0 @@ -/** - * WordPress dependencies - */ -import { addQueryArgs } from '@wordpress/url'; - -/** - * Creates new post. - * - * @this {import('.').Editor} - * @param {Object} object Object to create new post, along with tips enabling option. - * @param {string} [object.postType] Post type of the new post. - * @param {string} [object.title] Title of the new post. - * @param {string} [object.content] Content of the new post. - * @param {string} [object.excerpt] Excerpt of the new post. - * @param {boolean} [object.showWelcomeGuide] Whether to show the welcome guide. - */ -export async function createNewPost( { - postType, - title, - content, - excerpt, - showWelcomeGuide = false, -} = {} ) { - const query = addQueryArgs( '', { - post_type: postType, - post_title: title, - content, - excerpt, - } ).slice( 1 ); - - await this.visitAdminPage( 'post-new.php', query ); - - await this.page.waitForFunction( ( welcomeGuide ) => { - if ( ! window?.wp?.data?.dispatch ) { - return false; - } - window.wp.data - .dispatch( 'core/preferences' ) - .set( 'core/edit-post', 'welcomeGuide', welcomeGuide ); - - window.wp.data - .dispatch( 'core/preferences' ) - .set( 'core/edit-post', 'fullscreenMode', false ); - - return true; - }, showWelcomeGuide ); -} diff --git a/packages/e2e-test-utils-playwright/src/admin/create-new-post.ts b/packages/e2e-test-utils-playwright/src/admin/create-new-post.ts new file mode 100644 index 0000000000000..e9cfefd9f65d5 --- /dev/null +++ b/packages/e2e-test-utils-playwright/src/admin/create-new-post.ts @@ -0,0 +1,38 @@ +/** + * Internal dependencies + */ +import type { Admin } from './'; + +interface NewPostOptions { + postType?: string; + title?: string; + content?: string; + excerpt?: string; + showWelcomeGuide?: boolean; +} + +/** + * Creates new post. + * + * @param this + * @param options Options to create new post. + */ +export async function createNewPost( + this: Admin, + options: NewPostOptions = {} +) { + const query = new URLSearchParams(); + const { postType, title, content, excerpt } = options; + + if ( postType ) query.set( 'post_type', postType ); + if ( title ) query.set( 'post_title', title ); + if ( content ) query.set( 'content', content ); + if ( excerpt ) query.set( 'excerpt', excerpt ); + + await this.visitAdminPage( 'post-new.php', query.toString() ); + + await this.editor.setPreferences( 'core/edit-post', { + welcomeGuide: options.showWelcomeGuide ?? false, + fullscreenMode: false, + } ); +} diff --git a/packages/e2e-test-utils-playwright/src/admin/edit-post.ts b/packages/e2e-test-utils-playwright/src/admin/edit-post.ts new file mode 100644 index 0000000000000..77cf390d02aa0 --- /dev/null +++ b/packages/e2e-test-utils-playwright/src/admin/edit-post.ts @@ -0,0 +1,24 @@ +/** + * Internal dependencies + */ +import type { Admin } from '.'; + +/** + * Open the post with given ID in the editor. + * + * @param this + * @param postId Post ID to visit. + */ +export async function editPost( this: Admin, postId: string | number ) { + const query = new URLSearchParams(); + + query.set( 'post', String( postId ) ); + query.set( 'action', 'edit' ); + + await this.visitAdminPage( 'post.php', query.toString() ); + + await this.editor.setPreferences( 'core/edit-post', { + welcomeGuide: false, + fullscreenMode: false, + } ); +} diff --git a/packages/e2e-test-utils-playwright/src/admin/index.ts b/packages/e2e-test-utils-playwright/src/admin/index.ts index ed16564f8f4ab..08d2baf4b6520 100644 --- a/packages/e2e-test-utils-playwright/src/admin/index.ts +++ b/packages/e2e-test-utils-playwright/src/admin/index.ts @@ -9,29 +9,36 @@ import type { Browser, Page, BrowserContext } from '@playwright/test'; import { createNewPost } from './create-new-post'; import { getPageError } from './get-page-error'; import { visitAdminPage } from './visit-admin-page'; +import { editPost } from './edit-post'; import { visitSiteEditor } from './visit-site-editor'; import type { PageUtils } from '../page-utils'; +import type { Editor } from '../editor'; type AdminConstructorProps = { page: Page; pageUtils: PageUtils; + editor: Editor; }; export class Admin { - browser: Browser; page: Page; - pageUtils: PageUtils; context: BrowserContext; + browser: Browser; + pageUtils: PageUtils; + editor: Editor; - constructor( { page, pageUtils }: AdminConstructorProps ) { + constructor( { page, pageUtils, editor }: AdminConstructorProps ) { this.page = page; this.context = page.context(); this.browser = this.context.browser()!; this.pageUtils = pageUtils; + this.editor = editor; } /** @borrows createNewPost as this.createNewPost */ createNewPost: typeof createNewPost = createNewPost.bind( this ); + /** @borrows editPost as this.editPost */ + editPost: typeof editPost = editPost.bind( this ); /** @borrows getPageError as this.getPageError */ getPageError: typeof getPageError = getPageError.bind( this ); /** @borrows visitAdminPage as this.visitAdminPage */ diff --git a/packages/e2e-test-utils-playwright/src/admin/visit-site-editor.ts b/packages/e2e-test-utils-playwright/src/admin/visit-site-editor.ts index a545bdc704341..da21f17aade11 100644 --- a/packages/e2e-test-utils-playwright/src/admin/visit-site-editor.ts +++ b/packages/e2e-test-utils-playwright/src/admin/visit-site-editor.ts @@ -1,72 +1,51 @@ -/** - * WordPress dependencies - */ -import { addQueryArgs } from '@wordpress/url'; - /** * Internal dependencies */ import type { Admin } from './'; -export interface SiteEditorQueryParams { - postId: string | number; - postType: string; +interface SiteEditorOptions { + postId?: string | number; + postType?: string; + path?: string; + canvas?: string; + showWelcomeGuide?: boolean; } -const CANVAS_SELECTOR = 'iframe[title="Editor canvas"i] >> visible=true'; - /** - * Visits the Site Editor main page - * - * By default, it also skips the welcome guide. The option can be disabled if need be. + * Visits the Site Editor main page. * * @param this - * @param query Query params to be serialized as query portion of URL. - * @param skipWelcomeGuide Whether to skip the welcome guide as part of the navigation. + * @param options Options to visit the site editor. */ export async function visitSiteEditor( this: Admin, - query: SiteEditorQueryParams, - skipWelcomeGuide = true + options: SiteEditorOptions = {} ) { - const path = addQueryArgs( '', { - ...query, - } ).slice( 1 ); - - await this.visitAdminPage( 'site-editor.php', path ); - - if ( skipWelcomeGuide ) { - await this.page.evaluate( () => { - window.wp.data - .dispatch( 'core/preferences' ) - .set( 'core/edit-site', 'welcomeGuide', false ); - - window.wp.data - .dispatch( 'core/preferences' ) - .set( 'core/edit-site', 'welcomeGuideStyles', false ); - - window.wp.data - .dispatch( 'core/preferences' ) - .set( 'core/edit-site', 'welcomeGuidePage', false ); - - window.wp.data - .dispatch( 'core/preferences' ) - .set( 'core/edit-site', 'welcomeGuideTemplate', false ); + const { postId, postType, path, canvas } = options; + const query = new URLSearchParams(); + + if ( postId ) query.set( 'postId', String( postId ) ); + if ( postType ) query.set( 'postType', postType ); + if ( path ) query.set( 'path', path ); + if ( canvas ) query.set( 'canvas', canvas ); + + await this.visitAdminPage( 'site-editor.php', query.toString() ); + + if ( ! options.showWelcomeGuide ) { + await this.editor.setPreferences( 'core/edit-site', { + welcomeGuide: false, + welcomeGuideStyles: false, + welcomeGuidePage: false, + welcomeGuideTemplate: false, } ); } - // Check if the current page has an editor canvas first. - if ( ( await this.page.locator( CANVAS_SELECTOR ).count() ) > 0 ) { - // The site editor initially loads with an empty body, - // we need to wait for the editor canvas to be rendered. - await this.page - .frameLocator( CANVAS_SELECTOR ) - .locator( 'body > *' ) - .first() - .waitFor(); - } - - // TODO: Ideally the content underneath the canvas loader should be marked inert until it's ready. + /** + * @todo This is a workaround for the fact that the editor canvas is seen as + * ready and visible before the loading spinner is hidden. Ideally, the + * content underneath the loading overlay should be marked inert until the + * loading is done. + */ await this.page .locator( '.edit-site-canvas-loader' ) // Bigger timeout is needed for larger entities, for example the large diff --git a/packages/e2e-test-utils-playwright/src/editor/index.ts b/packages/e2e-test-utils-playwright/src/editor/index.ts index 8c10ba370b1a9..c222f68aecc90 100644 --- a/packages/e2e-test-utils-playwright/src/editor/index.ts +++ b/packages/e2e-test-utils-playwright/src/editor/index.ts @@ -22,6 +22,7 @@ import { publishPost } from './publish-post'; import { saveDraft } from './save-draft'; import { selectBlocks } from './select-blocks'; import { setContent } from './set-content'; +import { setPreferences } from './set-preferences'; import { showBlockToolbar } from './show-block-toolbar'; import { saveSiteEditorEntities } from './site-editor'; import { setIsFixedToolbar } from './set-is-fixed-toolbar'; @@ -76,6 +77,8 @@ export class Editor { selectBlocks: typeof selectBlocks = selectBlocks.bind( this ); /** @borrows setContent as this.setContent */ setContent: typeof setContent = setContent.bind( this ); + /** @borrows setPreferences as this.setPreferences */ + setPreferences: typeof setPreferences = setPreferences.bind( this ); /** @borrows showBlockToolbar as this.showBlockToolbar */ showBlockToolbar: typeof showBlockToolbar = showBlockToolbar.bind( this ); /** @borrows setIsFixedToolbar as this.setIsFixedToolbar */ diff --git a/packages/e2e-test-utils-playwright/src/editor/set-preferences.ts b/packages/e2e-test-utils-playwright/src/editor/set-preferences.ts new file mode 100644 index 0000000000000..9e5345db4b9e3 --- /dev/null +++ b/packages/e2e-test-utils-playwright/src/editor/set-preferences.ts @@ -0,0 +1,37 @@ +/** + * Internal dependencies + */ +import type { Editor } from './index'; + +type PreferencesContext = + | 'core/edit-post' + | 'core/edit-site' + | 'core/customize-widgets'; + +/** + * Set the preferences of the editor. + * + * @param this + * @param context Context to set preferences for. + * @param preferences Preferences to set. + */ +export async function setPreferences( + this: Editor, + context: PreferencesContext, + preferences: Record< string, any > +) { + await this.page.waitForFunction( () => window?.wp?.data ); + + await this.page.evaluate( + async ( props ) => { + for ( const [ key, value ] of Object.entries( + props.preferences + ) ) { + await window.wp.data + .dispatch( 'core/preferences' ) + .set( props.context, key, value ); + } + }, + { context, preferences } + ); +} diff --git a/packages/e2e-test-utils-playwright/src/test.ts b/packages/e2e-test-utils-playwright/src/test.ts index 778f71b6d770e..677eff31955bd 100644 --- a/packages/e2e-test-utils-playwright/src/test.ts +++ b/packages/e2e-test-utils-playwright/src/test.ts @@ -119,8 +119,8 @@ const test = base.extend< lighthousePort: number; } >( { - admin: async ( { page, pageUtils }, use ) => { - await use( new Admin( { page, pageUtils } ) ); + admin: async ( { page, pageUtils, editor }, use ) => { + await use( new Admin( { page, pageUtils, editor } ) ); }, editor: async ( { page }, use ) => { await use( new Editor( { page } ) ); diff --git a/test/e2e/specs/editor/blocks/query.spec.js b/test/e2e/specs/editor/blocks/query.spec.js index 79b15222630ef..dbefb66e353bc 100644 --- a/test/e2e/specs/editor/blocks/query.spec.js +++ b/test/e2e/specs/editor/blocks/query.spec.js @@ -21,7 +21,10 @@ test.describe( 'Query block', () => { } ); test.beforeEach( async ( { admin } ) => { - await admin.createNewPost( { postType: 'page', title: 'Query Page' } ); + await admin.createNewPost( { + postType: 'page', + title: 'Query Page', + } ); } ); test.afterEach( async ( { requestUtils } ) => { diff --git a/test/e2e/specs/editor/local/demo.spec.js b/test/e2e/specs/editor/local/demo.spec.js index acfee9296e232..2782461812ea8 100644 --- a/test/e2e/specs/editor/local/demo.spec.js +++ b/test/e2e/specs/editor/local/demo.spec.js @@ -7,21 +7,12 @@ test.describe( 'New editor state', () => { test( 'content should load, making the post dirty', async ( { page, admin, + editor, } ) => { await admin.visitAdminPage( 'post-new.php', 'gutenberg-demo' ); - await page.waitForFunction( () => { - if ( ! window?.wp?.data?.dispatch ) { - return false; - } - window.wp.data - .dispatch( 'core/preferences' ) - .set( 'core/edit-post', 'welcomeGuide', false ); - - window.wp.data - .dispatch( 'core/preferences' ) - .set( 'core/edit-post', 'fullscreenMode', false ); - - return true; + await editor.setPreferences( 'core/edit-site', { + welcomeGuide: false, + fullscreenMode: false, } ); const isDirty = await page.evaluate( () => { diff --git a/test/e2e/specs/editor/various/block-renaming.spec.js b/test/e2e/specs/editor/various/block-renaming.spec.js index 4150be64bd33d..f8d9548fbe866 100644 --- a/test/e2e/specs/editor/various/block-renaming.spec.js +++ b/test/e2e/specs/editor/various/block-renaming.spec.js @@ -15,10 +15,8 @@ test.describe( 'Block Renaming', () => { pageUtils, } ) => { // Turn on block list view by default. - await page.evaluate( () => { - window.wp.data - .dispatch( 'core/preferences' ) - .set( 'core/edit-site', 'showListViewByDefault', true ); + await editor.setPreferences( 'core/edit-site', { + showListViewByDefault: true, } ); const listView = page.getByRole( 'treegrid', { diff --git a/test/e2e/specs/editor/various/post-editor-template-mode.spec.js b/test/e2e/specs/editor/various/post-editor-template-mode.spec.js index 6f8bb5596bf2a..b9bfbf9dd6b05 100644 --- a/test/e2e/specs/editor/various/post-editor-template-mode.spec.js +++ b/test/e2e/specs/editor/various/post-editor-template-mode.spec.js @@ -121,10 +121,8 @@ class PostEditorTemplateMode { async disableTemplateWelcomeGuide() { // Turn off the welcome guide. - await this.page.evaluate( () => { - window.wp.data - .dispatch( 'core/preferences' ) - .set( 'core/edit-post', 'welcomeGuideTemplate', false ); + await this.editor.setPreferences( 'core/edit-post', { + welcomeGuideTemplate: false, } ); } diff --git a/test/e2e/specs/editor/various/preview.spec.js b/test/e2e/specs/editor/various/preview.spec.js index cfec384adba9b..91f222ab8116f 100644 --- a/test/e2e/specs/editor/various/preview.spec.js +++ b/test/e2e/specs/editor/various/preview.spec.js @@ -294,7 +294,10 @@ test.describe( 'Preview with private custom post type', () => { admin, page, } ) => { - await admin.createNewPost( { postType: 'not_public', title: 'aaaaa' } ); + await admin.createNewPost( { + postType: 'not_public', + title: 'aaaaa', + } ); // Open the view menu. await page.click( 'role=button[name="Preview"i]' ); diff --git a/test/e2e/specs/editor/various/switch-to-draft.spec.js b/test/e2e/specs/editor/various/switch-to-draft.spec.js index 59837a3d3c765..5cfeda60a2d18 100644 --- a/test/e2e/specs/editor/various/switch-to-draft.spec.js +++ b/test/e2e/specs/editor/various/switch-to-draft.spec.js @@ -139,20 +139,7 @@ class SwitchToDraftUtils { id = page.id; } - await this.#admin.visitAdminPage( - 'post.php', - `post=${ id }&action=edit` - ); - - // Disable welcome guide and full screen mode. - await this.#page.evaluate( () => { - window.wp.data - .dispatch( 'core/preferences' ) - .set( 'core/edit-post', 'welcomeGuide', false ); - window.wp.data - .dispatch( 'core/preferences' ) - .set( 'core/edit-post', 'fullscreenMode', false ); - } ); + await this.#admin.editPost( id ); }; getPostStatus = async () => { diff --git a/test/e2e/specs/site-editor/list-view.spec.js b/test/e2e/specs/site-editor/list-view.spec.js index ed64574168bd0..74d3559d4e3d2 100644 --- a/test/e2e/specs/site-editor/list-view.spec.js +++ b/test/e2e/specs/site-editor/list-view.spec.js @@ -23,16 +23,15 @@ test.describe( 'Site Editor List View', () => { test( 'should open by default when preference is enabled', async ( { page, + editor, } ) => { await expect( page.locator( 'role=region[name="List View"i]' ) ).toBeHidden(); // Turn on block list view by default. - await page.evaluate( () => { - window.wp.data - .dispatch( 'core/preferences' ) - .set( 'core/edit-site', 'showListViewByDefault', true ); + await editor.setPreferences( 'core/edit-site', { + showListViewByDefault: true, } ); await page.reload(); @@ -42,10 +41,8 @@ test.describe( 'Site Editor List View', () => { ).toBeVisible(); // The preferences cleanup. - await page.evaluate( () => { - window.wp.data - .dispatch( 'core/preferences' ) - .set( 'core/edit-site', 'showListViewByDefault', false ); + await editor.setPreferences( 'core/edit-site', { + showListViewByDefault: false, } ); } ); diff --git a/test/e2e/specs/widgets/customizing-widgets.spec.js b/test/e2e/specs/widgets/customizing-widgets.spec.js index 6a6a51cae2686..34400ea00976e 100644 --- a/test/e2e/specs/widgets/customizing-widgets.spec.js +++ b/test/e2e/specs/widgets/customizing-widgets.spec.js @@ -12,11 +12,17 @@ const { * @typedef {import('@playwright/test').FrameLocator} FrameLocator * @typedef {import('@wordpress/e2e-test-utils-playwright').PageUtils} PageUtils * @typedef {import('@wordpress/e2e-test-utils-playwright').RequestUtils} RequestUtils + * @typedef {import('@wordpress/e2e-test-utils-playwright').Editor} Editor */ test.use( { - widgetsCustomizerPage: async ( { admin, page, pageUtils }, use ) => { - await use( new WidgetsCustomizerPage( { admin, page, pageUtils } ) ); + widgetsCustomizerPage: async ( + { admin, page, pageUtils, editor }, + use + ) => { + await use( + new WidgetsCustomizerPage( { admin, page, pageUtils, editor } ) + ); }, } ); @@ -613,11 +619,13 @@ class WidgetsCustomizerPage { * @param {Admin} config.admin * @param {Page} config.page * @param {PageUtils} config.pageUtils + * @param {Editor} config.editor */ - constructor( { admin, page, pageUtils } ) { + constructor( { admin, page, pageUtils, editor } ) { this.admin = admin; this.page = page; this.pageUtils = pageUtils; + this.editor = editor; /** @type {FrameLocator} */ this.previewFrame = this.page @@ -631,10 +639,8 @@ class WidgetsCustomizerPage { await this.admin.visitAdminPage( 'customize.php' ); // Disable welcome guide. - await this.page.evaluate( () => { - window.wp.data - .dispatch( 'core/preferences' ) - .set( 'core/customize-widgets', 'welcomeGuide', false ); + await this.editor.setPreferences( 'core/customize-widgets', { + welcomeGuide: false, } ); } diff --git a/test/performance/fixtures/perf-utils.ts b/test/performance/fixtures/perf-utils.ts index dcd9579364e10..d17eec2c935b1 100644 --- a/test/performance/fixtures/perf-utils.ts +++ b/test/performance/fixtures/perf-utils.ts @@ -59,7 +59,9 @@ export class PerfUtils { this.page.getByRole( 'button', { name: 'Saved' } ) ).toBeDisabled(); - return this.page.url(); + const postId = new URL( this.page.url() ).searchParams.get( 'post' ); + + return postId; } /** diff --git a/test/performance/specs/post-editor.spec.js b/test/performance/specs/post-editor.spec.js index da20e3c3e667b..d5ff40570afd7 100644 --- a/test/performance/specs/post-editor.spec.js +++ b/test/performance/specs/post-editor.spec.js @@ -48,12 +48,12 @@ test.describe( 'Post Editor Performance', () => { } ); test.describe( 'Loading', () => { - let draftURL = null; + let draftId = null; test( 'Setup the test post', async ( { admin, perfUtils } ) => { await admin.createNewPost(); await perfUtils.loadBlocksForLargePost(); - draftURL = await perfUtils.saveDraft(); + draftId = await perfUtils.saveDraft(); } ); const samples = 10; @@ -61,12 +61,12 @@ test.describe( 'Post Editor Performance', () => { const iterations = samples + throwaway; for ( let i = 1; i <= iterations; i++ ) { test( `Run the test (${ i } of ${ iterations })`, async ( { - page, + admin, perfUtils, metrics, } ) => { // Open the test draft. - await page.goto( draftURL ); + await admin.editPost( draftId ); const canvas = await perfUtils.getCanvas(); // Wait for the first block. @@ -92,17 +92,17 @@ test.describe( 'Post Editor Performance', () => { } ); test.describe( 'Typing', () => { - let draftURL = null; + let draftId = null; test( 'Setup the test post', async ( { admin, perfUtils, editor } ) => { await admin.createNewPost(); await perfUtils.loadBlocksForLargePost(); await editor.insertBlock( { name: 'core/paragraph' } ); - draftURL = await perfUtils.saveDraft(); + draftId = await perfUtils.saveDraft(); } ); - test( 'Run the test', async ( { page, perfUtils, metrics } ) => { - await page.goto( draftURL ); + test( 'Run the test', async ( { admin, perfUtils, metrics } ) => { + await admin.editPost( draftId ); await perfUtils.disableAutosave(); const canvas = await perfUtils.getCanvas(); @@ -145,16 +145,16 @@ test.describe( 'Post Editor Performance', () => { } ); test.describe( 'Typing within containers', () => { - let draftURL = null; + let draftId = null; test( 'Set up the test post', async ( { admin, perfUtils } ) => { await admin.createNewPost(); await perfUtils.loadBlocksForSmallPostWithContainers(); - draftURL = await perfUtils.saveDraft(); + draftId = await perfUtils.saveDraft(); } ); - test( 'Run the test', async ( { page, perfUtils, metrics } ) => { - await page.goto( draftURL ); + test( 'Run the test', async ( { admin, perfUtils, metrics } ) => { + await admin.editPost( draftId ); await perfUtils.disableAutosave(); const canvas = await perfUtils.getCanvas(); @@ -201,16 +201,16 @@ test.describe( 'Post Editor Performance', () => { } ); test.describe( 'Selecting blocks', () => { - let draftURL = null; + let draftId = null; test( 'Set up the test post', async ( { admin, perfUtils } ) => { await admin.createNewPost(); await perfUtils.load1000Paragraphs(); - draftURL = await perfUtils.saveDraft(); + draftId = await perfUtils.saveDraft(); } ); - test( 'Run the test', async ( { page, perfUtils, metrics } ) => { - await page.goto( draftURL ); + test( 'Run the test', async ( { admin, page, perfUtils, metrics } ) => { + await admin.editPost( draftId ); await perfUtils.disableAutosave(); const canvas = await perfUtils.getCanvas(); @@ -251,16 +251,16 @@ test.describe( 'Post Editor Performance', () => { } ); test.describe( 'Opening persistent List View', () => { - let draftURL = null; + let draftId = null; test( 'Set up the test page', async ( { admin, perfUtils } ) => { await admin.createNewPost(); await perfUtils.load1000Paragraphs(); - draftURL = await perfUtils.saveDraft(); + draftId = await perfUtils.saveDraft(); } ); - test( 'Run the test', async ( { page, perfUtils, metrics } ) => { - await page.goto( draftURL ); + test( 'Run the test', async ( { page, admin, perfUtils, metrics } ) => { + await admin.editPost( draftId ); await perfUtils.disableAutosave(); const listViewToggle = page.getByRole( 'button', { @@ -301,17 +301,17 @@ test.describe( 'Post Editor Performance', () => { } ); test.describe( 'Opening Inserter', () => { - let draftURL = null; + let draftId = null; test( 'Set up the test page', async ( { admin, perfUtils } ) => { await admin.createNewPost(); await perfUtils.load1000Paragraphs(); - draftURL = await perfUtils.saveDraft(); + draftId = await perfUtils.saveDraft(); } ); - test( 'Run the test', async ( { page, perfUtils, metrics } ) => { + test( 'Run the test', async ( { page, admin, perfUtils, metrics } ) => { // Go to the test page. - await page.goto( draftURL ); + await admin.editPost( draftId ); await perfUtils.disableAutosave(); const globalInserterToggle = page.getByRole( 'button', { name: 'Toggle block inserter', @@ -357,17 +357,17 @@ test.describe( 'Post Editor Performance', () => { } ); test.describe( 'Searching Inserter', () => { - let draftURL = null; + let draftId = null; test( 'Set up the test page', async ( { admin, perfUtils } ) => { await admin.createNewPost(); await perfUtils.load1000Paragraphs(); - draftURL = await perfUtils.saveDraft(); + draftId = await perfUtils.saveDraft(); } ); - test( 'Run the test', async ( { page, perfUtils, metrics } ) => { + test( 'Run the test', async ( { page, admin, perfUtils, metrics } ) => { // Go to the test page. - await page.goto( draftURL ); + await admin.editPost( draftId ); await perfUtils.disableAutosave(); const globalInserterToggle = page.getByRole( 'button', { name: 'Toggle block inserter', @@ -413,17 +413,17 @@ test.describe( 'Post Editor Performance', () => { } ); test.describe( 'Hovering Inserter items', () => { - let draftURL = null; + let draftId = null; test( 'Set up the test page', async ( { admin, perfUtils } ) => { await admin.createNewPost(); await perfUtils.load1000Paragraphs(); - draftURL = await perfUtils.saveDraft(); + draftId = await perfUtils.saveDraft(); } ); - test( 'Run the test', async ( { page, perfUtils, metrics } ) => { + test( 'Run the test', async ( { page, admin, perfUtils, metrics } ) => { // Go to the test page. - await page.goto( draftURL ); + await admin.editPost( draftId ); await perfUtils.disableAutosave(); const globalInserterToggle = page.getByRole( 'button', {