Skip to content

Commit

Permalink
Performance Tests: Update method for creating sample content (#69210)
Browse files Browse the repository at this point in the history
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

1 comment on commit 31d48d7

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 31d48d7.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/13363729786
📝 Reported issues:

Please sign in to comment.