Skip to content

Commit 31d48d7

Browse files
Mamadukaswissspidy
andauthored
Performance Tests: Update method for creating sample content (#69210)
Co-authored-by: Mamaduka <[email protected]> Co-authored-by: swissspidy <[email protected]>
1 parent ac992f7 commit 31d48d7

File tree

3 files changed

+25
-12
lines changed

3 files changed

+25
-12
lines changed

packages/e2e-test-utils-playwright/src/request-utils/pages.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export async function createPage(
7474
const page = await this.rest< Page >( {
7575
method: 'POST',
7676
path: `/wp/v2/pages`,
77-
params: payload,
77+
data: { ...payload },
7878
} );
7979

8080
return page;

test/performance/fixtures/perf-utils.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,15 @@ export class PerfUtils {
139139
);
140140
}
141141

142+
/**
143+
* Loads the content of the large post fixture.
144+
*/
145+
async loadContentForLargePost() {
146+
return readFile(
147+
path.join( process.env.ASSETS_PATH!, 'large-post.html' )
148+
);
149+
}
150+
142151
/**
143152
* Loads blocks from an HTML fixture with given path into the editor canvas.
144153
*

test/performance/specs/site-editor.spec.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,14 @@ test.describe( 'Site Editor Performance', () => {
6262
test.describe( 'Loading', () => {
6363
let draftId = null;
6464

65-
test( 'Setup the test page', async ( { admin, perfUtils } ) => {
66-
await admin.createNewPost( { postType: 'page' } );
67-
await perfUtils.setRenderingMode( 'post-only' );
68-
await perfUtils.loadBlocksForLargePost();
65+
test( 'Setup the test page', async ( { requestUtils, perfUtils } ) => {
66+
const content = await perfUtils.loadContentForLargePost();
67+
const page = await requestUtils.createPage( {
68+
content,
69+
status: 'draft',
70+
} );
6971

70-
draftId = await perfUtils.saveDraft();
72+
draftId = page.id;
7173
} );
7274

7375
const samples = 10;
@@ -121,13 +123,15 @@ test.describe( 'Site Editor Performance', () => {
121123
test.describe( 'Typing', () => {
122124
let draftId = null;
123125

124-
test( 'Setup the test post', async ( { admin, editor, perfUtils } ) => {
125-
await admin.createNewPost( { postType: 'page' } );
126-
await perfUtils.setRenderingMode( 'post-only' );
127-
await perfUtils.loadBlocksForLargePost();
128-
await editor.insertBlock( { name: 'core/paragraph' } );
126+
test( 'Setup the test post', async ( { requestUtils, perfUtils } ) => {
127+
const content = await perfUtils.loadContentForLargePost();
128+
const page = await requestUtils.createPage( {
129+
content:
130+
content + `<!-- wp:paragraph --><!-- /wp:paragraph -->`,
131+
status: 'draft',
132+
} );
129133

130-
draftId = await perfUtils.saveDraft();
134+
draftId = page.id;
131135
} );
132136

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

0 commit comments

Comments
 (0)