@wordpress/e2e-tests 7.22.4 → 7.22.5

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": "7.22.4",
3
+ "version": "7.22.5",
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,11 +24,11 @@
24
24
  },
25
25
  "dependencies": {
26
26
  "@wordpress/e2e-test-utils": "^10.22.1",
27
- "@wordpress/interactivity": "^5.0.3",
28
- "@wordpress/interactivity-router": "^1.1.3",
27
+ "@wordpress/interactivity": "^5.0.4",
28
+ "@wordpress/interactivity-router": "^1.1.4",
29
29
  "@wordpress/jest-console": "^7.22.1",
30
30
  "@wordpress/jest-puppeteer-axe": "^6.22.1",
31
- "@wordpress/scripts": "^27.2.4",
31
+ "@wordpress/scripts": "^27.2.5",
32
32
  "@wordpress/url": "^3.52.1",
33
33
  "chalk": "^4.0.0",
34
34
  "expect-puppeteer": "^4.4.0",
@@ -46,5 +46,5 @@
46
46
  "publishConfig": {
47
47
  "access": "public"
48
48
  },
49
- "gitHead": "4927ea437069f9aed12f696df294a79bd8e12fd5"
49
+ "gitHead": "7d2a00f1998a0a696694802725e523628f994cfc"
50
50
  }
@@ -117,6 +117,24 @@ wp_enqueue_script_module( 'directive-context-view' );
117
117
  >
118
118
  obj.prop6
119
119
  </button>
120
+ <button
121
+ data-testid="child copy obj"
122
+ data-wp-on--click="actions.copyObj"
123
+ >
124
+ Copy obj
125
+ </button>
126
+ <div>
127
+ Is proxy preserved? <span
128
+ data-testid="is proxy preserved"
129
+ data-wp-text="state.isProxyPreserved"
130
+ ></span>
131
+ </div>
132
+ <div>
133
+ Is proxy preserved on copy? <span
134
+ data-testid="is proxy preserved on copy"
135
+ data-wp-text="state.isProxyPreservedOnCopy"
136
+ ></span>
137
+ </div>
120
138
  </div>
121
139
  <br />
122
140
 
@@ -12,6 +12,15 @@ store( 'directive-context', {
12
12
  get selected() {
13
13
  const { list, selected } = getContext();
14
14
  return list.find( ( obj ) => obj === selected )?.text;
15
+ },
16
+ get isProxyPreserved() {
17
+ const ctx = getContext();
18
+ const pointer = ctx.obj;
19
+ return pointer === ctx.obj;
20
+ },
21
+ get isProxyPreservedOnCopy() {
22
+ const { obj, obj2 } = getContext();
23
+ return obj === obj2;
15
24
  }
16
25
  },
17
26
  actions: {
@@ -34,6 +43,10 @@ store( 'directive-context', {
34
43
  replaceObj() {
35
44
  const ctx = getContext();
36
45
  ctx.obj = { overwritten: true };
46
+ },
47
+ copyObj() {
48
+ const ctx = getContext();
49
+ ctx.obj2 = ctx.obj;
37
50
  }
38
51
  },
39
52
  } );
@@ -0,0 +1,15 @@
1
+ {
2
+ "$schema": "https://schemas.wp.org/trunk/block.json",
3
+ "apiVersion": 2,
4
+ "name": "test/generator-scope",
5
+ "title": "E2E Interactivity tests - generator scope",
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,16 @@
1
+ <?php
2
+ /**
3
+ * HTML for testing scope restoration with generators.
4
+ *
5
+ * @package gutenberg-test-interactive-blocks
6
+ */
7
+ ?>
8
+
9
+ <div
10
+ data-wp-interactive="test/generator-scope"
11
+ <?php echo wp_interactivity_data_wp_context( array( 'result' => '' ) ); ?>
12
+ >
13
+ <input readonly data-wp-bind--value="context.result" data-testid="result" />
14
+ <button type="button" data-wp-on--click="callbacks.resolve" data-testid="resolve">Async resolve</button>
15
+ <button type="button" data-wp-on--click="callbacks.reject" data-testid="reject">Async reject</button>
16
+ </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
+ store( 'test/generator-scope', {
7
+ callbacks: {
8
+ *resolve() {
9
+ try {
10
+ getContext().result = yield Promise.resolve( 'ok' );
11
+ } catch ( err ) {
12
+ getContext().result = err.toString();
13
+ }
14
+ },
15
+ *reject() {
16
+ try {
17
+ getContext().result = yield Promise.reject( new Error( '😘' ) );
18
+ } catch ( err ) {
19
+ getContext().result = err.toString();
20
+ }
21
+ },
22
+ },
23
+ } );