Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataViews: add performance test for pages #63170

Merged
merged 2 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions test/performance/config/performance-reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export interface WPRawPerformanceResults {
inserterSearch: number[];
inserterHover: number[];
loadPatterns: number[];
loadPages: number[];
listViewOpen: number[];
navigate: number[];
wpBeforeTemplate: number[];
Expand Down Expand Up @@ -69,6 +70,7 @@ export interface WPPerformanceResults {
inserterSearch?: PerformanceStats;
inserterHover?: PerformanceStats;
loadPatterns?: PerformanceStats;
loadPages?: PerformanceStats;
listViewOpen?: PerformanceStats;
navigate?: PerformanceStats;
wpBeforeTemplate?: PerformanceStats;
Expand Down Expand Up @@ -106,6 +108,7 @@ export function curateResults(
inserterSearch: stats( results.inserterSearch ),
inserterHover: stats( results.inserterHover ),
loadPatterns: stats( results.loadPatterns ),
loadPages: stats( results.loadPages ),
listViewOpen: stats( results.listViewOpen ),
navigate: stats( results.navigate ),
wpBeforeTemplate: stats( results.wpBeforeTemplate ),
Expand Down
63 changes: 63 additions & 0 deletions test/performance/specs/site-editor.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const results = {
listViewOpen: [],
navigate: [],
loadPatterns: [],
loadPages: [],
};

test.describe( 'Site Editor Performance', () => {
Expand Down Expand Up @@ -384,6 +385,68 @@ test.describe( 'Site Editor Performance', () => {
}
} );
} );

test.describe( 'Loading Pages', () => {
test.beforeAll( async ( { requestUtils } ) => {
await requestUtils.activateTheme( 'twentytwentyfour' );
} );

test.afterAll( async ( { requestUtils } ) => {
await requestUtils.activateTheme( 'twentytwentyfour' );
} );

const perPage = 20;

test( 'Run the test', async ( { page, admin, requestUtils } ) => {
await Promise.all(
Array.from( { length: perPage }, async ( el, index ) => {
const { id } = await requestUtils.createPage( {
status: 'publish',
title: `Page (${ index })`,
content: `
<!-- wp:heading -->
<p>Hello</p>
<!-- /wp:heading -->
<!-- wp:paragraph -->
<p>Post content</p>
<!-- /wp:paragraph -->`,
} );

return id;
} )
);

const samples = 10;
for ( let i = 1; i <= samples; i++ ) {
// Start from the trash view, then navigate to all pages, so we
// test item loading rather than site editor load as a whole.
// For some reason `visiSiteEditor` does not work with these
// parameters.
await admin.visitAdminPage(
'site-editor.php?postType=page&layout=table&activeView=trash'
);

const startTime = performance.now();

await page.getByRole( 'button', { name: 'All Pages' } ).click();

// Wait for all pages to be rendered.
await Promise.all(
Copy link
Contributor

Choose a reason for hiding this comment

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

What are we waiting for exactly here, can we add a clarifying comment?

Copy link
Member Author

Choose a reason for hiding this comment

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

Added one, we are waiting for all pages to load.

Array.from( { length: perPage }, async ( el, index ) => {
return await page
.getByRole( 'link', {
name: `Page (${ index })`,
} )
.waitFor( { state: 'attached' } );
} )
);

const endTime = performance.now();

results.loadPages.push( endTime - startTime );
}
} );
} );
} );

/* eslint-enable playwright/no-conditional-in-test, playwright/expect-expect */
Loading