Metrics: Use utils provided by `@wordpress/e2e-test-utils-playwright` (#50626)
This commit is contained in:
parent
f91bcf44c7
commit
daa6a95b56
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: patch
|
||||||
|
Type: dev
|
||||||
|
|
||||||
|
Make the Metrics tests use utilities provided by the updated @wordpress/e2e-test-utils-playwright package.
|
|
@ -16,35 +16,6 @@ const BROWSER_IDLE_WAIT = 1000;
|
||||||
|
|
||||||
const results = {};
|
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.describe( 'Editor Performance', () => {
|
||||||
test.use( {
|
test.use( {
|
||||||
perfUtils: async ( { page }, use ) => {
|
perfUtils: async ( { page }, use ) => {
|
||||||
|
@ -86,7 +57,7 @@ test.describe( 'Editor Performance', () => {
|
||||||
metrics,
|
metrics,
|
||||||
} ) => {
|
} ) => {
|
||||||
// Open the test draft.
|
// Open the test draft.
|
||||||
await editPost( admin, page, draftId );
|
await admin.editPost( draftId );
|
||||||
const canvas = await perfUtils.getCanvas();
|
const canvas = await perfUtils.getCanvas();
|
||||||
|
|
||||||
// Wait for the first block.
|
// Wait for the first block.
|
||||||
|
@ -148,8 +119,8 @@ test.describe( 'Editor Performance', () => {
|
||||||
draftId = await perfUtils.saveDraft();
|
draftId = await perfUtils.saveDraft();
|
||||||
} );
|
} );
|
||||||
|
|
||||||
test( 'Run the test', async ( { admin, page, perfUtils, metrics } ) => {
|
test( 'Run the test', async ( { admin, perfUtils, metrics } ) => {
|
||||||
await editPost( admin, page, draftId );
|
await admin.editPost( draftId );
|
||||||
await perfUtils.disableAutosave();
|
await perfUtils.disableAutosave();
|
||||||
const canvas = await perfUtils.getCanvas();
|
const canvas = await perfUtils.getCanvas();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue