@wordpress/e2e-tests 8.14.0 → 8.15.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/LICENSE.md +1 -1
- package/package.json +9 -9
- package/plugins/block-bindings/index.js +45 -0
- package/plugins/block-bindings.php +5 -1
- package/plugins/interactive-blocks/directive-each/render.php +51 -0
- package/plugins/interactive-blocks/directive-each/view.js +22 -0
- package/plugins/interactive-blocks/router-styles-blue/assets/10x10_e2e_test_image_blue.png +0 -0
- package/plugins/interactive-blocks/router-styles-blue/block.json +15 -0
- package/plugins/interactive-blocks/router-styles-blue/render.php +35 -0
- package/plugins/interactive-blocks/router-styles-blue/style-from-link.css +7 -0
- package/plugins/interactive-blocks/router-styles-blue/style.css +4 -0
- package/plugins/interactive-blocks/router-styles-green/assets/10x10_e2e_test_image_green.png +0 -0
- package/plugins/interactive-blocks/router-styles-green/block.json +15 -0
- package/plugins/interactive-blocks/router-styles-green/render.php +35 -0
- package/plugins/interactive-blocks/router-styles-green/style-from-link.css +7 -0
- package/plugins/interactive-blocks/router-styles-green/style.css +4 -0
- package/plugins/interactive-blocks/router-styles-red/assets/10x10_e2e_test_image_red.png +0 -0
- package/plugins/interactive-blocks/router-styles-red/block.json +15 -0
- package/plugins/interactive-blocks/router-styles-red/render.php +35 -0
- package/plugins/interactive-blocks/router-styles-red/style-from-link.css +7 -0
- package/plugins/interactive-blocks/router-styles-red/style.css +4 -0
- package/plugins/interactive-blocks/router-styles-wrapper/block.json +16 -0
- package/plugins/interactive-blocks/router-styles-wrapper/render.php +70 -0
- package/plugins/interactive-blocks/router-styles-wrapper/style.css +3 -0
- package/plugins/interactive-blocks/router-styles-wrapper/view.asset.php +9 -0
- package/plugins/interactive-blocks/router-styles-wrapper/view.js +20 -0
package/CHANGELOG.md
CHANGED
package/LICENSE.md
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@wordpress/e2e-tests",
|
3
|
-
"version": "8.
|
3
|
+
"version": "8.15.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",
|
@@ -24,13 +24,13 @@
|
|
24
24
|
"npm": ">=8.19.2"
|
25
25
|
},
|
26
26
|
"dependencies": {
|
27
|
-
"@wordpress/e2e-test-utils": "
|
28
|
-
"@wordpress/interactivity": "
|
29
|
-
"@wordpress/interactivity-router": "
|
30
|
-
"@wordpress/jest-console": "
|
31
|
-
"@wordpress/jest-puppeteer-axe": "
|
32
|
-
"@wordpress/scripts": "
|
33
|
-
"@wordpress/url": "
|
27
|
+
"@wordpress/e2e-test-utils": "^11.15.0",
|
28
|
+
"@wordpress/interactivity": "^6.15.0",
|
29
|
+
"@wordpress/interactivity-router": "^2.15.0",
|
30
|
+
"@wordpress/jest-console": "^8.15.0",
|
31
|
+
"@wordpress/jest-puppeteer-axe": "^7.15.0",
|
32
|
+
"@wordpress/scripts": "^30.8.0",
|
33
|
+
"@wordpress/url": "^4.15.0",
|
34
34
|
"chalk": "^4.0.0",
|
35
35
|
"expect-puppeteer": "^4.4.0",
|
36
36
|
"filenamify": "^4.2.0",
|
@@ -47,5 +47,5 @@
|
|
47
47
|
"publishConfig": {
|
48
48
|
"access": "public"
|
49
49
|
},
|
50
|
-
"gitHead": "
|
50
|
+
"gitHead": "75a65eb8ffc168a92042544052f46d080a71ea45"
|
51
51
|
}
|
@@ -1,4 +1,9 @@
|
|
1
1
|
const { registerBlockBindingsSource } = wp.blocks;
|
2
|
+
const { InspectorControls } = wp.blockEditor;
|
3
|
+
const { PanelBody, TextControl } = wp.components;
|
4
|
+
const { createHigherOrderComponent } = wp.compose;
|
5
|
+
const { createElement: el, Fragment } = wp.element;
|
6
|
+
const { addFilter } = wp.hooks;
|
2
7
|
const { fieldsList } = window.testingBindings || {};
|
3
8
|
|
4
9
|
const getValues = ( { bindings } ) => {
|
@@ -46,3 +51,43 @@ registerBlockBindingsSource( {
|
|
46
51
|
getValues,
|
47
52
|
canUserEditValue: () => true,
|
48
53
|
} );
|
54
|
+
|
55
|
+
const withBlockBindingsInspectorControl = createHigherOrderComponent(
|
56
|
+
( BlockEdit ) => {
|
57
|
+
return ( props ) => {
|
58
|
+
if ( ! props.attributes?.metadata?.bindings?.content ) {
|
59
|
+
return el( BlockEdit, props );
|
60
|
+
}
|
61
|
+
|
62
|
+
return el(
|
63
|
+
Fragment,
|
64
|
+
{},
|
65
|
+
el( BlockEdit, props ),
|
66
|
+
el(
|
67
|
+
InspectorControls,
|
68
|
+
{},
|
69
|
+
el(
|
70
|
+
PanelBody,
|
71
|
+
{ title: 'Bindings' },
|
72
|
+
el( TextControl, {
|
73
|
+
__next40pxDefaultSize: true,
|
74
|
+
__nextHasNoMarginBottom: true,
|
75
|
+
label: 'Content',
|
76
|
+
value: props.attributes.content,
|
77
|
+
onChange: ( content ) =>
|
78
|
+
props.setAttributes( {
|
79
|
+
content,
|
80
|
+
} ),
|
81
|
+
} )
|
82
|
+
)
|
83
|
+
)
|
84
|
+
);
|
85
|
+
};
|
86
|
+
}
|
87
|
+
);
|
88
|
+
|
89
|
+
addFilter(
|
90
|
+
'editor.BlockEdit',
|
91
|
+
'testing/bindings-inspector-control',
|
92
|
+
withBlockBindingsInspectorControl
|
93
|
+
);
|
@@ -41,7 +41,11 @@ function gutenberg_test_block_bindings_registration() {
|
|
41
41
|
plugins_url( 'block-bindings/index.js', __FILE__ ),
|
42
42
|
array(
|
43
43
|
'wp-blocks',
|
44
|
-
'wp-
|
44
|
+
'wp-block-editor',
|
45
|
+
'wp-components',
|
46
|
+
'wp-compose',
|
47
|
+
'wp-element',
|
48
|
+
'wp-hooks',
|
45
49
|
),
|
46
50
|
filemtime( plugin_dir_path( __FILE__ ) . 'block-bindings/index.js' ),
|
47
51
|
true
|
@@ -260,3 +260,54 @@
|
|
260
260
|
data-wp-text="context.callbackRunCount"
|
261
261
|
></data>
|
262
262
|
</div>
|
263
|
+
|
264
|
+
<hr>
|
265
|
+
|
266
|
+
<div
|
267
|
+
data-wp-interactive="directive-each"
|
268
|
+
data-testid="each-with-unset"
|
269
|
+
>
|
270
|
+
<template data-wp-each="state.eachUnset"><p data-wp-text="context.item"></p></template>
|
271
|
+
</div>
|
272
|
+
<div
|
273
|
+
data-wp-interactive="directive-each"
|
274
|
+
data-testid="each-with-null"
|
275
|
+
>
|
276
|
+
<template data-wp-each="state.eachNull"><p data-wp-text="context.item"></p></template>
|
277
|
+
</div>
|
278
|
+
<div
|
279
|
+
data-wp-interactive="directive-each"
|
280
|
+
data-testid="each-with-undefined"
|
281
|
+
>
|
282
|
+
<template data-wp-each="state.eachUndefined"><p data-wp-text="context.item"></p></template>
|
283
|
+
</div>
|
284
|
+
<div
|
285
|
+
data-wp-interactive="directive-each"
|
286
|
+
data-testid="each-with-array"
|
287
|
+
>
|
288
|
+
<template data-wp-each="state.eachArray"><p data-wp-text="context.item"></p></template>
|
289
|
+
</div>
|
290
|
+
<div
|
291
|
+
data-wp-interactive="directive-each"
|
292
|
+
data-testid="each-with-set"
|
293
|
+
>
|
294
|
+
<template data-wp-each="state.eachSet"><p data-wp-text="context.item"></p></template>
|
295
|
+
</div>
|
296
|
+
<div
|
297
|
+
data-wp-interactive="directive-each"
|
298
|
+
data-testid="each-with-string"
|
299
|
+
>
|
300
|
+
<template data-wp-each="state.eachString"><p data-wp-text="context.item"></p></template>
|
301
|
+
</div>
|
302
|
+
<div
|
303
|
+
data-wp-interactive="directive-each"
|
304
|
+
data-testid="each-with-generator"
|
305
|
+
>
|
306
|
+
<template data-wp-each="state.eachGenerator"><p data-wp-text="context.item"></p></template>
|
307
|
+
</div>
|
308
|
+
<div
|
309
|
+
data-wp-interactive="directive-each"
|
310
|
+
data-testid="each-with-iterator"
|
311
|
+
>
|
312
|
+
<template data-wp-each="state.eachIterator"><p data-wp-text="context.item"></p></template>
|
313
|
+
</div>
|
@@ -13,6 +13,28 @@ const { state } = store( 'directive-each' );
|
|
13
13
|
store( 'directive-each', {
|
14
14
|
state: {
|
15
15
|
letters: [ 'A', 'B', 'C' ],
|
16
|
+
eachUndefined: undefined,
|
17
|
+
eachNull: null,
|
18
|
+
eachArray: [ 'an', 'array' ],
|
19
|
+
eachSet: new Set( [ 'a', 'set' ] ),
|
20
|
+
eachString: 'str',
|
21
|
+
*eachGenerator() {
|
22
|
+
yield 'a';
|
23
|
+
yield 'generator';
|
24
|
+
},
|
25
|
+
eachIterator: {
|
26
|
+
[ Symbol.iterator ]() {
|
27
|
+
const vals = [ 'implements', 'iterator' ];
|
28
|
+
let i = 0;
|
29
|
+
return {
|
30
|
+
next() {
|
31
|
+
return i < vals.length
|
32
|
+
? { value: vals[ i++ ], done: false }
|
33
|
+
: { done: true };
|
34
|
+
},
|
35
|
+
};
|
36
|
+
},
|
37
|
+
},
|
16
38
|
},
|
17
39
|
} );
|
18
40
|
|
Binary file
|
@@ -0,0 +1,15 @@
|
|
1
|
+
{
|
2
|
+
"$schema": "https://schemas.wp.org/trunk/block.json",
|
3
|
+
"apiVersion": 2,
|
4
|
+
"name": "test/router-styles-blue",
|
5
|
+
"title": "E2E Interactivity tests - router styles - Blue",
|
6
|
+
"category": "text",
|
7
|
+
"icon": "heart",
|
8
|
+
"description": "",
|
9
|
+
"supports": {
|
10
|
+
"interactivity": true
|
11
|
+
},
|
12
|
+
"textdomain": "e2e-interactivity",
|
13
|
+
"viewStyle": "file:./style.css",
|
14
|
+
"render": "file:./render.php"
|
15
|
+
}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
<?php
|
2
|
+
/**
|
3
|
+
* HTML for testing the iAPI's style assets management.
|
4
|
+
*
|
5
|
+
* @package gutenberg-test-interactive-blocks
|
6
|
+
*
|
7
|
+
* @phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable
|
8
|
+
*/
|
9
|
+
|
10
|
+
add_action(
|
11
|
+
'wp_enqueue_scripts',
|
12
|
+
function () {
|
13
|
+
wp_enqueue_style(
|
14
|
+
'blue-from-link',
|
15
|
+
plugin_dir_url( __FILE__ ) . 'style-from-link.css',
|
16
|
+
array()
|
17
|
+
);
|
18
|
+
|
19
|
+
$custom_css = '
|
20
|
+
.blue-from-inline {
|
21
|
+
color: rgb(0, 0, 255);
|
22
|
+
}
|
23
|
+
';
|
24
|
+
|
25
|
+
wp_register_style( 'test-router-styles', false );
|
26
|
+
wp_enqueue_style( 'test-router-styles' );
|
27
|
+
wp_add_inline_style( 'test-router-styles', $custom_css );
|
28
|
+
}
|
29
|
+
);
|
30
|
+
|
31
|
+
$wrapper_attributes = get_block_wrapper_attributes(
|
32
|
+
array( 'data-testid' => 'blue-block' )
|
33
|
+
);
|
34
|
+
?>
|
35
|
+
<p <?php echo $wrapper_attributes; ?>>Blue</p>
|
Binary file
|
@@ -0,0 +1,15 @@
|
|
1
|
+
{
|
2
|
+
"$schema": "https://schemas.wp.org/trunk/block.json",
|
3
|
+
"apiVersion": 2,
|
4
|
+
"name": "test/router-styles-green",
|
5
|
+
"title": "E2E Interactivity tests - router styles - Green",
|
6
|
+
"category": "text",
|
7
|
+
"icon": "heart",
|
8
|
+
"description": "",
|
9
|
+
"supports": {
|
10
|
+
"interactivity": true
|
11
|
+
},
|
12
|
+
"textdomain": "e2e-interactivity",
|
13
|
+
"viewStyle": "file:./style.css",
|
14
|
+
"render": "file:./render.php"
|
15
|
+
}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
<?php
|
2
|
+
/**
|
3
|
+
* HTML for testing the iAPI's style assets management.
|
4
|
+
*
|
5
|
+
* @package gutenberg-test-interactive-blocks
|
6
|
+
*
|
7
|
+
* @phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable
|
8
|
+
*/
|
9
|
+
|
10
|
+
add_action(
|
11
|
+
'wp_enqueue_scripts',
|
12
|
+
function () {
|
13
|
+
wp_enqueue_style(
|
14
|
+
'green-from-link',
|
15
|
+
plugin_dir_url( __FILE__ ) . 'style-from-link.css',
|
16
|
+
array()
|
17
|
+
);
|
18
|
+
|
19
|
+
$custom_css = '
|
20
|
+
.green-from-inline {
|
21
|
+
color: rgb(0, 255, 0);
|
22
|
+
}
|
23
|
+
';
|
24
|
+
|
25
|
+
wp_register_style( 'test-router-styles', false );
|
26
|
+
wp_enqueue_style( 'test-router-styles' );
|
27
|
+
wp_add_inline_style( 'test-router-styles', $custom_css );
|
28
|
+
}
|
29
|
+
);
|
30
|
+
|
31
|
+
$wrapper_attributes = get_block_wrapper_attributes(
|
32
|
+
array( 'data-testid' => 'green-block' )
|
33
|
+
);
|
34
|
+
?>
|
35
|
+
<p <?php echo $wrapper_attributes; ?>>Green</p>
|
Binary file
|
@@ -0,0 +1,15 @@
|
|
1
|
+
{
|
2
|
+
"$schema": "https://schemas.wp.org/trunk/block.json",
|
3
|
+
"apiVersion": 2,
|
4
|
+
"name": "test/router-styles-red",
|
5
|
+
"title": "E2E Interactivity tests - router styles - Red",
|
6
|
+
"category": "text",
|
7
|
+
"icon": "heart",
|
8
|
+
"description": "",
|
9
|
+
"supports": {
|
10
|
+
"interactivity": true
|
11
|
+
},
|
12
|
+
"textdomain": "e2e-interactivity",
|
13
|
+
"viewStyle": "file:./style.css",
|
14
|
+
"render": "file:./render.php"
|
15
|
+
}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
<?php
|
2
|
+
/**
|
3
|
+
* HTML for testing the iAPI's style assets management.
|
4
|
+
*
|
5
|
+
* @package gutenberg-test-interactive-blocks
|
6
|
+
*
|
7
|
+
* @phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable
|
8
|
+
*/
|
9
|
+
|
10
|
+
add_action(
|
11
|
+
'wp_enqueue_scripts',
|
12
|
+
function () {
|
13
|
+
wp_enqueue_style(
|
14
|
+
'red-from-link',
|
15
|
+
plugin_dir_url( __FILE__ ) . 'style-from-link.css',
|
16
|
+
array()
|
17
|
+
);
|
18
|
+
|
19
|
+
$custom_css = '
|
20
|
+
.red-from-inline {
|
21
|
+
color: rgb(255, 0, 0);
|
22
|
+
}
|
23
|
+
';
|
24
|
+
|
25
|
+
wp_register_style( 'test-router-styles', false );
|
26
|
+
wp_enqueue_style( 'test-router-styles' );
|
27
|
+
wp_add_inline_style( 'test-router-styles', $custom_css );
|
28
|
+
}
|
29
|
+
);
|
30
|
+
|
31
|
+
$wrapper_attributes = get_block_wrapper_attributes(
|
32
|
+
array( 'data-testid' => 'red-block' )
|
33
|
+
);
|
34
|
+
?>
|
35
|
+
<p <?php echo $wrapper_attributes; ?>>Red</p>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
{
|
2
|
+
"$schema": "https://schemas.wp.org/trunk/block.json",
|
3
|
+
"apiVersion": 2,
|
4
|
+
"name": "test/router-styles-wrapper",
|
5
|
+
"title": "E2E Interactivity tests - router styles - Wrapper",
|
6
|
+
"category": "text",
|
7
|
+
"icon": "heart",
|
8
|
+
"description": "",
|
9
|
+
"supports": {
|
10
|
+
"interactivity": true
|
11
|
+
},
|
12
|
+
"textdomain": "e2e-interactivity",
|
13
|
+
"viewScriptModule": "file:./view.js",
|
14
|
+
"viewStyle": "file:./style.css",
|
15
|
+
"render": "file:./render.php"
|
16
|
+
}
|
@@ -0,0 +1,70 @@
|
|
1
|
+
<?php
|
2
|
+
/**
|
3
|
+
* HTML for testing the iAPI's style assets management.
|
4
|
+
*
|
5
|
+
* @package gutenberg-test-interactive-blocks
|
6
|
+
*
|
7
|
+
* @phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable
|
8
|
+
*/
|
9
|
+
|
10
|
+
$wrapper_attributes = get_block_wrapper_attributes();
|
11
|
+
?>
|
12
|
+
<div <?php echo $wrapper_attributes; ?>>
|
13
|
+
<!-- These get colored when the corresponding block is present. -->
|
14
|
+
<fieldset>
|
15
|
+
<legend>Styles from block styles</legend>
|
16
|
+
<p data-testid="red" class="red">Red</p>
|
17
|
+
<p data-testid="green" class="green">Green</p>
|
18
|
+
<p data-testid="blue" class="blue">Blue</p>
|
19
|
+
<p data-testid="all" class="red green blue">All</p>
|
20
|
+
</fieldset>
|
21
|
+
|
22
|
+
<!-- These get colored when the corresponding block enqueues a referenced stylesheet. -->
|
23
|
+
<fieldset>
|
24
|
+
<legend>Styles from referenced style sheets</legend>
|
25
|
+
<p data-testid="red-from-link" class="red-from-link">Red from link</p>
|
26
|
+
<p data-testid="green-from-link" class="green-from-link">Green from link</p>
|
27
|
+
<p data-testid="blue-from-link" class="blue-from-link">Blue from link</p>
|
28
|
+
<p data-testid="all-from-link" class="red-from-link green-from-link blue-from-link">All from link</p>
|
29
|
+
<div data-testid="background-from-link"class="background-from-link" style="width: 10px; height: 10px"></div>
|
30
|
+
</fieldset>
|
31
|
+
|
32
|
+
<!-- These get colored when the corresponding block adds inline style. -->
|
33
|
+
<fieldset>
|
34
|
+
<legend>Styles from inline styles</legend>
|
35
|
+
<p data-testid="red-from-inline" class="red-from-inline">Red</p>
|
36
|
+
<p data-testid="green-from-inline" class="green-from-inline">Green</p>
|
37
|
+
<p data-testid="blue-from-inline" class="blue-from-inline">Blue</p>
|
38
|
+
<p data-testid="all-from-inline" class="red-from-inline green-from-inline blue-from-inline">All</p>
|
39
|
+
</fieldset>
|
40
|
+
|
41
|
+
<!-- Links to pages with different blocks combination. -->
|
42
|
+
<nav data-wp-interactive="test/router-styles">
|
43
|
+
<?php foreach ( $attributes['links'] as $label => $link ) : ?>
|
44
|
+
<a
|
45
|
+
data-testid="link <?php echo $label; ?>"
|
46
|
+
data-wp-on--click="actions.navigate"
|
47
|
+
href="<?php echo $link; ?>"
|
48
|
+
>
|
49
|
+
<?php echo $label; ?>
|
50
|
+
</a>
|
51
|
+
<?php endforeach; ?>
|
52
|
+
</nav>
|
53
|
+
|
54
|
+
<!-- HTML updated on navigation. -->
|
55
|
+
<div
|
56
|
+
data-wp-interactive="test/router-styles"
|
57
|
+
data-wp-router-region="router-styles"
|
58
|
+
>
|
59
|
+
<?php echo $content; ?>
|
60
|
+
</div>
|
61
|
+
|
62
|
+
<!-- Text to check whether a navigation was client-side. -->
|
63
|
+
<div
|
64
|
+
data-testid="client-side navigation"
|
65
|
+
data-wp-interactive="test/router-styles"
|
66
|
+
data-wp-bind--hidden="!state.clientSideNavigation"
|
67
|
+
>
|
68
|
+
Client-side navigation
|
69
|
+
</div>
|
70
|
+
</div>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
/**
|
2
|
+
* WordPress dependencies
|
3
|
+
*/
|
4
|
+
import { store } from '@wordpress/interactivity';
|
5
|
+
|
6
|
+
const { state } = store( 'test/router-styles', {
|
7
|
+
state: {
|
8
|
+
clientSideNavigation: false,
|
9
|
+
},
|
10
|
+
actions: {
|
11
|
+
*navigate( e ) {
|
12
|
+
e.preventDefault();
|
13
|
+
const { actions } = yield import(
|
14
|
+
'@wordpress/interactivity-router'
|
15
|
+
);
|
16
|
+
yield actions.navigate( e.target.href );
|
17
|
+
state.clientSideNavigation = true;
|
18
|
+
},
|
19
|
+
},
|
20
|
+
} );
|