Metrics: Use utils provided by `@wordpress/e2e-test-utils-playwright` (#50626)

This commit is contained in:
Bart Kalisz 2024-08-13 15:26:47 +02:00 committed by GitHub
parent f91bcf44c7
commit daa6a95b56
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 32 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: dev
Make the Metrics tests use utilities provided by the updated @wordpress/e2e-test-utils-playwright package.

View File

@ -16,35 +16,6 @@ const BROWSER_IDLE_WAIT = 1000;
const results = {};
async function setPreferences( page, context, preferences ) {
await page.waitForFunction( () => window?.wp?.data );
await page.evaluate(
async ( props ) => {
for ( const [ key, value ] of Object.entries(
props.preferences
) ) {
await window.wp.data
.dispatch( 'core/preferences' )
.set( props.context, key, value );
}
},
{ context, preferences }
);
}
async function editPost( admin, page, postId ) {
const query = new URLSearchParams();
query.set( 'post', String( postId ) );
query.set( 'action', 'edit' );
await admin.visitAdminPage( 'post.php', query.toString() );
await setPreferences( page, 'core/edit-post', {
welcomeGuide: false,
fullscreenMode: false,
} );
}
test.describe( 'Editor Performance', () => {
test.use( {
perfUtils: async ( { page }, use ) => {
@ -86,7 +57,7 @@ test.describe( 'Editor Performance', () => {
metrics,
} ) => {
// Open the test draft.
await editPost( admin, page, draftId );
await admin.editPost( draftId );
const canvas = await perfUtils.getCanvas();
// Wait for the first block.
@ -148,8 +119,8 @@ test.describe( 'Editor Performance', () => {
draftId = await perfUtils.saveDraft();
} );
test( 'Run the test', async ( { admin, page, perfUtils, metrics } ) => {
await editPost( admin, page, draftId );
test( 'Run the test', async ( { admin, perfUtils, metrics } ) => {
await admin.editPost( draftId );
await perfUtils.disableAutosave();
const canvas = await perfUtils.getCanvas();