From fe70678a2dc44ed3fbb7d21da3bea24f93ff5954 Mon Sep 17 00:00:00 2001 From: Bart Kalisz Date: Thu, 5 Oct 2023 14:39:47 +0200 Subject: [PATCH 01/17] Create editor.setPreferences util --- .../src/editor/index.ts | 3 ++ .../src/editor/set-preferences.ts | 32 +++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 packages/e2e-test-utils-playwright/src/editor/set-preferences.ts diff --git a/packages/e2e-test-utils-playwright/src/editor/index.ts b/packages/e2e-test-utils-playwright/src/editor/index.ts index 673149d4e69e0..cd5f629fa885d 100644 --- a/packages/e2e-test-utils-playwright/src/editor/index.ts +++ b/packages/e2e-test-utils-playwright/src/editor/index.ts @@ -21,6 +21,7 @@ import { openPreviewPage } from './preview'; import { publishPost } from './publish-post'; 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'; @@ -73,6 +74,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..df3a7671e0dde --- /dev/null +++ b/packages/e2e-test-utils-playwright/src/editor/set-preferences.ts @@ -0,0 +1,32 @@ +/** + * Internal dependencies + */ +import type { Editor } from './index'; + +interface PreferencesRepresentation { + welcomeGuide?: boolean; + fullscreenMode?: boolean; +} + +/** + * Set the preferences of the editor. + * + * @param this + * @param preferences Preferences to set. + */ +async function setPreferences( + this: Editor, + preferences: PreferencesRepresentation +) { + await this.page.waitForFunction( () => window?.wp?.data ); + + await this.page.evaluate( async ( _preferences ) => { + for ( const [ key, value ] of Object.entries( _preferences ) ) { + await window.wp.data + .dispatch( 'core/preferences' ) + .set( 'core/edit-post', key, value ); + } + }, preferences ); +} + +export { setPreferences }; From aecd765af1f17029ff246c7984d0898a7493cf3d Mon Sep 17 00:00:00 2001 From: Bart Kalisz Date: Thu, 5 Oct 2023 14:40:26 +0200 Subject: [PATCH 02/17] Migrate createNewPost to TS; use editor.setPreferences --- .../src/admin/create-new-post.js | 47 ------------------- .../src/admin/create-new-post.ts | 42 +++++++++++++++++ .../src/admin/index.ts | 10 ++-- .../e2e-test-utils-playwright/src/test.ts | 4 +- 4 files changed, 51 insertions(+), 52 deletions(-) delete mode 100644 packages/e2e-test-utils-playwright/src/admin/create-new-post.js create mode 100644 packages/e2e-test-utils-playwright/src/admin/create-new-post.ts 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..88e5957dd54b8 --- /dev/null +++ b/packages/e2e-test-utils-playwright/src/admin/create-new-post.ts @@ -0,0 +1,42 @@ +/** + * WordPress dependencies + */ +import { addQueryArgs } from '@wordpress/url'; + +/** + * 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 = addQueryArgs( '', { + post_type: options.postType, + post_title: options.title, + content: options.content, + excerpt: options.excerpt, + } ).slice( 1 ); + + await this.visitAdminPage( 'post-new.php', query ); + + await this.editor.setPreferences( { + welcomeGuide: options.showWelcomeGuide ?? 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..bf30abac6357c 100644 --- a/packages/e2e-test-utils-playwright/src/admin/index.ts +++ b/packages/e2e-test-utils-playwright/src/admin/index.ts @@ -11,23 +11,27 @@ import { getPageError } from './get-page-error'; import { visitAdminPage } from './visit-admin-page'; 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 */ 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 } ) ); From ecef484feeccf646fa769bba2946fb9cb84fedb1 Mon Sep 17 00:00:00 2001 From: Bart Kalisz Date: Thu, 5 Oct 2023 15:10:14 +0200 Subject: [PATCH 03/17] Create visitPostEditor util --- .../src/admin/index.ts | 3 + .../src/admin/visit-post-editor.ts | 41 +++++++++++ .../src/editor/set-preferences.ts | 4 +- test/performance/fixtures/perf-utils.ts | 4 +- test/performance/specs/post-editor.spec.js | 71 ++++++++++--------- 5 files changed, 86 insertions(+), 37 deletions(-) create mode 100644 packages/e2e-test-utils-playwright/src/admin/visit-post-editor.ts diff --git a/packages/e2e-test-utils-playwright/src/admin/index.ts b/packages/e2e-test-utils-playwright/src/admin/index.ts index bf30abac6357c..06934bdd150f3 100644 --- a/packages/e2e-test-utils-playwright/src/admin/index.ts +++ b/packages/e2e-test-utils-playwright/src/admin/index.ts @@ -9,6 +9,7 @@ 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 { visitPostEditor } from './visit-post-editor'; import { visitSiteEditor } from './visit-site-editor'; import type { PageUtils } from '../page-utils'; import type { Editor } from '../editor'; @@ -40,6 +41,8 @@ export class Admin { getPageError: typeof getPageError = getPageError.bind( this ); /** @borrows visitAdminPage as this.visitAdminPage */ visitAdminPage: typeof visitAdminPage = visitAdminPage.bind( this ); + /** @borrows visitPostEditor as this.visitPostEditor */ + visitPostEditor: typeof visitPostEditor = visitPostEditor.bind( this ); /** @borrows visitSiteEditor as this.visitSiteEditor */ visitSiteEditor: typeof visitSiteEditor = visitSiteEditor.bind( this ); } diff --git a/packages/e2e-test-utils-playwright/src/admin/visit-post-editor.ts b/packages/e2e-test-utils-playwright/src/admin/visit-post-editor.ts new file mode 100644 index 0000000000000..5640ad5fe23d2 --- /dev/null +++ b/packages/e2e-test-utils-playwright/src/admin/visit-post-editor.ts @@ -0,0 +1,41 @@ +/** + * WordPress dependencies + */ +import { addQueryArgs } from '@wordpress/url'; + +/** + * Internal dependencies + */ +import type { Admin } from './'; + +interface PostOptions { + postId?: string | number; + showWelcomeGuide?: boolean; +} + +/** + * Creates new post. + * + * @param this + * @param options Options to create new post. + */ +export async function visitPostEditor( + this: Admin, + options: PostOptions = {} +) { + if ( typeof options.postId === 'undefined' ) { + throw new Error( 'postId is required.' ); + } + + const query = addQueryArgs( '', { + post: options.postId, + action: 'edit', + } ).slice( 1 ); + + await this.visitAdminPage( 'post.php', query ); + + await this.editor.setPreferences( { + welcomeGuide: options.showWelcomeGuide ?? false, + fullscreenMode: false, + } ); +} diff --git a/packages/e2e-test-utils-playwright/src/editor/set-preferences.ts b/packages/e2e-test-utils-playwright/src/editor/set-preferences.ts index df3a7671e0dde..59629297f16b1 100644 --- a/packages/e2e-test-utils-playwright/src/editor/set-preferences.ts +++ b/packages/e2e-test-utils-playwright/src/editor/set-preferences.ts @@ -14,7 +14,7 @@ interface PreferencesRepresentation { * @param this * @param preferences Preferences to set. */ -async function setPreferences( +export async function setPreferences( this: Editor, preferences: PreferencesRepresentation ) { @@ -28,5 +28,3 @@ async function setPreferences( } }, preferences ); } - -export { setPreferences }; diff --git a/test/performance/fixtures/perf-utils.ts b/test/performance/fixtures/perf-utils.ts index a61af86684e6b..8efda3de64352 100644 --- a/test/performance/fixtures/perf-utils.ts +++ b/test/performance/fixtures/perf-utils.ts @@ -68,7 +68,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 7f59033046527..6001f0d938cf4 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.visitPostEditor( { postId: draftId } ); const canvas = await perfUtils.getCanvas(); // Wait for the first block. @@ -94,17 +94,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.visitPostEditor( { postId: draftId } ); await perfUtils.disableAutosave(); const canvas = await perfUtils.getCanvas(); @@ -147,16 +147,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.visitPostEditor( { postId: draftId } ); await perfUtils.disableAutosave(); const canvas = await perfUtils.getCanvas(); @@ -203,16 +203,21 @@ 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, + editor, + perfUtils, + metrics, + } ) => { + await admin.visitPostEditor( { postId: draftId } ); await perfUtils.disableAutosave(); const canvas = await perfUtils.getCanvas(); @@ -226,7 +231,7 @@ test.describe( 'Post Editor Performance', () => { for ( let i = 1; i <= iterations; i++ ) { // Wait for the browser to be idle before starting the monitoring. // eslint-disable-next-line no-restricted-syntax - await page.waitForTimeout( BROWSER_IDLE_WAIT ); + await editor.waitForTimeout( BROWSER_IDLE_WAIT ); // Start tracing. await metrics.startTracing(); @@ -253,16 +258,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.visitPostEditor( { postId: draftId } ); await perfUtils.disableAutosave(); const listViewToggle = page.getByRole( 'button', { @@ -303,17 +308,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.visitPostEditor( { postId: draftId } ); await perfUtils.disableAutosave(); const globalInserterToggle = page.getByRole( 'button', { name: 'Toggle block inserter', @@ -359,17 +364,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.visitPostEditor( { postId: draftId } ); await perfUtils.disableAutosave(); const globalInserterToggle = page.getByRole( 'button', { name: 'Toggle block inserter', @@ -415,17 +420,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.visitPostEditor( { postId: draftId } ); await perfUtils.disableAutosave(); const globalInserterToggle = page.getByRole( 'button', { From 86c8f797e47e98b636dafc0769b3431dcaab20fe Mon Sep 17 00:00:00 2001 From: Bart Kalisz Date: Thu, 5 Oct 2023 15:21:25 +0200 Subject: [PATCH 04/17] Allow for setting preferences context --- .../src/admin/create-new-post.ts | 2 +- .../src/admin/visit-post-editor.ts | 2 +- .../src/editor/set-preferences.ts | 9 ++++++++- 3 files changed, 10 insertions(+), 3 deletions(-) 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 index 88e5957dd54b8..76b9e47a4779d 100644 --- a/packages/e2e-test-utils-playwright/src/admin/create-new-post.ts +++ b/packages/e2e-test-utils-playwright/src/admin/create-new-post.ts @@ -35,7 +35,7 @@ export async function createNewPost( await this.visitAdminPage( 'post-new.php', query ); - await this.editor.setPreferences( { + await this.editor.setPreferences( 'core/edit-post', { welcomeGuide: options.showWelcomeGuide ?? false, fullscreenMode: false, } ); diff --git a/packages/e2e-test-utils-playwright/src/admin/visit-post-editor.ts b/packages/e2e-test-utils-playwright/src/admin/visit-post-editor.ts index 5640ad5fe23d2..0730509628c6a 100644 --- a/packages/e2e-test-utils-playwright/src/admin/visit-post-editor.ts +++ b/packages/e2e-test-utils-playwright/src/admin/visit-post-editor.ts @@ -34,7 +34,7 @@ export async function visitPostEditor( await this.visitAdminPage( 'post.php', query ); - await this.editor.setPreferences( { + await this.editor.setPreferences( 'core/edit-post', { welcomeGuide: options.showWelcomeGuide ?? false, fullscreenMode: false, } ); diff --git a/packages/e2e-test-utils-playwright/src/editor/set-preferences.ts b/packages/e2e-test-utils-playwright/src/editor/set-preferences.ts index 59629297f16b1..794793cbc793c 100644 --- a/packages/e2e-test-utils-playwright/src/editor/set-preferences.ts +++ b/packages/e2e-test-utils-playwright/src/editor/set-preferences.ts @@ -3,6 +3,11 @@ */ import type { Editor } from './index'; +type PreferencesContext = + | 'core/edit-post' + | 'core/edit-site' + | 'core/customize-widgets'; + interface PreferencesRepresentation { welcomeGuide?: boolean; fullscreenMode?: boolean; @@ -12,10 +17,12 @@ interface PreferencesRepresentation { * 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: PreferencesRepresentation ) { await this.page.waitForFunction( () => window?.wp?.data ); @@ -24,7 +31,7 @@ export async function setPreferences( for ( const [ key, value ] of Object.entries( _preferences ) ) { await window.wp.data .dispatch( 'core/preferences' ) - .set( 'core/edit-post', key, value ); + .set( context, key, value ); } }, preferences ); } From a3c356e83d632e3d5a71db719ceb69553764b0e1 Mon Sep 17 00:00:00 2001 From: Bart Kalisz Date: Thu, 5 Oct 2023 17:02:13 +0200 Subject: [PATCH 05/17] Pass context correctly --- .../src/editor/set-preferences.ts | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/packages/e2e-test-utils-playwright/src/editor/set-preferences.ts b/packages/e2e-test-utils-playwright/src/editor/set-preferences.ts index 794793cbc793c..4a69a0bee2433 100644 --- a/packages/e2e-test-utils-playwright/src/editor/set-preferences.ts +++ b/packages/e2e-test-utils-playwright/src/editor/set-preferences.ts @@ -8,11 +8,6 @@ type PreferencesContext = | 'core/edit-site' | 'core/customize-widgets'; -interface PreferencesRepresentation { - welcomeGuide?: boolean; - fullscreenMode?: boolean; -} - /** * Set the preferences of the editor. * @@ -23,15 +18,18 @@ interface PreferencesRepresentation { export async function setPreferences( this: Editor, context: PreferencesContext, - preferences: PreferencesRepresentation + preferences: Record< string, any > ) { await this.page.waitForFunction( () => window?.wp?.data ); - await this.page.evaluate( async ( _preferences ) => { - for ( const [ key, value ] of Object.entries( _preferences ) ) { - await window.wp.data - .dispatch( 'core/preferences' ) - .set( context, key, value ); - } - }, preferences ); + await this.page.evaluate( + async ( [ _context, _preferences ] ) => { + for ( const [ key, value ] of Object.entries( _preferences ) ) { + await window.wp.data + .dispatch( 'core/preferences' ) + .set( _context, key, value ); + } + }, + [ context, preferences ] + ); } From 8ac5f11d41308aadacd413ae9a520a29605f6bbe Mon Sep 17 00:00:00 2001 From: Bart Kalisz Date: Thu, 5 Oct 2023 17:02:30 +0200 Subject: [PATCH 06/17] Make visitSiteEditor consistent with other utils --- .../src/admin/visit-site-editor.ts | 64 ++++++------------- 1 file changed, 21 insertions(+), 43 deletions(-) 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..6560850225bbe 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 @@ -8,64 +8,42 @@ import { addQueryArgs } from '@wordpress/url'; */ 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, + const query = addQueryArgs( '', { + postId: options.postId, + postType: options.postType, + path: options.path, + canvas: options.canvas, } ).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 ); + await this.visitAdminPage( 'site-editor.php', query ); - window.wp.data - .dispatch( 'core/preferences' ) - .set( 'core/edit-site', 'welcomeGuidePage', false ); - - window.wp.data - .dispatch( 'core/preferences' ) - .set( 'core/edit-site', 'welcomeGuideTemplate', false ); + 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. await this.page .locator( '.edit-site-canvas-loader' ) From 148c15b8cba05abd49fc272b450206efd73dbe39 Mon Sep 17 00:00:00 2001 From: Bart Kalisz Date: Thu, 5 Oct 2023 17:18:04 +0200 Subject: [PATCH 07/17] Update tests to use editor.setPreferences() --- .../src/admin/visit-post-editor.ts | 3 ++- test/e2e/specs/editor/local/demo.spec.js | 17 ++++------------ .../editor/various/block-renaming.spec.js | 6 ++---- .../various/post-editor-template-mode.spec.js | 6 ++---- .../editor/various/switch-to-draft.spec.js | 16 +++------------ test/e2e/specs/site-editor/list-view.spec.js | 13 +++++------- .../specs/widgets/customizing-widgets.spec.js | 20 ++++++++++++------- 7 files changed, 31 insertions(+), 50 deletions(-) diff --git a/packages/e2e-test-utils-playwright/src/admin/visit-post-editor.ts b/packages/e2e-test-utils-playwright/src/admin/visit-post-editor.ts index 0730509628c6a..c5f9b15ee811b 100644 --- a/packages/e2e-test-utils-playwright/src/admin/visit-post-editor.ts +++ b/packages/e2e-test-utils-playwright/src/admin/visit-post-editor.ts @@ -10,6 +10,7 @@ import type { Admin } from './'; interface PostOptions { postId?: string | number; + action?: string; showWelcomeGuide?: boolean; } @@ -29,7 +30,7 @@ export async function visitPostEditor( const query = addQueryArgs( '', { post: options.postId, - action: 'edit', + action: options.action, } ).slice( 1 ); await this.visitAdminPage( 'post.php', query ); 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 1c8a958b23fd4..bbd57489c906d 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 629a437a41665..2f44c34a06521 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/switch-to-draft.spec.js b/test/e2e/specs/editor/various/switch-to-draft.spec.js index 59837a3d3c765..0c516b5422401 100644 --- a/test/e2e/specs/editor/various/switch-to-draft.spec.js +++ b/test/e2e/specs/editor/various/switch-to-draft.spec.js @@ -139,19 +139,9 @@ 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.visitPostEditor( { + postId: id, + action: 'edit', } ); }; 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, } ); } From ddfd8692feaafc8ceeca747ec538599395a8ea15 Mon Sep 17 00:00:00 2001 From: Bart Kalisz Date: Wed, 11 Oct 2023 12:02:13 +0200 Subject: [PATCH 08/17] Make action param fixed It's necessary for the post to open in the editor and not redirect to the edit.php page --- .../e2e-test-utils-playwright/src/admin/visit-post-editor.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/e2e-test-utils-playwright/src/admin/visit-post-editor.ts b/packages/e2e-test-utils-playwright/src/admin/visit-post-editor.ts index c5f9b15ee811b..0730509628c6a 100644 --- a/packages/e2e-test-utils-playwright/src/admin/visit-post-editor.ts +++ b/packages/e2e-test-utils-playwright/src/admin/visit-post-editor.ts @@ -10,7 +10,6 @@ import type { Admin } from './'; interface PostOptions { postId?: string | number; - action?: string; showWelcomeGuide?: boolean; } @@ -30,7 +29,7 @@ export async function visitPostEditor( const query = addQueryArgs( '', { post: options.postId, - action: options.action, + action: 'edit', } ).slice( 1 ); await this.visitAdminPage( 'post.php', query ); From 256f5b930fcd58f6268f7ddb89b549500ca9d5a4 Mon Sep 17 00:00:00 2001 From: Bart Kalisz Date: Wed, 11 Oct 2023 12:02:37 +0200 Subject: [PATCH 09/17] Update specs --- test/e2e/specs/editor/various/switch-to-draft.spec.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) 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 0c516b5422401..60a1b89ae9563 100644 --- a/test/e2e/specs/editor/various/switch-to-draft.spec.js +++ b/test/e2e/specs/editor/various/switch-to-draft.spec.js @@ -139,10 +139,7 @@ class SwitchToDraftUtils { id = page.id; } - await this.#admin.visitPostEditor( { - postId: id, - action: 'edit', - } ); + await this.#admin.visitPostEditor( { postId: id } ); }; getPostStatus = async () => { From 34f93b329f0c23718817febc7fbfca2b8b47b26b Mon Sep 17 00:00:00 2001 From: Bart Kalisz Date: Wed, 11 Oct 2023 12:03:05 +0200 Subject: [PATCH 10/17] Pass props as object to evaluate call --- .../src/editor/set-preferences.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/e2e-test-utils-playwright/src/editor/set-preferences.ts b/packages/e2e-test-utils-playwright/src/editor/set-preferences.ts index 4a69a0bee2433..9e5345db4b9e3 100644 --- a/packages/e2e-test-utils-playwright/src/editor/set-preferences.ts +++ b/packages/e2e-test-utils-playwright/src/editor/set-preferences.ts @@ -23,13 +23,15 @@ export async function setPreferences( await this.page.waitForFunction( () => window?.wp?.data ); await this.page.evaluate( - async ( [ _context, _preferences ] ) => { - for ( const [ key, value ] of Object.entries( _preferences ) ) { + async ( props ) => { + for ( const [ key, value ] of Object.entries( + props.preferences + ) ) { await window.wp.data .dispatch( 'core/preferences' ) - .set( _context, key, value ); + .set( props.context, key, value ); } }, - [ context, preferences ] + { context, preferences } ); } From 59720fe6b5072c37063c43887339ecd2653ca003 Mon Sep 17 00:00:00 2001 From: Bart Kalisz Date: Tue, 17 Oct 2023 14:48:20 +0200 Subject: [PATCH 11/17] Merge createNewPost into visitPostEditor Combine the two utils leaving only the latter. Update tests accordingly. --- .../src/admin/create-new-post.ts | 42 ----------------- .../src/admin/index.ts | 3 -- .../src/admin/visit-post-editor.ts | 45 ++++++++++++------- test/e2e/specs/editor/blocks/avatar.spec.js | 2 +- test/e2e/specs/editor/blocks/buttons.spec.js | 2 +- test/e2e/specs/editor/blocks/classic.spec.js | 2 +- test/e2e/specs/editor/blocks/code.spec.js | 2 +- test/e2e/specs/editor/blocks/columns.spec.js | 2 +- test/e2e/specs/editor/blocks/comments.spec.js | 12 ++--- test/e2e/specs/editor/blocks/cover.spec.js | 2 +- test/e2e/specs/editor/blocks/gallery.spec.js | 10 ++--- test/e2e/specs/editor/blocks/group.spec.js | 2 +- test/e2e/specs/editor/blocks/heading.spec.js | 2 +- test/e2e/specs/editor/blocks/html.spec.js | 2 +- test/e2e/specs/editor/blocks/image.spec.js | 4 +- test/e2e/specs/editor/blocks/links.spec.js | 6 +-- test/e2e/specs/editor/blocks/list.spec.js | 2 +- test/e2e/specs/editor/blocks/missing.spec.js | 2 +- .../editor/blocks/navigation-colors.spec.js | 2 +- .../blocks/navigation-list-view.spec.js | 2 +- .../specs/editor/blocks/navigation.spec.js | 16 +++---- .../e2e/specs/editor/blocks/paragraph.spec.js | 2 +- .../specs/editor/blocks/post-title.spec.js | 2 +- .../specs/editor/blocks/preformatted.spec.js | 2 +- .../e2e/specs/editor/blocks/pullquote.spec.js | 2 +- test/e2e/specs/editor/blocks/query.spec.js | 5 ++- test/e2e/specs/editor/blocks/quote.spec.js | 2 +- test/e2e/specs/editor/blocks/search.spec.js | 2 +- .../e2e/specs/editor/blocks/separator.spec.js | 2 +- test/e2e/specs/editor/blocks/spacer.spec.js | 2 +- test/e2e/specs/editor/blocks/table.spec.js | 2 +- .../blocks/verse-code-preformatted.spec.js | 2 +- .../editor/plugins/allowed-blocks.spec.js | 2 +- .../specs/editor/plugins/block-api.spec.js | 2 +- .../editor/plugins/block-variations.spec.js | 2 +- .../editor/plugins/custom-post-types.spec.js | 6 +-- .../plugins/deprecated-node-matcher.spec.js | 2 +- .../specs/editor/plugins/format-api.spec.js | 2 +- .../specs/editor/plugins/hooks-api.spec.js | 2 +- .../editor/plugins/iframed-block.spec.js | 2 +- ...amed-enqueue-block-editor-settings.spec.js | 2 +- .../iframed-equeue-block-assets.spec.js | 2 +- .../plugins/iframed-inline-styles.spec.js | 2 +- .../plugins/iframed-masonry-block.spec.js | 2 +- ...iframed-multiple-block-stylesheets.spec.js | 2 +- .../specs/editor/plugins/image-size.spec.js | 2 +- .../inner-blocks-allowed-blocks.spec.js | 2 +- test/e2e/specs/editor/plugins/nonce.spec.js | 2 +- .../plugins/post-type-templates.spec.js | 8 ++-- .../plugins/register-block-type-hooks.spec.js | 2 +- .../editor/plugins/wp-editor-meta-box.spec.js | 2 +- .../various/a11y-region-navigation.spec.js | 2 +- test/e2e/specs/editor/various/a11y.spec.js | 2 +- .../various/adding-inline-tokens.spec.js | 2 +- .../editor/various/adding-patterns.spec.js | 2 +- .../various/autocomplete-and-mentions.spec.js | 2 +- .../editor/various/block-deletion.spec.js | 2 +- .../block-hierarchy-navigation.spec.js | 2 +- .../editor/various/block-locking.spec.js | 2 +- .../specs/editor/various/block-mover.spec.js | 2 +- .../editor/various/block-moving-mode.spec.js | 2 +- .../editor/various/block-renaming.spec.js | 2 +- .../various/block-switcher-test.spec.js | 2 +- .../compatibility-classic-editor.spec.js | 2 +- .../editor/various/content-only-lock.spec.js | 2 +- .../editor/various/convert-block-type.spec.js | 2 +- .../editor/various/copy-cut-paste.spec.js | 2 +- .../editor/various/draggable-blocks.spec.js | 2 +- .../editor/various/duplicating-blocks.spec.js | 2 +- .../editor/various/font-size-picker.spec.js | 2 +- .../specs/editor/various/footnotes.spec.js | 2 +- .../various/format-library/text-color.spec.js | 2 +- .../editor/various/fullscreen-mode.spec.js | 2 +- .../various/inner-blocks-templates.spec.js | 2 +- .../editor/various/inserting-blocks.spec.js | 12 ++--- .../keep-styles-on-block-transforms.spec.js | 2 +- .../various/keyboard-navigable-blocks.spec.js | 2 +- .../specs/editor/various/list-view.spec.js | 2 +- .../e2e/specs/editor/various/mentions.spec.js | 2 +- .../various/multi-block-selection.spec.js | 2 +- .../editor/various/navigable-toolbar.spec.js | 2 +- .../various/new-post-default-content.spec.js | 2 +- .../e2e/specs/editor/various/new-post.spec.js | 10 ++--- .../e2e/specs/editor/various/patterns.spec.js | 2 +- .../e2e/specs/editor/various/popovers.spec.js | 2 +- .../various/post-editor-template-mode.spec.js | 2 +- .../editor/various/post-visibility.spec.js | 6 +-- test/e2e/specs/editor/various/preview.spec.js | 9 ++-- .../editor/various/publish-panel.spec.js | 2 +- .../rich-text-deprecated-multiline.spec.js | 2 +- .../specs/editor/various/rich-text.spec.js | 2 +- test/e2e/specs/editor/various/rtl.spec.js | 2 +- .../various/shortcut-focus-toolbar.spec.js | 2 +- .../editor/various/shortcut-help.spec.js | 2 +- .../editor/various/splitting-merging.spec.js | 2 +- .../editor/various/style-variation.spec.js | 2 +- .../various/toolbar-roving-tabindex.spec.js | 2 +- test/e2e/specs/editor/various/undo.spec.js | 2 +- .../specs/editor/various/writing-flow.spec.js | 2 +- test/performance/specs/post-editor.spec.js | 16 +++---- test/performance/specs/site-editor.spec.js | 4 +- 101 files changed, 177 insertions(+), 205 deletions(-) delete mode 100644 packages/e2e-test-utils-playwright/src/admin/create-new-post.ts 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 deleted file mode 100644 index 76b9e47a4779d..0000000000000 --- a/packages/e2e-test-utils-playwright/src/admin/create-new-post.ts +++ /dev/null @@ -1,42 +0,0 @@ -/** - * WordPress dependencies - */ -import { addQueryArgs } from '@wordpress/url'; - -/** - * 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 = addQueryArgs( '', { - post_type: options.postType, - post_title: options.title, - content: options.content, - excerpt: options.excerpt, - } ).slice( 1 ); - - await this.visitAdminPage( 'post-new.php', query ); - - await this.editor.setPreferences( 'core/edit-post', { - welcomeGuide: options.showWelcomeGuide ?? 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 06934bdd150f3..e2d9c7697f2a2 100644 --- a/packages/e2e-test-utils-playwright/src/admin/index.ts +++ b/packages/e2e-test-utils-playwright/src/admin/index.ts @@ -6,7 +6,6 @@ import type { Browser, Page, BrowserContext } from '@playwright/test'; /** * Internal dependencies */ -import { createNewPost } from './create-new-post'; import { getPageError } from './get-page-error'; import { visitAdminPage } from './visit-admin-page'; import { visitPostEditor } from './visit-post-editor'; @@ -35,8 +34,6 @@ export class Admin { this.editor = editor; } - /** @borrows createNewPost as this.createNewPost */ - createNewPost: typeof createNewPost = createNewPost.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-post-editor.ts b/packages/e2e-test-utils-playwright/src/admin/visit-post-editor.ts index 0730509628c6a..a0b0662e52e4b 100644 --- a/packages/e2e-test-utils-playwright/src/admin/visit-post-editor.ts +++ b/packages/e2e-test-utils-playwright/src/admin/visit-post-editor.ts @@ -1,38 +1,49 @@ -/** - * WordPress dependencies - */ -import { addQueryArgs } from '@wordpress/url'; - /** * Internal dependencies */ import type { Admin } from './'; -interface PostOptions { +interface PostEditorOptions { postId?: string | number; + postType?: string; + title?: string; + content?: string; + excerpt?: string; showWelcomeGuide?: boolean; } /** - * Creates new post. + * Creates new post or visits existing post if postId is provided. * * @param this - * @param options Options to create new post. + * @param options Options to create or visit post. */ export async function visitPostEditor( this: Admin, - options: PostOptions = {} + options: PostEditorOptions = {} ) { - if ( typeof options.postId === 'undefined' ) { - throw new Error( 'postId is required.' ); - } + const query = new URLSearchParams(); + let adminPage: string; + + if ( options.postId ) { + const { postId } = options; - const query = addQueryArgs( '', { - post: options.postId, - action: 'edit', - } ).slice( 1 ); + adminPage = 'post.php'; + + query.set( 'post', String( postId ) ); + query.set( 'action', 'edit' ); + } else { + const { postType, title, content, excerpt } = options; + + adminPage = 'post-new.php'; + + 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.php', query ); + await this.visitAdminPage( adminPage, query.toString() ); await this.editor.setPreferences( 'core/edit-post', { welcomeGuide: options.showWelcomeGuide ?? false, diff --git a/test/e2e/specs/editor/blocks/avatar.spec.js b/test/e2e/specs/editor/blocks/avatar.spec.js index 8bf39a7a60dba..b02120f6e46c6 100644 --- a/test/e2e/specs/editor/blocks/avatar.spec.js +++ b/test/e2e/specs/editor/blocks/avatar.spec.js @@ -19,7 +19,7 @@ test.describe( 'Avatar', () => { password: 'gravatargravatar123magic', } ); - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test.afterEach( async ( { requestUtils } ) => { diff --git a/test/e2e/specs/editor/blocks/buttons.spec.js b/test/e2e/specs/editor/blocks/buttons.spec.js index dcddfca2b5b28..d986b2a106090 100644 --- a/test/e2e/specs/editor/blocks/buttons.spec.js +++ b/test/e2e/specs/editor/blocks/buttons.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Buttons', () => { test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test( 'has focus on button content', async ( { editor, page } ) => { diff --git a/test/e2e/specs/editor/blocks/classic.spec.js b/test/e2e/specs/editor/blocks/classic.spec.js index 95d39906b0d8b..5ed43f2097ade 100644 --- a/test/e2e/specs/editor/blocks/classic.spec.js +++ b/test/e2e/specs/editor/blocks/classic.spec.js @@ -19,7 +19,7 @@ test.use( { test.describe( 'Classic', () => { test.beforeEach( async ( { admin, editor } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); // To do: run with iframe. await editor.switchToLegacyCanvas(); } ); diff --git a/test/e2e/specs/editor/blocks/code.spec.js b/test/e2e/specs/editor/blocks/code.spec.js index 6abfb15d10b83..6fdcb6dc9a5e5 100644 --- a/test/e2e/specs/editor/blocks/code.spec.js +++ b/test/e2e/specs/editor/blocks/code.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Code', () => { test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test( 'can be created by three backticks and enter', async ( { diff --git a/test/e2e/specs/editor/blocks/columns.spec.js b/test/e2e/specs/editor/blocks/columns.spec.js index bcb23c9a24099..78c80439314fa 100644 --- a/test/e2e/specs/editor/blocks/columns.spec.js +++ b/test/e2e/specs/editor/blocks/columns.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Columns', () => { test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test.afterEach( async ( { requestUtils } ) => { diff --git a/test/e2e/specs/editor/blocks/comments.spec.js b/test/e2e/specs/editor/blocks/comments.spec.js index 7fddb22f6a763..8bd7b59631ce4 100644 --- a/test/e2e/specs/editor/blocks/comments.spec.js +++ b/test/e2e/specs/editor/blocks/comments.spec.js @@ -48,7 +48,7 @@ test.describe( 'Comments', () => { requestUtils, } ) => { await requestUtils.deleteAllComments(); - await admin.createNewPost(); + await admin.visitPostEditor(); await editor.insertBlock( { name: 'core/comments' } ); await expect( editor.canvas.locator( @@ -63,7 +63,7 @@ test.describe( 'Comments', () => { page, requestUtils, } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); await editor.insertBlock( { name: 'core/comments' } ); const postId = await editor.publishPost(); @@ -117,7 +117,7 @@ test.describe( 'Comments', () => { commentsBlockUtils, } ) => { await commentsBlockUtils.setOption( 'page_comments', '0' ); - await admin.createNewPost(); + await admin.visitPostEditor(); await editor.insertBlock( { name: 'core/comments' } ); const postId = await editor.publishPost(); @@ -147,7 +147,7 @@ test.describe( 'Comments', () => { admin, editor, } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); await editor.insertBlock( { name: 'core/comments', attributes: { legacy: true, textColor: 'vivid-purple' }, @@ -184,7 +184,7 @@ test.describe( 'Comments', () => { editor, requestUtils, } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); await editor.insertBlock( { name: 'core/comments' } ); const postId = await editor.publishPost(); @@ -212,7 +212,7 @@ test.describe( 'Comments', () => { editor, requestUtils, } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); await editor.insertBlock( { name: 'core/comments', attributes: { legacy: true }, diff --git a/test/e2e/specs/editor/blocks/cover.spec.js b/test/e2e/specs/editor/blocks/cover.spec.js index fa5103ebaa4ee..0a11de3b4abde 100644 --- a/test/e2e/specs/editor/blocks/cover.spec.js +++ b/test/e2e/specs/editor/blocks/cover.spec.js @@ -21,7 +21,7 @@ test.use( { test.describe( 'Cover', () => { test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test( 'can set overlay color using color picker on block placeholder', async ( { diff --git a/test/e2e/specs/editor/blocks/gallery.spec.js b/test/e2e/specs/editor/blocks/gallery.spec.js index ef693cb8b5bb9..d2b7f0462404f 100644 --- a/test/e2e/specs/editor/blocks/gallery.spec.js +++ b/test/e2e/specs/editor/blocks/gallery.spec.js @@ -45,7 +45,7 @@ test.describe( 'Gallery', () => { page, pageUtils, } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); pageUtils.setClipboardData( { plainText: `[gallery ids="${ uploadedMedia.id }"]`, @@ -91,7 +91,7 @@ test.describe( 'Gallery', () => { editor, galleryBlockUtils, } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); await editor.insertBlock( { name: 'core/gallery' } ); const galleryBlock = editor.canvas.locator( 'role=document[name="Block: Gallery"i]' @@ -119,7 +119,7 @@ test.describe( 'Gallery', () => { } ) => { const galleryCaption = 'Tested gallery caption'; - await admin.createNewPost(); + await admin.visitPostEditor(); await editor.insertBlock( { name: 'core/gallery', innerBlocks: [ @@ -162,7 +162,7 @@ test.describe( 'Gallery', () => { } ) => { const caption = 'Tested caption'; - await admin.createNewPost(); + await admin.visitPostEditor(); await editor.insertBlock( { name: 'core/gallery', innerBlocks: [ @@ -204,7 +204,7 @@ test.describe( 'Gallery', () => { editor, page, } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); await editor.insertBlock( { name: 'core/gallery' } ); await editor.canvas .locator( 'role=button[name="Media Library"i]' ) diff --git a/test/e2e/specs/editor/blocks/group.spec.js b/test/e2e/specs/editor/blocks/group.spec.js index ccf522d8c4d53..cf493cd694b9e 100644 --- a/test/e2e/specs/editor/blocks/group.spec.js +++ b/test/e2e/specs/editor/blocks/group.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Group', () => { test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test( 'can be created using the block inserter', async ( { diff --git a/test/e2e/specs/editor/blocks/heading.spec.js b/test/e2e/specs/editor/blocks/heading.spec.js index 705bce2c3f2c9..f9ed8dec4e9f3 100644 --- a/test/e2e/specs/editor/blocks/heading.spec.js +++ b/test/e2e/specs/editor/blocks/heading.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Heading', () => { test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test( 'can be created by prefixing number sign and a space', async ( { diff --git a/test/e2e/specs/editor/blocks/html.spec.js b/test/e2e/specs/editor/blocks/html.spec.js index f034da6efe617..6f981fdc5e616 100644 --- a/test/e2e/specs/editor/blocks/html.spec.js +++ b/test/e2e/specs/editor/blocks/html.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'HTML block', () => { test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test( 'can be created by typing "/html"', async ( { editor, page } ) => { diff --git a/test/e2e/specs/editor/blocks/image.spec.js b/test/e2e/specs/editor/blocks/image.spec.js index db3ff72e3ab6e..0caa22839236f 100644 --- a/test/e2e/specs/editor/blocks/image.spec.js +++ b/test/e2e/specs/editor/blocks/image.spec.js @@ -25,7 +25,7 @@ test.describe( 'Image', () => { } ); test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test.afterEach( async ( { requestUtils } ) => { @@ -738,7 +738,7 @@ test.describe.skip( 'Image - interactivity', () => { } ); test.beforeEach( async ( { admin, editor } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); await editor.insertBlock( { name: 'core/image' } ); } ); diff --git a/test/e2e/specs/editor/blocks/links.spec.js b/test/e2e/specs/editor/blocks/links.spec.js index 7e654ca12790f..039cd73dd0795 100644 --- a/test/e2e/specs/editor/blocks/links.spec.js +++ b/test/e2e/specs/editor/blocks/links.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Links', () => { test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test.afterEach( async ( { requestUtils } ) => { @@ -30,7 +30,7 @@ test.describe( 'Links', () => { status: 'publish', } ); - await admin.createNewPost(); + await admin.visitPostEditor(); // Now in a new post and try to create a link from an autocomplete suggestion using the keyboard. await editor.insertBlock( { @@ -373,7 +373,7 @@ test.describe( 'Links', () => { status: 'publish', } ); - await admin.createNewPost(); + await admin.visitPostEditor(); // Now in a new post and try to create a link from an autocomplete suggestion using the keyboard. await editor.insertBlock( { diff --git a/test/e2e/specs/editor/blocks/list.spec.js b/test/e2e/specs/editor/blocks/list.spec.js index f10a266a41e65..f1bc47c6886bd 100644 --- a/test/e2e/specs/editor/blocks/list.spec.js +++ b/test/e2e/specs/editor/blocks/list.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'List (@firefox)', () => { test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test( 'can be created by using an asterisk at the start of a paragraph block', async ( { diff --git a/test/e2e/specs/editor/blocks/missing.spec.js b/test/e2e/specs/editor/blocks/missing.spec.js index 69c26c3f85876..91fcd741ea711 100644 --- a/test/e2e/specs/editor/blocks/missing.spec.js +++ b/test/e2e/specs/editor/blocks/missing.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'missing block', () => { test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test( 'should strip potentially malicious on* attributes', async ( { diff --git a/test/e2e/specs/editor/blocks/navigation-colors.spec.js b/test/e2e/specs/editor/blocks/navigation-colors.spec.js index 1ddd4af8ab2e1..3c3c8581731dd 100644 --- a/test/e2e/specs/editor/blocks/navigation-colors.spec.js +++ b/test/e2e/specs/editor/blocks/navigation-colors.spec.js @@ -25,7 +25,7 @@ test.describe( 'Navigation colors', () => { attributes: { openSubmenusOnClick: true }, } ); - await admin.createNewPost(); + await admin.visitPostEditor(); await editor.insertBlock( { name: 'core/navigation', diff --git a/test/e2e/specs/editor/blocks/navigation-list-view.spec.js b/test/e2e/specs/editor/blocks/navigation-list-view.spec.js index fd7113fe17095..d4249e193db53 100644 --- a/test/e2e/specs/editor/blocks/navigation-list-view.spec.js +++ b/test/e2e/specs/editor/blocks/navigation-list-view.spec.js @@ -29,7 +29,7 @@ test.describe( 'Navigation block - List view editing', () => { } ); test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test.afterAll( async ( { requestUtils } ) => { diff --git a/test/e2e/specs/editor/blocks/navigation.spec.js b/test/e2e/specs/editor/blocks/navigation.spec.js index 4757ccbb4a00f..ccb7b7a402dbc 100644 --- a/test/e2e/specs/editor/blocks/navigation.spec.js +++ b/test/e2e/specs/editor/blocks/navigation.spec.js @@ -24,7 +24,7 @@ test.describe( 'Navigation block', () => { admin, editor, } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); await editor.insertBlock( { name: 'core/navigation' } ); const pageListBlock = editor.canvas.getByRole( 'document', { @@ -52,7 +52,7 @@ test.describe( 'Navigation block', () => { page, requestUtils, } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); const createdMenu = await requestUtils.createNavigationMenu( { title: 'Test Menu 1', content: @@ -96,7 +96,7 @@ test.describe( 'Navigation block', () => { } ) => { // Create a classic menu. await requestUtils.createClassicMenu( 'Test Classic 1' ); - await admin.createNewPost(); + await admin.visitPostEditor(); await editor.insertBlock( { name: 'core/navigation' } ); // We need to check the canvas after inserting the navigation block to be able to target the block. @@ -130,7 +130,7 @@ test.describe( 'Navigation block', () => { editor, requestUtils, } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); await requestUtils.createNavigationMenu( { title: 'Test Menu 1', content: @@ -183,7 +183,7 @@ test.describe( 'Navigation block', () => { editor, requestUtils, } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); await requestUtils.createNavigationMenu( { title: 'Test Menu', content: '', @@ -220,7 +220,7 @@ test.describe( 'Navigation block', () => { editor, requestUtils, } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); await requestUtils.createNavigationMenu( { title: 'Test Menu', content: @@ -264,7 +264,7 @@ test.describe( 'Navigation block', () => { admin, editor, } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); await editor.insertBlock( { name: 'core/navigation', @@ -308,7 +308,7 @@ test.describe( 'Navigation block', () => { } ) ).toHaveLength( 0 ); - await admin.createNewPost(); + await admin.visitPostEditor(); await editor.insertBlock( { name: 'core/navigation', diff --git a/test/e2e/specs/editor/blocks/paragraph.spec.js b/test/e2e/specs/editor/blocks/paragraph.spec.js index 3cf3654870a35..616d1c1d10bee 100644 --- a/test/e2e/specs/editor/blocks/paragraph.spec.js +++ b/test/e2e/specs/editor/blocks/paragraph.spec.js @@ -16,7 +16,7 @@ test.use( { test.describe( 'Paragraph', () => { test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test( 'should output unwrapped editable paragraph', async ( { diff --git a/test/e2e/specs/editor/blocks/post-title.spec.js b/test/e2e/specs/editor/blocks/post-title.spec.js index b5c536c0ff246..f00699d465a37 100644 --- a/test/e2e/specs/editor/blocks/post-title.spec.js +++ b/test/e2e/specs/editor/blocks/post-title.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Post Title block', () => { test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test( 'Can edit the post title', async ( { editor, page } ) => { diff --git a/test/e2e/specs/editor/blocks/preformatted.spec.js b/test/e2e/specs/editor/blocks/preformatted.spec.js index 5cd20a051c4fb..ad50f11d8b941 100644 --- a/test/e2e/specs/editor/blocks/preformatted.spec.js +++ b/test/e2e/specs/editor/blocks/preformatted.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Preformatted', () => { test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test( 'should preserve character newlines', async ( { editor, page } ) => { diff --git a/test/e2e/specs/editor/blocks/pullquote.spec.js b/test/e2e/specs/editor/blocks/pullquote.spec.js index 33f833ca53678..9c78b8271f688 100644 --- a/test/e2e/specs/editor/blocks/pullquote.spec.js +++ b/test/e2e/specs/editor/blocks/pullquote.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Quote', () => { test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test( 'can be created by converting a quote and converted back to quote', async ( { diff --git a/test/e2e/specs/editor/blocks/query.spec.js b/test/e2e/specs/editor/blocks/query.spec.js index 79b15222630ef..44035e2a20f31 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.visitPostEditor( { + postType: 'page', + title: 'Query Page', + } ); } ); test.afterEach( async ( { requestUtils } ) => { diff --git a/test/e2e/specs/editor/blocks/quote.spec.js b/test/e2e/specs/editor/blocks/quote.spec.js index d25dedd4a0a39..20cbde17bb67a 100644 --- a/test/e2e/specs/editor/blocks/quote.spec.js +++ b/test/e2e/specs/editor/blocks/quote.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Quote', () => { test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test.afterEach( async ( { requestUtils } ) => { diff --git a/test/e2e/specs/editor/blocks/search.spec.js b/test/e2e/specs/editor/blocks/search.spec.js index d11efd7328afe..e51c4e1463cad 100644 --- a/test/e2e/specs/editor/blocks/search.spec.js +++ b/test/e2e/specs/editor/blocks/search.spec.js @@ -6,7 +6,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Search', () => { test.beforeEach( async ( { admin, requestUtils } ) => { await requestUtils.deleteAllMenus(); - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test.afterAll( async ( { requestUtils } ) => { diff --git a/test/e2e/specs/editor/blocks/separator.spec.js b/test/e2e/specs/editor/blocks/separator.spec.js index 70c61535e71bf..35e608172efbd 100644 --- a/test/e2e/specs/editor/blocks/separator.spec.js +++ b/test/e2e/specs/editor/blocks/separator.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Separator', () => { test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test( 'can be created by three dashes and enter', async ( { diff --git a/test/e2e/specs/editor/blocks/spacer.spec.js b/test/e2e/specs/editor/blocks/spacer.spec.js index f089402514623..4093bf7218aa5 100644 --- a/test/e2e/specs/editor/blocks/spacer.spec.js +++ b/test/e2e/specs/editor/blocks/spacer.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Spacer', () => { test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test( 'can be created by typing "/spacer"', async ( { editor, page } ) => { diff --git a/test/e2e/specs/editor/blocks/table.spec.js b/test/e2e/specs/editor/blocks/table.spec.js index 1e6dfdcd76e18..da6380b807e2d 100644 --- a/test/e2e/specs/editor/blocks/table.spec.js +++ b/test/e2e/specs/editor/blocks/table.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Table', () => { test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test( 'displays a form for choosing the row and column count of the table', async ( { diff --git a/test/e2e/specs/editor/blocks/verse-code-preformatted.spec.js b/test/e2e/specs/editor/blocks/verse-code-preformatted.spec.js index c3642bfbca312..8c0b8a7067fed 100644 --- a/test/e2e/specs/editor/blocks/verse-code-preformatted.spec.js +++ b/test/e2e/specs/editor/blocks/verse-code-preformatted.spec.js @@ -7,7 +7,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); [ 'core/verse', 'core/code', 'core/preformatted' ].forEach( ( blockName ) => { test.describe( blockName, () => { test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test( 'should exit on triple Enter and merge back', async ( { diff --git a/test/e2e/specs/editor/plugins/allowed-blocks.spec.js b/test/e2e/specs/editor/plugins/allowed-blocks.spec.js index 4211e42823821..1008b93e4474d 100644 --- a/test/e2e/specs/editor/plugins/allowed-blocks.spec.js +++ b/test/e2e/specs/editor/plugins/allowed-blocks.spec.js @@ -9,7 +9,7 @@ test.describe( 'Allowed Blocks Filter', () => { } ); test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test.afterAll( async ( { requestUtils } ) => { diff --git a/test/e2e/specs/editor/plugins/block-api.spec.js b/test/e2e/specs/editor/plugins/block-api.spec.js index dd2a89cd2beca..dbac441f812fa 100644 --- a/test/e2e/specs/editor/plugins/block-api.spec.js +++ b/test/e2e/specs/editor/plugins/block-api.spec.js @@ -16,7 +16,7 @@ test.describe( 'Using Block API', () => { admin, editor, } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); await editor.insertBlock( { name: 'e2e-tests/hello-world' } ); diff --git a/test/e2e/specs/editor/plugins/block-variations.spec.js b/test/e2e/specs/editor/plugins/block-variations.spec.js index 9f12c987efd39..9c8de2f6985da 100644 --- a/test/e2e/specs/editor/plugins/block-variations.spec.js +++ b/test/e2e/specs/editor/plugins/block-variations.spec.js @@ -9,7 +9,7 @@ test.describe( 'Block variations', () => { } ); test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test.afterAll( async ( { requestUtils } ) => { diff --git a/test/e2e/specs/editor/plugins/custom-post-types.spec.js b/test/e2e/specs/editor/plugins/custom-post-types.spec.js index 17a497f26cee0..4208cb52870e5 100644 --- a/test/e2e/specs/editor/plugins/custom-post-types.spec.js +++ b/test/e2e/specs/editor/plugins/custom-post-types.spec.js @@ -19,7 +19,7 @@ test.describe( 'Test Custom Post Types', () => { editor, page, } ) => { - await admin.createNewPost( { postType: 'hierar-no-title' } ); + await admin.visitPostEditor( { postType: 'hierar-no-title' } ); await editor.canvas .locator( 'role=button[name="Add default block"i]' ) .click(); @@ -27,7 +27,7 @@ test.describe( 'Test Custom Post Types', () => { await editor.publishPost(); // Create a post that is a child of the previously created post. - await admin.createNewPost( { postType: 'hierar-no-title' } ); + await admin.visitPostEditor( { postType: 'hierar-no-title' } ); await editor.openDocumentSettingsSidebar(); await page .getByRole( 'region', { name: 'Editor settings' } ) @@ -71,7 +71,7 @@ test.describe( 'Test Custom Post Types', () => { editor, page, } ) => { - await admin.createNewPost( { postType: 'leg_block_in_tpl' } ); + await admin.visitPostEditor( { postType: 'leg_block_in_tpl' } ); await editor.canvas .locator( 'role=button[name="Add default block"i]' ) .click(); diff --git a/test/e2e/specs/editor/plugins/deprecated-node-matcher.spec.js b/test/e2e/specs/editor/plugins/deprecated-node-matcher.spec.js index 58f742341ebc3..3fc89c987a680 100644 --- a/test/e2e/specs/editor/plugins/deprecated-node-matcher.spec.js +++ b/test/e2e/specs/editor/plugins/deprecated-node-matcher.spec.js @@ -14,7 +14,7 @@ test.describe( 'Deprecated Node Matcher', () => { } ); test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test.afterAll( async ( { requestUtils } ) => { diff --git a/test/e2e/specs/editor/plugins/format-api.spec.js b/test/e2e/specs/editor/plugins/format-api.spec.js index 1e631615313bd..d861194dfdc9a 100644 --- a/test/e2e/specs/editor/plugins/format-api.spec.js +++ b/test/e2e/specs/editor/plugins/format-api.spec.js @@ -13,7 +13,7 @@ test.describe( 'Using Format API', () => { } ); test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test( 'Clicking the control wraps the selected text properly with HTML code', async ( { diff --git a/test/e2e/specs/editor/plugins/hooks-api.spec.js b/test/e2e/specs/editor/plugins/hooks-api.spec.js index 95bc5bf8bfd2c..d397f4b33c0a4 100644 --- a/test/e2e/specs/editor/plugins/hooks-api.spec.js +++ b/test/e2e/specs/editor/plugins/hooks-api.spec.js @@ -14,7 +14,7 @@ test.describe( 'Using Hooks API', () => { } ); test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test( 'Should contain a reset block button on the sidebar', async ( { diff --git a/test/e2e/specs/editor/plugins/iframed-block.spec.js b/test/e2e/specs/editor/plugins/iframed-block.spec.js index 0b5343169d5bf..8325c3a7589a7 100644 --- a/test/e2e/specs/editor/plugins/iframed-block.spec.js +++ b/test/e2e/specs/editor/plugins/iframed-block.spec.js @@ -6,7 +6,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Iframed block', () => { test.beforeEach( async ( { requestUtils, admin } ) => { await requestUtils.activatePlugin( 'gutenberg-test-iframed-block' ); - await admin.createNewPost( { postType: 'page' } ); + await admin.visitPostEditor( { postType: 'page' } ); } ); test.afterEach( async ( { requestUtils } ) => { diff --git a/test/e2e/specs/editor/plugins/iframed-enqueue-block-editor-settings.spec.js b/test/e2e/specs/editor/plugins/iframed-enqueue-block-editor-settings.spec.js index b4f502b2c9d0b..cfa19599487fc 100644 --- a/test/e2e/specs/editor/plugins/iframed-enqueue-block-editor-settings.spec.js +++ b/test/e2e/specs/editor/plugins/iframed-enqueue-block-editor-settings.spec.js @@ -11,7 +11,7 @@ test.describe( 'iframed block editor settings styles', () => { } ); test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test.afterAll( async ( { requestUtils } ) => { diff --git a/test/e2e/specs/editor/plugins/iframed-equeue-block-assets.spec.js b/test/e2e/specs/editor/plugins/iframed-equeue-block-assets.spec.js index a523ba1f8e9e3..02877de0a7396 100644 --- a/test/e2e/specs/editor/plugins/iframed-equeue-block-assets.spec.js +++ b/test/e2e/specs/editor/plugins/iframed-equeue-block-assets.spec.js @@ -14,7 +14,7 @@ test.describe( 'iframed enqueue block assets', () => { } ); test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test.afterAll( async ( { requestUtils } ) => { diff --git a/test/e2e/specs/editor/plugins/iframed-inline-styles.spec.js b/test/e2e/specs/editor/plugins/iframed-inline-styles.spec.js index 8fa4cbffa9df8..b1ba8af1a5414 100644 --- a/test/e2e/specs/editor/plugins/iframed-inline-styles.spec.js +++ b/test/e2e/specs/editor/plugins/iframed-inline-styles.spec.js @@ -28,7 +28,7 @@ test.describe( 'iframed inline styles', () => { } } ); - await admin.createNewPost( { postType: 'page' } ); + await admin.visitPostEditor( { postType: 'page' } ); await editor.insertBlock( { name: 'test/iframed-inline-styles' } ); const block = editor.canvas.getByRole( 'document', { diff --git a/test/e2e/specs/editor/plugins/iframed-masonry-block.spec.js b/test/e2e/specs/editor/plugins/iframed-masonry-block.spec.js index edc6b0a68cd4a..c06346df0c17a 100644 --- a/test/e2e/specs/editor/plugins/iframed-masonry-block.spec.js +++ b/test/e2e/specs/editor/plugins/iframed-masonry-block.spec.js @@ -11,7 +11,7 @@ test.describe( 'iframed masonry block', () => { } ); test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test.afterAll( async ( { requestUtils } ) => { diff --git a/test/e2e/specs/editor/plugins/iframed-multiple-block-stylesheets.spec.js b/test/e2e/specs/editor/plugins/iframed-multiple-block-stylesheets.spec.js index 2e6f5b6b0cb6a..81af1c7666dc9 100644 --- a/test/e2e/specs/editor/plugins/iframed-multiple-block-stylesheets.spec.js +++ b/test/e2e/specs/editor/plugins/iframed-multiple-block-stylesheets.spec.js @@ -11,7 +11,7 @@ test.describe( 'iframed multiple block stylesheets', () => { } ); test.beforeEach( async ( { admin } ) => { - await admin.createNewPost( { postType: 'page' } ); + await admin.visitPostEditor( { postType: 'page' } ); } ); test.afterAll( async ( { requestUtils } ) => { diff --git a/test/e2e/specs/editor/plugins/image-size.spec.js b/test/e2e/specs/editor/plugins/image-size.spec.js index 1e0bc91407565..efb57f41c1b5a 100644 --- a/test/e2e/specs/editor/plugins/image-size.spec.js +++ b/test/e2e/specs/editor/plugins/image-size.spec.js @@ -31,7 +31,7 @@ test.describe( 'changing image size', () => { const filename = '1024x768_e2e_test_image_size.jpeg'; const filepath = path.join( './test/e2e/assets', filename ); - await admin.createNewPost(); + await admin.visitPostEditor(); const media = await requestUtils.uploadMedia( filepath ); await editor.insertBlock( { diff --git a/test/e2e/specs/editor/plugins/inner-blocks-allowed-blocks.spec.js b/test/e2e/specs/editor/plugins/inner-blocks-allowed-blocks.spec.js index c0627121f1649..e61814019f1fa 100644 --- a/test/e2e/specs/editor/plugins/inner-blocks-allowed-blocks.spec.js +++ b/test/e2e/specs/editor/plugins/inner-blocks-allowed-blocks.spec.js @@ -17,7 +17,7 @@ test.describe( 'Allowed Blocks Setting on InnerBlocks', () => { } ); test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test( 'allows all blocks if the allowed blocks setting was not set', async ( { diff --git a/test/e2e/specs/editor/plugins/nonce.spec.js b/test/e2e/specs/editor/plugins/nonce.spec.js index 1fbb6add87ff7..b15d0534c485c 100644 --- a/test/e2e/specs/editor/plugins/nonce.spec.js +++ b/test/e2e/specs/editor/plugins/nonce.spec.js @@ -14,7 +14,7 @@ test.describe( 'Nonce', () => { requestUtils, editor, } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); await expect( editor.canvas.getByRole( 'textbox', { name: 'Add title' } ) ).toBeFocused(); diff --git a/test/e2e/specs/editor/plugins/post-type-templates.spec.js b/test/e2e/specs/editor/plugins/post-type-templates.spec.js index a95f826c1f74c..17a05cac3f1e4 100644 --- a/test/e2e/specs/editor/plugins/post-type-templates.spec.js +++ b/test/e2e/specs/editor/plugins/post-type-templates.spec.js @@ -12,7 +12,7 @@ test.describe( 'Post type templates', () => { } ); test.beforeEach( async ( { admin } ) => { - await admin.createNewPost( { postType: 'book' } ); + await admin.visitPostEditor( { postType: 'book' } ); } ); test.afterAll( async ( { requestUtils } ) => { @@ -99,7 +99,7 @@ test.describe( 'Post type templates', () => { admin, editor, } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); await expect.poll( editor.getEditedPostContent ) .toBe( ` @@ -112,7 +112,7 @@ test.describe( 'Post type templates', () => { page, editor, } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); // Remove the default block template to verify that it's not // re-added after saving and reloading the editor. @@ -133,7 +133,7 @@ test.describe( 'Post type templates', () => { admin, editor, } ) => { - await admin.createNewPost( { postType: 'page' } ); + await admin.visitPostEditor( { postType: 'page' } ); await expect.poll( editor.getEditedPostContent ).toBe( '' ); } ); diff --git a/test/e2e/specs/editor/plugins/register-block-type-hooks.spec.js b/test/e2e/specs/editor/plugins/register-block-type-hooks.spec.js index 2ec62ffd056d3..4e3e6cc8d4351 100644 --- a/test/e2e/specs/editor/plugins/register-block-type-hooks.spec.js +++ b/test/e2e/specs/editor/plugins/register-block-type-hooks.spec.js @@ -8,7 +8,7 @@ test.describe( 'Register block type hooks', () => { await requestUtils.activatePlugin( 'gutenberg-test-register-block-type-hooks' ); - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test.afterEach( async ( { requestUtils } ) => { diff --git a/test/e2e/specs/editor/plugins/wp-editor-meta-box.spec.js b/test/e2e/specs/editor/plugins/wp-editor-meta-box.spec.js index 710e06b35e124..f50a0073d49f6 100644 --- a/test/e2e/specs/editor/plugins/wp-editor-meta-box.spec.js +++ b/test/e2e/specs/editor/plugins/wp-editor-meta-box.spec.js @@ -17,7 +17,7 @@ test.describe( 'WP Editor Meta Boxes', () => { } ); test( 'Should save the changes', async ( { admin, editor, page } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); // Add title to enable valid non-empty post save. await page diff --git a/test/e2e/specs/editor/various/a11y-region-navigation.spec.js b/test/e2e/specs/editor/various/a11y-region-navigation.spec.js index d8dda0cabdf84..09bdef52179d1 100644 --- a/test/e2e/specs/editor/various/a11y-region-navigation.spec.js +++ b/test/e2e/specs/editor/various/a11y-region-navigation.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Region navigation (@firefox, @webkit)', () => { test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test.afterAll( async ( { requestUtils } ) => { diff --git a/test/e2e/specs/editor/various/a11y.spec.js b/test/e2e/specs/editor/various/a11y.spec.js index 0a5e421debedb..9fa6dfbbf34cb 100644 --- a/test/e2e/specs/editor/various/a11y.spec.js +++ b/test/e2e/specs/editor/various/a11y.spec.js @@ -14,7 +14,7 @@ test.use( { test.describe( 'a11y (@firefox, @webkit)', () => { test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test( 'navigating through the Editor regions four times should land on the Editor top bar region', async ( { diff --git a/test/e2e/specs/editor/various/adding-inline-tokens.spec.js b/test/e2e/specs/editor/various/adding-inline-tokens.spec.js index 15f9d9ea87732..d65ecd543345c 100644 --- a/test/e2e/specs/editor/various/adding-inline-tokens.spec.js +++ b/test/e2e/specs/editor/various/adding-inline-tokens.spec.js @@ -13,7 +13,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'adding inline tokens', () => { test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test( 'should insert inline image', async ( { diff --git a/test/e2e/specs/editor/various/adding-patterns.spec.js b/test/e2e/specs/editor/various/adding-patterns.spec.js index 94b9dbd2646e8..da47978054d8a 100644 --- a/test/e2e/specs/editor/various/adding-patterns.spec.js +++ b/test/e2e/specs/editor/various/adding-patterns.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'adding patterns', () => { test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test( 'should insert a block pattern', async ( { page, editor } ) => { diff --git a/test/e2e/specs/editor/various/autocomplete-and-mentions.spec.js b/test/e2e/specs/editor/various/autocomplete-and-mentions.spec.js index 9d6fa02802efe..1504fe67f9c24 100644 --- a/test/e2e/specs/editor/various/autocomplete-and-mentions.spec.js +++ b/test/e2e/specs/editor/various/autocomplete-and-mentions.spec.js @@ -68,7 +68,7 @@ test.describe( 'Autocomplete (@firefox, @webkit)', () => { } ); test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test.afterEach( async ( { editor } ) => { diff --git a/test/e2e/specs/editor/various/block-deletion.spec.js b/test/e2e/specs/editor/various/block-deletion.spec.js index 9346412c46bcb..1601a4a8253a9 100644 --- a/test/e2e/specs/editor/various/block-deletion.spec.js +++ b/test/e2e/specs/editor/various/block-deletion.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Block deletion', () => { test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test( 'deleting the last block via its options menu', async ( { diff --git a/test/e2e/specs/editor/various/block-hierarchy-navigation.spec.js b/test/e2e/specs/editor/various/block-hierarchy-navigation.spec.js index f0bfe5bff203f..f9a1d8b3ffc43 100644 --- a/test/e2e/specs/editor/various/block-hierarchy-navigation.spec.js +++ b/test/e2e/specs/editor/various/block-hierarchy-navigation.spec.js @@ -34,7 +34,7 @@ const COLUMNS_BLOCK = [ test.describe( 'Navigating the block hierarchy', () => { test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test( 'should navigate using the list view sidebar', async ( { diff --git a/test/e2e/specs/editor/various/block-locking.spec.js b/test/e2e/specs/editor/various/block-locking.spec.js index b40e7a4b7448a..b172ca8cc5f76 100644 --- a/test/e2e/specs/editor/various/block-locking.spec.js +++ b/test/e2e/specs/editor/various/block-locking.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Block Locking', () => { test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test( 'can prevent removal', async ( { editor, page } ) => { diff --git a/test/e2e/specs/editor/various/block-mover.spec.js b/test/e2e/specs/editor/various/block-mover.spec.js index 5c3b04a069774..48aa48bff3207 100644 --- a/test/e2e/specs/editor/various/block-mover.spec.js +++ b/test/e2e/specs/editor/various/block-mover.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'block mover', () => { test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test( 'should show block mover when more than one block exists', async ( { diff --git a/test/e2e/specs/editor/various/block-moving-mode.spec.js b/test/e2e/specs/editor/various/block-moving-mode.spec.js index 5b8ef6bdcd051..7fe7b2f9b0383 100644 --- a/test/e2e/specs/editor/various/block-moving-mode.spec.js +++ b/test/e2e/specs/editor/various/block-moving-mode.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Block moving mode', () => { test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test.afterEach( async ( { requestUtils } ) => { diff --git a/test/e2e/specs/editor/various/block-renaming.spec.js b/test/e2e/specs/editor/various/block-renaming.spec.js index f8d9548fbe866..3fb99a77f0d44 100644 --- a/test/e2e/specs/editor/various/block-renaming.spec.js +++ b/test/e2e/specs/editor/various/block-renaming.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Block Renaming', () => { test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test.describe( 'Dialog renaming', () => { diff --git a/test/e2e/specs/editor/various/block-switcher-test.spec.js b/test/e2e/specs/editor/various/block-switcher-test.spec.js index 12fd843ed2ed1..e707f693635b9 100644 --- a/test/e2e/specs/editor/various/block-switcher-test.spec.js +++ b/test/e2e/specs/editor/various/block-switcher-test.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Block Switcher', () => { test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test( 'Block variation transforms', async ( { editor, page } ) => { diff --git a/test/e2e/specs/editor/various/compatibility-classic-editor.spec.js b/test/e2e/specs/editor/various/compatibility-classic-editor.spec.js index 71522c1d439a5..11fce3aa66401 100644 --- a/test/e2e/specs/editor/various/compatibility-classic-editor.spec.js +++ b/test/e2e/specs/editor/various/compatibility-classic-editor.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Compatibility with classic editor', () => { test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test.afterEach( async ( { requestUtils } ) => { diff --git a/test/e2e/specs/editor/various/content-only-lock.spec.js b/test/e2e/specs/editor/various/content-only-lock.spec.js index e7d52562636f3..fdebb38cf648f 100644 --- a/test/e2e/specs/editor/various/content-only-lock.spec.js +++ b/test/e2e/specs/editor/various/content-only-lock.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Content-only lock', () => { test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test( 'should be able to edit the content of blocks with content-only lock', async ( { diff --git a/test/e2e/specs/editor/various/convert-block-type.spec.js b/test/e2e/specs/editor/various/convert-block-type.spec.js index b26cc6124f831..9dac8d2f57588 100644 --- a/test/e2e/specs/editor/various/convert-block-type.spec.js +++ b/test/e2e/specs/editor/various/convert-block-type.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Code block', () => { test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test.afterEach( async ( { requestUtils } ) => { diff --git a/test/e2e/specs/editor/various/copy-cut-paste.spec.js b/test/e2e/specs/editor/various/copy-cut-paste.spec.js index 04113e013930b..3e0c40df80b34 100644 --- a/test/e2e/specs/editor/various/copy-cut-paste.spec.js +++ b/test/e2e/specs/editor/various/copy-cut-paste.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Copy/cut/paste', () => { test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test( 'should copy and paste individual blocks with collapsed selection', async ( { diff --git a/test/e2e/specs/editor/various/draggable-blocks.spec.js b/test/e2e/specs/editor/various/draggable-blocks.spec.js index fb56b43dc6e03..236ff463efe68 100644 --- a/test/e2e/specs/editor/various/draggable-blocks.spec.js +++ b/test/e2e/specs/editor/various/draggable-blocks.spec.js @@ -20,7 +20,7 @@ test.use( { test.describe( 'Draggable block', () => { test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test( 'can drag and drop to the top of a vertical block list', async ( { diff --git a/test/e2e/specs/editor/various/duplicating-blocks.spec.js b/test/e2e/specs/editor/various/duplicating-blocks.spec.js index aabb93e229572..521f98fcce4ae 100644 --- a/test/e2e/specs/editor/various/duplicating-blocks.spec.js +++ b/test/e2e/specs/editor/various/duplicating-blocks.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Duplicating blocks', () => { test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test( 'should duplicate blocks using the block settings menu and keyboard shortcut', async ( { diff --git a/test/e2e/specs/editor/various/font-size-picker.spec.js b/test/e2e/specs/editor/various/font-size-picker.spec.js index 5c6cb4b186e25..f3c70fb849597 100644 --- a/test/e2e/specs/editor/various/font-size-picker.spec.js +++ b/test/e2e/specs/editor/various/font-size-picker.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Font Size Picker', () => { test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test.afterEach( async ( { page } ) => { diff --git a/test/e2e/specs/editor/various/footnotes.spec.js b/test/e2e/specs/editor/various/footnotes.spec.js index 14a2fc653e387..fa79e410c6942 100644 --- a/test/e2e/specs/editor/various/footnotes.spec.js +++ b/test/e2e/specs/editor/various/footnotes.spec.js @@ -23,7 +23,7 @@ async function getFootnotes( page, withoutSave = false ) { test.describe( 'Footnotes', () => { test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test( 'can be inserted', async ( { editor, page } ) => { diff --git a/test/e2e/specs/editor/various/format-library/text-color.spec.js b/test/e2e/specs/editor/various/format-library/text-color.spec.js index aba77251e3833..15cc5f9f250b5 100644 --- a/test/e2e/specs/editor/various/format-library/text-color.spec.js +++ b/test/e2e/specs/editor/various/format-library/text-color.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Format Library - Text color', () => { test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test( 'should remove highlighting element', async ( { diff --git a/test/e2e/specs/editor/various/fullscreen-mode.spec.js b/test/e2e/specs/editor/various/fullscreen-mode.spec.js index 8b7a0785a7ed6..447498fd0a4dd 100644 --- a/test/e2e/specs/editor/various/fullscreen-mode.spec.js +++ b/test/e2e/specs/editor/various/fullscreen-mode.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Fullscreen Mode', () => { test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test.afterEach( async ( { requestUtils } ) => { diff --git a/test/e2e/specs/editor/various/inner-blocks-templates.spec.js b/test/e2e/specs/editor/various/inner-blocks-templates.spec.js index 0f9aed33d0773..4742b3b749d7e 100644 --- a/test/e2e/specs/editor/various/inner-blocks-templates.spec.js +++ b/test/e2e/specs/editor/various/inner-blocks-templates.spec.js @@ -11,7 +11,7 @@ test.describe( 'Inner blocks templates', () => { } ); test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test.afterAll( async ( { requestUtils } ) => { diff --git a/test/e2e/specs/editor/various/inserting-blocks.spec.js b/test/e2e/specs/editor/various/inserting-blocks.spec.js index a48fe117c97a2..44f35037b1741 100644 --- a/test/e2e/specs/editor/various/inserting-blocks.spec.js +++ b/test/e2e/specs/editor/various/inserting-blocks.spec.js @@ -30,7 +30,7 @@ test.describe( 'Inserting blocks (@firefox, @webkit)', () => { 'The clientX value is always 0 in firefox, see https://github.com/microsoft/playwright/issues/17761 for more info.' ); - await admin.createNewPost(); + await admin.visitPostEditor(); await editor.switchToLegacyCanvas(); // We need a dummy block in place to display the drop indicator due to a bug. @@ -108,7 +108,7 @@ test.describe( 'Inserting blocks (@firefox, @webkit)', () => { editor, insertingBlocksUtils, } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); await editor.switchToLegacyCanvas(); // We need a dummy block in place to display the drop indicator due to a bug. @@ -174,7 +174,7 @@ test.describe( 'Inserting blocks (@firefox, @webkit)', () => { 'The clientX value is always 0 in firefox, see https://github.com/microsoft/playwright/issues/17761 for more info.' ); - await admin.createNewPost(); + await admin.visitPostEditor(); await editor.switchToLegacyCanvas(); // We need a dummy block in place to display the drop indicator due to a bug. @@ -244,7 +244,7 @@ test.describe( 'Inserting blocks (@firefox, @webkit)', () => { editor, insertingBlocksUtils, } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); await editor.switchToLegacyCanvas(); // We need a dummy block in place to display the drop indicator due to a bug. @@ -308,7 +308,7 @@ test.describe( 'Inserting blocks (@firefox, @webkit)', () => { page, editor, } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); const inserterButton = page.getByRole( 'button', { name: 'Toggle block inserter', @@ -354,7 +354,7 @@ test.describe( 'insert media from inserter', () => { page, editor, } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); await page.click( 'role=region[name="Editor top bar"i] >> role=button[name="Toggle block inserter"i]' diff --git a/test/e2e/specs/editor/various/keep-styles-on-block-transforms.spec.js b/test/e2e/specs/editor/various/keep-styles-on-block-transforms.spec.js index 57b958fdfc4b4..712435730d5c1 100644 --- a/test/e2e/specs/editor/various/keep-styles-on-block-transforms.spec.js +++ b/test/e2e/specs/editor/various/keep-styles-on-block-transforms.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Keep styles on block transforms', () => { test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test( 'Should keep colors during a transform', async ( { diff --git a/test/e2e/specs/editor/various/keyboard-navigable-blocks.spec.js b/test/e2e/specs/editor/various/keyboard-navigable-blocks.spec.js index 080abe011206a..d4410ff430571 100644 --- a/test/e2e/specs/editor/various/keyboard-navigable-blocks.spec.js +++ b/test/e2e/specs/editor/various/keyboard-navigable-blocks.spec.js @@ -13,7 +13,7 @@ test.use( { test.describe( 'Order of block keyboard navigation', () => { test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test( 'permits tabbing through paragraph blocks in the expected order', async ( { diff --git a/test/e2e/specs/editor/various/list-view.spec.js b/test/e2e/specs/editor/various/list-view.spec.js index 222d743acdf39..93662974c839c 100644 --- a/test/e2e/specs/editor/various/list-view.spec.js +++ b/test/e2e/specs/editor/various/list-view.spec.js @@ -11,7 +11,7 @@ test.describe( 'List View', () => { } ); test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test( 'allows a user to drag a block to a new sibling position', async ( { diff --git a/test/e2e/specs/editor/various/mentions.spec.js b/test/e2e/specs/editor/various/mentions.spec.js index fef3b1c3e3d2e..bd953e3656738 100644 --- a/test/e2e/specs/editor/various/mentions.spec.js +++ b/test/e2e/specs/editor/various/mentions.spec.js @@ -15,7 +15,7 @@ test.describe( 'autocomplete mentions', () => { } ); test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test.afterAll( async ( { requestUtils } ) => { diff --git a/test/e2e/specs/editor/various/multi-block-selection.spec.js b/test/e2e/specs/editor/various/multi-block-selection.spec.js index 4fb39783954fa..cee9dcca194be 100644 --- a/test/e2e/specs/editor/various/multi-block-selection.spec.js +++ b/test/e2e/specs/editor/various/multi-block-selection.spec.js @@ -18,7 +18,7 @@ test.describe( 'Multi-block selection', () => { } ); test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test( 'should select with double ctrl+a and speak', async ( { diff --git a/test/e2e/specs/editor/various/navigable-toolbar.spec.js b/test/e2e/specs/editor/various/navigable-toolbar.spec.js index abdb1800d150a..3d35c42a8c597 100644 --- a/test/e2e/specs/editor/various/navigable-toolbar.spec.js +++ b/test/e2e/specs/editor/various/navigable-toolbar.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Block Toolbar', () => { test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test.describe( 'Contextual Toolbar', () => { diff --git a/test/e2e/specs/editor/various/new-post-default-content.spec.js b/test/e2e/specs/editor/various/new-post-default-content.spec.js index db9e3c38dc296..b68d9df7a071f 100644 --- a/test/e2e/specs/editor/various/new-post-default-content.spec.js +++ b/test/e2e/specs/editor/various/new-post-default-content.spec.js @@ -11,7 +11,7 @@ test.describe( 'new editor filtered state', () => { } ); test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test.afterAll( async ( { requestUtils } ) => { diff --git a/test/e2e/specs/editor/various/new-post.spec.js b/test/e2e/specs/editor/various/new-post.spec.js index cc0243eb8e631..f33cf4a77208f 100644 --- a/test/e2e/specs/editor/various/new-post.spec.js +++ b/test/e2e/specs/editor/various/new-post.spec.js @@ -21,7 +21,7 @@ test.describe( 'new editor state', () => { page, editor, } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); await expect( page ).toHaveURL( /post-new.php/ ); @@ -45,7 +45,7 @@ test.describe( 'new editor state', () => { } ); test( 'should have no history', async ( { admin, page } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); await expect( page.locator( 'role=button[name="Undo"i]' ) @@ -59,7 +59,7 @@ test.describe( 'new editor state', () => { admin, editor, } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); await expect( editor.canvas.locator( 'role=textbox[name="Add title"i]' ) @@ -71,7 +71,7 @@ test.describe( 'new editor state', () => { page, editor, } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); // Enter a title for this post. await editor.canvas @@ -93,7 +93,7 @@ test.describe( 'new editor state', () => { admin, page, } ) => { - await admin.createNewPost( { title: 'Here is the title' } ); + await admin.visitPostEditor( { title: 'Here is the title' } ); // Verify saveable by presence of the Save Draft button. const saveDraftButton = page.locator( diff --git a/test/e2e/specs/editor/various/patterns.spec.js b/test/e2e/specs/editor/various/patterns.spec.js index 941ae7e910a9b..3015de75576e2 100644 --- a/test/e2e/specs/editor/various/patterns.spec.js +++ b/test/e2e/specs/editor/various/patterns.spec.js @@ -10,7 +10,7 @@ test.describe( 'Unsynced pattern', () => { } ); test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test.afterEach( async ( { requestUtils } ) => { diff --git a/test/e2e/specs/editor/various/popovers.spec.js b/test/e2e/specs/editor/various/popovers.spec.js index 149e188db46f2..e1e6d515d3cbf 100644 --- a/test/e2e/specs/editor/various/popovers.spec.js +++ b/test/e2e/specs/editor/various/popovers.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'popovers', () => { test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test.describe( 'dropdown', () => { 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 b9bfbf9dd6b05..8dc98223054f0 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 @@ -153,7 +153,7 @@ class PostEditorTemplateMode { } async createPostAndSaveDraft() { - await this.admin.createNewPost(); + await this.admin.visitPostEditor(); // Create a random post. await this.page.keyboard.type( 'Just an FSE Post' ); await this.page.keyboard.press( 'Enter' ); diff --git a/test/e2e/specs/editor/various/post-visibility.spec.js b/test/e2e/specs/editor/various/post-visibility.spec.js index 365209ef2e4e5..dc23f65bf43d7 100644 --- a/test/e2e/specs/editor/various/post-visibility.spec.js +++ b/test/e2e/specs/editor/various/post-visibility.spec.js @@ -13,7 +13,7 @@ test.describe( 'Post visibility', () => { } ) => { await pageUtils.setBrowserViewport( viewport ); - await admin.createNewPost(); + await admin.visitPostEditor(); await editor.openDocumentSettingsSidebar(); @@ -42,7 +42,7 @@ test.describe( 'Post visibility', () => { } ) => { await pageUtils.setBrowserViewport( viewport ); - await admin.createNewPost(); + await admin.visitPostEditor(); await editor.openDocumentSettingsSidebar(); @@ -75,7 +75,7 @@ test.describe( 'Post visibility', () => { admin, editor, } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); // Enter a title for this post. await editor.canvas diff --git a/test/e2e/specs/editor/various/preview.spec.js b/test/e2e/specs/editor/various/preview.spec.js index cfec384adba9b..bb293f79ed187 100644 --- a/test/e2e/specs/editor/various/preview.spec.js +++ b/test/e2e/specs/editor/various/preview.spec.js @@ -11,7 +11,7 @@ test.use( { test.describe( 'Preview', () => { test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test( 'should open a preview window for a new post', async ( { @@ -217,7 +217,7 @@ test.describe( 'Preview', () => { test.describe( 'Preview with Custom Fields enabled', () => { test.beforeEach( async ( { admin, previewUtils } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); await previewUtils.toggleCustomFieldsOption( true ); } ); @@ -294,7 +294,10 @@ test.describe( 'Preview with private custom post type', () => { admin, page, } ) => { - await admin.createNewPost( { postType: 'not_public', title: 'aaaaa' } ); + await admin.visitPostEditor( { + 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/publish-panel.spec.js b/test/e2e/specs/editor/various/publish-panel.spec.js index 1ea72d7eb11a2..ec0c8e13fccad 100644 --- a/test/e2e/specs/editor/various/publish-panel.spec.js +++ b/test/e2e/specs/editor/various/publish-panel.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Post publish panel', () => { test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test( 'should move focus back to the Publish panel toggle button when canceling', async ( { diff --git a/test/e2e/specs/editor/various/rich-text-deprecated-multiline.spec.js b/test/e2e/specs/editor/various/rich-text-deprecated-multiline.spec.js index 9fa3fef903c7f..3a27a76dcec27 100644 --- a/test/e2e/specs/editor/various/rich-text-deprecated-multiline.spec.js +++ b/test/e2e/specs/editor/various/rich-text-deprecated-multiline.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'RichText deprecated multiline', () => { test.beforeEach( async ( { admin, page, editor } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); await page.evaluate( () => { const registerBlockType = window.wp.blocks.registerBlockType; const { useBlockProps, RichText } = window.wp.blockEditor; diff --git a/test/e2e/specs/editor/various/rich-text.spec.js b/test/e2e/specs/editor/various/rich-text.spec.js index 2969a33d25485..2b0e29067dd36 100644 --- a/test/e2e/specs/editor/various/rich-text.spec.js +++ b/test/e2e/specs/editor/various/rich-text.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'RichText', () => { test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test( 'should handle change in tag name gracefully', async ( { diff --git a/test/e2e/specs/editor/various/rtl.spec.js b/test/e2e/specs/editor/various/rtl.spec.js index aaf1186cc5aba..69e519c945726 100644 --- a/test/e2e/specs/editor/various/rtl.spec.js +++ b/test/e2e/specs/editor/various/rtl.spec.js @@ -16,7 +16,7 @@ test.describe( 'RTL', () => { } ); test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test.afterAll( async ( { requestUtils } ) => { diff --git a/test/e2e/specs/editor/various/shortcut-focus-toolbar.spec.js b/test/e2e/specs/editor/various/shortcut-focus-toolbar.spec.js index 0223821613f55..98ff86e55dc11 100644 --- a/test/e2e/specs/editor/various/shortcut-focus-toolbar.spec.js +++ b/test/e2e/specs/editor/various/shortcut-focus-toolbar.spec.js @@ -11,7 +11,7 @@ test.use( { test.describe( 'Focus toolbar shortcut (alt + F10)', () => { test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test( 'Focuses correct toolbar in default view options in edit mode', async ( { diff --git a/test/e2e/specs/editor/various/shortcut-help.spec.js b/test/e2e/specs/editor/various/shortcut-help.spec.js index 1aaf5e93c975c..b172611a63398 100644 --- a/test/e2e/specs/editor/various/shortcut-help.spec.js +++ b/test/e2e/specs/editor/various/shortcut-help.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'keyboard shortcut help modal', () => { test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test( 'opens from the options menu, closes with its close button and returns focus', async ( { diff --git a/test/e2e/specs/editor/various/splitting-merging.spec.js b/test/e2e/specs/editor/various/splitting-merging.spec.js index 29e7e5d64522c..a8f77cb5a8f09 100644 --- a/test/e2e/specs/editor/various/splitting-merging.spec.js +++ b/test/e2e/specs/editor/various/splitting-merging.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'splitting and merging blocks (@firefox, @webkit)', () => { test.beforeEach( async ( { admin, editor } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); await expect( editor.canvas.getByRole( 'textbox', { name: 'Add title' } ) ).toBeFocused(); diff --git a/test/e2e/specs/editor/various/style-variation.spec.js b/test/e2e/specs/editor/various/style-variation.spec.js index cc13dd1ad9238..467d3593291c2 100644 --- a/test/e2e/specs/editor/various/style-variation.spec.js +++ b/test/e2e/specs/editor/various/style-variation.spec.js @@ -9,7 +9,7 @@ test.describe( 'adding blocks', () => { editor, page, } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); // Inserting a quote block await editor.insertBlock( { diff --git a/test/e2e/specs/editor/various/toolbar-roving-tabindex.spec.js b/test/e2e/specs/editor/various/toolbar-roving-tabindex.spec.js index e706dfc3607dc..324975805227c 100644 --- a/test/e2e/specs/editor/various/toolbar-roving-tabindex.spec.js +++ b/test/e2e/specs/editor/various/toolbar-roving-tabindex.spec.js @@ -11,7 +11,7 @@ test.use( { test.describe( 'Toolbar roving tabindex', () => { test.beforeEach( async ( { admin, editor, page } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); await editor.insertBlock( { name: 'core/paragraph' } ); await page.keyboard.type( 'First block' ); diff --git a/test/e2e/specs/editor/various/undo.spec.js b/test/e2e/specs/editor/various/undo.spec.js index 9df1c43b59474..c11a611b10d6c 100644 --- a/test/e2e/specs/editor/various/undo.spec.js +++ b/test/e2e/specs/editor/various/undo.spec.js @@ -11,7 +11,7 @@ test.use( { test.describe( 'undo', () => { test.beforeEach( async ( { admin } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); } ); test( 'should undo typing after a pause', async ( { diff --git a/test/e2e/specs/editor/various/writing-flow.spec.js b/test/e2e/specs/editor/various/writing-flow.spec.js index a772bd91276c2..b31969ec51912 100644 --- a/test/e2e/specs/editor/various/writing-flow.spec.js +++ b/test/e2e/specs/editor/various/writing-flow.spec.js @@ -11,7 +11,7 @@ test.use( { test.describe( 'Writing Flow (@firefox, @webkit)', () => { test.beforeEach( async ( { admin, editor } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); await expect( editor.canvas.getByRole( 'textbox', { name: 'Add title' } ) ).toBeFocused(); diff --git a/test/performance/specs/post-editor.spec.js b/test/performance/specs/post-editor.spec.js index 6001f0d938cf4..0ca617c4e4153 100644 --- a/test/performance/specs/post-editor.spec.js +++ b/test/performance/specs/post-editor.spec.js @@ -51,7 +51,7 @@ test.describe( 'Post Editor Performance', () => { let draftId = null; test( 'Setup the test post', async ( { admin, perfUtils } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); await perfUtils.loadBlocksForLargePost(); draftId = await perfUtils.saveDraft(); } ); @@ -97,7 +97,7 @@ test.describe( 'Post Editor Performance', () => { let draftId = null; test( 'Setup the test post', async ( { admin, perfUtils, editor } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); await perfUtils.loadBlocksForLargePost(); await editor.insertBlock( { name: 'core/paragraph' } ); draftId = await perfUtils.saveDraft(); @@ -150,7 +150,7 @@ test.describe( 'Post Editor Performance', () => { let draftId = null; test( 'Set up the test post', async ( { admin, perfUtils } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); await perfUtils.loadBlocksForSmallPostWithContainers(); draftId = await perfUtils.saveDraft(); } ); @@ -206,7 +206,7 @@ test.describe( 'Post Editor Performance', () => { let draftId = null; test( 'Set up the test post', async ( { admin, perfUtils } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); await perfUtils.load1000Paragraphs(); draftId = await perfUtils.saveDraft(); } ); @@ -261,7 +261,7 @@ test.describe( 'Post Editor Performance', () => { let draftId = null; test( 'Set up the test page', async ( { admin, perfUtils } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); await perfUtils.load1000Paragraphs(); draftId = await perfUtils.saveDraft(); } ); @@ -311,7 +311,7 @@ test.describe( 'Post Editor Performance', () => { let draftId = null; test( 'Set up the test page', async ( { admin, perfUtils } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); await perfUtils.load1000Paragraphs(); draftId = await perfUtils.saveDraft(); } ); @@ -367,7 +367,7 @@ test.describe( 'Post Editor Performance', () => { let draftId = null; test( 'Set up the test page', async ( { admin, perfUtils } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); await perfUtils.load1000Paragraphs(); draftId = await perfUtils.saveDraft(); } ); @@ -423,7 +423,7 @@ test.describe( 'Post Editor Performance', () => { let draftId = null; test( 'Set up the test page', async ( { admin, perfUtils } ) => { - await admin.createNewPost(); + await admin.visitPostEditor(); await perfUtils.load1000Paragraphs(); draftId = await perfUtils.saveDraft(); } ); diff --git a/test/performance/specs/site-editor.spec.js b/test/performance/specs/site-editor.spec.js index f2f211dd52e6e..46e7067c5e3c9 100644 --- a/test/performance/specs/site-editor.spec.js +++ b/test/performance/specs/site-editor.spec.js @@ -60,7 +60,7 @@ test.describe( 'Site Editor Performance', () => { let draftURL = null; test( 'Setup the test page', async ( { page, admin, perfUtils } ) => { - await admin.createNewPost( { postType: 'page' } ); + await admin.visitPostEditor( { postType: 'page' } ); await perfUtils.loadBlocksForLargePost(); await perfUtils.saveDraft(); @@ -117,7 +117,7 @@ test.describe( 'Site Editor Performance', () => { editor, perfUtils, } ) => { - await admin.createNewPost( { postType: 'page' } ); + await admin.visitPostEditor( { postType: 'page' } ); await perfUtils.loadBlocksForLargePost(); await editor.insertBlock( { name: 'core/paragraph' } ); await perfUtils.saveDraft(); From d2aba51c6b6a3bedfcf5fabc23757a44328d472d Mon Sep 17 00:00:00 2001 From: Bart Kalisz Date: Tue, 17 Oct 2023 14:57:08 +0200 Subject: [PATCH 12/17] Update visitSiteEditor to use URLSearchParams --- .../src/admin/visit-site-editor.ts | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) 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 6560850225bbe..9d16c9046293c 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,8 +1,3 @@ -/** - * WordPress dependencies - */ -import { addQueryArgs } from '@wordpress/url'; - /** * Internal dependencies */ @@ -26,14 +21,15 @@ export async function visitSiteEditor( this: Admin, options: SiteEditorOptions = {} ) { - const query = addQueryArgs( '', { - postId: options.postId, - postType: options.postType, - path: options.path, - canvas: options.canvas, - } ).slice( 1 ); + 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 ); + await this.visitAdminPage( 'site-editor.php', query.toString() ); if ( ! options.showWelcomeGuide ) { await this.editor.setPreferences( 'core/edit-site', { From 9559d8e2e1981a7d9234a793a9fcb74f97d3ee4a Mon Sep 17 00:00:00 2001 From: Bart Kalisz Date: Tue, 17 Oct 2023 15:03:23 +0200 Subject: [PATCH 13/17] Restore canvas check to avoid unrelated changes --- .../src/admin/visit-site-editor.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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 9d16c9046293c..0f5d6010a58aa 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 @@ -11,6 +11,8 @@ interface SiteEditorOptions { showWelcomeGuide?: boolean; } +const CANVAS_SELECTOR = 'iframe[title="Editor canvas"i] >> visible=true'; + /** * Visits the Site Editor main page. * @@ -40,7 +42,18 @@ export async function visitSiteEditor( } ); } - // TODO: Ideally the content underneath the canvas loader should be marked inert until it's ready. + // 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. await this.page .locator( '.edit-site-canvas-loader' ) // Bigger timeout is needed for larger entities, for example the large From 7658a0a94536723540a0cb63783fd1bf7e90464a Mon Sep 17 00:00:00 2001 From: Bart Kalisz Date: Wed, 18 Oct 2023 12:14:35 +0200 Subject: [PATCH 14/17] Fix accidental page->editor rename --- test/performance/specs/post-editor.spec.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/test/performance/specs/post-editor.spec.js b/test/performance/specs/post-editor.spec.js index 0ca617c4e4153..1d5219677284c 100644 --- a/test/performance/specs/post-editor.spec.js +++ b/test/performance/specs/post-editor.spec.js @@ -211,12 +211,7 @@ test.describe( 'Post Editor Performance', () => { draftId = await perfUtils.saveDraft(); } ); - test( 'Run the test', async ( { - admin, - editor, - perfUtils, - metrics, - } ) => { + test( 'Run the test', async ( { admin, page, perfUtils, metrics } ) => { await admin.visitPostEditor( { postId: draftId } ); await perfUtils.disableAutosave(); const canvas = await perfUtils.getCanvas(); @@ -231,7 +226,7 @@ test.describe( 'Post Editor Performance', () => { for ( let i = 1; i <= iterations; i++ ) { // Wait for the browser to be idle before starting the monitoring. // eslint-disable-next-line no-restricted-syntax - await editor.waitForTimeout( BROWSER_IDLE_WAIT ); + await page.waitForTimeout( BROWSER_IDLE_WAIT ); // Start tracing. await metrics.startTracing(); From 36b26c2470ea0ba2ac1c4d8063c6e01227ade6e7 Mon Sep 17 00:00:00 2001 From: Bart Kalisz Date: Wed, 18 Oct 2023 16:28:19 +0200 Subject: [PATCH 15/17] Increase perf tests action timeout to 2 minutes. 10 seconds doesn't cut it for the perf tests as we're often testing against a large content there. --- test/performance/playwright.config.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/test/performance/playwright.config.ts b/test/performance/playwright.config.ts index a8208342ac2d8..ed221b1dc7bfb 100644 --- a/test/performance/playwright.config.ts +++ b/test/performance/playwright.config.ts @@ -27,6 +27,7 @@ const config = defineConfig( { ), use: { ...baseConfig.use, + actionTimeout: 120_000, // 2 minutes. video: 'off', }, } ); From 99c2b2dbf158bf154f363e27725b4a8e2186fb88 Mon Sep 17 00:00:00 2001 From: Bart Kalisz Date: Thu, 19 Oct 2023 13:21:27 +0200 Subject: [PATCH 16/17] Remove canvas waiter from visitSiteEditor as it's actually breaking some tests --- .../src/admin/visit-site-editor.ts | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) 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 0f5d6010a58aa..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 @@ -11,8 +11,6 @@ interface SiteEditorOptions { showWelcomeGuide?: boolean; } -const CANVAS_SELECTOR = 'iframe[title="Editor canvas"i] >> visible=true'; - /** * Visits the Site Editor main page. * @@ -42,18 +40,12 @@ export async function visitSiteEditor( } ); } - // 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 From fa96ad246e4d4ef879730f7bd9a27b2e476287de Mon Sep 17 00:00:00 2001 From: Bart Kalisz Date: Fri, 3 Nov 2023 16:35:56 +0100 Subject: [PATCH 17/17] Drop visitPostEditor in favor of createNewPost + editPost --- .../src/admin/create-new-post.ts | 38 ++++++++++++++ .../src/admin/edit-post.ts | 24 +++++++++ .../src/admin/index.ts | 9 ++-- .../src/admin/visit-post-editor.ts | 52 ------------------- test/e2e/specs/editor/blocks/avatar.spec.js | 2 +- test/e2e/specs/editor/blocks/buttons.spec.js | 2 +- test/e2e/specs/editor/blocks/classic.spec.js | 2 +- test/e2e/specs/editor/blocks/code.spec.js | 2 +- test/e2e/specs/editor/blocks/columns.spec.js | 2 +- test/e2e/specs/editor/blocks/comments.spec.js | 12 ++--- test/e2e/specs/editor/blocks/cover.spec.js | 2 +- test/e2e/specs/editor/blocks/gallery.spec.js | 10 ++-- test/e2e/specs/editor/blocks/group.spec.js | 2 +- test/e2e/specs/editor/blocks/heading.spec.js | 2 +- test/e2e/specs/editor/blocks/html.spec.js | 2 +- test/e2e/specs/editor/blocks/image.spec.js | 4 +- test/e2e/specs/editor/blocks/links.spec.js | 6 +-- test/e2e/specs/editor/blocks/list.spec.js | 2 +- test/e2e/specs/editor/blocks/missing.spec.js | 2 +- .../editor/blocks/navigation-colors.spec.js | 2 +- .../blocks/navigation-list-view.spec.js | 2 +- .../specs/editor/blocks/navigation.spec.js | 16 +++--- .../e2e/specs/editor/blocks/paragraph.spec.js | 2 +- .../specs/editor/blocks/post-title.spec.js | 2 +- .../specs/editor/blocks/preformatted.spec.js | 2 +- .../e2e/specs/editor/blocks/pullquote.spec.js | 2 +- test/e2e/specs/editor/blocks/query.spec.js | 2 +- test/e2e/specs/editor/blocks/quote.spec.js | 2 +- test/e2e/specs/editor/blocks/search.spec.js | 2 +- .../e2e/specs/editor/blocks/separator.spec.js | 2 +- test/e2e/specs/editor/blocks/spacer.spec.js | 2 +- test/e2e/specs/editor/blocks/table.spec.js | 2 +- .../blocks/verse-code-preformatted.spec.js | 2 +- .../editor/plugins/allowed-blocks.spec.js | 2 +- .../specs/editor/plugins/block-api.spec.js | 2 +- .../editor/plugins/block-variations.spec.js | 2 +- .../editor/plugins/custom-post-types.spec.js | 6 +-- .../plugins/deprecated-node-matcher.spec.js | 2 +- .../specs/editor/plugins/format-api.spec.js | 2 +- .../specs/editor/plugins/hooks-api.spec.js | 2 +- .../editor/plugins/iframed-block.spec.js | 2 +- ...amed-enqueue-block-editor-settings.spec.js | 2 +- .../iframed-equeue-block-assets.spec.js | 2 +- .../plugins/iframed-inline-styles.spec.js | 2 +- .../plugins/iframed-masonry-block.spec.js | 2 +- ...iframed-multiple-block-stylesheets.spec.js | 2 +- .../specs/editor/plugins/image-size.spec.js | 2 +- .../inner-blocks-allowed-blocks.spec.js | 2 +- test/e2e/specs/editor/plugins/nonce.spec.js | 2 +- .../plugins/post-type-templates.spec.js | 8 +-- .../plugins/register-block-type-hooks.spec.js | 2 +- .../editor/plugins/wp-editor-meta-box.spec.js | 2 +- .../various/a11y-region-navigation.spec.js | 2 +- test/e2e/specs/editor/various/a11y.spec.js | 2 +- .../various/adding-inline-tokens.spec.js | 2 +- .../editor/various/adding-patterns.spec.js | 2 +- .../various/autocomplete-and-mentions.spec.js | 2 +- .../editor/various/block-deletion.spec.js | 2 +- .../block-hierarchy-navigation.spec.js | 2 +- .../editor/various/block-locking.spec.js | 2 +- .../specs/editor/various/block-mover.spec.js | 2 +- .../editor/various/block-moving-mode.spec.js | 2 +- .../editor/various/block-renaming.spec.js | 2 +- .../various/block-switcher-test.spec.js | 2 +- .../compatibility-classic-editor.spec.js | 2 +- .../editor/various/content-only-lock.spec.js | 2 +- .../editor/various/convert-block-type.spec.js | 2 +- .../editor/various/copy-cut-paste.spec.js | 2 +- .../editor/various/draggable-blocks.spec.js | 2 +- .../editor/various/duplicating-blocks.spec.js | 2 +- .../editor/various/font-size-picker.spec.js | 2 +- .../specs/editor/various/footnotes.spec.js | 2 +- .../various/format-library/text-color.spec.js | 2 +- .../editor/various/fullscreen-mode.spec.js | 2 +- .../various/inner-blocks-templates.spec.js | 2 +- .../editor/various/inserting-blocks.spec.js | 12 ++--- .../keep-styles-on-block-transforms.spec.js | 2 +- .../various/keyboard-navigable-blocks.spec.js | 2 +- .../specs/editor/various/list-view.spec.js | 2 +- .../e2e/specs/editor/various/mentions.spec.js | 2 +- .../various/multi-block-selection.spec.js | 2 +- .../editor/various/navigable-toolbar.spec.js | 2 +- .../various/new-post-default-content.spec.js | 2 +- .../e2e/specs/editor/various/new-post.spec.js | 10 ++-- .../e2e/specs/editor/various/patterns.spec.js | 2 +- .../e2e/specs/editor/various/popovers.spec.js | 2 +- .../various/post-editor-template-mode.spec.js | 2 +- .../editor/various/post-visibility.spec.js | 6 +-- test/e2e/specs/editor/various/preview.spec.js | 6 +-- .../editor/various/publish-panel.spec.js | 2 +- .../rich-text-deprecated-multiline.spec.js | 2 +- .../specs/editor/various/rich-text.spec.js | 2 +- test/e2e/specs/editor/various/rtl.spec.js | 2 +- .../various/shortcut-focus-toolbar.spec.js | 2 +- .../editor/various/shortcut-help.spec.js | 2 +- .../editor/various/splitting-merging.spec.js | 2 +- .../editor/various/style-variation.spec.js | 2 +- .../editor/various/switch-to-draft.spec.js | 2 +- .../various/toolbar-roving-tabindex.spec.js | 2 +- test/e2e/specs/editor/various/undo.spec.js | 2 +- .../specs/editor/various/writing-flow.spec.js | 2 +- test/performance/specs/post-editor.spec.js | 32 ++++++------ test/performance/specs/site-editor.spec.js | 4 +- 103 files changed, 220 insertions(+), 207 deletions(-) create mode 100644 packages/e2e-test-utils-playwright/src/admin/create-new-post.ts create mode 100644 packages/e2e-test-utils-playwright/src/admin/edit-post.ts delete mode 100644 packages/e2e-test-utils-playwright/src/admin/visit-post-editor.ts 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 e2d9c7697f2a2..08d2baf4b6520 100644 --- a/packages/e2e-test-utils-playwright/src/admin/index.ts +++ b/packages/e2e-test-utils-playwright/src/admin/index.ts @@ -6,9 +6,10 @@ import type { Browser, Page, BrowserContext } from '@playwright/test'; /** * Internal dependencies */ +import { createNewPost } from './create-new-post'; import { getPageError } from './get-page-error'; import { visitAdminPage } from './visit-admin-page'; -import { visitPostEditor } from './visit-post-editor'; +import { editPost } from './edit-post'; import { visitSiteEditor } from './visit-site-editor'; import type { PageUtils } from '../page-utils'; import type { Editor } from '../editor'; @@ -34,12 +35,14 @@ export class Admin { 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 */ visitAdminPage: typeof visitAdminPage = visitAdminPage.bind( this ); - /** @borrows visitPostEditor as this.visitPostEditor */ - visitPostEditor: typeof visitPostEditor = visitPostEditor.bind( this ); /** @borrows visitSiteEditor as this.visitSiteEditor */ visitSiteEditor: typeof visitSiteEditor = visitSiteEditor.bind( this ); } diff --git a/packages/e2e-test-utils-playwright/src/admin/visit-post-editor.ts b/packages/e2e-test-utils-playwright/src/admin/visit-post-editor.ts deleted file mode 100644 index a0b0662e52e4b..0000000000000 --- a/packages/e2e-test-utils-playwright/src/admin/visit-post-editor.ts +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Internal dependencies - */ -import type { Admin } from './'; - -interface PostEditorOptions { - postId?: string | number; - postType?: string; - title?: string; - content?: string; - excerpt?: string; - showWelcomeGuide?: boolean; -} - -/** - * Creates new post or visits existing post if postId is provided. - * - * @param this - * @param options Options to create or visit post. - */ -export async function visitPostEditor( - this: Admin, - options: PostEditorOptions = {} -) { - const query = new URLSearchParams(); - let adminPage: string; - - if ( options.postId ) { - const { postId } = options; - - adminPage = 'post.php'; - - query.set( 'post', String( postId ) ); - query.set( 'action', 'edit' ); - } else { - const { postType, title, content, excerpt } = options; - - adminPage = 'post-new.php'; - - 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( adminPage, query.toString() ); - - await this.editor.setPreferences( 'core/edit-post', { - welcomeGuide: options.showWelcomeGuide ?? false, - fullscreenMode: false, - } ); -} diff --git a/test/e2e/specs/editor/blocks/avatar.spec.js b/test/e2e/specs/editor/blocks/avatar.spec.js index b02120f6e46c6..8bf39a7a60dba 100644 --- a/test/e2e/specs/editor/blocks/avatar.spec.js +++ b/test/e2e/specs/editor/blocks/avatar.spec.js @@ -19,7 +19,7 @@ test.describe( 'Avatar', () => { password: 'gravatargravatar123magic', } ); - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test.afterEach( async ( { requestUtils } ) => { diff --git a/test/e2e/specs/editor/blocks/buttons.spec.js b/test/e2e/specs/editor/blocks/buttons.spec.js index d986b2a106090..dcddfca2b5b28 100644 --- a/test/e2e/specs/editor/blocks/buttons.spec.js +++ b/test/e2e/specs/editor/blocks/buttons.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Buttons', () => { test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test( 'has focus on button content', async ( { editor, page } ) => { diff --git a/test/e2e/specs/editor/blocks/classic.spec.js b/test/e2e/specs/editor/blocks/classic.spec.js index 5ed43f2097ade..95d39906b0d8b 100644 --- a/test/e2e/specs/editor/blocks/classic.spec.js +++ b/test/e2e/specs/editor/blocks/classic.spec.js @@ -19,7 +19,7 @@ test.use( { test.describe( 'Classic', () => { test.beforeEach( async ( { admin, editor } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); // To do: run with iframe. await editor.switchToLegacyCanvas(); } ); diff --git a/test/e2e/specs/editor/blocks/code.spec.js b/test/e2e/specs/editor/blocks/code.spec.js index 6fdcb6dc9a5e5..6abfb15d10b83 100644 --- a/test/e2e/specs/editor/blocks/code.spec.js +++ b/test/e2e/specs/editor/blocks/code.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Code', () => { test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test( 'can be created by three backticks and enter', async ( { diff --git a/test/e2e/specs/editor/blocks/columns.spec.js b/test/e2e/specs/editor/blocks/columns.spec.js index 78c80439314fa..bcb23c9a24099 100644 --- a/test/e2e/specs/editor/blocks/columns.spec.js +++ b/test/e2e/specs/editor/blocks/columns.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Columns', () => { test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test.afterEach( async ( { requestUtils } ) => { diff --git a/test/e2e/specs/editor/blocks/comments.spec.js b/test/e2e/specs/editor/blocks/comments.spec.js index 8bd7b59631ce4..7fddb22f6a763 100644 --- a/test/e2e/specs/editor/blocks/comments.spec.js +++ b/test/e2e/specs/editor/blocks/comments.spec.js @@ -48,7 +48,7 @@ test.describe( 'Comments', () => { requestUtils, } ) => { await requestUtils.deleteAllComments(); - await admin.visitPostEditor(); + await admin.createNewPost(); await editor.insertBlock( { name: 'core/comments' } ); await expect( editor.canvas.locator( @@ -63,7 +63,7 @@ test.describe( 'Comments', () => { page, requestUtils, } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); await editor.insertBlock( { name: 'core/comments' } ); const postId = await editor.publishPost(); @@ -117,7 +117,7 @@ test.describe( 'Comments', () => { commentsBlockUtils, } ) => { await commentsBlockUtils.setOption( 'page_comments', '0' ); - await admin.visitPostEditor(); + await admin.createNewPost(); await editor.insertBlock( { name: 'core/comments' } ); const postId = await editor.publishPost(); @@ -147,7 +147,7 @@ test.describe( 'Comments', () => { admin, editor, } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); await editor.insertBlock( { name: 'core/comments', attributes: { legacy: true, textColor: 'vivid-purple' }, @@ -184,7 +184,7 @@ test.describe( 'Comments', () => { editor, requestUtils, } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); await editor.insertBlock( { name: 'core/comments' } ); const postId = await editor.publishPost(); @@ -212,7 +212,7 @@ test.describe( 'Comments', () => { editor, requestUtils, } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); await editor.insertBlock( { name: 'core/comments', attributes: { legacy: true }, diff --git a/test/e2e/specs/editor/blocks/cover.spec.js b/test/e2e/specs/editor/blocks/cover.spec.js index 0a11de3b4abde..fa5103ebaa4ee 100644 --- a/test/e2e/specs/editor/blocks/cover.spec.js +++ b/test/e2e/specs/editor/blocks/cover.spec.js @@ -21,7 +21,7 @@ test.use( { test.describe( 'Cover', () => { test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test( 'can set overlay color using color picker on block placeholder', async ( { diff --git a/test/e2e/specs/editor/blocks/gallery.spec.js b/test/e2e/specs/editor/blocks/gallery.spec.js index d2b7f0462404f..ef693cb8b5bb9 100644 --- a/test/e2e/specs/editor/blocks/gallery.spec.js +++ b/test/e2e/specs/editor/blocks/gallery.spec.js @@ -45,7 +45,7 @@ test.describe( 'Gallery', () => { page, pageUtils, } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); pageUtils.setClipboardData( { plainText: `[gallery ids="${ uploadedMedia.id }"]`, @@ -91,7 +91,7 @@ test.describe( 'Gallery', () => { editor, galleryBlockUtils, } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); await editor.insertBlock( { name: 'core/gallery' } ); const galleryBlock = editor.canvas.locator( 'role=document[name="Block: Gallery"i]' @@ -119,7 +119,7 @@ test.describe( 'Gallery', () => { } ) => { const galleryCaption = 'Tested gallery caption'; - await admin.visitPostEditor(); + await admin.createNewPost(); await editor.insertBlock( { name: 'core/gallery', innerBlocks: [ @@ -162,7 +162,7 @@ test.describe( 'Gallery', () => { } ) => { const caption = 'Tested caption'; - await admin.visitPostEditor(); + await admin.createNewPost(); await editor.insertBlock( { name: 'core/gallery', innerBlocks: [ @@ -204,7 +204,7 @@ test.describe( 'Gallery', () => { editor, page, } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); await editor.insertBlock( { name: 'core/gallery' } ); await editor.canvas .locator( 'role=button[name="Media Library"i]' ) diff --git a/test/e2e/specs/editor/blocks/group.spec.js b/test/e2e/specs/editor/blocks/group.spec.js index cf493cd694b9e..ccf522d8c4d53 100644 --- a/test/e2e/specs/editor/blocks/group.spec.js +++ b/test/e2e/specs/editor/blocks/group.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Group', () => { test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test( 'can be created using the block inserter', async ( { diff --git a/test/e2e/specs/editor/blocks/heading.spec.js b/test/e2e/specs/editor/blocks/heading.spec.js index f9ed8dec4e9f3..705bce2c3f2c9 100644 --- a/test/e2e/specs/editor/blocks/heading.spec.js +++ b/test/e2e/specs/editor/blocks/heading.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Heading', () => { test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test( 'can be created by prefixing number sign and a space', async ( { diff --git a/test/e2e/specs/editor/blocks/html.spec.js b/test/e2e/specs/editor/blocks/html.spec.js index 6f981fdc5e616..f034da6efe617 100644 --- a/test/e2e/specs/editor/blocks/html.spec.js +++ b/test/e2e/specs/editor/blocks/html.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'HTML block', () => { test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test( 'can be created by typing "/html"', async ( { editor, page } ) => { diff --git a/test/e2e/specs/editor/blocks/image.spec.js b/test/e2e/specs/editor/blocks/image.spec.js index 0caa22839236f..db3ff72e3ab6e 100644 --- a/test/e2e/specs/editor/blocks/image.spec.js +++ b/test/e2e/specs/editor/blocks/image.spec.js @@ -25,7 +25,7 @@ test.describe( 'Image', () => { } ); test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test.afterEach( async ( { requestUtils } ) => { @@ -738,7 +738,7 @@ test.describe.skip( 'Image - interactivity', () => { } ); test.beforeEach( async ( { admin, editor } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); await editor.insertBlock( { name: 'core/image' } ); } ); diff --git a/test/e2e/specs/editor/blocks/links.spec.js b/test/e2e/specs/editor/blocks/links.spec.js index 039cd73dd0795..7e654ca12790f 100644 --- a/test/e2e/specs/editor/blocks/links.spec.js +++ b/test/e2e/specs/editor/blocks/links.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Links', () => { test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test.afterEach( async ( { requestUtils } ) => { @@ -30,7 +30,7 @@ test.describe( 'Links', () => { status: 'publish', } ); - await admin.visitPostEditor(); + await admin.createNewPost(); // Now in a new post and try to create a link from an autocomplete suggestion using the keyboard. await editor.insertBlock( { @@ -373,7 +373,7 @@ test.describe( 'Links', () => { status: 'publish', } ); - await admin.visitPostEditor(); + await admin.createNewPost(); // Now in a new post and try to create a link from an autocomplete suggestion using the keyboard. await editor.insertBlock( { diff --git a/test/e2e/specs/editor/blocks/list.spec.js b/test/e2e/specs/editor/blocks/list.spec.js index f1bc47c6886bd..f10a266a41e65 100644 --- a/test/e2e/specs/editor/blocks/list.spec.js +++ b/test/e2e/specs/editor/blocks/list.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'List (@firefox)', () => { test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test( 'can be created by using an asterisk at the start of a paragraph block', async ( { diff --git a/test/e2e/specs/editor/blocks/missing.spec.js b/test/e2e/specs/editor/blocks/missing.spec.js index 91fcd741ea711..69c26c3f85876 100644 --- a/test/e2e/specs/editor/blocks/missing.spec.js +++ b/test/e2e/specs/editor/blocks/missing.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'missing block', () => { test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test( 'should strip potentially malicious on* attributes', async ( { diff --git a/test/e2e/specs/editor/blocks/navigation-colors.spec.js b/test/e2e/specs/editor/blocks/navigation-colors.spec.js index 3c3c8581731dd..1ddd4af8ab2e1 100644 --- a/test/e2e/specs/editor/blocks/navigation-colors.spec.js +++ b/test/e2e/specs/editor/blocks/navigation-colors.spec.js @@ -25,7 +25,7 @@ test.describe( 'Navigation colors', () => { attributes: { openSubmenusOnClick: true }, } ); - await admin.visitPostEditor(); + await admin.createNewPost(); await editor.insertBlock( { name: 'core/navigation', diff --git a/test/e2e/specs/editor/blocks/navigation-list-view.spec.js b/test/e2e/specs/editor/blocks/navigation-list-view.spec.js index d4249e193db53..fd7113fe17095 100644 --- a/test/e2e/specs/editor/blocks/navigation-list-view.spec.js +++ b/test/e2e/specs/editor/blocks/navigation-list-view.spec.js @@ -29,7 +29,7 @@ test.describe( 'Navigation block - List view editing', () => { } ); test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test.afterAll( async ( { requestUtils } ) => { diff --git a/test/e2e/specs/editor/blocks/navigation.spec.js b/test/e2e/specs/editor/blocks/navigation.spec.js index ccb7b7a402dbc..4757ccbb4a00f 100644 --- a/test/e2e/specs/editor/blocks/navigation.spec.js +++ b/test/e2e/specs/editor/blocks/navigation.spec.js @@ -24,7 +24,7 @@ test.describe( 'Navigation block', () => { admin, editor, } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); await editor.insertBlock( { name: 'core/navigation' } ); const pageListBlock = editor.canvas.getByRole( 'document', { @@ -52,7 +52,7 @@ test.describe( 'Navigation block', () => { page, requestUtils, } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); const createdMenu = await requestUtils.createNavigationMenu( { title: 'Test Menu 1', content: @@ -96,7 +96,7 @@ test.describe( 'Navigation block', () => { } ) => { // Create a classic menu. await requestUtils.createClassicMenu( 'Test Classic 1' ); - await admin.visitPostEditor(); + await admin.createNewPost(); await editor.insertBlock( { name: 'core/navigation' } ); // We need to check the canvas after inserting the navigation block to be able to target the block. @@ -130,7 +130,7 @@ test.describe( 'Navigation block', () => { editor, requestUtils, } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); await requestUtils.createNavigationMenu( { title: 'Test Menu 1', content: @@ -183,7 +183,7 @@ test.describe( 'Navigation block', () => { editor, requestUtils, } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); await requestUtils.createNavigationMenu( { title: 'Test Menu', content: '', @@ -220,7 +220,7 @@ test.describe( 'Navigation block', () => { editor, requestUtils, } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); await requestUtils.createNavigationMenu( { title: 'Test Menu', content: @@ -264,7 +264,7 @@ test.describe( 'Navigation block', () => { admin, editor, } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); await editor.insertBlock( { name: 'core/navigation', @@ -308,7 +308,7 @@ test.describe( 'Navigation block', () => { } ) ).toHaveLength( 0 ); - await admin.visitPostEditor(); + await admin.createNewPost(); await editor.insertBlock( { name: 'core/navigation', diff --git a/test/e2e/specs/editor/blocks/paragraph.spec.js b/test/e2e/specs/editor/blocks/paragraph.spec.js index 616d1c1d10bee..3cf3654870a35 100644 --- a/test/e2e/specs/editor/blocks/paragraph.spec.js +++ b/test/e2e/specs/editor/blocks/paragraph.spec.js @@ -16,7 +16,7 @@ test.use( { test.describe( 'Paragraph', () => { test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test( 'should output unwrapped editable paragraph', async ( { diff --git a/test/e2e/specs/editor/blocks/post-title.spec.js b/test/e2e/specs/editor/blocks/post-title.spec.js index f00699d465a37..b5c536c0ff246 100644 --- a/test/e2e/specs/editor/blocks/post-title.spec.js +++ b/test/e2e/specs/editor/blocks/post-title.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Post Title block', () => { test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test( 'Can edit the post title', async ( { editor, page } ) => { diff --git a/test/e2e/specs/editor/blocks/preformatted.spec.js b/test/e2e/specs/editor/blocks/preformatted.spec.js index ad50f11d8b941..5cd20a051c4fb 100644 --- a/test/e2e/specs/editor/blocks/preformatted.spec.js +++ b/test/e2e/specs/editor/blocks/preformatted.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Preformatted', () => { test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test( 'should preserve character newlines', async ( { editor, page } ) => { diff --git a/test/e2e/specs/editor/blocks/pullquote.spec.js b/test/e2e/specs/editor/blocks/pullquote.spec.js index 9c78b8271f688..33f833ca53678 100644 --- a/test/e2e/specs/editor/blocks/pullquote.spec.js +++ b/test/e2e/specs/editor/blocks/pullquote.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Quote', () => { test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test( 'can be created by converting a quote and converted back to quote', async ( { diff --git a/test/e2e/specs/editor/blocks/query.spec.js b/test/e2e/specs/editor/blocks/query.spec.js index 44035e2a20f31..dbefb66e353bc 100644 --- a/test/e2e/specs/editor/blocks/query.spec.js +++ b/test/e2e/specs/editor/blocks/query.spec.js @@ -21,7 +21,7 @@ test.describe( 'Query block', () => { } ); test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor( { + await admin.createNewPost( { postType: 'page', title: 'Query Page', } ); diff --git a/test/e2e/specs/editor/blocks/quote.spec.js b/test/e2e/specs/editor/blocks/quote.spec.js index 20cbde17bb67a..d25dedd4a0a39 100644 --- a/test/e2e/specs/editor/blocks/quote.spec.js +++ b/test/e2e/specs/editor/blocks/quote.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Quote', () => { test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test.afterEach( async ( { requestUtils } ) => { diff --git a/test/e2e/specs/editor/blocks/search.spec.js b/test/e2e/specs/editor/blocks/search.spec.js index e51c4e1463cad..d11efd7328afe 100644 --- a/test/e2e/specs/editor/blocks/search.spec.js +++ b/test/e2e/specs/editor/blocks/search.spec.js @@ -6,7 +6,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Search', () => { test.beforeEach( async ( { admin, requestUtils } ) => { await requestUtils.deleteAllMenus(); - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test.afterAll( async ( { requestUtils } ) => { diff --git a/test/e2e/specs/editor/blocks/separator.spec.js b/test/e2e/specs/editor/blocks/separator.spec.js index 35e608172efbd..70c61535e71bf 100644 --- a/test/e2e/specs/editor/blocks/separator.spec.js +++ b/test/e2e/specs/editor/blocks/separator.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Separator', () => { test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test( 'can be created by three dashes and enter', async ( { diff --git a/test/e2e/specs/editor/blocks/spacer.spec.js b/test/e2e/specs/editor/blocks/spacer.spec.js index 4093bf7218aa5..f089402514623 100644 --- a/test/e2e/specs/editor/blocks/spacer.spec.js +++ b/test/e2e/specs/editor/blocks/spacer.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Spacer', () => { test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test( 'can be created by typing "/spacer"', async ( { editor, page } ) => { diff --git a/test/e2e/specs/editor/blocks/table.spec.js b/test/e2e/specs/editor/blocks/table.spec.js index da6380b807e2d..1e6dfdcd76e18 100644 --- a/test/e2e/specs/editor/blocks/table.spec.js +++ b/test/e2e/specs/editor/blocks/table.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Table', () => { test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test( 'displays a form for choosing the row and column count of the table', async ( { diff --git a/test/e2e/specs/editor/blocks/verse-code-preformatted.spec.js b/test/e2e/specs/editor/blocks/verse-code-preformatted.spec.js index 8c0b8a7067fed..c3642bfbca312 100644 --- a/test/e2e/specs/editor/blocks/verse-code-preformatted.spec.js +++ b/test/e2e/specs/editor/blocks/verse-code-preformatted.spec.js @@ -7,7 +7,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); [ 'core/verse', 'core/code', 'core/preformatted' ].forEach( ( blockName ) => { test.describe( blockName, () => { test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test( 'should exit on triple Enter and merge back', async ( { diff --git a/test/e2e/specs/editor/plugins/allowed-blocks.spec.js b/test/e2e/specs/editor/plugins/allowed-blocks.spec.js index 1008b93e4474d..4211e42823821 100644 --- a/test/e2e/specs/editor/plugins/allowed-blocks.spec.js +++ b/test/e2e/specs/editor/plugins/allowed-blocks.spec.js @@ -9,7 +9,7 @@ test.describe( 'Allowed Blocks Filter', () => { } ); test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test.afterAll( async ( { requestUtils } ) => { diff --git a/test/e2e/specs/editor/plugins/block-api.spec.js b/test/e2e/specs/editor/plugins/block-api.spec.js index dbac441f812fa..dd2a89cd2beca 100644 --- a/test/e2e/specs/editor/plugins/block-api.spec.js +++ b/test/e2e/specs/editor/plugins/block-api.spec.js @@ -16,7 +16,7 @@ test.describe( 'Using Block API', () => { admin, editor, } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); await editor.insertBlock( { name: 'e2e-tests/hello-world' } ); diff --git a/test/e2e/specs/editor/plugins/block-variations.spec.js b/test/e2e/specs/editor/plugins/block-variations.spec.js index 9c8de2f6985da..9f12c987efd39 100644 --- a/test/e2e/specs/editor/plugins/block-variations.spec.js +++ b/test/e2e/specs/editor/plugins/block-variations.spec.js @@ -9,7 +9,7 @@ test.describe( 'Block variations', () => { } ); test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test.afterAll( async ( { requestUtils } ) => { diff --git a/test/e2e/specs/editor/plugins/custom-post-types.spec.js b/test/e2e/specs/editor/plugins/custom-post-types.spec.js index 4208cb52870e5..17a497f26cee0 100644 --- a/test/e2e/specs/editor/plugins/custom-post-types.spec.js +++ b/test/e2e/specs/editor/plugins/custom-post-types.spec.js @@ -19,7 +19,7 @@ test.describe( 'Test Custom Post Types', () => { editor, page, } ) => { - await admin.visitPostEditor( { postType: 'hierar-no-title' } ); + await admin.createNewPost( { postType: 'hierar-no-title' } ); await editor.canvas .locator( 'role=button[name="Add default block"i]' ) .click(); @@ -27,7 +27,7 @@ test.describe( 'Test Custom Post Types', () => { await editor.publishPost(); // Create a post that is a child of the previously created post. - await admin.visitPostEditor( { postType: 'hierar-no-title' } ); + await admin.createNewPost( { postType: 'hierar-no-title' } ); await editor.openDocumentSettingsSidebar(); await page .getByRole( 'region', { name: 'Editor settings' } ) @@ -71,7 +71,7 @@ test.describe( 'Test Custom Post Types', () => { editor, page, } ) => { - await admin.visitPostEditor( { postType: 'leg_block_in_tpl' } ); + await admin.createNewPost( { postType: 'leg_block_in_tpl' } ); await editor.canvas .locator( 'role=button[name="Add default block"i]' ) .click(); diff --git a/test/e2e/specs/editor/plugins/deprecated-node-matcher.spec.js b/test/e2e/specs/editor/plugins/deprecated-node-matcher.spec.js index 3fc89c987a680..58f742341ebc3 100644 --- a/test/e2e/specs/editor/plugins/deprecated-node-matcher.spec.js +++ b/test/e2e/specs/editor/plugins/deprecated-node-matcher.spec.js @@ -14,7 +14,7 @@ test.describe( 'Deprecated Node Matcher', () => { } ); test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test.afterAll( async ( { requestUtils } ) => { diff --git a/test/e2e/specs/editor/plugins/format-api.spec.js b/test/e2e/specs/editor/plugins/format-api.spec.js index d861194dfdc9a..1e631615313bd 100644 --- a/test/e2e/specs/editor/plugins/format-api.spec.js +++ b/test/e2e/specs/editor/plugins/format-api.spec.js @@ -13,7 +13,7 @@ test.describe( 'Using Format API', () => { } ); test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test( 'Clicking the control wraps the selected text properly with HTML code', async ( { diff --git a/test/e2e/specs/editor/plugins/hooks-api.spec.js b/test/e2e/specs/editor/plugins/hooks-api.spec.js index d397f4b33c0a4..95bc5bf8bfd2c 100644 --- a/test/e2e/specs/editor/plugins/hooks-api.spec.js +++ b/test/e2e/specs/editor/plugins/hooks-api.spec.js @@ -14,7 +14,7 @@ test.describe( 'Using Hooks API', () => { } ); test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test( 'Should contain a reset block button on the sidebar', async ( { diff --git a/test/e2e/specs/editor/plugins/iframed-block.spec.js b/test/e2e/specs/editor/plugins/iframed-block.spec.js index 8325c3a7589a7..0b5343169d5bf 100644 --- a/test/e2e/specs/editor/plugins/iframed-block.spec.js +++ b/test/e2e/specs/editor/plugins/iframed-block.spec.js @@ -6,7 +6,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Iframed block', () => { test.beforeEach( async ( { requestUtils, admin } ) => { await requestUtils.activatePlugin( 'gutenberg-test-iframed-block' ); - await admin.visitPostEditor( { postType: 'page' } ); + await admin.createNewPost( { postType: 'page' } ); } ); test.afterEach( async ( { requestUtils } ) => { diff --git a/test/e2e/specs/editor/plugins/iframed-enqueue-block-editor-settings.spec.js b/test/e2e/specs/editor/plugins/iframed-enqueue-block-editor-settings.spec.js index cfa19599487fc..b4f502b2c9d0b 100644 --- a/test/e2e/specs/editor/plugins/iframed-enqueue-block-editor-settings.spec.js +++ b/test/e2e/specs/editor/plugins/iframed-enqueue-block-editor-settings.spec.js @@ -11,7 +11,7 @@ test.describe( 'iframed block editor settings styles', () => { } ); test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test.afterAll( async ( { requestUtils } ) => { diff --git a/test/e2e/specs/editor/plugins/iframed-equeue-block-assets.spec.js b/test/e2e/specs/editor/plugins/iframed-equeue-block-assets.spec.js index 02877de0a7396..a523ba1f8e9e3 100644 --- a/test/e2e/specs/editor/plugins/iframed-equeue-block-assets.spec.js +++ b/test/e2e/specs/editor/plugins/iframed-equeue-block-assets.spec.js @@ -14,7 +14,7 @@ test.describe( 'iframed enqueue block assets', () => { } ); test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test.afterAll( async ( { requestUtils } ) => { diff --git a/test/e2e/specs/editor/plugins/iframed-inline-styles.spec.js b/test/e2e/specs/editor/plugins/iframed-inline-styles.spec.js index b1ba8af1a5414..8fa4cbffa9df8 100644 --- a/test/e2e/specs/editor/plugins/iframed-inline-styles.spec.js +++ b/test/e2e/specs/editor/plugins/iframed-inline-styles.spec.js @@ -28,7 +28,7 @@ test.describe( 'iframed inline styles', () => { } } ); - await admin.visitPostEditor( { postType: 'page' } ); + await admin.createNewPost( { postType: 'page' } ); await editor.insertBlock( { name: 'test/iframed-inline-styles' } ); const block = editor.canvas.getByRole( 'document', { diff --git a/test/e2e/specs/editor/plugins/iframed-masonry-block.spec.js b/test/e2e/specs/editor/plugins/iframed-masonry-block.spec.js index c06346df0c17a..edc6b0a68cd4a 100644 --- a/test/e2e/specs/editor/plugins/iframed-masonry-block.spec.js +++ b/test/e2e/specs/editor/plugins/iframed-masonry-block.spec.js @@ -11,7 +11,7 @@ test.describe( 'iframed masonry block', () => { } ); test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test.afterAll( async ( { requestUtils } ) => { diff --git a/test/e2e/specs/editor/plugins/iframed-multiple-block-stylesheets.spec.js b/test/e2e/specs/editor/plugins/iframed-multiple-block-stylesheets.spec.js index 81af1c7666dc9..2e6f5b6b0cb6a 100644 --- a/test/e2e/specs/editor/plugins/iframed-multiple-block-stylesheets.spec.js +++ b/test/e2e/specs/editor/plugins/iframed-multiple-block-stylesheets.spec.js @@ -11,7 +11,7 @@ test.describe( 'iframed multiple block stylesheets', () => { } ); test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor( { postType: 'page' } ); + await admin.createNewPost( { postType: 'page' } ); } ); test.afterAll( async ( { requestUtils } ) => { diff --git a/test/e2e/specs/editor/plugins/image-size.spec.js b/test/e2e/specs/editor/plugins/image-size.spec.js index efb57f41c1b5a..1e0bc91407565 100644 --- a/test/e2e/specs/editor/plugins/image-size.spec.js +++ b/test/e2e/specs/editor/plugins/image-size.spec.js @@ -31,7 +31,7 @@ test.describe( 'changing image size', () => { const filename = '1024x768_e2e_test_image_size.jpeg'; const filepath = path.join( './test/e2e/assets', filename ); - await admin.visitPostEditor(); + await admin.createNewPost(); const media = await requestUtils.uploadMedia( filepath ); await editor.insertBlock( { diff --git a/test/e2e/specs/editor/plugins/inner-blocks-allowed-blocks.spec.js b/test/e2e/specs/editor/plugins/inner-blocks-allowed-blocks.spec.js index e61814019f1fa..c0627121f1649 100644 --- a/test/e2e/specs/editor/plugins/inner-blocks-allowed-blocks.spec.js +++ b/test/e2e/specs/editor/plugins/inner-blocks-allowed-blocks.spec.js @@ -17,7 +17,7 @@ test.describe( 'Allowed Blocks Setting on InnerBlocks', () => { } ); test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test( 'allows all blocks if the allowed blocks setting was not set', async ( { diff --git a/test/e2e/specs/editor/plugins/nonce.spec.js b/test/e2e/specs/editor/plugins/nonce.spec.js index b15d0534c485c..1fbb6add87ff7 100644 --- a/test/e2e/specs/editor/plugins/nonce.spec.js +++ b/test/e2e/specs/editor/plugins/nonce.spec.js @@ -14,7 +14,7 @@ test.describe( 'Nonce', () => { requestUtils, editor, } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); await expect( editor.canvas.getByRole( 'textbox', { name: 'Add title' } ) ).toBeFocused(); diff --git a/test/e2e/specs/editor/plugins/post-type-templates.spec.js b/test/e2e/specs/editor/plugins/post-type-templates.spec.js index 17a05cac3f1e4..a95f826c1f74c 100644 --- a/test/e2e/specs/editor/plugins/post-type-templates.spec.js +++ b/test/e2e/specs/editor/plugins/post-type-templates.spec.js @@ -12,7 +12,7 @@ test.describe( 'Post type templates', () => { } ); test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor( { postType: 'book' } ); + await admin.createNewPost( { postType: 'book' } ); } ); test.afterAll( async ( { requestUtils } ) => { @@ -99,7 +99,7 @@ test.describe( 'Post type templates', () => { admin, editor, } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); await expect.poll( editor.getEditedPostContent ) .toBe( ` @@ -112,7 +112,7 @@ test.describe( 'Post type templates', () => { page, editor, } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); // Remove the default block template to verify that it's not // re-added after saving and reloading the editor. @@ -133,7 +133,7 @@ test.describe( 'Post type templates', () => { admin, editor, } ) => { - await admin.visitPostEditor( { postType: 'page' } ); + await admin.createNewPost( { postType: 'page' } ); await expect.poll( editor.getEditedPostContent ).toBe( '' ); } ); diff --git a/test/e2e/specs/editor/plugins/register-block-type-hooks.spec.js b/test/e2e/specs/editor/plugins/register-block-type-hooks.spec.js index 4e3e6cc8d4351..2ec62ffd056d3 100644 --- a/test/e2e/specs/editor/plugins/register-block-type-hooks.spec.js +++ b/test/e2e/specs/editor/plugins/register-block-type-hooks.spec.js @@ -8,7 +8,7 @@ test.describe( 'Register block type hooks', () => { await requestUtils.activatePlugin( 'gutenberg-test-register-block-type-hooks' ); - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test.afterEach( async ( { requestUtils } ) => { diff --git a/test/e2e/specs/editor/plugins/wp-editor-meta-box.spec.js b/test/e2e/specs/editor/plugins/wp-editor-meta-box.spec.js index f50a0073d49f6..710e06b35e124 100644 --- a/test/e2e/specs/editor/plugins/wp-editor-meta-box.spec.js +++ b/test/e2e/specs/editor/plugins/wp-editor-meta-box.spec.js @@ -17,7 +17,7 @@ test.describe( 'WP Editor Meta Boxes', () => { } ); test( 'Should save the changes', async ( { admin, editor, page } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); // Add title to enable valid non-empty post save. await page diff --git a/test/e2e/specs/editor/various/a11y-region-navigation.spec.js b/test/e2e/specs/editor/various/a11y-region-navigation.spec.js index 09bdef52179d1..d8dda0cabdf84 100644 --- a/test/e2e/specs/editor/various/a11y-region-navigation.spec.js +++ b/test/e2e/specs/editor/various/a11y-region-navigation.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Region navigation (@firefox, @webkit)', () => { test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test.afterAll( async ( { requestUtils } ) => { diff --git a/test/e2e/specs/editor/various/a11y.spec.js b/test/e2e/specs/editor/various/a11y.spec.js index 9fa6dfbbf34cb..0a5e421debedb 100644 --- a/test/e2e/specs/editor/various/a11y.spec.js +++ b/test/e2e/specs/editor/various/a11y.spec.js @@ -14,7 +14,7 @@ test.use( { test.describe( 'a11y (@firefox, @webkit)', () => { test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test( 'navigating through the Editor regions four times should land on the Editor top bar region', async ( { diff --git a/test/e2e/specs/editor/various/adding-inline-tokens.spec.js b/test/e2e/specs/editor/various/adding-inline-tokens.spec.js index d65ecd543345c..15f9d9ea87732 100644 --- a/test/e2e/specs/editor/various/adding-inline-tokens.spec.js +++ b/test/e2e/specs/editor/various/adding-inline-tokens.spec.js @@ -13,7 +13,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'adding inline tokens', () => { test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test( 'should insert inline image', async ( { diff --git a/test/e2e/specs/editor/various/adding-patterns.spec.js b/test/e2e/specs/editor/various/adding-patterns.spec.js index da47978054d8a..94b9dbd2646e8 100644 --- a/test/e2e/specs/editor/various/adding-patterns.spec.js +++ b/test/e2e/specs/editor/various/adding-patterns.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'adding patterns', () => { test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test( 'should insert a block pattern', async ( { page, editor } ) => { diff --git a/test/e2e/specs/editor/various/autocomplete-and-mentions.spec.js b/test/e2e/specs/editor/various/autocomplete-and-mentions.spec.js index 6d43f3f2c790f..aae72f50cd25f 100644 --- a/test/e2e/specs/editor/various/autocomplete-and-mentions.spec.js +++ b/test/e2e/specs/editor/various/autocomplete-and-mentions.spec.js @@ -68,7 +68,7 @@ test.describe( 'Autocomplete (@firefox, @webkit)', () => { } ); test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test.afterEach( async ( { editor } ) => { diff --git a/test/e2e/specs/editor/various/block-deletion.spec.js b/test/e2e/specs/editor/various/block-deletion.spec.js index 1601a4a8253a9..9346412c46bcb 100644 --- a/test/e2e/specs/editor/various/block-deletion.spec.js +++ b/test/e2e/specs/editor/various/block-deletion.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Block deletion', () => { test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test( 'deleting the last block via its options menu', async ( { diff --git a/test/e2e/specs/editor/various/block-hierarchy-navigation.spec.js b/test/e2e/specs/editor/various/block-hierarchy-navigation.spec.js index f9a1d8b3ffc43..f0bfe5bff203f 100644 --- a/test/e2e/specs/editor/various/block-hierarchy-navigation.spec.js +++ b/test/e2e/specs/editor/various/block-hierarchy-navigation.spec.js @@ -34,7 +34,7 @@ const COLUMNS_BLOCK = [ test.describe( 'Navigating the block hierarchy', () => { test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test( 'should navigate using the list view sidebar', async ( { diff --git a/test/e2e/specs/editor/various/block-locking.spec.js b/test/e2e/specs/editor/various/block-locking.spec.js index b172ca8cc5f76..b40e7a4b7448a 100644 --- a/test/e2e/specs/editor/various/block-locking.spec.js +++ b/test/e2e/specs/editor/various/block-locking.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Block Locking', () => { test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test( 'can prevent removal', async ( { editor, page } ) => { diff --git a/test/e2e/specs/editor/various/block-mover.spec.js b/test/e2e/specs/editor/various/block-mover.spec.js index 48aa48bff3207..5c3b04a069774 100644 --- a/test/e2e/specs/editor/various/block-mover.spec.js +++ b/test/e2e/specs/editor/various/block-mover.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'block mover', () => { test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test( 'should show block mover when more than one block exists', async ( { diff --git a/test/e2e/specs/editor/various/block-moving-mode.spec.js b/test/e2e/specs/editor/various/block-moving-mode.spec.js index 7fe7b2f9b0383..5b8ef6bdcd051 100644 --- a/test/e2e/specs/editor/various/block-moving-mode.spec.js +++ b/test/e2e/specs/editor/various/block-moving-mode.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Block moving mode', () => { test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test.afterEach( async ( { requestUtils } ) => { diff --git a/test/e2e/specs/editor/various/block-renaming.spec.js b/test/e2e/specs/editor/various/block-renaming.spec.js index 3fb99a77f0d44..f8d9548fbe866 100644 --- a/test/e2e/specs/editor/various/block-renaming.spec.js +++ b/test/e2e/specs/editor/various/block-renaming.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Block Renaming', () => { test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test.describe( 'Dialog renaming', () => { diff --git a/test/e2e/specs/editor/various/block-switcher-test.spec.js b/test/e2e/specs/editor/various/block-switcher-test.spec.js index e707f693635b9..12fd843ed2ed1 100644 --- a/test/e2e/specs/editor/various/block-switcher-test.spec.js +++ b/test/e2e/specs/editor/various/block-switcher-test.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Block Switcher', () => { test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test( 'Block variation transforms', async ( { editor, page } ) => { diff --git a/test/e2e/specs/editor/various/compatibility-classic-editor.spec.js b/test/e2e/specs/editor/various/compatibility-classic-editor.spec.js index 11fce3aa66401..71522c1d439a5 100644 --- a/test/e2e/specs/editor/various/compatibility-classic-editor.spec.js +++ b/test/e2e/specs/editor/various/compatibility-classic-editor.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Compatibility with classic editor', () => { test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test.afterEach( async ( { requestUtils } ) => { diff --git a/test/e2e/specs/editor/various/content-only-lock.spec.js b/test/e2e/specs/editor/various/content-only-lock.spec.js index fdebb38cf648f..e7d52562636f3 100644 --- a/test/e2e/specs/editor/various/content-only-lock.spec.js +++ b/test/e2e/specs/editor/various/content-only-lock.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Content-only lock', () => { test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test( 'should be able to edit the content of blocks with content-only lock', async ( { diff --git a/test/e2e/specs/editor/various/convert-block-type.spec.js b/test/e2e/specs/editor/various/convert-block-type.spec.js index 9dac8d2f57588..b26cc6124f831 100644 --- a/test/e2e/specs/editor/various/convert-block-type.spec.js +++ b/test/e2e/specs/editor/various/convert-block-type.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Code block', () => { test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test.afterEach( async ( { requestUtils } ) => { diff --git a/test/e2e/specs/editor/various/copy-cut-paste.spec.js b/test/e2e/specs/editor/various/copy-cut-paste.spec.js index 3e0c40df80b34..04113e013930b 100644 --- a/test/e2e/specs/editor/various/copy-cut-paste.spec.js +++ b/test/e2e/specs/editor/various/copy-cut-paste.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Copy/cut/paste', () => { test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test( 'should copy and paste individual blocks with collapsed selection', async ( { diff --git a/test/e2e/specs/editor/various/draggable-blocks.spec.js b/test/e2e/specs/editor/various/draggable-blocks.spec.js index 236ff463efe68..fb56b43dc6e03 100644 --- a/test/e2e/specs/editor/various/draggable-blocks.spec.js +++ b/test/e2e/specs/editor/various/draggable-blocks.spec.js @@ -20,7 +20,7 @@ test.use( { test.describe( 'Draggable block', () => { test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test( 'can drag and drop to the top of a vertical block list', async ( { diff --git a/test/e2e/specs/editor/various/duplicating-blocks.spec.js b/test/e2e/specs/editor/various/duplicating-blocks.spec.js index 521f98fcce4ae..aabb93e229572 100644 --- a/test/e2e/specs/editor/various/duplicating-blocks.spec.js +++ b/test/e2e/specs/editor/various/duplicating-blocks.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Duplicating blocks', () => { test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test( 'should duplicate blocks using the block settings menu and keyboard shortcut', async ( { diff --git a/test/e2e/specs/editor/various/font-size-picker.spec.js b/test/e2e/specs/editor/various/font-size-picker.spec.js index f3c70fb849597..5c6cb4b186e25 100644 --- a/test/e2e/specs/editor/various/font-size-picker.spec.js +++ b/test/e2e/specs/editor/various/font-size-picker.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Font Size Picker', () => { test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test.afterEach( async ( { page } ) => { diff --git a/test/e2e/specs/editor/various/footnotes.spec.js b/test/e2e/specs/editor/various/footnotes.spec.js index fa79e410c6942..14a2fc653e387 100644 --- a/test/e2e/specs/editor/various/footnotes.spec.js +++ b/test/e2e/specs/editor/various/footnotes.spec.js @@ -23,7 +23,7 @@ async function getFootnotes( page, withoutSave = false ) { test.describe( 'Footnotes', () => { test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test( 'can be inserted', async ( { editor, page } ) => { diff --git a/test/e2e/specs/editor/various/format-library/text-color.spec.js b/test/e2e/specs/editor/various/format-library/text-color.spec.js index 15cc5f9f250b5..aba77251e3833 100644 --- a/test/e2e/specs/editor/various/format-library/text-color.spec.js +++ b/test/e2e/specs/editor/various/format-library/text-color.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Format Library - Text color', () => { test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test( 'should remove highlighting element', async ( { diff --git a/test/e2e/specs/editor/various/fullscreen-mode.spec.js b/test/e2e/specs/editor/various/fullscreen-mode.spec.js index 447498fd0a4dd..8b7a0785a7ed6 100644 --- a/test/e2e/specs/editor/various/fullscreen-mode.spec.js +++ b/test/e2e/specs/editor/various/fullscreen-mode.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Fullscreen Mode', () => { test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test.afterEach( async ( { requestUtils } ) => { diff --git a/test/e2e/specs/editor/various/inner-blocks-templates.spec.js b/test/e2e/specs/editor/various/inner-blocks-templates.spec.js index 4742b3b749d7e..0f9aed33d0773 100644 --- a/test/e2e/specs/editor/various/inner-blocks-templates.spec.js +++ b/test/e2e/specs/editor/various/inner-blocks-templates.spec.js @@ -11,7 +11,7 @@ test.describe( 'Inner blocks templates', () => { } ); test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test.afterAll( async ( { requestUtils } ) => { diff --git a/test/e2e/specs/editor/various/inserting-blocks.spec.js b/test/e2e/specs/editor/various/inserting-blocks.spec.js index 44f35037b1741..a48fe117c97a2 100644 --- a/test/e2e/specs/editor/various/inserting-blocks.spec.js +++ b/test/e2e/specs/editor/various/inserting-blocks.spec.js @@ -30,7 +30,7 @@ test.describe( 'Inserting blocks (@firefox, @webkit)', () => { 'The clientX value is always 0 in firefox, see https://github.com/microsoft/playwright/issues/17761 for more info.' ); - await admin.visitPostEditor(); + await admin.createNewPost(); await editor.switchToLegacyCanvas(); // We need a dummy block in place to display the drop indicator due to a bug. @@ -108,7 +108,7 @@ test.describe( 'Inserting blocks (@firefox, @webkit)', () => { editor, insertingBlocksUtils, } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); await editor.switchToLegacyCanvas(); // We need a dummy block in place to display the drop indicator due to a bug. @@ -174,7 +174,7 @@ test.describe( 'Inserting blocks (@firefox, @webkit)', () => { 'The clientX value is always 0 in firefox, see https://github.com/microsoft/playwright/issues/17761 for more info.' ); - await admin.visitPostEditor(); + await admin.createNewPost(); await editor.switchToLegacyCanvas(); // We need a dummy block in place to display the drop indicator due to a bug. @@ -244,7 +244,7 @@ test.describe( 'Inserting blocks (@firefox, @webkit)', () => { editor, insertingBlocksUtils, } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); await editor.switchToLegacyCanvas(); // We need a dummy block in place to display the drop indicator due to a bug. @@ -308,7 +308,7 @@ test.describe( 'Inserting blocks (@firefox, @webkit)', () => { page, editor, } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); const inserterButton = page.getByRole( 'button', { name: 'Toggle block inserter', @@ -354,7 +354,7 @@ test.describe( 'insert media from inserter', () => { page, editor, } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); await page.click( 'role=region[name="Editor top bar"i] >> role=button[name="Toggle block inserter"i]' diff --git a/test/e2e/specs/editor/various/keep-styles-on-block-transforms.spec.js b/test/e2e/specs/editor/various/keep-styles-on-block-transforms.spec.js index 712435730d5c1..57b958fdfc4b4 100644 --- a/test/e2e/specs/editor/various/keep-styles-on-block-transforms.spec.js +++ b/test/e2e/specs/editor/various/keep-styles-on-block-transforms.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Keep styles on block transforms', () => { test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test( 'Should keep colors during a transform', async ( { diff --git a/test/e2e/specs/editor/various/keyboard-navigable-blocks.spec.js b/test/e2e/specs/editor/various/keyboard-navigable-blocks.spec.js index d4410ff430571..080abe011206a 100644 --- a/test/e2e/specs/editor/various/keyboard-navigable-blocks.spec.js +++ b/test/e2e/specs/editor/various/keyboard-navigable-blocks.spec.js @@ -13,7 +13,7 @@ test.use( { test.describe( 'Order of block keyboard navigation', () => { test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test( 'permits tabbing through paragraph blocks in the expected order', async ( { diff --git a/test/e2e/specs/editor/various/list-view.spec.js b/test/e2e/specs/editor/various/list-view.spec.js index 93662974c839c..222d743acdf39 100644 --- a/test/e2e/specs/editor/various/list-view.spec.js +++ b/test/e2e/specs/editor/various/list-view.spec.js @@ -11,7 +11,7 @@ test.describe( 'List View', () => { } ); test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test( 'allows a user to drag a block to a new sibling position', async ( { diff --git a/test/e2e/specs/editor/various/mentions.spec.js b/test/e2e/specs/editor/various/mentions.spec.js index bd953e3656738..fef3b1c3e3d2e 100644 --- a/test/e2e/specs/editor/various/mentions.spec.js +++ b/test/e2e/specs/editor/various/mentions.spec.js @@ -15,7 +15,7 @@ test.describe( 'autocomplete mentions', () => { } ); test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test.afterAll( async ( { requestUtils } ) => { diff --git a/test/e2e/specs/editor/various/multi-block-selection.spec.js b/test/e2e/specs/editor/various/multi-block-selection.spec.js index cee9dcca194be..4fb39783954fa 100644 --- a/test/e2e/specs/editor/various/multi-block-selection.spec.js +++ b/test/e2e/specs/editor/various/multi-block-selection.spec.js @@ -18,7 +18,7 @@ test.describe( 'Multi-block selection', () => { } ); test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test( 'should select with double ctrl+a and speak', async ( { diff --git a/test/e2e/specs/editor/various/navigable-toolbar.spec.js b/test/e2e/specs/editor/various/navigable-toolbar.spec.js index 3d35c42a8c597..abdb1800d150a 100644 --- a/test/e2e/specs/editor/various/navigable-toolbar.spec.js +++ b/test/e2e/specs/editor/various/navigable-toolbar.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Block Toolbar', () => { test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test.describe( 'Contextual Toolbar', () => { diff --git a/test/e2e/specs/editor/various/new-post-default-content.spec.js b/test/e2e/specs/editor/various/new-post-default-content.spec.js index b68d9df7a071f..db9e3c38dc296 100644 --- a/test/e2e/specs/editor/various/new-post-default-content.spec.js +++ b/test/e2e/specs/editor/various/new-post-default-content.spec.js @@ -11,7 +11,7 @@ test.describe( 'new editor filtered state', () => { } ); test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test.afterAll( async ( { requestUtils } ) => { diff --git a/test/e2e/specs/editor/various/new-post.spec.js b/test/e2e/specs/editor/various/new-post.spec.js index f33cf4a77208f..cc0243eb8e631 100644 --- a/test/e2e/specs/editor/various/new-post.spec.js +++ b/test/e2e/specs/editor/various/new-post.spec.js @@ -21,7 +21,7 @@ test.describe( 'new editor state', () => { page, editor, } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); await expect( page ).toHaveURL( /post-new.php/ ); @@ -45,7 +45,7 @@ test.describe( 'new editor state', () => { } ); test( 'should have no history', async ( { admin, page } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); await expect( page.locator( 'role=button[name="Undo"i]' ) @@ -59,7 +59,7 @@ test.describe( 'new editor state', () => { admin, editor, } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); await expect( editor.canvas.locator( 'role=textbox[name="Add title"i]' ) @@ -71,7 +71,7 @@ test.describe( 'new editor state', () => { page, editor, } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); // Enter a title for this post. await editor.canvas @@ -93,7 +93,7 @@ test.describe( 'new editor state', () => { admin, page, } ) => { - await admin.visitPostEditor( { title: 'Here is the title' } ); + await admin.createNewPost( { title: 'Here is the title' } ); // Verify saveable by presence of the Save Draft button. const saveDraftButton = page.locator( diff --git a/test/e2e/specs/editor/various/patterns.spec.js b/test/e2e/specs/editor/various/patterns.spec.js index 3015de75576e2..941ae7e910a9b 100644 --- a/test/e2e/specs/editor/various/patterns.spec.js +++ b/test/e2e/specs/editor/various/patterns.spec.js @@ -10,7 +10,7 @@ test.describe( 'Unsynced pattern', () => { } ); test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test.afterEach( async ( { requestUtils } ) => { diff --git a/test/e2e/specs/editor/various/popovers.spec.js b/test/e2e/specs/editor/various/popovers.spec.js index e1e6d515d3cbf..149e188db46f2 100644 --- a/test/e2e/specs/editor/various/popovers.spec.js +++ b/test/e2e/specs/editor/various/popovers.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'popovers', () => { test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test.describe( 'dropdown', () => { 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 8dc98223054f0..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 @@ -153,7 +153,7 @@ class PostEditorTemplateMode { } async createPostAndSaveDraft() { - await this.admin.visitPostEditor(); + await this.admin.createNewPost(); // Create a random post. await this.page.keyboard.type( 'Just an FSE Post' ); await this.page.keyboard.press( 'Enter' ); diff --git a/test/e2e/specs/editor/various/post-visibility.spec.js b/test/e2e/specs/editor/various/post-visibility.spec.js index dc23f65bf43d7..365209ef2e4e5 100644 --- a/test/e2e/specs/editor/various/post-visibility.spec.js +++ b/test/e2e/specs/editor/various/post-visibility.spec.js @@ -13,7 +13,7 @@ test.describe( 'Post visibility', () => { } ) => { await pageUtils.setBrowserViewport( viewport ); - await admin.visitPostEditor(); + await admin.createNewPost(); await editor.openDocumentSettingsSidebar(); @@ -42,7 +42,7 @@ test.describe( 'Post visibility', () => { } ) => { await pageUtils.setBrowserViewport( viewport ); - await admin.visitPostEditor(); + await admin.createNewPost(); await editor.openDocumentSettingsSidebar(); @@ -75,7 +75,7 @@ test.describe( 'Post visibility', () => { admin, editor, } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); // Enter a title for this post. await editor.canvas diff --git a/test/e2e/specs/editor/various/preview.spec.js b/test/e2e/specs/editor/various/preview.spec.js index bb293f79ed187..91f222ab8116f 100644 --- a/test/e2e/specs/editor/various/preview.spec.js +++ b/test/e2e/specs/editor/various/preview.spec.js @@ -11,7 +11,7 @@ test.use( { test.describe( 'Preview', () => { test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test( 'should open a preview window for a new post', async ( { @@ -217,7 +217,7 @@ test.describe( 'Preview', () => { test.describe( 'Preview with Custom Fields enabled', () => { test.beforeEach( async ( { admin, previewUtils } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); await previewUtils.toggleCustomFieldsOption( true ); } ); @@ -294,7 +294,7 @@ test.describe( 'Preview with private custom post type', () => { admin, page, } ) => { - await admin.visitPostEditor( { + await admin.createNewPost( { postType: 'not_public', title: 'aaaaa', } ); diff --git a/test/e2e/specs/editor/various/publish-panel.spec.js b/test/e2e/specs/editor/various/publish-panel.spec.js index ec0c8e13fccad..1ea72d7eb11a2 100644 --- a/test/e2e/specs/editor/various/publish-panel.spec.js +++ b/test/e2e/specs/editor/various/publish-panel.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Post publish panel', () => { test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test( 'should move focus back to the Publish panel toggle button when canceling', async ( { diff --git a/test/e2e/specs/editor/various/rich-text-deprecated-multiline.spec.js b/test/e2e/specs/editor/various/rich-text-deprecated-multiline.spec.js index 3a27a76dcec27..9fa3fef903c7f 100644 --- a/test/e2e/specs/editor/various/rich-text-deprecated-multiline.spec.js +++ b/test/e2e/specs/editor/various/rich-text-deprecated-multiline.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'RichText deprecated multiline', () => { test.beforeEach( async ( { admin, page, editor } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); await page.evaluate( () => { const registerBlockType = window.wp.blocks.registerBlockType; const { useBlockProps, RichText } = window.wp.blockEditor; diff --git a/test/e2e/specs/editor/various/rich-text.spec.js b/test/e2e/specs/editor/various/rich-text.spec.js index 2b0e29067dd36..2969a33d25485 100644 --- a/test/e2e/specs/editor/various/rich-text.spec.js +++ b/test/e2e/specs/editor/various/rich-text.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'RichText', () => { test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test( 'should handle change in tag name gracefully', async ( { diff --git a/test/e2e/specs/editor/various/rtl.spec.js b/test/e2e/specs/editor/various/rtl.spec.js index 69e519c945726..aaf1186cc5aba 100644 --- a/test/e2e/specs/editor/various/rtl.spec.js +++ b/test/e2e/specs/editor/various/rtl.spec.js @@ -16,7 +16,7 @@ test.describe( 'RTL', () => { } ); test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test.afterAll( async ( { requestUtils } ) => { diff --git a/test/e2e/specs/editor/various/shortcut-focus-toolbar.spec.js b/test/e2e/specs/editor/various/shortcut-focus-toolbar.spec.js index 98ff86e55dc11..0223821613f55 100644 --- a/test/e2e/specs/editor/various/shortcut-focus-toolbar.spec.js +++ b/test/e2e/specs/editor/various/shortcut-focus-toolbar.spec.js @@ -11,7 +11,7 @@ test.use( { test.describe( 'Focus toolbar shortcut (alt + F10)', () => { test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test( 'Focuses correct toolbar in default view options in edit mode', async ( { diff --git a/test/e2e/specs/editor/various/shortcut-help.spec.js b/test/e2e/specs/editor/various/shortcut-help.spec.js index b172611a63398..1aaf5e93c975c 100644 --- a/test/e2e/specs/editor/various/shortcut-help.spec.js +++ b/test/e2e/specs/editor/various/shortcut-help.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'keyboard shortcut help modal', () => { test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test( 'opens from the options menu, closes with its close button and returns focus', async ( { diff --git a/test/e2e/specs/editor/various/splitting-merging.spec.js b/test/e2e/specs/editor/various/splitting-merging.spec.js index a8f77cb5a8f09..29e7e5d64522c 100644 --- a/test/e2e/specs/editor/various/splitting-merging.spec.js +++ b/test/e2e/specs/editor/various/splitting-merging.spec.js @@ -5,7 +5,7 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'splitting and merging blocks (@firefox, @webkit)', () => { test.beforeEach( async ( { admin, editor } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); await expect( editor.canvas.getByRole( 'textbox', { name: 'Add title' } ) ).toBeFocused(); diff --git a/test/e2e/specs/editor/various/style-variation.spec.js b/test/e2e/specs/editor/various/style-variation.spec.js index 467d3593291c2..cc13dd1ad9238 100644 --- a/test/e2e/specs/editor/various/style-variation.spec.js +++ b/test/e2e/specs/editor/various/style-variation.spec.js @@ -9,7 +9,7 @@ test.describe( 'adding blocks', () => { editor, page, } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); // Inserting a quote block await editor.insertBlock( { 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 60a1b89ae9563..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,7 +139,7 @@ class SwitchToDraftUtils { id = page.id; } - await this.#admin.visitPostEditor( { postId: id } ); + await this.#admin.editPost( id ); }; getPostStatus = async () => { diff --git a/test/e2e/specs/editor/various/toolbar-roving-tabindex.spec.js b/test/e2e/specs/editor/various/toolbar-roving-tabindex.spec.js index 324975805227c..e706dfc3607dc 100644 --- a/test/e2e/specs/editor/various/toolbar-roving-tabindex.spec.js +++ b/test/e2e/specs/editor/various/toolbar-roving-tabindex.spec.js @@ -11,7 +11,7 @@ test.use( { test.describe( 'Toolbar roving tabindex', () => { test.beforeEach( async ( { admin, editor, page } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); await editor.insertBlock( { name: 'core/paragraph' } ); await page.keyboard.type( 'First block' ); diff --git a/test/e2e/specs/editor/various/undo.spec.js b/test/e2e/specs/editor/various/undo.spec.js index c11a611b10d6c..9df1c43b59474 100644 --- a/test/e2e/specs/editor/various/undo.spec.js +++ b/test/e2e/specs/editor/various/undo.spec.js @@ -11,7 +11,7 @@ test.use( { test.describe( 'undo', () => { test.beforeEach( async ( { admin } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); } ); test( 'should undo typing after a pause', async ( { diff --git a/test/e2e/specs/editor/various/writing-flow.spec.js b/test/e2e/specs/editor/various/writing-flow.spec.js index 29b6b3ab35e6b..a248915a21fcb 100644 --- a/test/e2e/specs/editor/various/writing-flow.spec.js +++ b/test/e2e/specs/editor/various/writing-flow.spec.js @@ -11,7 +11,7 @@ test.use( { test.describe( 'Writing Flow (@firefox, @webkit)', () => { test.beforeEach( async ( { admin, editor } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); await expect( editor.canvas.getByRole( 'textbox', { name: 'Add title' } ) ).toBeFocused(); diff --git a/test/performance/specs/post-editor.spec.js b/test/performance/specs/post-editor.spec.js index 00368b8340fcb..d5ff40570afd7 100644 --- a/test/performance/specs/post-editor.spec.js +++ b/test/performance/specs/post-editor.spec.js @@ -51,7 +51,7 @@ test.describe( 'Post Editor Performance', () => { let draftId = null; test( 'Setup the test post', async ( { admin, perfUtils } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); await perfUtils.loadBlocksForLargePost(); draftId = await perfUtils.saveDraft(); } ); @@ -66,7 +66,7 @@ test.describe( 'Post Editor Performance', () => { metrics, } ) => { // Open the test draft. - await admin.visitPostEditor( { postId: draftId } ); + await admin.editPost( draftId ); const canvas = await perfUtils.getCanvas(); // Wait for the first block. @@ -95,14 +95,14 @@ test.describe( 'Post Editor Performance', () => { let draftId = null; test( 'Setup the test post', async ( { admin, perfUtils, editor } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); await perfUtils.loadBlocksForLargePost(); await editor.insertBlock( { name: 'core/paragraph' } ); draftId = await perfUtils.saveDraft(); } ); test( 'Run the test', async ( { admin, perfUtils, metrics } ) => { - await admin.visitPostEditor( { postId: draftId } ); + await admin.editPost( draftId ); await perfUtils.disableAutosave(); const canvas = await perfUtils.getCanvas(); @@ -148,13 +148,13 @@ test.describe( 'Post Editor Performance', () => { let draftId = null; test( 'Set up the test post', async ( { admin, perfUtils } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); await perfUtils.loadBlocksForSmallPostWithContainers(); draftId = await perfUtils.saveDraft(); } ); test( 'Run the test', async ( { admin, perfUtils, metrics } ) => { - await admin.visitPostEditor( { postId: draftId } ); + await admin.editPost( draftId ); await perfUtils.disableAutosave(); const canvas = await perfUtils.getCanvas(); @@ -204,13 +204,13 @@ test.describe( 'Post Editor Performance', () => { let draftId = null; test( 'Set up the test post', async ( { admin, perfUtils } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); await perfUtils.load1000Paragraphs(); draftId = await perfUtils.saveDraft(); } ); test( 'Run the test', async ( { admin, page, perfUtils, metrics } ) => { - await admin.visitPostEditor( { postId: draftId } ); + await admin.editPost( draftId ); await perfUtils.disableAutosave(); const canvas = await perfUtils.getCanvas(); @@ -254,13 +254,13 @@ test.describe( 'Post Editor Performance', () => { let draftId = null; test( 'Set up the test page', async ( { admin, perfUtils } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); await perfUtils.load1000Paragraphs(); draftId = await perfUtils.saveDraft(); } ); test( 'Run the test', async ( { page, admin, perfUtils, metrics } ) => { - await admin.visitPostEditor( { postId: draftId } ); + await admin.editPost( draftId ); await perfUtils.disableAutosave(); const listViewToggle = page.getByRole( 'button', { @@ -304,14 +304,14 @@ test.describe( 'Post Editor Performance', () => { let draftId = null; test( 'Set up the test page', async ( { admin, perfUtils } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); await perfUtils.load1000Paragraphs(); draftId = await perfUtils.saveDraft(); } ); test( 'Run the test', async ( { page, admin, perfUtils, metrics } ) => { // Go to the test page. - await admin.visitPostEditor( { postId: draftId } ); + await admin.editPost( draftId ); await perfUtils.disableAutosave(); const globalInserterToggle = page.getByRole( 'button', { name: 'Toggle block inserter', @@ -360,14 +360,14 @@ test.describe( 'Post Editor Performance', () => { let draftId = null; test( 'Set up the test page', async ( { admin, perfUtils } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); await perfUtils.load1000Paragraphs(); draftId = await perfUtils.saveDraft(); } ); test( 'Run the test', async ( { page, admin, perfUtils, metrics } ) => { // Go to the test page. - await admin.visitPostEditor( { postId: draftId } ); + await admin.editPost( draftId ); await perfUtils.disableAutosave(); const globalInserterToggle = page.getByRole( 'button', { name: 'Toggle block inserter', @@ -416,14 +416,14 @@ test.describe( 'Post Editor Performance', () => { let draftId = null; test( 'Set up the test page', async ( { admin, perfUtils } ) => { - await admin.visitPostEditor(); + await admin.createNewPost(); await perfUtils.load1000Paragraphs(); draftId = await perfUtils.saveDraft(); } ); test( 'Run the test', async ( { page, admin, perfUtils, metrics } ) => { // Go to the test page. - await admin.visitPostEditor( { postId: draftId } ); + await admin.editPost( draftId ); await perfUtils.disableAutosave(); const globalInserterToggle = page.getByRole( 'button', { diff --git a/test/performance/specs/site-editor.spec.js b/test/performance/specs/site-editor.spec.js index edba7727cec1d..28a1cbb0ecde2 100644 --- a/test/performance/specs/site-editor.spec.js +++ b/test/performance/specs/site-editor.spec.js @@ -60,7 +60,7 @@ test.describe( 'Site Editor Performance', () => { let draftURL = null; test( 'Setup the test page', async ( { page, admin, perfUtils } ) => { - await admin.visitPostEditor( { postType: 'page' } ); + await admin.createNewPost( { postType: 'page' } ); await perfUtils.loadBlocksForLargePost(); await perfUtils.saveDraft(); @@ -115,7 +115,7 @@ test.describe( 'Site Editor Performance', () => { editor, perfUtils, } ) => { - await admin.visitPostEditor( { postType: 'page' } ); + await admin.createNewPost( { postType: 'page' } ); await perfUtils.loadBlocksForLargePost(); await editor.insertBlock( { name: 'core/paragraph' } ); await perfUtils.saveDraft();