From 3496d556f1f19664c00885b1d63cc8c793974494 Mon Sep 17 00:00:00 2001 From: Tyler Bailey Date: Thu, 18 Jul 2024 15:33:27 -0400 Subject: [PATCH] Add rendering mode parameter to the setRenderingMode utility --- .../src/admin/create-new-post.ts | 3 +-- .../src/editor/set-rendering-mode.ts | 9 +++++---- 2 files changed, 6 insertions(+), 6 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 df6cfdad2d474f..f6947d5e7ca144 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 @@ -41,8 +41,7 @@ export async function createNewPost( // Navigate to the new post page. await this.visitAdminPage( 'post-new.php', query.toString() ); - // Set editing mode - await this.editor.setRenderingMode(); + await this.editor.setRenderingMode( 'post-only' ); await this.editor.setPreferences( 'core/edit-post', { welcomeGuide: options.showWelcomeGuide ?? false, diff --git a/packages/e2e-test-utils-playwright/src/editor/set-rendering-mode.ts b/packages/e2e-test-utils-playwright/src/editor/set-rendering-mode.ts index 9f193e20fd0429..7b41eede7cf79f 100644 --- a/packages/e2e-test-utils-playwright/src/editor/set-rendering-mode.ts +++ b/packages/e2e-test-utils-playwright/src/editor/set-rendering-mode.ts @@ -7,16 +7,17 @@ import type { Editor } from './index'; * Set the rendering mode of the editor. * * @param this + * @param mode The rendering mode to set. */ -async function setRenderingMode( this: Editor ) { +async function setRenderingMode( this: Editor, mode: string = 'post-only' ) { await this.page.waitForFunction( () => window?.wp?.data ); - await this.page.evaluate( () => { + await this.page.evaluate( ( renderingMode ) => { // Set editing mode window.wp.data .dispatch( 'core/editor' ) - .setRenderingMode( 'post-only' ); - } ); + .setRenderingMode( renderingMode ); + }, mode ); } export { setRenderingMode };