Skip to content

Commit

Permalink
Performance tests: make site editor performance test backwards compat…
Browse files Browse the repository at this point in the history
…ible (#59266)

* Update Performance tests base branch after #59259
This commit makes the test backwards compatible until the performance tests base  commit is updated.

* use locator

Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>
Co-authored-by: youknowriad <youknowriad@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
  • Loading branch information
4 people authored Feb 22, 2024
1 parent a94648b commit 270ff99
Showing 1 changed file with 35 additions and 3 deletions.
38 changes: 35 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,47 @@ 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 isActionsButtonVisible = await page
.locator(
'.edit-site-template-card__actions button[aria-label="Actions"]'
)
.isVisible();

if ( isActionsButtonVisible ) {
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 ( isActionsButtonVisible ) {
await page
.getByRole( 'menuitem', { name: 'Replace template' } )
.click();
} else {
await page
.getByRole( 'button', { name: 'Transform into:' } )
.click();
}

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

1 comment on commit 270ff99

@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 270ff99.
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/8001119390
📝 Reported issues:

Please sign in to comment.