@wordpress/e2e-tests 7.9.0 → 7.10.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 +2 -0
- package/package.json +7 -7
- package/plugins/iframed-enqueue-block-editor-settings.php +19 -0
- package/plugins/interactive-blocks/directive-effect/render.php +1 -1
- package/plugins/interactive-blocks/directive-effect/view.js +7 -16
- package/plugins/interactive-blocks/directive-priorities/render.php +4 -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/reusable-blocks.test.js +6 -3
- package/specs/site-editor/settings-sidebar.test.js +1 -1
- package/plugins/interactive-blocks/directive-show/block.json +0 -14
- 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/iframed-equeue-block-assets.test.js +0 -51
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@wordpress/e2e-tests",
|
3
|
-
"version": "7.
|
3
|
+
"version": "7.10.0",
|
4
4
|
"description": "End-To-End (E2E) tests for WordPress.",
|
5
5
|
"author": "The WordPress Contributors",
|
6
6
|
"license": "GPL-2.0-or-later",
|
@@ -23,11 +23,11 @@
|
|
23
23
|
"node": ">=14"
|
24
24
|
},
|
25
25
|
"dependencies": {
|
26
|
-
"@wordpress/e2e-test-utils": "^10.
|
27
|
-
"@wordpress/jest-console": "^7.
|
28
|
-
"@wordpress/jest-puppeteer-axe": "^6.
|
29
|
-
"@wordpress/scripts": "^26.
|
30
|
-
"@wordpress/url": "^3.
|
26
|
+
"@wordpress/e2e-test-utils": "^10.10.0",
|
27
|
+
"@wordpress/jest-console": "^7.10.0",
|
28
|
+
"@wordpress/jest-puppeteer-axe": "^6.10.0",
|
29
|
+
"@wordpress/scripts": "^26.10.0",
|
30
|
+
"@wordpress/url": "^3.40.0",
|
31
31
|
"chalk": "^4.0.0",
|
32
32
|
"expect-puppeteer": "^4.4.0",
|
33
33
|
"filenamify": "^4.2.0",
|
@@ -45,5 +45,5 @@
|
|
45
45
|
"publishConfig": {
|
46
46
|
"access": "public"
|
47
47
|
},
|
48
|
-
"gitHead": "
|
48
|
+
"gitHead": "b898cf1dc8e70841d1647ea0994ac6278acc18a7"
|
49
49
|
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<?php
|
2
|
+
/**
|
3
|
+
* Plugin Name: Gutenberg Test Iframed enqueue block editor settings
|
4
|
+
* Plugin URI: https://github.com/WordPress/gutenberg
|
5
|
+
* Author: Gutenberg Team
|
6
|
+
*
|
7
|
+
* @package gutenberg-test-iframed-iframed-enqueue-block-editor-settings
|
8
|
+
*/
|
9
|
+
|
10
|
+
add_action(
|
11
|
+
'block_editor_settings_all',
|
12
|
+
function( $settings ) {
|
13
|
+
$settings['styles'][] = array(
|
14
|
+
'css' => 'p { border: 1px solid red }',
|
15
|
+
'__unstableType' => 'plugin',
|
16
|
+
);
|
17
|
+
return $settings;
|
18
|
+
}
|
19
|
+
);
|
@@ -1,28 +1,19 @@
|
|
1
1
|
( ( { wp } ) => {
|
2
|
-
const { store, directive
|
2
|
+
const { store, directive } = wp.interactivity;
|
3
3
|
|
4
|
-
// Fake `data-wp-
|
5
|
-
// Replace with `data-wp-show` when it's ready.
|
4
|
+
// Fake `data-wp-show-mock` directive to test when things are removed from the
|
5
|
+
// DOM. Replace with `data-wp-show` when it's ready.
|
6
6
|
directive(
|
7
|
-
'
|
7
|
+
'show-mock',
|
8
8
|
( {
|
9
9
|
directives: {
|
10
|
-
|
10
|
+
"show-mock": { default: showMock },
|
11
11
|
},
|
12
12
|
element,
|
13
13
|
evaluate,
|
14
|
-
context,
|
15
14
|
} ) => {
|
16
|
-
|
17
|
-
|
18
|
-
() =>
|
19
|
-
element.type === 'template'
|
20
|
-
? element.props.templateChildren
|
21
|
-
: element,
|
22
|
-
[]
|
23
|
-
);
|
24
|
-
if ( ! evaluate( fakeshow, { context: contextValue } ) ) return null;
|
25
|
-
return children;
|
15
|
+
if ( ! evaluate( showMock ) ) return null;
|
16
|
+
return element;
|
26
17
|
}
|
27
18
|
);
|
28
19
|
|
@@ -7,14 +7,14 @@
|
|
7
7
|
|
8
8
|
?>
|
9
9
|
<div>
|
10
|
-
<div data-wp-show="state.falseValue">
|
10
|
+
<div data-wp-show-mock="state.falseValue">
|
11
11
|
<span data-testid="not inside an island">
|
12
12
|
This should be shown because it is inside an island.
|
13
13
|
</span>
|
14
14
|
</div>
|
15
15
|
|
16
16
|
<div data-wp-interactive>
|
17
|
-
<div data-wp-show="state.falseValue">
|
17
|
+
<div data-wp-show-mock="state.falseValue">
|
18
18
|
<span data-testid="inside an island">
|
19
19
|
This should not be shown because it is inside an island.
|
20
20
|
</span>
|
@@ -23,7 +23,7 @@
|
|
23
23
|
|
24
24
|
<div data-wp-interactive>
|
25
25
|
<div data-wp-ignore>
|
26
|
-
<div data-wp-show="state.falseValue">
|
26
|
+
<div data-wp-show-mock="state.falseValue">
|
27
27
|
<span
|
28
28
|
data-testid="inside an inner block of an isolated island"
|
29
29
|
>
|
@@ -37,7 +37,7 @@
|
|
37
37
|
<div data-wp-interactive>
|
38
38
|
<div data-wp-interactive>
|
39
39
|
<div
|
40
|
-
data-wp-show="state.falseValue"
|
40
|
+
data-wp-show-mock="state.falseValue"
|
41
41
|
data-testid="island inside another island"
|
42
42
|
>
|
43
43
|
<span>
|
@@ -51,7 +51,7 @@
|
|
51
51
|
<div data-wp-interactive>
|
52
52
|
<div>
|
53
53
|
<div data-wp-interactive data-wp-ignore>
|
54
|
-
<div data-wp-show="state.falseValue">
|
54
|
+
<div data-wp-show-mock="state.falseValue">
|
55
55
|
<span
|
56
56
|
data-testid="island inside inner block of isolated island"
|
57
57
|
>
|
@@ -1,5 +1,22 @@
|
|
1
1
|
( ( { wp } ) => {
|
2
|
-
const { store } = wp.interactivity;
|
2
|
+
const { store, directive, createElement } = wp.interactivity;
|
3
|
+
|
4
|
+
// Fake `data-wp-show-mock` directive to test when things are removed from the
|
5
|
+
// DOM. Replace with `data-wp-show` when it's ready.
|
6
|
+
directive(
|
7
|
+
'show-mock',
|
8
|
+
( {
|
9
|
+
directives: {
|
10
|
+
"show-mock": { default: showMock },
|
11
|
+
},
|
12
|
+
element,
|
13
|
+
evaluate,
|
14
|
+
} ) => {
|
15
|
+
if ( ! evaluate( showMock ) )
|
16
|
+
element.props.children =
|
17
|
+
createElement( "template", null, element.props.children );
|
18
|
+
}
|
19
|
+
);
|
3
20
|
|
4
21
|
store( {
|
5
22
|
state: {
|
@@ -0,0 +1,108 @@
|
|
1
|
+
/**
|
2
|
+
* WordPress dependencies
|
3
|
+
*/
|
4
|
+
import {
|
5
|
+
activatePlugin,
|
6
|
+
createNewPost,
|
7
|
+
deactivatePlugin,
|
8
|
+
canvas,
|
9
|
+
activateTheme,
|
10
|
+
} from '@wordpress/e2e-test-utils';
|
11
|
+
|
12
|
+
async function getComputedStyle( context, selector, property ) {
|
13
|
+
return await context.evaluate(
|
14
|
+
( sel, prop ) =>
|
15
|
+
window.getComputedStyle( document.querySelector( sel ) )[ prop ],
|
16
|
+
selector,
|
17
|
+
property
|
18
|
+
);
|
19
|
+
}
|
20
|
+
|
21
|
+
describe( 'iframed block editor settings styles', () => {
|
22
|
+
beforeEach( async () => {
|
23
|
+
// Activate the empty theme (block based theme), which is iframed.
|
24
|
+
await activateTheme( 'emptytheme' );
|
25
|
+
await activatePlugin(
|
26
|
+
'gutenberg-test-iframed-enqueue-block-editor-settings'
|
27
|
+
);
|
28
|
+
await createNewPost();
|
29
|
+
} );
|
30
|
+
|
31
|
+
afterEach( async () => {
|
32
|
+
await deactivatePlugin(
|
33
|
+
'gutenberg-test-iframed-enqueue-block-editor-settings'
|
34
|
+
);
|
35
|
+
await activateTheme( 'twentytwentyone' );
|
36
|
+
} );
|
37
|
+
|
38
|
+
it( 'should load styles added through block editor settings', async () => {
|
39
|
+
await page.waitForSelector( 'iframe[name="editor-canvas"]' );
|
40
|
+
// Expect a red border (added in PHP).
|
41
|
+
expect( await getComputedStyle( canvas(), 'p', 'border-color' ) ).toBe(
|
42
|
+
'rgb(255, 0, 0)'
|
43
|
+
);
|
44
|
+
|
45
|
+
await page.evaluate( () => {
|
46
|
+
const settings = window.wp.data
|
47
|
+
.select( 'core/editor' )
|
48
|
+
.getEditorSettings();
|
49
|
+
wp.data.dispatch( 'core/editor' ).updateEditorSettings( {
|
50
|
+
...settings,
|
51
|
+
styles: [
|
52
|
+
...settings.styles,
|
53
|
+
{
|
54
|
+
css: 'p { border-width: 2px; }',
|
55
|
+
__unstableType: 'plugin',
|
56
|
+
},
|
57
|
+
],
|
58
|
+
} );
|
59
|
+
} );
|
60
|
+
|
61
|
+
// Expect a 2px border (added in JS).
|
62
|
+
expect( await getComputedStyle( canvas(), 'p', 'border-width' ) ).toBe(
|
63
|
+
'2px'
|
64
|
+
);
|
65
|
+
} );
|
66
|
+
|
67
|
+
it( 'should load theme styles added through block editor settings', async () => {
|
68
|
+
await page.waitForSelector( 'iframe[name="editor-canvas"]' );
|
69
|
+
|
70
|
+
await page.evaluate( () => {
|
71
|
+
// Make sure that theme styles are added even if the theme styles
|
72
|
+
// preference is off.
|
73
|
+
window.wp.data
|
74
|
+
.dispatch( 'core/edit-post' )
|
75
|
+
.toggleFeature( 'themeStyles' );
|
76
|
+
const settings = window.wp.data
|
77
|
+
.select( 'core/editor' )
|
78
|
+
.getEditorSettings();
|
79
|
+
wp.data.dispatch( 'core/editor' ).updateEditorSettings( {
|
80
|
+
...settings,
|
81
|
+
styles: [
|
82
|
+
...settings.styles,
|
83
|
+
{
|
84
|
+
css: 'p { border-width: 2px; }',
|
85
|
+
__unstableType: 'theme',
|
86
|
+
},
|
87
|
+
],
|
88
|
+
} );
|
89
|
+
} );
|
90
|
+
|
91
|
+
// Expect a 1px border because theme styles are disabled.
|
92
|
+
expect( await getComputedStyle( canvas(), 'p', 'border-width' ) ).toBe(
|
93
|
+
'1px'
|
94
|
+
);
|
95
|
+
|
96
|
+
await page.evaluate( () => {
|
97
|
+
// Now enable theme styles.
|
98
|
+
window.wp.data
|
99
|
+
.dispatch( 'core/edit-post' )
|
100
|
+
.toggleFeature( 'themeStyles' );
|
101
|
+
} );
|
102
|
+
|
103
|
+
// Expect a 2px border because theme styles are enabled.
|
104
|
+
expect( await getComputedStyle( canvas(), 'p', 'border-width' ) ).toBe(
|
105
|
+
'2px'
|
106
|
+
);
|
107
|
+
} );
|
108
|
+
} );
|
@@ -111,7 +111,8 @@ describe( 'Reusable blocks', () => {
|
|
111
111
|
await insertReusableBlock( 'Surprised greeting block' );
|
112
112
|
|
113
113
|
// Convert block to a regular block.
|
114
|
-
await clickBlockToolbarButton( '
|
114
|
+
await clickBlockToolbarButton( 'Options' );
|
115
|
+
await clickMenuItem( 'Detach pattern' );
|
115
116
|
|
116
117
|
// Check that we have a paragraph block on the page.
|
117
118
|
const paragraphBlock = await canvas().$(
|
@@ -217,7 +218,8 @@ describe( 'Reusable blocks', () => {
|
|
217
218
|
await insertReusableBlock( 'Multi-selection reusable block' );
|
218
219
|
|
219
220
|
// Convert block to a regular block.
|
220
|
-
await clickBlockToolbarButton( '
|
221
|
+
await clickBlockToolbarButton( 'Options' );
|
222
|
+
await clickMenuItem( 'Detach patterns' );
|
221
223
|
|
222
224
|
// Check that we have two paragraph blocks on the page.
|
223
225
|
expect( await getEditedPostContent() ).toMatchSnapshot();
|
@@ -349,7 +351,8 @@ describe( 'Reusable blocks', () => {
|
|
349
351
|
|
350
352
|
// Convert back to regular blocks.
|
351
353
|
await clickBlockToolbarButton( 'Select Edited block' );
|
352
|
-
await clickBlockToolbarButton( '
|
354
|
+
await clickBlockToolbarButton( 'Options' );
|
355
|
+
await clickMenuItem( 'Detach pattern' );
|
353
356
|
await page.waitForXPath( selector, {
|
354
357
|
hidden: true,
|
355
358
|
} );
|
@@ -81,7 +81,7 @@ describe( 'Settings sidebar', () => {
|
|
81
81
|
expect( templateCardAfterNavigation ).toMatchObject( {
|
82
82
|
title: 'Single Entries',
|
83
83
|
description:
|
84
|
-
'Displays any single entry, such as a post or a page. This template will serve as a fallback when a more specific template (e.g
|
84
|
+
'Displays any single entry, such as a post or a page. This template will serve as a fallback when a more specific template (e.g. Single Post, Page, or Attachment) cannot be found.',
|
85
85
|
} );
|
86
86
|
} );
|
87
87
|
} );
|
@@ -1,14 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"apiVersion": 2,
|
3
|
-
"name": "test/directive-show",
|
4
|
-
"title": "E2E Interactivity tests - directive show",
|
5
|
-
"category": "text",
|
6
|
-
"icon": "heart",
|
7
|
-
"description": "",
|
8
|
-
"supports": {
|
9
|
-
"interactivity": true
|
10
|
-
},
|
11
|
-
"textdomain": "e2e-interactivity",
|
12
|
-
"viewScript": "directive-show-view",
|
13
|
-
"render": "file:./render.php"
|
14
|
-
}
|
@@ -1,53 +0,0 @@
|
|
1
|
-
<?php
|
2
|
-
/**
|
3
|
-
* HTML for testing the directive `data-wp-show`.
|
4
|
-
*
|
5
|
-
* @package gutenberg-test-interactive-blocks
|
6
|
-
*/
|
7
|
-
|
8
|
-
?>
|
9
|
-
<div data-wp-interactive>
|
10
|
-
<button
|
11
|
-
data-wp-on--click="actions.toggleTrueValue"
|
12
|
-
data-testid="toggle trueValue"
|
13
|
-
>
|
14
|
-
Toggle trueValue
|
15
|
-
</button>
|
16
|
-
|
17
|
-
<button
|
18
|
-
data-wp-on--click="actions.toggleFalseValue"
|
19
|
-
data-testid="toggle falseValue"
|
20
|
-
>
|
21
|
-
Toggle falseValue
|
22
|
-
</button>
|
23
|
-
|
24
|
-
<div
|
25
|
-
data-wp-show="state.trueValue"
|
26
|
-
id="truthy-div"
|
27
|
-
data-testid="show if callback returns truthy value"
|
28
|
-
>
|
29
|
-
<p>trueValue children</p>
|
30
|
-
</div>
|
31
|
-
|
32
|
-
<div
|
33
|
-
data-wp-show="state.falseValue"
|
34
|
-
data-testid="do not show if callback returns false value"
|
35
|
-
>
|
36
|
-
<p>falseValue children</p>
|
37
|
-
</div>
|
38
|
-
|
39
|
-
<div data-wp-context='{ "falseValue": false }'>
|
40
|
-
<div
|
41
|
-
data-wp-show="context.falseValue"
|
42
|
-
data-testid="can use context values"
|
43
|
-
>
|
44
|
-
falseValue
|
45
|
-
</div>
|
46
|
-
<button
|
47
|
-
data-wp-on--click="actions.toggleContextFalseValue"
|
48
|
-
data-testid="toggle context false value"
|
49
|
-
>
|
50
|
-
Toggle context falseValue
|
51
|
-
</button>
|
52
|
-
</div>
|
53
|
-
</div>
|
@@ -1,24 +0,0 @@
|
|
1
|
-
( ( { wp } ) => {
|
2
|
-
/**
|
3
|
-
* WordPress dependencies
|
4
|
-
*/
|
5
|
-
const { store } = wp.interactivity;
|
6
|
-
|
7
|
-
store( {
|
8
|
-
state: {
|
9
|
-
trueValue: true,
|
10
|
-
falseValue: false,
|
11
|
-
},
|
12
|
-
actions: {
|
13
|
-
toggleTrueValue: ( { state } ) => {
|
14
|
-
state.trueValue = ! state.trueValue;
|
15
|
-
},
|
16
|
-
toggleFalseValue: ( { state } ) => {
|
17
|
-
state.falseValue = ! state.falseValue;
|
18
|
-
},
|
19
|
-
toggleContextFalseValue: ( { context } ) => {
|
20
|
-
context.falseValue = ! context.falseValue;
|
21
|
-
},
|
22
|
-
},
|
23
|
-
} );
|
24
|
-
} )( window );
|
@@ -1,59 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import {
|
5
|
-
activatePlugin,
|
6
|
-
clickOnMoreMenuItem,
|
7
|
-
createNewPost,
|
8
|
-
deactivatePlugin,
|
9
|
-
searchForBlock,
|
10
|
-
} from '@wordpress/e2e-test-utils';
|
11
|
-
|
12
|
-
describe( 'Allowed Blocks Filter', () => {
|
13
|
-
beforeAll( async () => {
|
14
|
-
await activatePlugin( 'gutenberg-test-allowed-blocks' );
|
15
|
-
} );
|
16
|
-
|
17
|
-
beforeEach( async () => {
|
18
|
-
await createNewPost();
|
19
|
-
} );
|
20
|
-
|
21
|
-
afterAll( async () => {
|
22
|
-
await deactivatePlugin( 'gutenberg-test-allowed-blocks' );
|
23
|
-
} );
|
24
|
-
|
25
|
-
it( 'should restrict the allowed blocks in the inserter', async () => {
|
26
|
-
// The paragraph block is available.
|
27
|
-
await searchForBlock( 'Paragraph' );
|
28
|
-
const paragraphBlockButton = (
|
29
|
-
await page.$x( `//button//span[contains(text(), 'Paragraph')]` )
|
30
|
-
)[ 0 ];
|
31
|
-
expect( paragraphBlockButton ).not.toBeNull();
|
32
|
-
|
33
|
-
// The gallery block is not available.
|
34
|
-
await searchForBlock( 'Gallery' );
|
35
|
-
|
36
|
-
const galleryBlockButton = (
|
37
|
-
await page.$x( `//button//span[contains(text(), 'Gallery')]` )
|
38
|
-
)[ 0 ];
|
39
|
-
expect( galleryBlockButton ).toBeUndefined();
|
40
|
-
} );
|
41
|
-
|
42
|
-
it( 'should remove not allowed blocks from the block manager', async () => {
|
43
|
-
await clickOnMoreMenuItem( 'Preferences' );
|
44
|
-
const [ blocksTab ] = await page.$x(
|
45
|
-
`//button[contains(text(), "Blocks")]`
|
46
|
-
);
|
47
|
-
await blocksTab.click();
|
48
|
-
|
49
|
-
const BLOCK_LABEL_SELECTOR =
|
50
|
-
'.edit-post-block-manager__checklist-item .components-checkbox-control__label';
|
51
|
-
await page.waitForSelector( BLOCK_LABEL_SELECTOR );
|
52
|
-
const blocks = await page.evaluate( ( selector ) => {
|
53
|
-
return Array.from( document.querySelectorAll( selector ) )
|
54
|
-
.map( ( element ) => ( element.innerText || '' ).trim() )
|
55
|
-
.sort();
|
56
|
-
}, BLOCK_LABEL_SELECTOR );
|
57
|
-
expect( blocks ).toEqual( [ 'Image', 'Paragraph' ] );
|
58
|
-
} );
|
59
|
-
} );
|
@@ -1,51 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import {
|
5
|
-
activatePlugin,
|
6
|
-
createNewPost,
|
7
|
-
deactivatePlugin,
|
8
|
-
canvas,
|
9
|
-
activateTheme,
|
10
|
-
} from '@wordpress/e2e-test-utils';
|
11
|
-
|
12
|
-
async function getComputedStyle( context, selector, property ) {
|
13
|
-
return await context.evaluate(
|
14
|
-
( sel, prop ) =>
|
15
|
-
window.getComputedStyle( document.querySelector( sel ) )[ prop ],
|
16
|
-
selector,
|
17
|
-
property
|
18
|
-
);
|
19
|
-
}
|
20
|
-
|
21
|
-
describe( 'iframed inline styles', () => {
|
22
|
-
beforeEach( async () => {
|
23
|
-
// Activate the empty theme (block based theme), which is iframed.
|
24
|
-
await activateTheme( 'emptytheme' );
|
25
|
-
await activatePlugin( 'gutenberg-test-iframed-enqueue_block_assets' );
|
26
|
-
await createNewPost();
|
27
|
-
} );
|
28
|
-
|
29
|
-
afterEach( async () => {
|
30
|
-
await deactivatePlugin( 'gutenberg-test-iframed-enqueue_block_assets' );
|
31
|
-
await activateTheme( 'twentytwentyone' );
|
32
|
-
} );
|
33
|
-
|
34
|
-
it( 'should load styles added through enqueue_block_assets', async () => {
|
35
|
-
await page.waitForSelector( 'iframe[name="editor-canvas"]' );
|
36
|
-
// Check stylesheet.
|
37
|
-
expect(
|
38
|
-
await getComputedStyle( canvas(), 'body', 'background-color' )
|
39
|
-
).toBe( 'rgb(33, 117, 155)' );
|
40
|
-
// Check inline style.
|
41
|
-
expect( await getComputedStyle( canvas(), 'body', 'padding' ) ).toBe(
|
42
|
-
'20px'
|
43
|
-
);
|
44
|
-
|
45
|
-
expect(
|
46
|
-
await canvas().evaluate( () => ( { ...document.body.dataset } ) )
|
47
|
-
).toEqual( {
|
48
|
-
iframedEnqueueBlockAssetsL10n: 'Iframed Enqueue Block Assets!',
|
49
|
-
} );
|
50
|
-
} );
|
51
|
-
} );
|