From 31d48d750d74cb7f4e01b77fa875c9a6528253fe Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Mon, 17 Feb 2025 13:45:32 +0800 Subject: [PATCH] Performance Tests: Update method for creating sample content (#69210) Co-authored-by: Mamaduka Co-authored-by: swissspidy --- .../src/request-utils/pages.ts | 2 +- test/performance/fixtures/perf-utils.ts | 9 +++++++ test/performance/specs/site-editor.spec.js | 26 +++++++++++-------- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/packages/e2e-test-utils-playwright/src/request-utils/pages.ts b/packages/e2e-test-utils-playwright/src/request-utils/pages.ts index 6fe70ef3cb3fde..74f8770e8a7969 100644 --- a/packages/e2e-test-utils-playwright/src/request-utils/pages.ts +++ b/packages/e2e-test-utils-playwright/src/request-utils/pages.ts @@ -74,7 +74,7 @@ export async function createPage( const page = await this.rest< Page >( { method: 'POST', path: `/wp/v2/pages`, - params: payload, + data: { ...payload }, } ); return page; diff --git a/test/performance/fixtures/perf-utils.ts b/test/performance/fixtures/perf-utils.ts index 8d23d91ff91bfd..6574189b1ab5d7 100644 --- a/test/performance/fixtures/perf-utils.ts +++ b/test/performance/fixtures/perf-utils.ts @@ -139,6 +139,15 @@ export class PerfUtils { ); } + /** + * Loads the content of the large post fixture. + */ + async loadContentForLargePost() { + return readFile( + path.join( process.env.ASSETS_PATH!, 'large-post.html' ) + ); + } + /** * Loads blocks from an HTML fixture with given path into the editor canvas. * diff --git a/test/performance/specs/site-editor.spec.js b/test/performance/specs/site-editor.spec.js index 5a0c7f0e952116..57e36a9a4d14d3 100644 --- a/test/performance/specs/site-editor.spec.js +++ b/test/performance/specs/site-editor.spec.js @@ -62,12 +62,14 @@ test.describe( 'Site Editor Performance', () => { test.describe( 'Loading', () => { let draftId = null; - test( 'Setup the test page', async ( { admin, perfUtils } ) => { - await admin.createNewPost( { postType: 'page' } ); - await perfUtils.setRenderingMode( 'post-only' ); - await perfUtils.loadBlocksForLargePost(); + test( 'Setup the test page', async ( { requestUtils, perfUtils } ) => { + const content = await perfUtils.loadContentForLargePost(); + const page = await requestUtils.createPage( { + content, + status: 'draft', + } ); - draftId = await perfUtils.saveDraft(); + draftId = page.id; } ); const samples = 10; @@ -121,13 +123,15 @@ test.describe( 'Site Editor Performance', () => { test.describe( 'Typing', () => { let draftId = null; - test( 'Setup the test post', async ( { admin, editor, perfUtils } ) => { - await admin.createNewPost( { postType: 'page' } ); - await perfUtils.setRenderingMode( 'post-only' ); - await perfUtils.loadBlocksForLargePost(); - await editor.insertBlock( { name: 'core/paragraph' } ); + test( 'Setup the test post', async ( { requestUtils, perfUtils } ) => { + const content = await perfUtils.loadContentForLargePost(); + const page = await requestUtils.createPage( { + content: + content + ``, + status: 'draft', + } ); - draftId = await perfUtils.saveDraft(); + draftId = page.id; } ); test( 'Run the test', async ( { admin, perfUtils, metrics, page } ) => {