-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Perf testing: Cover Site Editor loading time (#23842)
Add some performance test coverage to the site editor (loading time), specifically to avoid perfomance regressions with regard to template resolution and `wp_template` auto-draft creation (see e.g. #23662). Changes some of the underlying performance test framework to allow for multiple test files.
- Loading branch information
Showing
7 changed files
with
169 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { basename, join } from 'path'; | ||
import { writeFileSync } from 'fs'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { useExperimentalFeatures } from '../../experimental-features'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { trashAllPosts, visitAdminPage } from '@wordpress/e2e-test-utils'; | ||
import { addQueryArgs } from '@wordpress/url'; | ||
|
||
jest.setTimeout( 1000000 ); | ||
|
||
describe( 'Site Editor Performance', () => { | ||
useExperimentalFeatures( [ | ||
'#gutenberg-full-site-editing', | ||
'#gutenberg-full-site-editing-demo', | ||
] ); | ||
|
||
beforeAll( async () => { | ||
await trashAllPosts( 'wp_template' ); | ||
await trashAllPosts( 'wp_template_part' ); | ||
} ); | ||
afterAll( async () => { | ||
await trashAllPosts( 'wp_template' ); | ||
await trashAllPosts( 'wp_template_part' ); | ||
} ); | ||
|
||
it( 'Loading', async () => { | ||
const results = { | ||
load: [], | ||
domcontentloaded: [], | ||
type: [], | ||
focus: [], | ||
}; | ||
|
||
await visitAdminPage( | ||
'admin.php', | ||
addQueryArgs( '', { | ||
page: 'gutenberg-edit-site', | ||
} ).slice( 1 ) | ||
); | ||
|
||
let i = 3; | ||
|
||
// Measuring loading time | ||
while ( i-- ) { | ||
await page.reload( { waitUntil: [ 'domcontentloaded', 'load' ] } ); | ||
const timings = JSON.parse( | ||
await page.evaluate( () => | ||
JSON.stringify( window.performance.timing ) | ||
) | ||
); | ||
const { | ||
navigationStart, | ||
domContentLoadedEventEnd, | ||
loadEventEnd, | ||
} = timings; | ||
results.load.push( loadEventEnd - navigationStart ); | ||
results.domcontentloaded.push( | ||
domContentLoadedEventEnd - navigationStart | ||
); | ||
} | ||
|
||
const resultsFilename = basename( __filename, '.js' ) + '.results.json'; | ||
|
||
writeFileSync( | ||
join( __dirname, resultsFilename ), | ||
JSON.stringify( results, null, 2 ) | ||
); | ||
|
||
expect( true ).toBe( true ); | ||
} ); | ||
} ); |