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

Performance tests: make site editor performance test backwards compatible #59266

Merged
merged 2 commits into from
Feb 22, 2024
Merged
Changes from 1 commit
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
36 changes: 33 additions & 3 deletions test/performance/specs/site-editor.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,15 +229,45 @@ test.describe( 'Site Editor Performance', () => {
} );
await editor.openDocumentSettingsSidebar();

/*
* https://github.com/WordPress/gutenberg/pull/55091 updated the HTML by
* removing the replace template button in sidebar-edit-mode/template-panel/replace-template-button.js
* with a "transform into" list. https://github.com/WordPress/gutenberg/pull/59259 made these tests
* compatible with the new UI, however, the performance tests compare previous versions of the UI.
*
* The following code is a workaround to test the performance of the new UI.
* `actionsButtonElement` is used to check if the old UI is present.
* If there is a Replace template button (old UI), click it, otherwise, click the "transform into" button.
* Once the performance tests are updated to compare compatible versions this code can be removed.
*/
// eslint-disable-next-line no-restricted-syntax
const actionsButtonElement = await page.$$(
".edit-site-template-card__actions button[aria-label='Actions']"
);
ramonjd marked this conversation as resolved.
Show resolved Hide resolved

if ( actionsButtonElement.length ) {
await page
.getByRole( 'button', {
name: 'Actions',
} )
.click();
}

// Wait for the browser to be idle before starting the monitoring.
// eslint-disable-next-line no-restricted-syntax
await page.waitForTimeout( BROWSER_IDLE_WAIT );

const startTime = performance.now();

await page
.getByRole( 'button', { name: 'Transform into:' } )
.click();
if ( actionsButtonElement.length ) {
await page
.getByRole( 'menuitem', { name: 'Replace template' } )
.click();
} else {
await page
.getByRole( 'button', { name: 'Transform into:' } )
.click();
}

const patterns = [
'Blogging home template',
Expand Down
Loading