@wordpress/e2e-tests 7.8.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 +4 -0
- package/package.json +7 -7
- package/plugins/block-context.php +9 -13
- package/plugins/iframed-enqueue-block-assets/script.js +3 -0
- package/plugins/iframed-enqueue-block-assets.php +13 -0
- 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/{directive-show → directive-style}/block.json +3 -3
- package/plugins/interactive-blocks/directive-style/render.php +93 -0
- package/plugins/interactive-blocks/directive-style/view.js +22 -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/__snapshots__/container-blocks.test.js.snap +5 -4
- package/specs/editor/plugins/iframed-enqueue-block-editor-settings.test.js +108 -0
- package/specs/editor/various/publish-button.test.js +0 -15
- package/specs/editor/various/reusable-blocks.test.js +8 -11
- package/specs/site-editor/multi-entity-saving.test.js +0 -102
- package/specs/site-editor/settings-sidebar.test.js +1 -1
- 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 -44
- package/specs/editor/various/adding-inline-tokens.test.js +0 -80
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
|
}
|
@@ -8,10 +8,10 @@
|
|
8
8
|
*/
|
9
9
|
|
10
10
|
/**
|
11
|
-
*
|
11
|
+
* Registers plugin test context blocks.
|
12
12
|
*/
|
13
|
-
function
|
14
|
-
|
13
|
+
function gutenberg_test_register_context_blocks() {
|
14
|
+
wp_register_script(
|
15
15
|
'gutenberg-test-block-context',
|
16
16
|
plugins_url( 'block-context/index.js', __FILE__ ),
|
17
17
|
array(
|
@@ -22,37 +22,32 @@ function gutenberg_test_enqueue_block_context_script() {
|
|
22
22
|
filemtime( plugin_dir_path( __FILE__ ) . 'block-context/index.js' ),
|
23
23
|
true
|
24
24
|
);
|
25
|
-
}
|
26
|
-
add_action( 'init', 'gutenberg_test_enqueue_block_context_script' );
|
27
25
|
|
28
|
-
/**
|
29
|
-
* Registers plugin test context blocks.
|
30
|
-
*/
|
31
|
-
function gutenberg_test_register_context_blocks() {
|
32
26
|
register_block_type(
|
33
27
|
'gutenberg/test-context-provider',
|
34
28
|
array(
|
35
|
-
'attributes'
|
29
|
+
'attributes' => array(
|
36
30
|
'recordId' => array(
|
37
31
|
'type' => 'number',
|
38
32
|
'default' => 0,
|
39
33
|
),
|
40
34
|
),
|
41
|
-
'provides_context'
|
35
|
+
'provides_context' => array(
|
42
36
|
'gutenberg/recordId' => 'recordId',
|
43
37
|
),
|
38
|
+
'editor_script_handles' => array( 'gutenberg-test-block-context' ),
|
44
39
|
)
|
45
40
|
);
|
46
41
|
|
47
42
|
register_block_type(
|
48
43
|
'gutenberg/test-context-consumer',
|
49
44
|
array(
|
50
|
-
'uses_context'
|
45
|
+
'uses_context' => array(
|
51
46
|
'gutenberg/recordId',
|
52
47
|
'postId',
|
53
48
|
'postType',
|
54
49
|
),
|
55
|
-
'render_callback'
|
50
|
+
'render_callback' => static function( $attributes, $content, $block ) {
|
56
51
|
$ordered_context = array(
|
57
52
|
$block->context['gutenberg/recordId'],
|
58
53
|
$block->context['postId'],
|
@@ -61,6 +56,7 @@ function gutenberg_test_register_context_blocks() {
|
|
61
56
|
|
62
57
|
return implode( ',', $ordered_context );
|
63
58
|
},
|
59
|
+
'editor_script_handles' => array( 'gutenberg-test-block-context' ),
|
64
60
|
)
|
65
61
|
);
|
66
62
|
}
|
@@ -17,5 +17,18 @@ add_action(
|
|
17
17
|
filemtime( plugin_dir_path( __FILE__ ) . 'iframed-enqueue-block-assets/style.css' )
|
18
18
|
);
|
19
19
|
wp_add_inline_style( 'iframed-enqueue-block-assets', 'body{padding:20px!important}' );
|
20
|
+
wp_enqueue_script(
|
21
|
+
'iframed-enqueue-block-assets-script',
|
22
|
+
plugin_dir_url( __FILE__ ) . 'iframed-enqueue-block-assets/script.js',
|
23
|
+
array(),
|
24
|
+
filemtime( plugin_dir_path( __FILE__ ) . 'iframed-enqueue-block-assets/script.js' )
|
25
|
+
);
|
26
|
+
wp_localize_script(
|
27
|
+
'iframed-enqueue-block-assets-script',
|
28
|
+
'iframedEnqueueBlockAssetsL10n',
|
29
|
+
array(
|
30
|
+
'test' => 'Iframed Enqueue Block Assets!',
|
31
|
+
)
|
32
|
+
);
|
20
33
|
}
|
21
34
|
);
|
@@ -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
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"apiVersion": 2,
|
3
|
-
"name": "test/directive-
|
4
|
-
"title": "E2E Interactivity tests - directive
|
3
|
+
"name": "test/directive-style",
|
4
|
+
"title": "E2E Interactivity tests - directive style",
|
5
5
|
"category": "text",
|
6
6
|
"icon": "heart",
|
7
7
|
"description": "",
|
@@ -9,6 +9,6 @@
|
|
9
9
|
"interactivity": true
|
10
10
|
},
|
11
11
|
"textdomain": "e2e-interactivity",
|
12
|
-
"viewScript": "directive-
|
12
|
+
"viewScript": "directive-style-view",
|
13
13
|
"render": "file:./render.php"
|
14
14
|
}
|
@@ -0,0 +1,93 @@
|
|
1
|
+
<?php
|
2
|
+
/**
|
3
|
+
* HTML for testing the directive `data-wp-style`.
|
4
|
+
*
|
5
|
+
* @package gutenberg-test-interactive-blocks
|
6
|
+
*/
|
7
|
+
|
8
|
+
?>
|
9
|
+
|
10
|
+
<div data-wp-interactive>
|
11
|
+
<button
|
12
|
+
data-wp-on--click="actions.toggleColor"
|
13
|
+
data-testid="toggle color"
|
14
|
+
>
|
15
|
+
Toggle Color
|
16
|
+
</button>
|
17
|
+
|
18
|
+
<button
|
19
|
+
data-wp-on--click="actions.switchColorToFalse"
|
20
|
+
data-testid="switch color to false"
|
21
|
+
>
|
22
|
+
Switch Color to False
|
23
|
+
</button>
|
24
|
+
|
25
|
+
<div
|
26
|
+
style="color: red; background: green;"
|
27
|
+
data-wp-style--color="state.color"
|
28
|
+
data-testid="dont change style if callback returns same value on hydration"
|
29
|
+
>Don't change style if callback returns same value on hydration</div>
|
30
|
+
|
31
|
+
<div
|
32
|
+
style="color: blue; background: green;"
|
33
|
+
data-wp-style--color="state.falseValue"
|
34
|
+
data-testid="remove style if callback returns falsy value on hydration"
|
35
|
+
>Remove style if callback returns falsy value on hydration</div>
|
36
|
+
|
37
|
+
<div
|
38
|
+
style="color: blue; background: green;"
|
39
|
+
data-wp-style--color="state.color"
|
40
|
+
data-testid="change style if callback returns a new value on hydration"
|
41
|
+
>Change style if callback returns a new value on hydration</div>
|
42
|
+
|
43
|
+
<div
|
44
|
+
style="color: blue; background: green; border: 1px solid black"
|
45
|
+
data-wp-style--color="state.falseValue"
|
46
|
+
data-wp-style--background="state.color"
|
47
|
+
data-wp-style--border="state.border"
|
48
|
+
data-testid="handles multiple styles and callbacks on hydration"
|
49
|
+
>Handles multiple styles and callbacks on hydration</div>
|
50
|
+
|
51
|
+
<div
|
52
|
+
data-wp-style--color="state.color"
|
53
|
+
data-testid="can add style when style attribute is missing on hydration"
|
54
|
+
>Can add style when style attribute is missing on hydration</div>
|
55
|
+
|
56
|
+
<div
|
57
|
+
style="color: red;"
|
58
|
+
data-wp-style--color="state.color"
|
59
|
+
data-testid="can toggle style"
|
60
|
+
>Can toggle style</div>
|
61
|
+
|
62
|
+
<div
|
63
|
+
style="color: red;"
|
64
|
+
data-wp-style--color="state.color"
|
65
|
+
data-testid="can remove style"
|
66
|
+
>Can remove style</div>
|
67
|
+
|
68
|
+
<div
|
69
|
+
style="color: blue; background: green; border: 1px solid black;"
|
70
|
+
data-wp-style--background="state.color"
|
71
|
+
data-testid="can toggle style in the middle"
|
72
|
+
>Can toggle style in the middle</div>
|
73
|
+
|
74
|
+
<div
|
75
|
+
style="background-color: green;"
|
76
|
+
data-wp-style--background-color="state.color"
|
77
|
+
data-testid="handles styles names with hyphens"
|
78
|
+
>Handles styles names with hyphens</div>
|
79
|
+
|
80
|
+
<div data-wp-context='{ "color": "blue" }'>
|
81
|
+
<div
|
82
|
+
style="color: blue;"
|
83
|
+
data-wp-style--color="context.color"
|
84
|
+
data-testid="can use context values"
|
85
|
+
></div>
|
86
|
+
<button
|
87
|
+
data-wp-on--click="actions.toggleContext"
|
88
|
+
data-testid="toggle context"
|
89
|
+
>
|
90
|
+
Toggle context
|
91
|
+
</button>
|
92
|
+
</div>
|
93
|
+
</div>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
( ( { wp } ) => {
|
2
|
+
const { store } = wp.interactivity;
|
3
|
+
|
4
|
+
store( {
|
5
|
+
state: {
|
6
|
+
falseValue: false,
|
7
|
+
color: "red",
|
8
|
+
border: "2px solid yellow"
|
9
|
+
},
|
10
|
+
actions: {
|
11
|
+
toggleColor: ( { state } ) => {
|
12
|
+
state.color = state.color === "red" ? "blue" : "red";
|
13
|
+
},
|
14
|
+
switchColorToFalse: ({ state }) => {
|
15
|
+
state.color = false;
|
16
|
+
},
|
17
|
+
toggleContext: ( { context } ) => {
|
18
|
+
context.color = context.color === "red" ? "blue" : "red";
|
19
|
+
},
|
20
|
+
},
|
21
|
+
} );
|
22
|
+
} )( window );
|
@@ -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: {
|
@@ -22,10 +22,11 @@ exports[`InnerBlocks Template Sync Ensures blocks without locking are kept intac
|
|
22
22
|
<p class="has-large-font-size">Content…</p>
|
23
23
|
<!-- /wp:paragraph -->
|
24
24
|
|
25
|
-
<!-- wp:paragraph -->
|
26
|
-
<p>added paragraph</p>
|
27
|
-
<!-- /wp:paragraph -->
|
28
|
-
<!-- /wp:test/test-inner-blocks-no-locking -->
|
25
|
+
<!-- wp:paragraph -->
|
26
|
+
<p>added paragraph</p>
|
27
|
+
<!-- /wp:paragraph -->
|
28
|
+
<!-- /wp:test/test-inner-blocks-no-locking -->
|
29
|
+
"
|
29
30
|
`;
|
30
31
|
|
31
32
|
exports[`InnerBlocks Template Sync Removes blocks that are not expected by the template if a lock all exists 1`] = `
|
@@ -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
|
+
} );
|
@@ -43,19 +43,4 @@ describe( 'PostPublishButton', () => {
|
|
43
43
|
await page.$( '.editor-post-publish-button[aria-disabled="true"]' )
|
44
44
|
).not.toBeNull();
|
45
45
|
} );
|
46
|
-
|
47
|
-
it( 'should be disabled when metabox is being saved', async () => {
|
48
|
-
await canvas().type( '.editor-post-title__input', 'E2E Test Post' ); // Make it saveable.
|
49
|
-
expect(
|
50
|
-
await page.$( '.editor-post-publish-button[aria-disabled="true"]' )
|
51
|
-
).toBeNull();
|
52
|
-
|
53
|
-
await page.evaluate( () => {
|
54
|
-
window.wp.data.dispatch( 'core/edit-post' ).requestMetaBoxUpdates();
|
55
|
-
return true;
|
56
|
-
} );
|
57
|
-
expect(
|
58
|
-
await page.$( '.editor-post-publish-button[aria-disabled="true"]' )
|
59
|
-
).not.toBeNull();
|
60
|
-
} );
|
61
46
|
} );
|
@@ -23,8 +23,6 @@ const reusableBlockNameInputSelector =
|
|
23
23
|
'.reusable-blocks-menu-items__convert-modal .components-text-control__input';
|
24
24
|
const reusableBlockInspectorNameInputSelector =
|
25
25
|
'.block-editor-block-inspector .components-text-control__input';
|
26
|
-
const syncToggleSelector =
|
27
|
-
'.reusable-blocks-menu-items__convert-modal .components-form-toggle__input';
|
28
26
|
const syncToggleSelectorChecked =
|
29
27
|
'.reusable-blocks-menu-items__convert-modal .components-form-toggle.is-checked';
|
30
28
|
|
@@ -113,7 +111,8 @@ describe( 'Reusable blocks', () => {
|
|
113
111
|
await insertReusableBlock( 'Surprised greeting block' );
|
114
112
|
|
115
113
|
// Convert block to a regular block.
|
116
|
-
await clickBlockToolbarButton( '
|
114
|
+
await clickBlockToolbarButton( 'Options' );
|
115
|
+
await clickMenuItem( 'Detach pattern' );
|
117
116
|
|
118
117
|
// Check that we have a paragraph block on the page.
|
119
118
|
const paragraphBlock = await canvas().$(
|
@@ -205,14 +204,12 @@ describe( 'Reusable blocks', () => {
|
|
205
204
|
);
|
206
205
|
await nameInput.click();
|
207
206
|
await page.keyboard.type( 'Multi-selection reusable block' );
|
208
|
-
const syncToggle = await page.waitForSelector( syncToggleSelector );
|
209
|
-
syncToggle.click();
|
210
207
|
await page.waitForSelector( syncToggleSelectorChecked );
|
211
208
|
await page.keyboard.press( 'Enter' );
|
212
209
|
|
213
210
|
// Wait for creation to finish.
|
214
211
|
await page.waitForXPath(
|
215
|
-
'//*[contains(@class, "components-snackbar")]/*[text()
|
212
|
+
'//*[contains(@class, "components-snackbar")]/*[contains(text(),"Pattern created:")]'
|
216
213
|
);
|
217
214
|
|
218
215
|
await clearAllBlocks();
|
@@ -221,7 +218,8 @@ describe( 'Reusable blocks', () => {
|
|
221
218
|
await insertReusableBlock( 'Multi-selection reusable block' );
|
222
219
|
|
223
220
|
// Convert block to a regular block.
|
224
|
-
await clickBlockToolbarButton( '
|
221
|
+
await clickBlockToolbarButton( 'Options' );
|
222
|
+
await clickMenuItem( 'Detach patterns' );
|
225
223
|
|
226
224
|
// Check that we have two paragraph blocks on the page.
|
227
225
|
expect( await getEditedPostContent() ).toMatchSnapshot();
|
@@ -352,8 +350,9 @@ describe( 'Reusable blocks', () => {
|
|
352
350
|
expect( reusableBlockWithParagraph ).toBeTruthy();
|
353
351
|
|
354
352
|
// Convert back to regular blocks.
|
355
|
-
await clickBlockToolbarButton( 'Select
|
356
|
-
await clickBlockToolbarButton( '
|
353
|
+
await clickBlockToolbarButton( 'Select Edited block' );
|
354
|
+
await clickBlockToolbarButton( 'Options' );
|
355
|
+
await clickMenuItem( 'Detach pattern' );
|
357
356
|
await page.waitForXPath( selector, {
|
358
357
|
hidden: true,
|
359
358
|
} );
|
@@ -389,8 +388,6 @@ describe( 'Reusable blocks', () => {
|
|
389
388
|
);
|
390
389
|
await nameInput.click();
|
391
390
|
await page.keyboard.type( 'Block with styles' );
|
392
|
-
const syncToggle = await page.waitForSelector( syncToggleSelector );
|
393
|
-
syncToggle.click();
|
394
391
|
await page.waitForSelector( syncToggleSelectorChecked );
|
395
392
|
await page.keyboard.press( 'Enter' );
|
396
393
|
const reusableBlock = await canvas().waitForSelector(
|
@@ -12,8 +12,6 @@ import {
|
|
12
12
|
activateTheme,
|
13
13
|
clickButton,
|
14
14
|
createReusableBlock,
|
15
|
-
visitSiteEditor,
|
16
|
-
enterEditMode,
|
17
15
|
deleteAllTemplates,
|
18
16
|
canvas,
|
19
17
|
} from '@wordpress/e2e-test-utils';
|
@@ -239,104 +237,4 @@ describe( 'Multi-entity save flow', () => {
|
|
239
237
|
expect( checkboxInputs ).toHaveLength( 1 );
|
240
238
|
} );
|
241
239
|
} );
|
242
|
-
|
243
|
-
describe( 'Site Editor', () => {
|
244
|
-
// Selectors - Site editor specific.
|
245
|
-
const saveSiteSelector = '.edit-site-save-button__button';
|
246
|
-
const activeSaveSiteSelector = `${ saveSiteSelector }[aria-disabled=false]`;
|
247
|
-
const disabledSaveSiteSelector = `${ saveSiteSelector }[aria-disabled=true]`;
|
248
|
-
const saveA11ySelector = '.edit-site-editor__toggle-save-panel-button';
|
249
|
-
|
250
|
-
const saveAllChanges = async () => {
|
251
|
-
// Clicking button should open panel with boxes checked.
|
252
|
-
await page.click( activeSaveSiteSelector );
|
253
|
-
await page.waitForSelector( savePanelSelector );
|
254
|
-
await assertAllBoxesChecked();
|
255
|
-
|
256
|
-
// Save a11y button should not be present with save panel open.
|
257
|
-
await assertExistence( saveA11ySelector, false );
|
258
|
-
|
259
|
-
// Saving should result in items being saved.
|
260
|
-
await page.click( entitiesSaveSelector );
|
261
|
-
};
|
262
|
-
|
263
|
-
it( 'Save flow should work as expected', async () => {
|
264
|
-
// Navigate to site editor.
|
265
|
-
await visitSiteEditor( {
|
266
|
-
postId: 'emptytheme//index',
|
267
|
-
postType: 'wp_template',
|
268
|
-
} );
|
269
|
-
|
270
|
-
await enterEditMode();
|
271
|
-
|
272
|
-
// Select the header template part via list view.
|
273
|
-
await page.click( '.edit-site-header-edit-mode__list-view-toggle' );
|
274
|
-
const headerTemplatePartListViewButton = await page.waitForXPath(
|
275
|
-
'//a[contains(@class, "block-editor-list-view-block-select-button")][contains(., "header")]'
|
276
|
-
);
|
277
|
-
headerTemplatePartListViewButton.click();
|
278
|
-
await page.click( 'button[aria-label="Close"]' );
|
279
|
-
|
280
|
-
// Insert something to dirty the editor.
|
281
|
-
await insertBlock( 'Paragraph' );
|
282
|
-
|
283
|
-
const enabledButton = await page.waitForSelector(
|
284
|
-
activeSaveSiteSelector
|
285
|
-
);
|
286
|
-
|
287
|
-
// Should be enabled after edits.
|
288
|
-
expect( enabledButton ).not.toBeNull();
|
289
|
-
|
290
|
-
// Save a11y button should be present.
|
291
|
-
await assertExistence( saveA11ySelector, true );
|
292
|
-
|
293
|
-
// Save all changes.
|
294
|
-
await saveAllChanges();
|
295
|
-
|
296
|
-
const disabledButton = await page.waitForSelector(
|
297
|
-
disabledSaveSiteSelector
|
298
|
-
);
|
299
|
-
expect( disabledButton ).not.toBeNull();
|
300
|
-
} );
|
301
|
-
|
302
|
-
it( 'Save flow should allow re-saving after changing the same block attribute', async () => {
|
303
|
-
// Navigate to site editor.
|
304
|
-
await visitSiteEditor( {
|
305
|
-
postId: 'emptytheme//index',
|
306
|
-
postType: 'wp_template',
|
307
|
-
} );
|
308
|
-
|
309
|
-
await enterEditMode();
|
310
|
-
|
311
|
-
// Insert a paragraph at the bottom.
|
312
|
-
await insertBlock( 'Paragraph' );
|
313
|
-
|
314
|
-
// Open the block settings.
|
315
|
-
await page.click( 'button[aria-label="Settings"]' );
|
316
|
-
|
317
|
-
// Wait for the font size picker controls.
|
318
|
-
await page.waitForSelector(
|
319
|
-
'.components-font-size-picker__controls'
|
320
|
-
);
|
321
|
-
|
322
|
-
// Change the font size.
|
323
|
-
await page.click(
|
324
|
-
'.components-font-size-picker__controls button[aria-label="Small"]'
|
325
|
-
);
|
326
|
-
|
327
|
-
// Save all changes.
|
328
|
-
await saveAllChanges();
|
329
|
-
|
330
|
-
// Change the font size.
|
331
|
-
await page.click(
|
332
|
-
'.components-font-size-picker__controls button[aria-label="Medium"]'
|
333
|
-
);
|
334
|
-
|
335
|
-
// Assert that the save button has been re-enabled.
|
336
|
-
const saveButton = await page.waitForSelector(
|
337
|
-
activeSaveSiteSelector
|
338
|
-
);
|
339
|
-
expect( saveButton ).not.toBeNull();
|
340
|
-
} );
|
341
|
-
} );
|
342
240
|
} );
|
@@ -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,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,44 +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
|
-
// Check stylesheet.
|
36
|
-
expect(
|
37
|
-
await getComputedStyle( canvas(), 'body', 'background-color' )
|
38
|
-
).toBe( 'rgb(33, 117, 155)' );
|
39
|
-
// Check inline style.
|
40
|
-
expect( await getComputedStyle( canvas(), 'body', 'padding' ) ).toBe(
|
41
|
-
'20px'
|
42
|
-
);
|
43
|
-
} );
|
44
|
-
} );
|
@@ -1,80 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* External dependencies
|
3
|
-
*/
|
4
|
-
import path from 'path';
|
5
|
-
import fs from 'fs';
|
6
|
-
import os from 'os';
|
7
|
-
import { v4 as uuid } from 'uuid';
|
8
|
-
|
9
|
-
/**
|
10
|
-
* WordPress dependencies
|
11
|
-
*/
|
12
|
-
import {
|
13
|
-
clickBlockAppender,
|
14
|
-
getEditedPostContent,
|
15
|
-
createNewPost,
|
16
|
-
clickBlockToolbarButton,
|
17
|
-
clickButton,
|
18
|
-
pressKeyWithModifier,
|
19
|
-
} from '@wordpress/e2e-test-utils';
|
20
|
-
|
21
|
-
describe( 'adding inline tokens', () => {
|
22
|
-
beforeEach( async () => {
|
23
|
-
await createNewPost();
|
24
|
-
} );
|
25
|
-
|
26
|
-
it( 'should insert inline image', async () => {
|
27
|
-
// Create a paragraph.
|
28
|
-
await clickBlockAppender();
|
29
|
-
await page.keyboard.type( 'a ' );
|
30
|
-
|
31
|
-
await clickBlockToolbarButton( 'More' );
|
32
|
-
await clickButton( 'Inline image' );
|
33
|
-
|
34
|
-
// Wait for media modal to appear and upload image.
|
35
|
-
// Wait for media modal to appear and upload image.
|
36
|
-
const inputElement = await page.waitForSelector(
|
37
|
-
'.media-modal .moxie-shim input[type=file]'
|
38
|
-
);
|
39
|
-
const testImagePath = path.join(
|
40
|
-
__dirname,
|
41
|
-
'..',
|
42
|
-
'..',
|
43
|
-
'..',
|
44
|
-
'assets',
|
45
|
-
'10x10_e2e_test_image_z9T8jK.png'
|
46
|
-
);
|
47
|
-
const filename = uuid();
|
48
|
-
const tmpFileName = path.join( os.tmpdir(), filename + '.png' );
|
49
|
-
fs.copyFileSync( testImagePath, tmpFileName );
|
50
|
-
await inputElement.uploadFile( tmpFileName );
|
51
|
-
|
52
|
-
// Wait for upload.
|
53
|
-
await page.waitForSelector(
|
54
|
-
`.media-modal li[aria-label="${ filename }"]`
|
55
|
-
);
|
56
|
-
|
57
|
-
// Insert the uploaded image.
|
58
|
-
await page.click( '.media-modal button.media-button-select' );
|
59
|
-
|
60
|
-
// Check the content.
|
61
|
-
const regex = new RegExp(
|
62
|
-
`<!-- wp:paragraph -->\\s*<p>a <img class="wp-image-\\d+" style="width:\\s*10px;?" src="[^"]+\\/${ filename }\\.png" alt=""\\/?><\\/p>\\s*<!-- \\/wp:paragraph -->`
|
63
|
-
);
|
64
|
-
expect( await getEditedPostContent() ).toMatch( regex );
|
65
|
-
|
66
|
-
await pressKeyWithModifier( 'shift', 'ArrowLeft' );
|
67
|
-
await page.waitForSelector(
|
68
|
-
'.block-editor-format-toolbar__image-popover'
|
69
|
-
);
|
70
|
-
await page.keyboard.press( 'Tab' );
|
71
|
-
await page.keyboard.type( '20' );
|
72
|
-
await page.keyboard.press( 'Enter' );
|
73
|
-
|
74
|
-
// Check the content.
|
75
|
-
const regex2 = new RegExp(
|
76
|
-
`<!-- wp:paragraph -->\\s*<p>a <img class="wp-image-\\d+" style="width:\\s*20px;?" src="[^"]+\\/${ filename }\\.png" alt=""\\/?><\\/p>\\s*<!-- \\/wp:paragraph -->`
|
77
|
-
);
|
78
|
-
expect( await getEditedPostContent() ).toMatch( regex2 );
|
79
|
-
} );
|
80
|
-
} );
|