@wordpress/e2e-tests 9.3.0 → 9.3.1-next.v.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/e2e-tests",
3
- "version": "9.3.0",
3
+ "version": "9.3.1-next.v.0+b8934fcf9",
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",
@@ -24,8 +24,8 @@
24
24
  "npm": ">=8.19.2"
25
25
  },
26
26
  "dependencies": {
27
- "@wordpress/interactivity": "^6.38.0",
28
- "@wordpress/interactivity-router": "^2.38.0"
27
+ "@wordpress/interactivity": "^6.38.1-next.v.0+b8934fcf9",
28
+ "@wordpress/interactivity-router": "^2.38.2-next.v.0+b8934fcf9"
29
29
  },
30
30
  "peerDependencies": {
31
31
  "jest": ">=29",
@@ -36,5 +36,5 @@
36
36
  "publishConfig": {
37
37
  "access": "public"
38
38
  },
39
- "gitHead": "50c4c0f51e4797c217946ce42adfaa5eb026f33f"
39
+ "gitHead": "17529010285784fd2e735348a28391c79de87c88"
40
40
  }
@@ -0,0 +1,15 @@
1
+ {
2
+ "$schema": "https://schemas.wp.org/trunk/block.json",
3
+ "apiVersion": 3,
4
+ "name": "test/hydration-timing",
5
+ "title": "E2E Interactivity tests - hydration timing",
6
+ "category": "text",
7
+ "icon": "heart",
8
+ "description": "",
9
+ "supports": {
10
+ "interactivity": true
11
+ },
12
+ "textdomain": "e2e-interactivity",
13
+ "viewScriptModule": "file:./view.js",
14
+ "render": "file:./render.php"
15
+ }
@@ -0,0 +1,31 @@
1
+ <?php
2
+ /**
3
+ * HTML for testing hydration timing with delayed module loading.
4
+ *
5
+ * @package gutenberg-test-interactive-blocks
6
+ *
7
+ * @phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable
8
+ */
9
+ ?>
10
+
11
+ <div
12
+ data-wp-interactive="test/hydration-timing"
13
+ <?php echo wp_interactivity_data_wp_context( array( 'initialized' => false ) ); ?>
14
+ >
15
+ <p
16
+ data-wp-text="state.moduleLoaded"
17
+ data-testid="module-loaded"
18
+ >no</p>
19
+
20
+ <p
21
+ data-wp-text="context.initialized"
22
+ data-testid="context-initialized"
23
+ >no</p>
24
+
25
+ <div
26
+ data-wp-init="callbacks.init"
27
+ data-testid="hydration-status"
28
+ >
29
+ Hydration test block
30
+ </div>
31
+ </div>
@@ -0,0 +1 @@
1
+ <?php return array( 'dependencies' => array( '@wordpress/interactivity' ) );
@@ -0,0 +1,23 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { store, getContext } from '@wordpress/interactivity';
5
+
6
+ // This is the "fast" module that loads immediately. It imports
7
+ // @wordpress/interactivity, which initializes the runtime.
8
+ //
9
+ // The test pairs this with a "slow" module (hydration-timing-slow) that is
10
+ // artificially delayed. The race condition occurs when this fast module
11
+ // triggers hydration before the slow module has finished loading.
12
+
13
+ store( 'test/hydration-timing', {
14
+ state: {
15
+ moduleLoaded: 'yes',
16
+ },
17
+ callbacks: {
18
+ init() {
19
+ const context = getContext();
20
+ context.initialized = true;
21
+ },
22
+ },
23
+ } );
@@ -0,0 +1,15 @@
1
+ {
2
+ "$schema": "https://schemas.wp.org/trunk/block.json",
3
+ "apiVersion": 3,
4
+ "name": "test/hydration-timing-async",
5
+ "title": "E2E Interactivity tests - hydration timing async import",
6
+ "category": "text",
7
+ "icon": "heart",
8
+ "description": "",
9
+ "supports": {
10
+ "interactivity": true
11
+ },
12
+ "textdomain": "e2e-interactivity",
13
+ "viewScriptModule": "file:./view.js",
14
+ "render": "file:./render.php"
15
+ }
@@ -0,0 +1,36 @@
1
+ <?php
2
+ /**
3
+ * HTML for testing hydration timing - async import block.
4
+ *
5
+ * This block's view module dynamically imports @wordpress/interactivity
6
+ * on DOMContentLoaded, simulating a lazy-loading scenario. The test verifies
7
+ * that hydration still occurs even when the library is loaded after
8
+ * DOMContentLoaded has fired.
9
+ *
10
+ * @package gutenberg-test-interactive-blocks
11
+ *
12
+ * @phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable
13
+ */
14
+ ?>
15
+
16
+ <div
17
+ data-wp-interactive="test/hydration-timing-async"
18
+ <?php echo wp_interactivity_data_wp_context( array( 'hydrated' => false ) ); ?>
19
+ >
20
+ <p
21
+ data-wp-text="state.asyncModuleLoaded"
22
+ data-testid="async-module-loaded"
23
+ >no</p>
24
+
25
+ <p
26
+ data-wp-text="context.hydrated"
27
+ data-testid="async-hydrated"
28
+ >no</p>
29
+
30
+ <div
31
+ data-wp-init="callbacks.init"
32
+ data-testid="async-hydration-status"
33
+ >
34
+ Async import hydration test block
35
+ </div>
36
+ </div>
@@ -0,0 +1,8 @@
1
+ <?php return array(
2
+ 'dependencies' => array(
3
+ array(
4
+ 'id' => '@wordpress/interactivity',
5
+ 'import' => 'dynamic',
6
+ ),
7
+ ),
8
+ );
@@ -0,0 +1,29 @@
1
+ /**
2
+ * This module dynamically imports @wordpress/interactivity on DOMContentLoaded.
3
+ *
4
+ * This simulates a lazy-loading scenario where the Interactivity API is not
5
+ * statically imported. The test verifies that hydration still occurs even
6
+ * when the library is loaded after DOMContentLoaded has already fired.
7
+ */
8
+
9
+ const initStore = async () => {
10
+ const { store, getContext } = await import( '@wordpress/interactivity' );
11
+
12
+ store( 'test/hydration-timing-async', {
13
+ state: {
14
+ asyncModuleLoaded: 'yes',
15
+ },
16
+ callbacks: {
17
+ // TODO: this could be unavailable during hydration. Fix
18
+ // `data-wp-init` to support that case.
19
+ init() {
20
+ const context = getContext();
21
+ context.hydrated = true;
22
+ },
23
+ },
24
+ } );
25
+ };
26
+
27
+ document.addEventListener( 'DOMContentLoaded', () =>
28
+ setTimeout( initStore, 1 )
29
+ );
@@ -0,0 +1,15 @@
1
+ {
2
+ "$schema": "https://schemas.wp.org/trunk/block.json",
3
+ "apiVersion": 3,
4
+ "name": "test/hydration-timing-slow",
5
+ "title": "E2E Interactivity tests - hydration timing slow module",
6
+ "category": "text",
7
+ "icon": "heart",
8
+ "description": "",
9
+ "supports": {
10
+ "interactivity": true
11
+ },
12
+ "textdomain": "e2e-interactivity",
13
+ "viewScriptModule": "file:./view.js",
14
+ "render": "file:./render.php"
15
+ }
@@ -0,0 +1,36 @@
1
+ <?php
2
+ /**
3
+ * HTML for testing hydration timing - slow module block.
4
+ *
5
+ * This block's view module will be artificially delayed in the test
6
+ * to simulate a slow network connection. The test verifies that
7
+ * hydration waits for this module to load even when other modules
8
+ * that import @wordpress/interactivity have already been evaluated.
9
+ *
10
+ * @package gutenberg-test-interactive-blocks
11
+ *
12
+ * @phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable
13
+ */
14
+ ?>
15
+
16
+ <div
17
+ data-wp-interactive="test/hydration-timing"
18
+ <?php echo wp_interactivity_data_wp_context( array( 'slowInitialized' => false ) ); ?>
19
+ >
20
+ <p
21
+ data-wp-text="state.slowModuleLoaded"
22
+ data-testid="slow-module-loaded"
23
+ >no</p>
24
+
25
+ <p
26
+ data-wp-text="context.slowInitialized"
27
+ data-testid="slow-context-initialized"
28
+ >no</p>
29
+
30
+ <div
31
+ data-wp-init="callbacks.slowInit"
32
+ data-testid="slow-hydration-status"
33
+ >
34
+ Slow module hydration test block
35
+ </div>
36
+ </div>
@@ -0,0 +1 @@
1
+ <?php return array( 'dependencies' => array( '@wordpress/interactivity' ) );
@@ -0,0 +1,22 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { store, getContext } from '@wordpress/interactivity';
5
+
6
+ // This module will be artificially delayed in the test.
7
+ // It also imports @wordpress/interactivity, so when it's evaluated,
8
+ // the interactivity runtime will have already been initialized by
9
+ // the fast module. The test verifies that hydration waits for this
10
+ // module to finish loading before running.
11
+
12
+ store( 'test/hydration-timing', {
13
+ state: {
14
+ slowModuleLoaded: 'yes',
15
+ },
16
+ callbacks: {
17
+ slowInit() {
18
+ const context = getContext();
19
+ context.slowInitialized = true;
20
+ },
21
+ },
22
+ } );
@@ -11,6 +11,7 @@
11
11
  <section>
12
12
  <h2>Region 1</h2>
13
13
  <div
14
+ data-testid="region-1"
14
15
  data-wp-interactive="router-regions"
15
16
  data-wp-router-region="region-1"
16
17
  >
@@ -54,8 +55,11 @@
54
55
  <section>
55
56
  <h2>Region 2</h2>
56
57
  <div
58
+ data-testid="region-2"
59
+ data-wp-key="region-2"
57
60
  data-wp-interactive="router-regions"
58
61
  data-wp-router-region="region-2"
62
+ data-wp-run="callbacks.nope"
59
63
  >
60
64
  <p
61
65
  data-testid="region-2-text"
@@ -113,6 +117,7 @@
113
117
  <!-- Router region inside data-wp-interactive -->
114
118
  <div
115
119
  data-testid="valid-inside-interactive"
120
+ data-wp-key="valid-inside-interactive"
116
121
  data-wp-interactive="router-regions"
117
122
  data-wp-router-region="valid-inside-interactive"
118
123
  data-wp-context='{ "counter": { "value": 0 } }'
@@ -131,6 +136,7 @@
131
136
  <!-- Router region inside data-wp-router-region -->
132
137
  <div
133
138
  data-testid="valid-inside-router-region"
139
+ data-wp-key="valid-inside-router-region"
134
140
  data-wp-interactive="router-regions"
135
141
  data-wp-router-region="valid-inside-router-region"
136
142
  data-wp-context='{ "counter": { "value": 0 } }'
@@ -192,6 +198,7 @@
192
198
  data-wp-interactive="router-regions"
193
199
  data-wp-router-region='$region_data'
194
200
  data-testid="$region_id"
201
+ data-wp-key="$region_id"
195
202
  $has_directives
196
203
  >
197
204
  <div $context_data>
@@ -64,5 +64,8 @@ const { state } = store( 'router-regions', {
64
64
  init() {
65
65
  state.initCount += 1;
66
66
  },
67
+ nope() {
68
+ // This function does nothing.
69
+ },
67
70
  },
68
71
  } );