@wordpress/e2e-tests 7.10.0 → 7.11.1
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 +2 -0
- package/jest.config.js +1 -4
- package/package.json +9 -9
- package/plugins/interactive-blocks/directive-body/block.json +14 -0
- 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 +12 -0
- package/plugins/interactive-blocks/directive-effect/view.js +7 -0
- 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/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/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 +4 -4
- package/specs/editor/various/rich-text.test.js +11 -0
- package/specs/experiments/blocks/post-comments-form.test.js +2 -2
- 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/specs/editor/plugins/block-variations.test.js +0 -191
- 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,77 +0,0 @@
|
|
1
|
-
<!-- wp:columns {"align":"full"} -->
|
2
|
-
<div class="wp-block-columns alignfull"><!-- wp:column -->
|
3
|
-
<div class="wp-block-column"><!-- wp:heading {"level":3} -->
|
4
|
-
<h3 class="wp-block-heading">Heading</h3>
|
5
|
-
<!-- /wp:heading -->
|
6
|
-
|
7
|
-
<!-- wp:paragraph -->
|
8
|
-
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
|
9
|
-
<!-- /wp:paragraph -->
|
10
|
-
|
11
|
-
<!-- wp:list -->
|
12
|
-
<ul><!-- wp:list-item -->
|
13
|
-
<li>one</li>
|
14
|
-
<!-- /wp:list-item -->
|
15
|
-
|
16
|
-
<!-- wp:list-item -->
|
17
|
-
<li>two</li>
|
18
|
-
<!-- /wp:list-item -->
|
19
|
-
|
20
|
-
<!-- wp:list-item -->
|
21
|
-
<li>three</li>
|
22
|
-
<!-- /wp:list-item --></ul>
|
23
|
-
<!-- /wp:list --></div>
|
24
|
-
<!-- /wp:column -->
|
25
|
-
|
26
|
-
<!-- wp:column -->
|
27
|
-
<div class="wp-block-column"><!-- wp:heading {"level":3} -->
|
28
|
-
<h3 class="wp-block-heading">Heading</h3>
|
29
|
-
<!-- /wp:heading -->
|
30
|
-
|
31
|
-
<!-- wp:paragraph -->
|
32
|
-
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
|
33
|
-
<!-- /wp:paragraph -->
|
34
|
-
|
35
|
-
<!-- wp:list -->
|
36
|
-
<ul><!-- wp:list-item -->
|
37
|
-
<li>one</li>
|
38
|
-
<!-- /wp:list-item -->
|
39
|
-
|
40
|
-
<!-- wp:list-item -->
|
41
|
-
<li>two</li>
|
42
|
-
<!-- /wp:list-item -->
|
43
|
-
|
44
|
-
<!-- wp:list-item -->
|
45
|
-
<li>three</li>
|
46
|
-
<!-- /wp:list-item --></ul>
|
47
|
-
<!-- /wp:list --></div>
|
48
|
-
<!-- /wp:column -->
|
49
|
-
|
50
|
-
<!-- wp:column -->
|
51
|
-
<div class="wp-block-column"><!-- wp:heading {"level":3} -->
|
52
|
-
<h3 class="wp-block-heading">Heading</h3>
|
53
|
-
<!-- /wp:heading -->
|
54
|
-
|
55
|
-
<!-- wp:paragraph -->
|
56
|
-
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
|
57
|
-
<!-- /wp:paragraph -->
|
58
|
-
|
59
|
-
<!-- wp:list -->
|
60
|
-
<ul><!-- wp:list-item -->
|
61
|
-
<li>one</li>
|
62
|
-
<!-- /wp:list-item -->
|
63
|
-
|
64
|
-
<!-- wp:list-item -->
|
65
|
-
<li>two</li>
|
66
|
-
<!-- /wp:list-item -->
|
67
|
-
|
68
|
-
<!-- wp:list-item -->
|
69
|
-
<li>three</li>
|
70
|
-
<!-- /wp:list-item --></ul>
|
71
|
-
<!-- /wp:list --></div>
|
72
|
-
<!-- /wp:column --></div>
|
73
|
-
<!-- /wp:columns -->
|
74
|
-
|
75
|
-
<!-- wp:paragraph -->
|
76
|
-
<p></p>
|
77
|
-
<!-- /wp:paragraph -->
|
@@ -1,177 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* External dependencies
|
3
|
-
*/
|
4
|
-
const { readFileSync, existsSync } = require( 'fs' );
|
5
|
-
const path = require( 'path' );
|
6
|
-
const chalk = require( 'chalk' );
|
7
|
-
|
8
|
-
function average( array ) {
|
9
|
-
return array.reduce( ( a, b ) => a + b ) / array.length;
|
10
|
-
}
|
11
|
-
|
12
|
-
function round( number, decimalPlaces = 2 ) {
|
13
|
-
const factor = Math.pow( 10, decimalPlaces );
|
14
|
-
return Math.round( number * factor ) / factor;
|
15
|
-
}
|
16
|
-
|
17
|
-
const title = chalk.bold;
|
18
|
-
const success = chalk.bold.green;
|
19
|
-
|
20
|
-
class PerformanceReporter {
|
21
|
-
onTestResult( test ) {
|
22
|
-
const basename = path.basename( test.path, '.js' );
|
23
|
-
const filepath = path.join(
|
24
|
-
process.env.WP_ARTIFACTS_PATH,
|
25
|
-
basename + '.performance-results.json'
|
26
|
-
);
|
27
|
-
|
28
|
-
if ( ! existsSync( filepath ) ) {
|
29
|
-
return;
|
30
|
-
}
|
31
|
-
|
32
|
-
const results = readFileSync( filepath, 'utf8' );
|
33
|
-
const {
|
34
|
-
serverResponse,
|
35
|
-
firstPaint,
|
36
|
-
domContentLoaded,
|
37
|
-
loaded,
|
38
|
-
firstContentfulPaint,
|
39
|
-
firstBlock,
|
40
|
-
type,
|
41
|
-
typeContainer,
|
42
|
-
focus,
|
43
|
-
listViewOpen,
|
44
|
-
inserterOpen,
|
45
|
-
inserterHover,
|
46
|
-
inserterSearch,
|
47
|
-
} = JSON.parse( results );
|
48
|
-
|
49
|
-
if ( serverResponse && serverResponse.length ) {
|
50
|
-
// eslint-disable-next-line no-console
|
51
|
-
console.log( `
|
52
|
-
${ title( 'Loading Time:' ) }
|
53
|
-
Average time to server response (subtracted from client side metrics): ${ success(
|
54
|
-
round( average( serverResponse ) ) + 'ms'
|
55
|
-
) }
|
56
|
-
Average time to first paint: ${ success(
|
57
|
-
round( average( firstPaint ) ) + 'ms'
|
58
|
-
) }
|
59
|
-
Average time to DOM content load: ${ success(
|
60
|
-
round( average( domContentLoaded ) ) + 'ms'
|
61
|
-
) }
|
62
|
-
Average time to load: ${ success( round( average( loaded ) ) + 'ms' ) }
|
63
|
-
Average time to first contentful paint: ${ success(
|
64
|
-
round( average( firstContentfulPaint ) ) + 'ms'
|
65
|
-
) }
|
66
|
-
Average time to first block: ${ success(
|
67
|
-
round( average( firstBlock ) ) + 'ms'
|
68
|
-
) }` );
|
69
|
-
}
|
70
|
-
|
71
|
-
if ( type && type.length ) {
|
72
|
-
// eslint-disable-next-line no-console
|
73
|
-
console.log( `
|
74
|
-
${ title( 'Typing:' ) }
|
75
|
-
Average time to type character: ${ success( round( average( type ) ) + 'ms' ) }
|
76
|
-
Slowest time to type character: ${ success(
|
77
|
-
round( Math.max( ...type ) ) + 'ms'
|
78
|
-
) }
|
79
|
-
Fastest time to type character: ${ success(
|
80
|
-
round( Math.min( ...type ) ) + 'ms'
|
81
|
-
) }` );
|
82
|
-
}
|
83
|
-
|
84
|
-
if ( typeContainer && typeContainer.length ) {
|
85
|
-
// eslint-disable-next-line no-console
|
86
|
-
console.log( `
|
87
|
-
${ title( 'Typing within a container:' ) }
|
88
|
-
Average time to type within a container: ${ success(
|
89
|
-
round( average( typeContainer ) ) + 'ms'
|
90
|
-
) }
|
91
|
-
Slowest time to type within a container: ${ success(
|
92
|
-
round( Math.max( ...typeContainer ) ) + 'ms'
|
93
|
-
) }
|
94
|
-
Fastest time to type within a container: ${ success(
|
95
|
-
round( Math.min( ...typeContainer ) ) + 'ms'
|
96
|
-
) }` );
|
97
|
-
}
|
98
|
-
|
99
|
-
if ( focus && focus.length ) {
|
100
|
-
// eslint-disable-next-line no-console
|
101
|
-
console.log( `
|
102
|
-
${ title( 'Block Selection:' ) }
|
103
|
-
Average time to select a block: ${ success( round( average( focus ) ) + 'ms' ) }
|
104
|
-
Slowest time to select a block: ${ success(
|
105
|
-
round( Math.max( ...focus ) ) + 'ms'
|
106
|
-
) }
|
107
|
-
Fastest time to select a block: ${ success(
|
108
|
-
round( Math.min( ...focus ) ) + 'ms'
|
109
|
-
) }` );
|
110
|
-
}
|
111
|
-
|
112
|
-
if ( listViewOpen && listViewOpen.length ) {
|
113
|
-
// eslint-disable-next-line no-console
|
114
|
-
console.log( `
|
115
|
-
${ title( 'Opening List View:' ) }
|
116
|
-
Average time to open list view: ${ success(
|
117
|
-
round( average( listViewOpen ) ) + 'ms'
|
118
|
-
) }
|
119
|
-
Slowest time to open list view: ${ success(
|
120
|
-
round( Math.max( ...listViewOpen ) ) + 'ms'
|
121
|
-
) }
|
122
|
-
Fastest time to open list view: ${ success(
|
123
|
-
round( Math.min( ...listViewOpen ) ) + 'ms'
|
124
|
-
) }` );
|
125
|
-
}
|
126
|
-
|
127
|
-
if ( inserterOpen && inserterOpen.length ) {
|
128
|
-
// eslint-disable-next-line no-console
|
129
|
-
console.log( `
|
130
|
-
${ title( 'Opening Global Inserter:' ) }
|
131
|
-
Average time to open global inserter: ${ success(
|
132
|
-
round( average( inserterOpen ) ) + 'ms'
|
133
|
-
) }
|
134
|
-
Slowest time to open global inserter: ${ success(
|
135
|
-
round( Math.max( ...inserterOpen ) ) + 'ms'
|
136
|
-
) }
|
137
|
-
Fastest time to open global inserter: ${ success(
|
138
|
-
round( Math.min( ...inserterOpen ) ) + 'ms'
|
139
|
-
) }` );
|
140
|
-
}
|
141
|
-
|
142
|
-
if ( inserterSearch && inserterSearch.length ) {
|
143
|
-
// eslint-disable-next-line no-console
|
144
|
-
console.log( `
|
145
|
-
${ title( 'Inserter Search:' ) }
|
146
|
-
Average time to type the inserter search input: ${ success(
|
147
|
-
round( average( inserterSearch ) ) + 'ms'
|
148
|
-
) }
|
149
|
-
Slowest time to type the inserter search input: ${ success(
|
150
|
-
round( Math.max( ...inserterSearch ) ) + 'ms'
|
151
|
-
) }
|
152
|
-
Fastest time to type the inserter search input: ${ success(
|
153
|
-
round( Math.min( ...inserterSearch ) ) + 'ms'
|
154
|
-
) }` );
|
155
|
-
}
|
156
|
-
|
157
|
-
if ( inserterHover && inserterHover.length ) {
|
158
|
-
// eslint-disable-next-line no-console
|
159
|
-
console.log( `
|
160
|
-
${ title( 'Inserter Block Item Hover:' ) }
|
161
|
-
Average time to move mouse between two block item in the inserter: ${ success(
|
162
|
-
round( average( inserterHover ) ) + 'ms'
|
163
|
-
) }
|
164
|
-
Slowest time to move mouse between two block item in the inserter: ${ success(
|
165
|
-
round( Math.max( ...inserterHover ) ) + 'ms'
|
166
|
-
) }
|
167
|
-
Fastest time to move mouse between two block item in the inserter: ${ success(
|
168
|
-
round( Math.min( ...inserterHover ) ) + 'ms'
|
169
|
-
) }` );
|
170
|
-
}
|
171
|
-
|
172
|
-
// eslint-disable-next-line no-console
|
173
|
-
console.log( '' );
|
174
|
-
}
|
175
|
-
}
|
176
|
-
|
177
|
-
module.exports = PerformanceReporter;
|
@@ -1,51 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import {
|
5
|
-
activatePlugin,
|
6
|
-
clearLocalStorage,
|
7
|
-
enablePageDialogAccept,
|
8
|
-
setBrowserViewport,
|
9
|
-
trashAllPosts,
|
10
|
-
} from '@wordpress/e2e-test-utils';
|
11
|
-
|
12
|
-
/**
|
13
|
-
* Timeout, in seconds, that the test should be allowed to run.
|
14
|
-
*
|
15
|
-
* @type {string|undefined}
|
16
|
-
*/
|
17
|
-
const PUPPETEER_TIMEOUT = process.env.PUPPETEER_TIMEOUT;
|
18
|
-
|
19
|
-
// The Jest timeout is increased because these tests are a bit slow.
|
20
|
-
jest.setTimeout( PUPPETEER_TIMEOUT || 100000 );
|
21
|
-
|
22
|
-
async function setupPage() {
|
23
|
-
await setBrowserViewport( 'large' );
|
24
|
-
await page.emulateMediaFeatures( [
|
25
|
-
{ name: 'prefers-reduced-motion', value: 'reduce' },
|
26
|
-
] );
|
27
|
-
}
|
28
|
-
|
29
|
-
// Before every test suite run, delete all content created by the test. This
|
30
|
-
// ensures other posts/comments/etc. aren't dirtying tests and tests don't
|
31
|
-
// depend on each other's side-effects.
|
32
|
-
beforeAll( async () => {
|
33
|
-
enablePageDialogAccept();
|
34
|
-
|
35
|
-
await trashAllPosts();
|
36
|
-
await trashAllPosts( 'wp_block' );
|
37
|
-
await activatePlugin( 'gutenberg-test-plugin-disables-the-css-animations' );
|
38
|
-
await clearLocalStorage();
|
39
|
-
await setupPage();
|
40
|
-
} );
|
41
|
-
|
42
|
-
afterEach( async () => {
|
43
|
-
// Clear localStorage between tests so that the next test starts clean.
|
44
|
-
await clearLocalStorage();
|
45
|
-
// Close the previous page entirely and create a new page, so that the next
|
46
|
-
// test isn't affected by page unload work.
|
47
|
-
await page.close();
|
48
|
-
page = await browser.newPage();
|
49
|
-
// Set up testing config on new page.
|
50
|
-
await setupPage();
|
51
|
-
} );
|
@@ -1,16 +0,0 @@
|
|
1
|
-
module.exports = {
|
2
|
-
...require( '@wordpress/scripts/config/jest-e2e.config' ),
|
3
|
-
testMatch: [ '**/performance/*.test.js' ],
|
4
|
-
setupFiles: [ '<rootDir>/config/is-gutenberg-plugin.js' ],
|
5
|
-
setupFilesAfterEnv: [
|
6
|
-
'<rootDir>/config/setup-performance-test.js',
|
7
|
-
'@wordpress/jest-console',
|
8
|
-
'@wordpress/jest-puppeteer-axe',
|
9
|
-
'expect-puppeteer',
|
10
|
-
],
|
11
|
-
transformIgnorePatterns: [
|
12
|
-
'node_modules',
|
13
|
-
'scripts/config/puppeteer.config.js',
|
14
|
-
],
|
15
|
-
reporters: [ 'default', '<rootDir>/config/performance-reporter.js' ],
|
16
|
-
};
|
@@ -1,191 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import {
|
5
|
-
activatePlugin,
|
6
|
-
createNewPost,
|
7
|
-
deactivatePlugin,
|
8
|
-
insertBlock,
|
9
|
-
searchForBlock,
|
10
|
-
pressKeyWithModifier,
|
11
|
-
openDocumentSettingsSidebar,
|
12
|
-
togglePreferencesOption,
|
13
|
-
toggleMoreMenu,
|
14
|
-
canvas,
|
15
|
-
} from '@wordpress/e2e-test-utils';
|
16
|
-
|
17
|
-
describe( 'Block variations', () => {
|
18
|
-
beforeAll( async () => {
|
19
|
-
await activatePlugin( 'gutenberg-test-block-variations' );
|
20
|
-
} );
|
21
|
-
|
22
|
-
beforeEach( async () => {
|
23
|
-
await createNewPost();
|
24
|
-
} );
|
25
|
-
|
26
|
-
afterAll( async () => {
|
27
|
-
await deactivatePlugin( 'gutenberg-test-block-variations' );
|
28
|
-
} );
|
29
|
-
|
30
|
-
const expectInserterItem = async ( blockTitle ) => {
|
31
|
-
const inserterItem = await page.$x(
|
32
|
-
`//button[contains(@class, 'block-editor-block-types-list__item')]//span[text()="${ blockTitle }"]`
|
33
|
-
);
|
34
|
-
expect( inserterItem ).toBeDefined();
|
35
|
-
expect( inserterItem ).toHaveLength( 1 );
|
36
|
-
};
|
37
|
-
|
38
|
-
test( 'Search for the overridden default Quote block', async () => {
|
39
|
-
await searchForBlock( 'Quote' );
|
40
|
-
|
41
|
-
expect( await page.$( '.editor-block-list-item-quote' ) ).toBeNull();
|
42
|
-
expectInserterItem( 'Large Quote' );
|
43
|
-
} );
|
44
|
-
|
45
|
-
test( 'Insert the overridden default Quote block variation', async () => {
|
46
|
-
await insertBlock( 'Large Quote' );
|
47
|
-
|
48
|
-
expect(
|
49
|
-
await canvas().$(
|
50
|
-
'.wp-block[data-type="core/quote"] blockquote.is-style-large'
|
51
|
-
)
|
52
|
-
).toBeDefined();
|
53
|
-
} );
|
54
|
-
|
55
|
-
test( 'Insert the Large Quote block variation with slash command', async () => {
|
56
|
-
await insertBlock( 'Paragraph' );
|
57
|
-
|
58
|
-
await page.keyboard.type( '/large' );
|
59
|
-
await page.keyboard.press( 'Enter' );
|
60
|
-
|
61
|
-
expect(
|
62
|
-
await canvas().$(
|
63
|
-
'.wp-block[data-type="core/quote"] blockquote.is-style-large'
|
64
|
-
)
|
65
|
-
).toBeDefined();
|
66
|
-
} );
|
67
|
-
|
68
|
-
test( 'Search for the Paragraph block with 2 additional variations', async () => {
|
69
|
-
await searchForBlock( 'Paragraph' );
|
70
|
-
|
71
|
-
expectInserterItem( 'Paragraph' );
|
72
|
-
expectInserterItem( 'Success Message' );
|
73
|
-
expectInserterItem( 'Warning Message' );
|
74
|
-
} );
|
75
|
-
|
76
|
-
test( 'Insert the Success Message block variation', async () => {
|
77
|
-
await insertBlock( 'Success Message' );
|
78
|
-
|
79
|
-
const successMessageBlock = await canvas().$(
|
80
|
-
'.wp-block[data-type="core/paragraph"]'
|
81
|
-
);
|
82
|
-
expect( successMessageBlock ).toBeDefined();
|
83
|
-
expect(
|
84
|
-
await successMessageBlock.evaluate( ( node ) => node.innerText )
|
85
|
-
).toBe( 'This is a success message!' );
|
86
|
-
} );
|
87
|
-
test( 'Pick the additional variation in the inserted Columns block', async () => {
|
88
|
-
await insertBlock( 'Columns' );
|
89
|
-
|
90
|
-
const fourColumnsVariation = await canvas().waitForSelector(
|
91
|
-
'.wp-block[data-type="core/columns"] .block-editor-block-variation-picker__variation[aria-label="Four columns"]'
|
92
|
-
);
|
93
|
-
await fourColumnsVariation.click();
|
94
|
-
expect(
|
95
|
-
await canvas().$$(
|
96
|
-
'.wp-block[data-type="core/columns"] .wp-block[data-type="core/column"]'
|
97
|
-
)
|
98
|
-
).toHaveLength( 4 );
|
99
|
-
} );
|
100
|
-
// @see @wordpres/block-editor/src/components/use-block-display-information (`useBlockDisplayInformation` hook).
|
101
|
-
describe( 'testing block display information with matching variations', () => {
|
102
|
-
beforeEach( async () => {
|
103
|
-
await togglePreferencesOption(
|
104
|
-
'General',
|
105
|
-
'Display block breadcrumbs',
|
106
|
-
true
|
107
|
-
);
|
108
|
-
await toggleMoreMenu( 'close' );
|
109
|
-
} );
|
110
|
-
|
111
|
-
afterEach( async () => {
|
112
|
-
await togglePreferencesOption(
|
113
|
-
'General',
|
114
|
-
'Display block breadcrumbs',
|
115
|
-
false
|
116
|
-
);
|
117
|
-
await toggleMoreMenu( 'close' );
|
118
|
-
} );
|
119
|
-
|
120
|
-
const getActiveBreadcrumb = async () =>
|
121
|
-
page.evaluate(
|
122
|
-
() =>
|
123
|
-
document.querySelector(
|
124
|
-
'.block-editor-block-breadcrumb__current'
|
125
|
-
).textContent
|
126
|
-
);
|
127
|
-
const getFirstNavigationItem = async () => {
|
128
|
-
await pressKeyWithModifier( 'access', 'o' );
|
129
|
-
// This also returns the visually hidden text `(selected block)`.
|
130
|
-
// For example `Paragraph(selected block)`. In order to hide this
|
131
|
-
// implementation detail and search for childNodes, we choose to
|
132
|
-
// test with `String.prototype.startsWith()`.
|
133
|
-
return page.evaluate(
|
134
|
-
() =>
|
135
|
-
document.querySelector(
|
136
|
-
'.block-editor-list-view-block-select-button'
|
137
|
-
).textContent
|
138
|
-
);
|
139
|
-
};
|
140
|
-
const getBlockCardDescription = async () => {
|
141
|
-
await openDocumentSettingsSidebar();
|
142
|
-
return page.evaluate(
|
143
|
-
() =>
|
144
|
-
document.querySelector(
|
145
|
-
'.block-editor-block-card__description'
|
146
|
-
).textContent
|
147
|
-
);
|
148
|
-
};
|
149
|
-
|
150
|
-
it( 'should show block information when no matching variation is found', async () => {
|
151
|
-
await insertBlock( 'Large Quote' );
|
152
|
-
// Select the quote block.
|
153
|
-
await page.keyboard.press( 'ArrowDown' );
|
154
|
-
const breadcrumb = await getActiveBreadcrumb();
|
155
|
-
expect( breadcrumb ).toEqual( 'Quote' );
|
156
|
-
const navigationItem = await getFirstNavigationItem();
|
157
|
-
expect( navigationItem.startsWith( 'Quote' ) ).toBeTruthy();
|
158
|
-
const description = await getBlockCardDescription();
|
159
|
-
expect( description ).toEqual(
|
160
|
-
'Give quoted text visual emphasis. "In quoting others, we cite ourselves." — Julio Cortázar'
|
161
|
-
);
|
162
|
-
} );
|
163
|
-
it( 'should display variations info if all declared', async () => {
|
164
|
-
await insertBlock( 'Success Message' );
|
165
|
-
const breadcrumb = await getActiveBreadcrumb();
|
166
|
-
expect( breadcrumb ).toEqual( 'Success Message' );
|
167
|
-
const navigationItem = await getFirstNavigationItem();
|
168
|
-
expect(
|
169
|
-
navigationItem.startsWith( 'Success Message' )
|
170
|
-
).toBeTruthy();
|
171
|
-
const description = await getBlockCardDescription();
|
172
|
-
expect( description ).toEqual(
|
173
|
-
'This block displays a success message. This description overrides the default one provided for the Paragraph block.'
|
174
|
-
);
|
175
|
-
} );
|
176
|
-
it( 'should display mixed block and variation match information', async () => {
|
177
|
-
// Warning Message variation is missing the `description`.
|
178
|
-
await insertBlock( 'Warning Message' );
|
179
|
-
const breadcrumb = await getActiveBreadcrumb();
|
180
|
-
expect( breadcrumb ).toEqual( 'Warning Message' );
|
181
|
-
const navigationItem = await getFirstNavigationItem();
|
182
|
-
expect(
|
183
|
-
navigationItem.startsWith( 'Warning Message' )
|
184
|
-
).toBeTruthy();
|
185
|
-
const description = await getBlockCardDescription();
|
186
|
-
expect( description ).toEqual(
|
187
|
-
'Start with the basic building block of all narrative.'
|
188
|
-
);
|
189
|
-
} );
|
190
|
-
} );
|
191
|
-
} );
|
@@ -1,77 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import { activateTheme, createURL, logout } from '@wordpress/e2e-test-utils';
|
5
|
-
|
6
|
-
/**
|
7
|
-
* Internal dependencies
|
8
|
-
*/
|
9
|
-
import { saveResultsFile } from './utils';
|
10
|
-
|
11
|
-
describe( 'Front End Performance', () => {
|
12
|
-
const results = {
|
13
|
-
timeToFirstByte: [],
|
14
|
-
largestContentfulPaint: [],
|
15
|
-
lcpMinusTtfb: [],
|
16
|
-
};
|
17
|
-
|
18
|
-
beforeAll( async () => {
|
19
|
-
await activateTheme( 'gutenberg-test-themes/twentytwentythree' );
|
20
|
-
await logout();
|
21
|
-
} );
|
22
|
-
|
23
|
-
afterAll( async () => {
|
24
|
-
saveResultsFile( __filename, results );
|
25
|
-
} );
|
26
|
-
|
27
|
-
it( 'Report TTFB, LCP, and LCP-TTFB', async () => {
|
28
|
-
// Based on https://addyosmani.com/blog/puppeteer-recipes/#performance-observer-lcp
|
29
|
-
function calcLCP() {
|
30
|
-
// By using -1 we know when it didn't record any event.
|
31
|
-
window.largestContentfulPaint = -1;
|
32
|
-
|
33
|
-
const observer = new PerformanceObserver( ( entryList ) => {
|
34
|
-
const entries = entryList.getEntries();
|
35
|
-
const lastEntry = entries[ entries.length - 1 ];
|
36
|
-
// According to the spec, we can use startTime
|
37
|
-
// as it'll report renderTime || loadTime:
|
38
|
-
// https://www.w3.org/TR/largest-contentful-paint/#largestcontentfulpaint
|
39
|
-
window.largestContentfulPaint = lastEntry.startTime;
|
40
|
-
} );
|
41
|
-
|
42
|
-
observer.observe( {
|
43
|
-
type: 'largest-contentful-paint',
|
44
|
-
buffered: true,
|
45
|
-
} );
|
46
|
-
|
47
|
-
document.addEventListener( 'visibilitychange', () => {
|
48
|
-
if ( document.visibilityState === 'hidden' ) {
|
49
|
-
observer.takeRecords();
|
50
|
-
observer.disconnect();
|
51
|
-
}
|
52
|
-
} );
|
53
|
-
}
|
54
|
-
|
55
|
-
let i = 16;
|
56
|
-
while ( i-- ) {
|
57
|
-
await page.evaluateOnNewDocument( calcLCP );
|
58
|
-
// By waiting for networkidle we make sure navigation won't be considered finished on load,
|
59
|
-
// hence, it'll paint the page and largest-contentful-paint events will be dispatched.
|
60
|
-
// https://pptr.dev/api/puppeteer.page.goto#remarks
|
61
|
-
await page.goto( createURL( '/' ), { waitUntil: 'networkidle0' } );
|
62
|
-
|
63
|
-
const { lcp, ttfb } = await page.evaluate( () => {
|
64
|
-
const [ { responseStart, startTime } ] =
|
65
|
-
performance.getEntriesByType( 'navigation' );
|
66
|
-
return {
|
67
|
-
lcp: window.largestContentfulPaint,
|
68
|
-
ttfb: responseStart - startTime,
|
69
|
-
};
|
70
|
-
} );
|
71
|
-
|
72
|
-
results.largestContentfulPaint.push( lcp );
|
73
|
-
results.timeToFirstByte.push( ttfb );
|
74
|
-
results.lcpMinusTtfb.push( lcp - ttfb );
|
75
|
-
}
|
76
|
-
} );
|
77
|
-
} );
|
@@ -1,77 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import { activateTheme, createURL, logout } from '@wordpress/e2e-test-utils';
|
5
|
-
|
6
|
-
/**
|
7
|
-
* Internal dependencies
|
8
|
-
*/
|
9
|
-
import { saveResultsFile } from './utils';
|
10
|
-
|
11
|
-
describe( 'Front End Performance', () => {
|
12
|
-
const results = {
|
13
|
-
timeToFirstByte: [],
|
14
|
-
largestContentfulPaint: [],
|
15
|
-
lcpMinusTtfb: [],
|
16
|
-
};
|
17
|
-
|
18
|
-
beforeAll( async () => {
|
19
|
-
await activateTheme( 'gutenberg-test-themes/twentytwentyone' );
|
20
|
-
await logout();
|
21
|
-
} );
|
22
|
-
|
23
|
-
afterAll( async () => {
|
24
|
-
saveResultsFile( __filename, results );
|
25
|
-
} );
|
26
|
-
|
27
|
-
it( 'Report TTFB, LCP, and LCP-TTFB', async () => {
|
28
|
-
// Based on https://addyosmani.com/blog/puppeteer-recipes/#performance-observer-lcp
|
29
|
-
function calcLCP() {
|
30
|
-
// By using -1 we know when it didn't record any event.
|
31
|
-
window.largestContentfulPaint = -1;
|
32
|
-
|
33
|
-
const observer = new PerformanceObserver( ( entryList ) => {
|
34
|
-
const entries = entryList.getEntries();
|
35
|
-
const lastEntry = entries[ entries.length - 1 ];
|
36
|
-
// According to the spec, we can use startTime
|
37
|
-
// as it'll report renderTime || loadTime:
|
38
|
-
// https://www.w3.org/TR/largest-contentful-paint/#largestcontentfulpaint
|
39
|
-
window.largestContentfulPaint = lastEntry.startTime;
|
40
|
-
} );
|
41
|
-
|
42
|
-
observer.observe( {
|
43
|
-
type: 'largest-contentful-paint',
|
44
|
-
buffered: true,
|
45
|
-
} );
|
46
|
-
|
47
|
-
document.addEventListener( 'visibilitychange', () => {
|
48
|
-
if ( document.visibilityState === 'hidden' ) {
|
49
|
-
observer.takeRecords();
|
50
|
-
observer.disconnect();
|
51
|
-
}
|
52
|
-
} );
|
53
|
-
}
|
54
|
-
|
55
|
-
let i = 16;
|
56
|
-
while ( i-- ) {
|
57
|
-
await page.evaluateOnNewDocument( calcLCP );
|
58
|
-
// By waiting for networkidle we make sure navigation won't be considered finished on load,
|
59
|
-
// hence, it'll paint the page and largest-contentful-paint events will be dispatched.
|
60
|
-
// https://pptr.dev/api/puppeteer.page.goto#remarks
|
61
|
-
await page.goto( createURL( '/' ), { waitUntil: 'networkidle0' } );
|
62
|
-
|
63
|
-
const { lcp, ttfb } = await page.evaluate( () => {
|
64
|
-
const [ { responseStart, startTime } ] =
|
65
|
-
performance.getEntriesByType( 'navigation' );
|
66
|
-
return {
|
67
|
-
lcp: window.largestContentfulPaint,
|
68
|
-
ttfb: responseStart - startTime,
|
69
|
-
};
|
70
|
-
} );
|
71
|
-
|
72
|
-
results.largestContentfulPaint.push( lcp );
|
73
|
-
results.timeToFirstByte.push( ttfb );
|
74
|
-
results.lcpMinusTtfb.push( lcp - ttfb );
|
75
|
-
}
|
76
|
-
} );
|
77
|
-
} );
|