@wordpress/e2e-tests 7.9.0 → 7.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/jest.config.js +1 -4
- package/package.json +7 -7
- package/plugins/iframed-enqueue-block-editor-settings.php +19 -0
- package/plugins/interactive-blocks/{directive-show → directive-body}/block.json +3 -3
- package/plugins/interactive-blocks/directive-body/render.php +22 -0
- package/plugins/interactive-blocks/directive-body/view.js +11 -0
- package/plugins/interactive-blocks/directive-class/render.php +11 -0
- package/plugins/interactive-blocks/directive-effect/render.php +13 -1
- package/plugins/interactive-blocks/directive-effect/view.js +14 -16
- package/plugins/interactive-blocks/directive-init/block.json +14 -0
- package/plugins/interactive-blocks/directive-init/render.php +42 -0
- package/plugins/interactive-blocks/directive-init/view.js +64 -0
- package/plugins/interactive-blocks/directive-on/block.json +14 -0
- package/plugins/interactive-blocks/directive-on/render.php +52 -0
- package/plugins/interactive-blocks/directive-on/view.js +27 -0
- package/plugins/interactive-blocks/directive-priorities/render.php +4 -0
- package/plugins/interactive-blocks/store-afterload/block.json +14 -0
- package/plugins/interactive-blocks/store-afterload/render.php +41 -0
- package/plugins/interactive-blocks/store-afterload/view.js +60 -0
- package/plugins/interactive-blocks/tovdom-islands/render.php +5 -5
- package/plugins/interactive-blocks/tovdom-islands/view.js +18 -1
- package/specs/editor/plugins/iframed-enqueue-block-editor-settings.test.js +108 -0
- package/specs/editor/various/__snapshots__/inserting-blocks.test.js.snap +2 -2
- package/specs/editor/various/__snapshots__/rich-text.test.js.snap +15 -1
- package/specs/editor/various/block-editor-keyboard-shortcuts.test.js +3 -3
- package/specs/editor/various/reusable-blocks.test.js +10 -7
- package/specs/editor/various/rich-text.test.js +11 -0
- package/specs/experiments/blocks/post-comments-form.test.js +2 -2
- package/specs/site-editor/settings-sidebar.test.js +1 -1
- package/assets/large-post.html +0 -5553
- package/assets/small-post-with-containers.html +0 -77
- package/config/performance-reporter.js +0 -177
- package/config/setup-performance-test.js +0 -51
- package/jest.performance.config.js +0 -16
- package/plugins/interactive-blocks/directive-show/render.php +0 -53
- package/plugins/interactive-blocks/directive-show/view.js +0 -24
- package/specs/editor/plugins/allowed-blocks.test.js +0 -59
- package/specs/editor/plugins/block-variations.test.js +0 -191
- package/specs/editor/plugins/iframed-equeue-block-assets.test.js +0 -51
- package/specs/performance/front-end-block-theme.test.js +0 -77
- package/specs/performance/front-end-classic-theme.test.js +0 -77
- package/specs/performance/post-editor.test.js +0 -369
- package/specs/performance/site-editor.test.js +0 -188
- package/specs/performance/utils.js +0 -146
@@ -1,188 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* External dependencies
|
3
|
-
*/
|
4
|
-
import path from 'path';
|
5
|
-
|
6
|
-
/**
|
7
|
-
* WordPress dependencies
|
8
|
-
*/
|
9
|
-
import {
|
10
|
-
activateTheme,
|
11
|
-
canvas,
|
12
|
-
createNewPost,
|
13
|
-
visitSiteEditor,
|
14
|
-
saveDraft,
|
15
|
-
insertBlock,
|
16
|
-
deleteAllTemplates,
|
17
|
-
enterEditMode,
|
18
|
-
} from '@wordpress/e2e-test-utils';
|
19
|
-
|
20
|
-
/**
|
21
|
-
* Internal dependencies
|
22
|
-
*/
|
23
|
-
import {
|
24
|
-
readFile,
|
25
|
-
deleteFile,
|
26
|
-
saveResultsFile,
|
27
|
-
getTraceFilePath,
|
28
|
-
getTypingEventDurations,
|
29
|
-
getLoadingDurations,
|
30
|
-
sequence,
|
31
|
-
} from './utils';
|
32
|
-
|
33
|
-
jest.setTimeout( 1000000 );
|
34
|
-
|
35
|
-
const results = {
|
36
|
-
serverResponse: [],
|
37
|
-
firstPaint: [],
|
38
|
-
domContentLoaded: [],
|
39
|
-
loaded: [],
|
40
|
-
firstContentfulPaint: [],
|
41
|
-
firstBlock: [],
|
42
|
-
type: [],
|
43
|
-
typeContainer: [],
|
44
|
-
focus: [],
|
45
|
-
inserterOpen: [],
|
46
|
-
inserterHover: [],
|
47
|
-
inserterSearch: [],
|
48
|
-
listViewOpen: [],
|
49
|
-
};
|
50
|
-
|
51
|
-
let postId;
|
52
|
-
|
53
|
-
describe( 'Site Editor Performance', () => {
|
54
|
-
beforeAll( async () => {
|
55
|
-
await activateTheme( 'emptytheme' );
|
56
|
-
await deleteAllTemplates( 'wp_template' );
|
57
|
-
await deleteAllTemplates( 'wp_template_part' );
|
58
|
-
|
59
|
-
const html = readFile(
|
60
|
-
path.join( __dirname, '../../assets/large-post.html' )
|
61
|
-
);
|
62
|
-
|
63
|
-
await createNewPost( { postType: 'page' } );
|
64
|
-
|
65
|
-
await page.evaluate( ( _html ) => {
|
66
|
-
const { parse } = window.wp.blocks;
|
67
|
-
const { dispatch } = window.wp.data;
|
68
|
-
const blocks = parse( _html );
|
69
|
-
|
70
|
-
blocks.forEach( ( block ) => {
|
71
|
-
if ( block.name === 'core/image' ) {
|
72
|
-
delete block.attributes.id;
|
73
|
-
delete block.attributes.url;
|
74
|
-
}
|
75
|
-
} );
|
76
|
-
|
77
|
-
dispatch( 'core/block-editor' ).resetBlocks( blocks );
|
78
|
-
}, html );
|
79
|
-
await saveDraft();
|
80
|
-
|
81
|
-
postId = await page.evaluate( () =>
|
82
|
-
new URL( document.location ).searchParams.get( 'post' )
|
83
|
-
);
|
84
|
-
} );
|
85
|
-
|
86
|
-
afterAll( async () => {
|
87
|
-
saveResultsFile( __filename, results );
|
88
|
-
await deleteAllTemplates( 'wp_template' );
|
89
|
-
await deleteAllTemplates( 'wp_template_part' );
|
90
|
-
} );
|
91
|
-
|
92
|
-
// Number of loading measurements to take.
|
93
|
-
const loadingSamples = 3;
|
94
|
-
// Number of throwaway measurements to perform before recording samples.
|
95
|
-
// Having at least one helps ensure that caching quirks don't manifest
|
96
|
-
// in the results.
|
97
|
-
const loadingSamplesThrowaway = 1;
|
98
|
-
const loadingIterations = sequence(
|
99
|
-
1,
|
100
|
-
loadingSamples + loadingSamplesThrowaway
|
101
|
-
);
|
102
|
-
it.each( loadingIterations )(
|
103
|
-
`Loading (%i of ${ loadingIterations.length })`,
|
104
|
-
async ( i ) => {
|
105
|
-
// Open the test page in Site Editor.
|
106
|
-
await visitSiteEditor( {
|
107
|
-
postId,
|
108
|
-
postType: 'page',
|
109
|
-
} );
|
110
|
-
|
111
|
-
// Wait for the first block.
|
112
|
-
await canvas().waitForSelector( '.wp-block' );
|
113
|
-
|
114
|
-
// Save results.
|
115
|
-
if ( i > loadingSamplesThrowaway ) {
|
116
|
-
const {
|
117
|
-
serverResponse,
|
118
|
-
firstPaint,
|
119
|
-
domContentLoaded,
|
120
|
-
loaded,
|
121
|
-
firstContentfulPaint,
|
122
|
-
firstBlock,
|
123
|
-
} = await getLoadingDurations();
|
124
|
-
|
125
|
-
results.serverResponse.push( serverResponse );
|
126
|
-
results.firstPaint.push( firstPaint );
|
127
|
-
results.domContentLoaded.push( domContentLoaded );
|
128
|
-
results.loaded.push( loaded );
|
129
|
-
results.firstContentfulPaint.push( firstContentfulPaint );
|
130
|
-
results.firstBlock.push( firstBlock );
|
131
|
-
}
|
132
|
-
|
133
|
-
expect( true ).toBe( true );
|
134
|
-
}
|
135
|
-
);
|
136
|
-
|
137
|
-
it( 'Typing', async () => {
|
138
|
-
// Open the test page in Site Editor.
|
139
|
-
await visitSiteEditor( {
|
140
|
-
postId,
|
141
|
-
postType: 'page',
|
142
|
-
} );
|
143
|
-
|
144
|
-
// Wait for the first block to be ready.
|
145
|
-
await canvas().waitForSelector( '.wp-block' );
|
146
|
-
|
147
|
-
// Get inside the post content.
|
148
|
-
await enterEditMode();
|
149
|
-
|
150
|
-
// Select the post content block wrapper.
|
151
|
-
await canvas().click( '.wp-block-post-content' );
|
152
|
-
|
153
|
-
// Select the first paragraph in the post content block.
|
154
|
-
const firstParagraph = await canvas().waitForXPath(
|
155
|
-
'//p[contains(text(), "Lorem ipsum dolor sit amet")]'
|
156
|
-
);
|
157
|
-
await firstParagraph.click();
|
158
|
-
|
159
|
-
await insertBlock( 'Paragraph' );
|
160
|
-
|
161
|
-
// Start tracing.
|
162
|
-
const traceFilePath = getTraceFilePath();
|
163
|
-
await page.tracing.start( {
|
164
|
-
path: traceFilePath,
|
165
|
-
screenshots: false,
|
166
|
-
categories: [ 'devtools.timeline' ],
|
167
|
-
} );
|
168
|
-
|
169
|
-
// Type "x" 200 times.
|
170
|
-
await page.keyboard.type( new Array( 200 ).fill( 'x' ).join( '' ) );
|
171
|
-
|
172
|
-
// Stop tracing and save results.
|
173
|
-
await page.tracing.stop();
|
174
|
-
const traceResults = JSON.parse( readFile( traceFilePath ) );
|
175
|
-
const [ keyDownEvents, keyPressEvents, keyUpEvents ] =
|
176
|
-
getTypingEventDurations( traceResults );
|
177
|
-
for ( let i = 0; i < keyDownEvents.length; i++ ) {
|
178
|
-
results.type.push(
|
179
|
-
keyDownEvents[ i ] + keyPressEvents[ i ] + keyUpEvents[ i ]
|
180
|
-
);
|
181
|
-
}
|
182
|
-
|
183
|
-
// Delete the original trace file.
|
184
|
-
deleteFile( traceFilePath );
|
185
|
-
|
186
|
-
expect( true ).toBe( true );
|
187
|
-
} );
|
188
|
-
} );
|
@@ -1,146 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* External dependencies
|
3
|
-
*/
|
4
|
-
import path from 'path';
|
5
|
-
import { existsSync, readFileSync, unlinkSync, writeFileSync } from 'fs';
|
6
|
-
|
7
|
-
export function readFile( filePath ) {
|
8
|
-
return existsSync( filePath )
|
9
|
-
? readFileSync( filePath, 'utf8' ).trim()
|
10
|
-
: '';
|
11
|
-
}
|
12
|
-
|
13
|
-
export function deleteFile( filePath ) {
|
14
|
-
if ( existsSync( filePath ) ) {
|
15
|
-
unlinkSync( filePath );
|
16
|
-
}
|
17
|
-
}
|
18
|
-
|
19
|
-
export function getTraceFilePath() {
|
20
|
-
return path.join( process.env.WP_ARTIFACTS_PATH, '/trace.json' );
|
21
|
-
}
|
22
|
-
|
23
|
-
export function saveResultsFile( testFilename, results ) {
|
24
|
-
const resultsFilename =
|
25
|
-
process.env.RESULTS_FILENAME ||
|
26
|
-
path.basename( testFilename, '.js' ) + '.performance-results.json';
|
27
|
-
|
28
|
-
return writeFileSync(
|
29
|
-
path.join( process.env.WP_ARTIFACTS_PATH, resultsFilename ),
|
30
|
-
JSON.stringify( results, null, 2 )
|
31
|
-
);
|
32
|
-
}
|
33
|
-
|
34
|
-
function isEvent( item ) {
|
35
|
-
return (
|
36
|
-
item.cat === 'devtools.timeline' &&
|
37
|
-
item.name === 'EventDispatch' &&
|
38
|
-
item.dur &&
|
39
|
-
item.args &&
|
40
|
-
item.args.data
|
41
|
-
);
|
42
|
-
}
|
43
|
-
|
44
|
-
function isKeyDownEvent( item ) {
|
45
|
-
return isEvent( item ) && item.args.data.type === 'keydown';
|
46
|
-
}
|
47
|
-
|
48
|
-
function isKeyPressEvent( item ) {
|
49
|
-
return isEvent( item ) && item.args.data.type === 'keypress';
|
50
|
-
}
|
51
|
-
|
52
|
-
function isKeyUpEvent( item ) {
|
53
|
-
return isEvent( item ) && item.args.data.type === 'keyup';
|
54
|
-
}
|
55
|
-
|
56
|
-
function isFocusEvent( item ) {
|
57
|
-
return isEvent( item ) && item.args.data.type === 'focus';
|
58
|
-
}
|
59
|
-
|
60
|
-
function isFocusInEvent( item ) {
|
61
|
-
return isEvent( item ) && item.args.data.type === 'focusin';
|
62
|
-
}
|
63
|
-
|
64
|
-
function isClickEvent( item ) {
|
65
|
-
return isEvent( item ) && item.args.data.type === 'click';
|
66
|
-
}
|
67
|
-
|
68
|
-
function isMouseOverEvent( item ) {
|
69
|
-
return isEvent( item ) && item.args.data.type === 'mouseover';
|
70
|
-
}
|
71
|
-
|
72
|
-
function isMouseOutEvent( item ) {
|
73
|
-
return isEvent( item ) && item.args.data.type === 'mouseout';
|
74
|
-
}
|
75
|
-
|
76
|
-
function getEventDurationsForType( trace, filterFunction ) {
|
77
|
-
return trace.traceEvents
|
78
|
-
.filter( filterFunction )
|
79
|
-
.map( ( item ) => item.dur / 1000 );
|
80
|
-
}
|
81
|
-
|
82
|
-
export function getTypingEventDurations( trace ) {
|
83
|
-
return [
|
84
|
-
getEventDurationsForType( trace, isKeyDownEvent ),
|
85
|
-
getEventDurationsForType( trace, isKeyPressEvent ),
|
86
|
-
getEventDurationsForType( trace, isKeyUpEvent ),
|
87
|
-
];
|
88
|
-
}
|
89
|
-
|
90
|
-
export function getSelectionEventDurations( trace ) {
|
91
|
-
return [
|
92
|
-
getEventDurationsForType( trace, isFocusEvent ),
|
93
|
-
getEventDurationsForType( trace, isFocusInEvent ),
|
94
|
-
];
|
95
|
-
}
|
96
|
-
|
97
|
-
export function getClickEventDurations( trace ) {
|
98
|
-
return [ getEventDurationsForType( trace, isClickEvent ) ];
|
99
|
-
}
|
100
|
-
|
101
|
-
export function getHoverEventDurations( trace ) {
|
102
|
-
return [
|
103
|
-
getEventDurationsForType( trace, isMouseOverEvent ),
|
104
|
-
getEventDurationsForType( trace, isMouseOutEvent ),
|
105
|
-
];
|
106
|
-
}
|
107
|
-
|
108
|
-
export async function getLoadingDurations() {
|
109
|
-
return await page.evaluate( () => {
|
110
|
-
const [
|
111
|
-
{
|
112
|
-
requestStart,
|
113
|
-
responseStart,
|
114
|
-
responseEnd,
|
115
|
-
domContentLoadedEventEnd,
|
116
|
-
loadEventEnd,
|
117
|
-
},
|
118
|
-
] = performance.getEntriesByType( 'navigation' );
|
119
|
-
const paintTimings = performance.getEntriesByType( 'paint' );
|
120
|
-
return {
|
121
|
-
// Server side metric.
|
122
|
-
serverResponse: responseStart - requestStart,
|
123
|
-
// For client side metrics, consider the end of the response (the
|
124
|
-
// browser receives the HTML) as the start time (0).
|
125
|
-
firstPaint:
|
126
|
-
paintTimings.find( ( { name } ) => name === 'first-paint' )
|
127
|
-
.startTime - responseEnd,
|
128
|
-
domContentLoaded: domContentLoadedEventEnd - responseEnd,
|
129
|
-
loaded: loadEventEnd - responseEnd,
|
130
|
-
firstContentfulPaint:
|
131
|
-
paintTimings.find(
|
132
|
-
( { name } ) => name === 'first-contentful-paint'
|
133
|
-
).startTime - responseEnd,
|
134
|
-
// This is evaluated right after Puppeteer found the block selector.
|
135
|
-
firstBlock: performance.now() - responseEnd,
|
136
|
-
};
|
137
|
-
} );
|
138
|
-
}
|
139
|
-
|
140
|
-
export function sum( arr ) {
|
141
|
-
return arr.reduce( ( a, b ) => a + b, 0 );
|
142
|
-
}
|
143
|
-
|
144
|
-
export function sequence( start, length ) {
|
145
|
-
return Array.from( { length }, ( _, i ) => i + start );
|
146
|
-
}
|