@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.
Files changed (27) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/LICENSE.md +1 -1
  3. package/package.json +9 -9
  4. package/plugins/block-bindings/index.js +45 -0
  5. package/plugins/block-bindings.php +5 -1
  6. package/plugins/interactive-blocks/directive-each/render.php +51 -0
  7. package/plugins/interactive-blocks/directive-each/view.js +22 -0
  8. package/plugins/interactive-blocks/router-styles-blue/assets/10x10_e2e_test_image_blue.png +0 -0
  9. package/plugins/interactive-blocks/router-styles-blue/block.json +15 -0
  10. package/plugins/interactive-blocks/router-styles-blue/render.php +35 -0
  11. package/plugins/interactive-blocks/router-styles-blue/style-from-link.css +7 -0
  12. package/plugins/interactive-blocks/router-styles-blue/style.css +4 -0
  13. package/plugins/interactive-blocks/router-styles-green/assets/10x10_e2e_test_image_green.png +0 -0
  14. package/plugins/interactive-blocks/router-styles-green/block.json +15 -0
  15. package/plugins/interactive-blocks/router-styles-green/render.php +35 -0
  16. package/plugins/interactive-blocks/router-styles-green/style-from-link.css +7 -0
  17. package/plugins/interactive-blocks/router-styles-green/style.css +4 -0
  18. package/plugins/interactive-blocks/router-styles-red/assets/10x10_e2e_test_image_red.png +0 -0
  19. package/plugins/interactive-blocks/router-styles-red/block.json +15 -0
  20. package/plugins/interactive-blocks/router-styles-red/render.php +35 -0
  21. package/plugins/interactive-blocks/router-styles-red/style-from-link.css +7 -0
  22. package/plugins/interactive-blocks/router-styles-red/style.css +4 -0
  23. package/plugins/interactive-blocks/router-styles-wrapper/block.json +16 -0
  24. package/plugins/interactive-blocks/router-styles-wrapper/render.php +70 -0
  25. package/plugins/interactive-blocks/router-styles-wrapper/style.css +3 -0
  26. package/plugins/interactive-blocks/router-styles-wrapper/view.asset.php +9 -0
  27. package/plugins/interactive-blocks/router-styles-wrapper/view.js +20 -0
package/CHANGELOG.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 8.15.0 (2025-01-02)
6
+
5
7
  ## 8.14.0 (2024-12-11)
6
8
 
7
9
  ## 8.13.0 (2024-11-27)
package/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ## Gutenberg
2
2
 
3
- Copyright 2016-2024 by the contributors
3
+ Copyright 2016-2025 by the contributors
4
4
 
5
5
  **License for Contributions (on and after April 15, 2021)**
6
6
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/e2e-tests",
3
- "version": "8.14.0",
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": "b432c18934c9db866b6dba7d37517a4e97d642e3"
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-private-apis',
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
 
@@ -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>
@@ -0,0 +1,7 @@
1
+ .blue-from-link {
2
+ color: rgb(0, 0, 255);
3
+ }
4
+
5
+ .background-from-link {
6
+ background-image: url('./assets/10x10_e2e_test_image_blue.png');
7
+ }
@@ -0,0 +1,4 @@
1
+ .wp-block-test-router-styles-blue,
2
+ .blue {
3
+ color: rgb(0, 0, 255);
4
+ }
@@ -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>
@@ -0,0 +1,7 @@
1
+ .green-from-link {
2
+ color: rgb(0, 255, 0);
3
+ }
4
+
5
+ .background-from-link {
6
+ background-image: url('./assets/10x10_e2e_test_image_green.png');
7
+ }
@@ -0,0 +1,4 @@
1
+ .wp-block-test-router-styles-green,
2
+ .green {
3
+ color: rgb(0, 255, 0);
4
+ }
@@ -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,7 @@
1
+ .red-from-link {
2
+ color: rgb(255, 0, 0);
3
+ }
4
+
5
+ .background-from-link {
6
+ background-image: url('./assets/10x10_e2e_test_image_red.png');
7
+ }
@@ -0,0 +1,4 @@
1
+ .wp-block-test-router-styles-red,
2
+ .red {
3
+ color: rgb(255, 0, 0);
4
+ }
@@ -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,3 @@
1
+ .wp-block-test-router-styles-wrapper {
2
+ color: rgb(160, 12, 60);
3
+ }
@@ -0,0 +1,9 @@
1
+ <?php return array(
2
+ 'dependencies' => array(
3
+ '@wordpress/interactivity',
4
+ array(
5
+ 'id' => '@wordpress/interactivity-router',
6
+ 'import' => 'dynamic',
7
+ ),
8
+ ),
9
+ );
@@ -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
+ } );