@wordpress/e2e-tests 9.22.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.
Files changed (29) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/package.json +5 -5
  3. package/plugins/animated-image-subsizes.php +10 -0
  4. package/plugins/autosave-failures.php +144 -0
  5. package/plugins/content-security-policy.php +43 -0
  6. package/plugins/entity-actions-api/close-comments.js +49 -0
  7. package/plugins/entity-actions-api.php +106 -0
  8. package/plugins/entity-fields-api/comment-status.css +24 -0
  9. package/plugins/entity-fields-api/comment-status.js +26 -0
  10. package/plugins/entity-fields-api/reading-time.css +21 -0
  11. package/plugins/entity-fields-api/reading-time.js +82 -0
  12. package/plugins/entity-fields-api.php +291 -0
  13. package/plugins/image-picture-wrapper.php +30 -0
  14. package/plugins/interactive-blocks/directive-context/render.php +2 -2
  15. package/plugins/interactive-blocks/directive-html/render.php +19 -7
  16. package/plugins/interactive-blocks/directive-html/view.js +21 -2
  17. package/plugins/interactive-blocks/hydration-timing-async/view.js +1 -1
  18. package/plugins/interactive-blocks/router-html/block.json +19 -0
  19. package/plugins/interactive-blocks/router-html/render.php +64 -0
  20. package/plugins/interactive-blocks/router-html/view.asset.php +9 -0
  21. package/plugins/interactive-blocks/router-html/view.js +56 -0
  22. package/plugins/interactive-blocks/router-html-regions/block.json +17 -0
  23. package/plugins/interactive-blocks/router-html-regions/render.php +77 -0
  24. package/plugins/interactive-blocks/router-html-regions/view.asset.php +15 -0
  25. package/plugins/interactive-blocks/router-html-regions/view.js +36 -0
  26. package/plugins/interactive-blocks/store-tag/render.php +3 -3
  27. package/plugins/interactive-blocks.php +12 -0
  28. package/plugins/react-18-compat-block/editor.js +38 -0
  29. package/plugins/rtc-websocket-provider/src/index.js +1 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 10.1.0 (2026-11-04)
6
+
7
+ ## 10.0.0 (2026-10-20)
8
+
9
+ ### Breaking Changes
10
+
11
+ - Raise the minimum required Node.js version to `>=22.13.0`, for stable `require(esm)` support ([#84313](https://github.com/WordPress/gutenberg/pull/84313)).
12
+
5
13
  ## 9.22.0 (2026-10-07)
6
14
 
7
15
  ### Enhancements
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/e2e-tests",
3
- "version": "9.22.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",
@@ -20,11 +20,11 @@
20
20
  "url": "https://github.com/WordPress/gutenberg/issues"
21
21
  },
22
22
  "engines": {
23
- "node": ">=18.12.0"
23
+ "node": ">=22.13.0"
24
24
  },
25
25
  "dependencies": {
26
- "@wordpress/interactivity": "^7.0.0",
27
- "@wordpress/interactivity-router": "^2.57.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": "12441e2520c78b2254a792a8cba40c34110be060"
39
+ "gitHead": "9b70363b9f93cff0583a1f3153738d383cf5a49e"
40
40
  }
@@ -0,0 +1,10 @@
1
+ <?php
2
+ /**
3
+ * Plugin Name: Gutenberg Test Animated Image Subsizes
4
+ * Plugin URI: https://github.com/WordPress/gutenberg
5
+ * Author: Gutenberg Team
6
+ *
7
+ * @package gutenberg-test-animated-image-subsizes
8
+ */
9
+
10
+ add_filter( 'wp_generate_animated_image_subsizes', '__return_false' );
@@ -0,0 +1,144 @@
1
+ <?php
2
+ /**
3
+ * Plugin Name: Gutenberg Test Autosave Failures
4
+ * Plugin URI: https://github.com/WordPress/gutenberg
5
+ * Author: Gutenberg Team
6
+ *
7
+ * @package gutenberg-test-autosave-failures
8
+ */
9
+
10
+ /**
11
+ * Makes autosave requests fail in the way named by the
12
+ * `gutenberg_test_autosave_failure` cookie.
13
+ *
14
+ * @param mixed $result Response to replace the requested version with.
15
+ * @param WP_REST_Server $server Server instance.
16
+ * @param WP_REST_Request $request Request used to generate the response.
17
+ * @return mixed
18
+ */
19
+ function gutenberg_test_autosave_failure( $result, $server, $request ) {
20
+ if (
21
+ 'POST' !== $request->get_method() ||
22
+ ! str_ends_with( $request->get_route(), '/autosaves' ) ||
23
+ empty( $_COOKIE['gutenberg_test_autosave_failure'] )
24
+ ) {
25
+ return $result;
26
+ }
27
+
28
+ global $wpdb;
29
+
30
+ switch ( $_COOKIE['gutenberg_test_autosave_failure'] ) {
31
+ case 'fatal-error':
32
+ ini_set( 'display_errors', '0' );
33
+ gutenberg_test_autosave_undefined_function();
34
+ break;
35
+
36
+ case 'fatal-error-displayed':
37
+ ini_set( 'display_errors', '1' );
38
+ gutenberg_test_autosave_undefined_function();
39
+ break;
40
+
41
+ case 'database-connection-lost':
42
+ $wpdb->query( 'KILL CONNECTION_ID()' );
43
+ $wpdb->dbhost = '127.0.0.1:1';
44
+ $wpdb->reconnect_retries = 1;
45
+ break;
46
+
47
+ case 'database-write':
48
+ add_filter(
49
+ 'query',
50
+ static function ( $query ) use ( $wpdb ) {
51
+ if ( str_starts_with( $query, "UPDATE `{$wpdb->posts}`" ) ) {
52
+ return "UPDATE `{$wpdb->posts}_missing` SET ID = 0";
53
+ }
54
+ return $query;
55
+ }
56
+ );
57
+ break;
58
+
59
+ case 'permission':
60
+ add_filter(
61
+ 'map_meta_cap',
62
+ static function ( $caps, $cap ) {
63
+ return 'edit_post' === $cap ? array( 'do_not_allow' ) : $caps;
64
+ },
65
+ 10,
66
+ 2
67
+ );
68
+ break;
69
+
70
+ case 'plain-message':
71
+ return new WP_Error( 'test_error', 'Something went wrong on the server.', array( 'status' => 500 ) );
72
+
73
+ case 'link-in-message':
74
+ return new WP_Error( 'test_error', 'Blocked. <a href="https://example.com">Learn more</a>.', array( 'status' => 403 ) );
75
+
76
+ case 'no-message':
77
+ status_header( 500 );
78
+ header( 'Content-Type: application/json' );
79
+ echo '{}';
80
+ exit;
81
+
82
+ case 'zero':
83
+ status_header( 500 );
84
+ header( 'Content-Type: application/json' );
85
+ echo '0';
86
+ exit;
87
+
88
+ case 'too-many-requests':
89
+ status_header( 429 );
90
+ header( 'Content-Type: text/html' );
91
+ echo '<html><body><h1>429 Too Many Requests</h1></body></html>';
92
+ exit;
93
+
94
+ case 'bad-gateway':
95
+ status_header( 502 );
96
+ header( 'Content-Type: text/html' );
97
+ echo '<html><body><h1>502 Bad Gateway</h1></body></html>';
98
+ exit;
99
+
100
+ case 'dropped-connection':
101
+ posix_kill( getmypid(), 9 );
102
+ break;
103
+
104
+ case 'warning-displayed':
105
+ ini_set( 'display_errors', '1' );
106
+ trigger_error( 'A plugin printed a warning.', E_USER_WARNING );
107
+ break;
108
+
109
+ case 'slow':
110
+ sleep( 3 );
111
+ break;
112
+
113
+ case 'redirect-to-login':
114
+ wp_redirect( wp_login_url() );
115
+ exit;
116
+
117
+ case 'redirect-to-other-site':
118
+ wp_redirect( str_replace( '://localhost', '://127.0.0.1', wp_login_url() ) );
119
+ exit;
120
+ }
121
+
122
+ return $result;
123
+ }
124
+ add_filter( 'rest_pre_dispatch', 'gutenberg_test_autosave_failure', 10, 3 );
125
+
126
+ /**
127
+ * Turns on maintenance mode for requests that ask for it. WordPress includes
128
+ * this file on every request, before plugins load.
129
+ */
130
+ function gutenberg_test_autosave_failures_activate() {
131
+ file_put_contents(
132
+ ABSPATH . '.maintenance',
133
+ "<?php\n\$upgrading = 'maintenance' === ( \$_COOKIE['gutenberg_test_autosave_failure'] ?? '' ) ? time() : 0;\n"
134
+ );
135
+ }
136
+ register_activation_hook( __FILE__, 'gutenberg_test_autosave_failures_activate' );
137
+
138
+ /**
139
+ * Removes the maintenance file.
140
+ */
141
+ function gutenberg_test_autosave_failures_deactivate() {
142
+ wp_delete_file( ABSPATH . '.maintenance' );
143
+ }
144
+ register_deactivation_hook( __FILE__, 'gutenberg_test_autosave_failures_deactivate' );
@@ -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
+ );
@@ -0,0 +1,49 @@
1
+ /**
2
+ * The JavaScript parts of the `gutenberg-test-entity-actions-api/close-comments`
3
+ * action the test plugin registers for Pages.
4
+ *
5
+ * The default export maps action ids to the properties of the action that PHP
6
+ * cannot serialize. The module applies to the actions it was registered with:
7
+ * `gutenberg-test-entity-actions-api/close-comments`. The
8
+ * `gutenberg-test-entity-actions-api/archive` entry is a whole action no PHP
9
+ * registration names: the editor ignores it, as a module only augments the
10
+ * actions registered with it.
11
+ *
12
+ * No build step: the callback dispatches through the data registry it
13
+ * receives, so the module imports nothing.
14
+ */
15
+
16
+ const closeComments = {
17
+ isEligible: ( item ) => item.comment_status === 'open',
18
+ callback: async ( items, { registry, onActionPerformed } ) => {
19
+ const { saveEntityRecord } = registry.dispatch( 'core' );
20
+ await Promise.all(
21
+ items.map( ( item ) =>
22
+ saveEntityRecord( 'postType', 'page', {
23
+ id: item.id,
24
+ comment_status: 'closed',
25
+ } )
26
+ )
27
+ );
28
+ registry
29
+ .dispatch( 'core/notices' )
30
+ .createSuccessNotice( 'Comments closed.', { type: 'snackbar' } );
31
+ onActionPerformed?.( items );
32
+ },
33
+ };
34
+
35
+ /**
36
+ * A complete action definition, id and label included, with no registration
37
+ * in PHP naming it. The editor merges a module into the actions the server
38
+ * registered the module with, so this entry never becomes an action.
39
+ */
40
+ const archive = {
41
+ id: 'gutenberg-test-entity-actions-api/archive',
42
+ label: 'Archive',
43
+ callback: () => {},
44
+ };
45
+
46
+ export default {
47
+ 'gutenberg-test-entity-actions-api/close-comments': closeComments,
48
+ 'gutenberg-test-entity-actions-api/archive': archive,
49
+ };
@@ -0,0 +1,106 @@
1
+ <?php
2
+ /**
3
+ * Plugin Name: Gutenberg Test Entity Actions API
4
+ * Plugin URI: https://github.com/WordPress/gutenberg
5
+ * Author: Gutenberg Team
6
+ *
7
+ * Extends the actions of Pages through the entity actions API, one self-contained
8
+ * function per case. Every case registers its actions on
9
+ * `wp_entity_actions_api_init`, the action the registry fires the first time its
10
+ * actions are read, after `init`, once the core actions are registered.
11
+ *
12
+ * 1. `add_action_with_script_module`: an action
13
+ * (`gutenberg-test-entity-actions-api/close-comments`) whose data is registered
14
+ * here and whose JavaScript parts come from
15
+ * `entity-actions-api/close-comments.js`. The same module exports a complete
16
+ * `gutenberg-test-entity-actions-api/archive` action no registration names: the
17
+ * module augments the actions it was registered with, so the entry is
18
+ * ignored and the action is not shown.
19
+ * 2. `replace_action`: a substitute for a core action (`move-to-trash`),
20
+ * unregistered and registered again with a new label, merged into the core
21
+ * definition, and with the script module of the core action, which keeps
22
+ * its JavaScript parts.
23
+ * 3. `remove_action`: the removal of a core action (`duplicate-post`).
24
+ *
25
+ * @package gutenberg-test-entity-actions-api
26
+ */
27
+
28
+ /**
29
+ * Case 1: an action (`gutenberg-test-entity-actions-api/close-comments`) whose
30
+ * eligibility and callback come from a script module. Two functions:
31
+ *
32
+ * - The module, on `init` like any plugin asset. It is registered, not
33
+ * enqueued: Gutenberg adds the modules of the registered actions to the
34
+ * import map of the editor pages.
35
+ * - The action, on `wp_entity_actions_api_init`. The action fires whenever the
36
+ * registry is first read, during REST requests too, so its callback
37
+ * registers the action and nothing else.
38
+ */
39
+ function gutenberg_test_entity_actions_api_register_close_comments_module() {
40
+ wp_register_script_module(
41
+ 'gutenberg-test-entity-actions-api/close-comments',
42
+ plugins_url( 'entity-actions-api/close-comments.js', __FILE__ ),
43
+ array(),
44
+ filemtime( __DIR__ . '/entity-actions-api/close-comments.js' )
45
+ );
46
+ }
47
+ add_action( 'init', 'gutenberg_test_entity_actions_api_register_close_comments_module' );
48
+
49
+ function gutenberg_test_entity_actions_api_add_action_with_script_module() {
50
+ wp_register_entity_actions(
51
+ 'gutenberg-test-entity-actions-api',
52
+ 'postType',
53
+ 'page',
54
+ array(
55
+ array(
56
+ 'id' => 'gutenberg-test-entity-actions-api/close-comments',
57
+ 'label' => 'Close comments',
58
+ 'supportsBulk' => true,
59
+ ),
60
+ ),
61
+ 'gutenberg-test-entity-actions-api/close-comments'
62
+ );
63
+ }
64
+ add_action( 'wp_entity_actions_api_init', 'gutenberg_test_entity_actions_api_add_action_with_script_module' );
65
+
66
+ /**
67
+ * Case 2: a substitute for a core action (`move-to-trash`). Unregistering
68
+ * drops its definition and detaches its script module, so the registration
69
+ * that follows is the whole action: the core definition it returns, with a new
70
+ * label, and not primary, so it moves from the row to the actions menu.
71
+ * Registered with the script module of the core action, it keeps its
72
+ * eligibility and its confirmation modal. It is only registered again when it
73
+ * was registered, as WordPress registers some actions only for the users who
74
+ * can perform them. The default priority runs after the core actions: there is
75
+ * nothing to unregister before.
76
+ */
77
+ function gutenberg_test_entity_actions_api_replace_action() {
78
+ $removed = wp_unregister_entity_actions( 'postType', 'page', array( 'move-to-trash' ) );
79
+ if ( ! $removed ) {
80
+ return;
81
+ }
82
+ wp_register_entity_actions(
83
+ 'gutenberg-test-entity-actions-api',
84
+ 'postType',
85
+ 'page',
86
+ array(
87
+ array_merge(
88
+ $removed[0],
89
+ array(
90
+ 'label' => 'Move to bin',
91
+ 'isPrimary' => false,
92
+ )
93
+ ),
94
+ ),
95
+ '@wordpress/core-actions/post_type_supports'
96
+ );
97
+ }
98
+ add_action( 'wp_entity_actions_api_init', 'gutenberg_test_entity_actions_api_replace_action' );
99
+
100
+ /**
101
+ * Case 3: the removal of a core action (`duplicate-post`).
102
+ */
103
+ function gutenberg_test_entity_actions_api_remove_action() {
104
+ wp_unregister_entity_actions( 'postType', 'page', array( 'duplicate-post' ) );
105
+ }
106
+ add_action( 'wp_entity_actions_api_init', 'gutenberg_test_entity_actions_api_remove_action' );
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Styles for the patched `comment_status` field. Only fields with a
3
+ * JavaScript `render` can be targeted: it is the render that emits the class
4
+ * name.
5
+ */
6
+
7
+ .gutenberg-test-comment-status::before {
8
+ content: "";
9
+ display: inline-block;
10
+ width: 8px;
11
+ height: 8px;
12
+ margin-right: 6px;
13
+ border-radius: 50%;
14
+ background: #757575;
15
+ vertical-align: middle;
16
+ }
17
+
18
+ .gutenberg-test-comment-status.is-open::before {
19
+ background: #00a32a;
20
+ }
21
+
22
+ .gutenberg-test-comment-status.is-closed::before {
23
+ background: #d63638;
24
+ }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * The JavaScript parts of the patch of the `comment_status` field the test
3
+ * plugin registers for Pages: a render replacing the default one.
4
+ *
5
+ * No build step: script modules cannot import the `@wordpress/*` scripts, so
6
+ * the `wp.*` globals the editor already loaded are used instead.
7
+ */
8
+ const { createElement } = window.wp.element;
9
+
10
+ const commentStatus = {
11
+ render: ( { item, field } ) => {
12
+ const value = field.getValue( { item } );
13
+ const option = ( field.elements ?? [] ).find(
14
+ ( element ) => element.value === value
15
+ );
16
+ return createElement(
17
+ 'span',
18
+ { className: `gutenberg-test-comment-status is-${ value }` },
19
+ option ? option.label : value
20
+ );
21
+ },
22
+ };
23
+
24
+ export default {
25
+ comment_status: commentStatus,
26
+ };
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Styles for the `reading_time` field. Only fields with a JavaScript `render`
3
+ * can be targeted: it is the render that emits the class name.
4
+ */
5
+
6
+ .gutenberg-test-reading-time {
7
+ display: inline-block;
8
+ padding: 0 6px;
9
+ border-radius: 2px;
10
+ background: rgb(56, 88, 233);
11
+ color: #fff;
12
+ line-height: 20px;
13
+ }
14
+
15
+ .gutenberg-test-reading-time.is-empty {
16
+ background: rgb(148, 148, 148);
17
+ }
18
+
19
+ .gutenberg-test-reading-time.is-long {
20
+ background: rgb(204, 24, 24);
21
+ }
@@ -0,0 +1,82 @@
1
+ /**
2
+ * The JavaScript parts of the `reading_time` field the test plugin registers
3
+ * for Pages.
4
+ *
5
+ * The default export maps field ids to the properties of the field that PHP
6
+ * cannot serialize. The module applies to the fields it was registered with:
7
+ * `reading_time`. The `word_count` entry is a whole field no PHP registration
8
+ * names: the editor ignores it, as a module only augments the fields
9
+ * registered with it.
10
+ *
11
+ * No build step: script modules cannot import the `@wordpress/*` scripts, so
12
+ * the `wp.*` globals the editor already loaded are used instead.
13
+ */
14
+ const { createElement } = window.wp.element;
15
+
16
+ const WORDS_PER_MINUTE = 200;
17
+ const LONG_READ_MINUTES = 10;
18
+
19
+ const readingTime = {
20
+ getValue: ( { item } ) => {
21
+ const content =
22
+ typeof item.content === 'string'
23
+ ? item.content
24
+ : ( item.content?.raw ?? item.content?.rendered ?? '' );
25
+ const words = content
26
+ .replace( /<[^>]*>/g, ' ' )
27
+ .split( /\s+/ )
28
+ .filter( Boolean ).length;
29
+ return Math.ceil( words / WORDS_PER_MINUTE );
30
+ },
31
+ render: ( { item, field } ) => {
32
+ const minutes = field.getValue( { item } );
33
+ const className = [
34
+ 'gutenberg-test-reading-time',
35
+ minutes === 0 && 'is-empty',
36
+ minutes >= LONG_READ_MINUTES && 'is-long',
37
+ ]
38
+ .filter( Boolean )
39
+ .join( ' ' );
40
+ return createElement(
41
+ 'span',
42
+ { className },
43
+ minutes === 0 ? 'Empty' : `${ minutes } min`
44
+ );
45
+ },
46
+ };
47
+
48
+ /**
49
+ * A complete field definition, id and label included, with no registration
50
+ * in PHP naming it. The editor merges a module into the fields the server
51
+ * registered the module with, so this entry never becomes a field.
52
+ */
53
+ const wordCount = {
54
+ id: 'word_count',
55
+ type: 'integer',
56
+ label: 'Word count',
57
+ enableSorting: false,
58
+ enableHiding: true,
59
+ filterBy: false,
60
+ readOnly: true,
61
+ getValue: ( { item } ) => {
62
+ const content =
63
+ typeof item.content === 'string'
64
+ ? item.content
65
+ : ( item.content?.raw ?? item.content?.rendered ?? '' );
66
+ return content
67
+ .replace( /<[^>]*>/g, ' ' )
68
+ .split( /\s+/ )
69
+ .filter( Boolean ).length;
70
+ },
71
+ render: ( { item, field } ) =>
72
+ createElement(
73
+ 'span',
74
+ { className: 'gutenberg-test-word-count' },
75
+ `${ field.getValue( { item } ) } words`
76
+ ),
77
+ };
78
+
79
+ export default {
80
+ reading_time: readingTime,
81
+ word_count: wordCount,
82
+ };