Skip to content

Commit

Permalink
Performance Tests: Update method for creating sample content (WordPre…
Browse files Browse the repository at this point in the history
…ss#69210)


Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: swissspidy <[email protected]>
  • Loading branch information
3 people authored Feb 17, 2025
1 parent ac992f7 commit 31d48d7
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 9 additions & 0 deletions test/performance/fixtures/perf-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
26 changes: 15 additions & 11 deletions test/performance/specs/site-editor.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 + `<!-- wp:paragraph --><!-- /wp:paragraph -->`,
status: 'draft',
} );

draftId = await perfUtils.saveDraft();
draftId = page.id;
} );

test( 'Run the test', async ( { admin, perfUtils, metrics, page } ) => {
Expand Down

0 comments on commit 31d48d7

Please sign in to comment.