@wordpress/e2e-tests 10.0.0 → 10.1.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 CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 10.1.0 (2026-11-04)
6
+
5
7
  ## 10.0.0 (2026-10-20)
6
8
 
7
9
  ### Breaking Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/e2e-tests",
3
- "version": "10.0.0",
3
+ "version": "10.1.0",
4
4
  "description": "Test plugins and mu-plugins for E2E tests in WordPress.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -23,8 +23,8 @@
23
23
  "node": ">=22.13.0"
24
24
  },
25
25
  "dependencies": {
26
- "@wordpress/interactivity": "^8.0.0",
27
- "@wordpress/interactivity-router": "^3.0.0"
26
+ "@wordpress/interactivity": "^8.1.0",
27
+ "@wordpress/interactivity-router": "^3.1.0"
28
28
  },
29
29
  "devDependencies": {
30
30
  "y-websocket": "^3.0.0"
@@ -36,5 +36,5 @@
36
36
  "publishConfig": {
37
37
  "access": "public"
38
38
  },
39
- "gitHead": "8d30f92cbbde3ddf781c8799443c649befbbcb88"
39
+ "gitHead": "9b70363b9f93cff0583a1f3153738d383cf5a49e"
40
40
  }
@@ -0,0 +1,43 @@
1
+ <?php
2
+ /**
3
+ * Plugin Name: Gutenberg Test Content Security Policy
4
+ * Plugin URI: https://github.com/WordPress/gutenberg
5
+ * Author: Gutenberg Team
6
+ *
7
+ * Sends a Content Security Policy that allows neither 'unsafe-eval' nor
8
+ * 'wasm-unsafe-eval' when the `csp` query parameter is `nonce` or `allowlist`.
9
+ * The nonce policy relies on the filters that WordPress provides to add the
10
+ * nonce to the scripts it prints.
11
+ *
12
+ * @package gutenberg-test-content-security-policy
13
+ */
14
+
15
+ add_action(
16
+ 'init',
17
+ static function () {
18
+ $name = isset( $_GET['csp'] ) && is_string( $_GET['csp'] ) ? sanitize_key( wp_unslash( $_GET['csp'] ) ) : '';
19
+
20
+ if ( 'nonce' === $name ) {
21
+ $nonce = base64_encode( random_bytes( 16 ) );
22
+ $script_src = "'nonce-$nonce' 'strict-dynamic'";
23
+
24
+ $add_nonce = static function ( $attributes ) use ( $nonce ) {
25
+ $attributes['nonce'] = $nonce;
26
+ return $attributes;
27
+ };
28
+ add_filter( 'wp_script_attributes', $add_nonce );
29
+ add_filter( 'wp_inline_script_attributes', $add_nonce );
30
+ } elseif ( 'allowlist' === $name ) {
31
+ $script_src = "'self' 'unsafe-inline' blob:";
32
+ } else {
33
+ return;
34
+ }
35
+
36
+ add_action(
37
+ 'send_headers',
38
+ static function () use ( $script_src ) {
39
+ header( "Content-Security-Policy: script-src $script_src; object-src 'none'; base-uri 'none'" );
40
+ }
41
+ );
42
+ }
43
+ );
@@ -87,7 +87,7 @@ function gutenberg_test_entity_actions_api_replace_action() {
87
87
  array_merge(
88
88
  $removed[0],
89
89
  array(
90
- 'label' => 'Move to bin…',
90
+ 'label' => 'Move to bin',
91
91
  'isPrimary' => false,
92
92
  )
93
93
  ),
@@ -0,0 +1,30 @@
1
+ <?php
2
+ /**
3
+ * Plugin Name: Gutenberg Test Image Picture Wrapper
4
+ * Plugin URI: https://github.com/WordPress/gutenberg
5
+ * Author: Gutenberg Team
6
+ *
7
+ * @package gutenberg-test-image-picture-wrapper
8
+ */
9
+
10
+ /**
11
+ * Wraps the `img` of an Image block in a `picture` element, the way the Modern
12
+ * Image Formats plugin does when its picture element setting is enabled.
13
+ *
14
+ * @param string $block_content Rendered block content.
15
+ * @param array $block Parsed block.
16
+ * @return string Filtered block content.
17
+ */
18
+ function gutenberg_test_wrap_image_in_picture( $block_content, $block ) {
19
+ if ( 'core/image' !== $block['blockName'] || ! str_contains( $block_content, '<img' ) ) {
20
+ return $block_content;
21
+ }
22
+
23
+ return preg_replace(
24
+ '/<img[^>]+>/',
25
+ '<picture style="display: contents;">$0</picture>',
26
+ $block_content,
27
+ 1
28
+ );
29
+ }
30
+ add_filter( 'render_block', 'gutenberg_test_wrap_image_in_picture', 10, 2 );
@@ -12,7 +12,7 @@
12
12
  >
13
13
  <pre
14
14
  data-testid="parent context"
15
- data-wp-bind--children="state.renderContext"
15
+ data-wp-text="state.renderContext"
16
16
  >
17
17
  <!-- rendered during hydration -->
18
18
  </pre>
@@ -62,7 +62,7 @@
62
62
  >
63
63
  <pre
64
64
  data-testid="child context"
65
- data-wp-bind--children="state.renderContext"
65
+ data-wp-text="state.renderContext"
66
66
  >
67
67
  <!-- rendered during hydration -->
68
68
  </pre>
@@ -0,0 +1,17 @@
1
+ {
2
+ "$schema": "https://schemas.wp.org/trunk/block.json",
3
+ "apiVersion": 3,
4
+ "name": "test/router-html-regions",
5
+ "title": "E2E Interactivity tests - HTML router regions",
6
+ "category": "text",
7
+ "supports": { "interactivity": true },
8
+ "attributes": {
9
+ "letter": { "type": "string", "default": "A" },
10
+ "next": { "type": "string", "default": "" },
11
+ "mode": { "type": "string", "default": "fallback" },
12
+ "before": { "type": "boolean", "default": false },
13
+ "copy": { "type": "boolean", "default": true }
14
+ },
15
+ "viewScriptModule": "file:./view.js",
16
+ "render": "file:./render.php"
17
+ }
@@ -0,0 +1,77 @@
1
+ <?php
2
+ /**
3
+ * Markup for navigation around inert HTML content.
4
+ *
5
+ * @package gutenberg-test-interactive-blocks
6
+ */
7
+
8
+ // Block rendering supplies attributes; standalone inclusion uses defaults.
9
+ $fixture_attributes = get_defined_vars()['attributes'] ?? array();
10
+ $letter = $fixture_attributes['letter'] ?? 'A';
11
+ $mode = $fixture_attributes['mode'] ?? 'fallback';
12
+ $has_copy = $fixture_attributes['copy'] ?? true;
13
+ $copy_before = $fixture_attributes['before'] ?? false;
14
+ $region_value = 'attach' === $mode ? wp_json_encode(
15
+ array(
16
+ 'id' => 'html/o',
17
+ 'attachTo' => 'body',
18
+ )
19
+ ) : 'html/r';
20
+
21
+ // Derived server state keeps fallback content without defining a client value.
22
+ wp_interactivity_state(
23
+ 'router-html-regions',
24
+ array(
25
+ /**
26
+ * Computes the fallback's pending server value.
27
+ *
28
+ * @return null The client getter is intentionally unavailable.
29
+ */
30
+ 'pending' => static function () {
31
+ return null;
32
+ },
33
+ )
34
+ );
35
+
36
+ add_filter(
37
+ 'script_module_data_@wordpress/interactivity',
38
+ /**
39
+ * Declares the server getter referenced by the HTML directive.
40
+ *
41
+ * @param array|null $data Serialized runtime data.
42
+ * @return array Runtime data with the pending getter declaration.
43
+ */
44
+ static function ( $data ) {
45
+ $data = $data ?? array();
46
+ $data['derivedStateClosures']['router-html-regions'][] = 'state.pending';
47
+ return $data;
48
+ }
49
+ );
50
+
51
+ $copy_markup = $has_copy ? sprintf(
52
+ '<div data-testid="html-owner" data-wp-html="state.pending"><div data-testid="copy" data-wp-interactive="router-html-regions" data-wp-router-region="%s" data-wp-init="actions.mark"><p>copy</p></div></div>',
53
+ esc_attr( $region_value )
54
+ ) : '';
55
+ ?>
56
+ <div data-wp-interactive="router-html-regions">
57
+ <a data-testid="next" data-wp-on--click="actions.navigate" href="<?php echo esc_url( $fixture_attributes['next'] ?? '' ); ?>">Next</a>
58
+ <output data-testid="marks" data-wp-text="state.marks">0</output>
59
+ <?php
60
+ if ( $copy_before && 'fallback' === $mode ) {
61
+ echo $copy_markup;
62
+ }
63
+ ?>
64
+ <?php if ( 'attach' !== $mode || 'B' === $letter ) : ?>
65
+ <div data-testid="real" data-wp-interactive="router-html-regions" data-wp-router-region="<?php echo esc_attr( $region_value ); ?>">
66
+ <p><?php echo esc_html( 'attach' === $mode ? 'overlay ' . $letter : $letter ); ?></p>
67
+ </div>
68
+ <?php endif; ?>
69
+ <?php
70
+ if ( ! $copy_before && 'inserted' !== $mode ) {
71
+ echo $copy_markup;
72
+ }
73
+ ?>
74
+ <?php if ( 'inserted' === $mode && 'A' === $letter ) : ?>
75
+ <div data-testid="html-owner" data-wp-html="state.inserted"></div>
76
+ <?php endif; ?>
77
+ </div>
@@ -0,0 +1,15 @@
1
+ <?php
2
+ /**
3
+ * Script module dependencies for HTML router regions.
4
+ *
5
+ * @package gutenberg-test-interactive-blocks
6
+ */
7
+ return array(
8
+ 'dependencies' => array(
9
+ '@wordpress/interactivity',
10
+ array(
11
+ 'id' => '@wordpress/interactivity-router',
12
+ 'import' => 'dynamic',
13
+ ),
14
+ ),
15
+ );
@@ -0,0 +1,36 @@
1
+ import {
2
+ asDangerousHTML,
3
+ store,
4
+ withSyncEvent,
5
+ } from '@wordpress/interactivity';
6
+
7
+ const { state } = store( 'router-html-regions', {
8
+ state: {
9
+ /** Number of directives initialized inside inert copies. */
10
+ marks: 0,
11
+ /** HTML supplied during hydration, outside every router region. */
12
+ inserted: asDangerousHTML(
13
+ '<div data-wp-interactive="router-html-regions" data-wp-router-region="html/r"><p>inserted</p></div>'
14
+ ),
15
+ },
16
+ actions: {
17
+ /** Records an initialization that must not occur inside HTML content. */
18
+ mark() {
19
+ state.marks++;
20
+ },
21
+ /**
22
+ * Navigates from a fixture link without a document reload.
23
+ *
24
+ * @param {MouseEvent} event Link click.
25
+ * @return {Object} Iterator yielding navigation completion.
26
+ */
27
+ navigate: withSyncEvent( function* ( event ) {
28
+ event.preventDefault();
29
+ // currentTarget is only available during synchronous event dispatch.
30
+ const href = event.currentTarget.href;
31
+ const { actions } =
32
+ yield import( '@wordpress/interactivity-router' );
33
+ yield actions.navigate( href );
34
+ } ),
35
+ },
36
+ } );
@@ -16,14 +16,14 @@ $test_store_tag_double = $test_store_tag_counter * 2;
16
16
  <div>
17
17
  Counter:
18
18
  <span
19
- data-wp-bind--children="state.counter.value"
19
+ data-wp-text="state.counter.value"
20
20
  data-testid="counter value"
21
21
  ><?php echo $test_store_tag_counter; ?></span
22
22
  >
23
23
  <br />
24
24
  Double:
25
25
  <span
26
- data-wp-bind--children="state.counter.double"
26
+ data-wp-text="state.counter.double"
27
27
  data-testid="counter double"
28
28
  ><?php echo $test_store_tag_double; ?></span
29
29
  >
@@ -35,7 +35,7 @@ $test_store_tag_double = $test_store_tag_counter * 2;
35
35
  +1
36
36
  </button>
37
37
  <span
38
- data-wp-bind--children="state.counter.clicks"
38
+ data-wp-text="state.counter.clicks"
39
39
  data-testid="counter clicks"
40
40
  >0</span
41
41
  >