@wordpress/e2e-tests 7.22.4 → 7.22.6

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.6",
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.5",
28
+ "@wordpress/interactivity-router": "^1.1.5",
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": "f8226c028ffa05f4e863c3346e46058ad09431e8"
50
50
  }
@@ -0,0 +1,15 @@
1
+ {
2
+ "$schema": "https://schemas.wp.org/trunk/block.json",
3
+ "apiVersion": 2,
4
+ "name": "test/deferred-store",
5
+ "title": "E2E Interactivity tests - deferred store",
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,15 @@
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/deferred-store"
11
+ <?php echo wp_interactivity_data_wp_context( array( 'text' => '!dlrow ,olleH' ) ); ?>
12
+ >
13
+ <span data-wp-text="state.reversedText" data-testid="result"></span>
14
+ <span data-wp-text="state.reversedTextGetter" data-testid="result-getter"></span>
15
+ </div>
@@ -0,0 +1 @@
1
+ <?php return array( 'dependencies' => array( '@wordpress/interactivity' ) );
@@ -0,0 +1,20 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { store, getContext } from '@wordpress/interactivity';
5
+
6
+ document.addEventListener( 'DOMContentLoaded', () => {
7
+ setTimeout( () => {
8
+ store( 'test/deferred-store', {
9
+ state: {
10
+ reversedText() {
11
+ return [ ...getContext().text ].reverse().join( '' );
12
+ },
13
+
14
+ get reversedTextGetter() {
15
+ return [ ...getContext().text ].reverse().join( '' );
16
+ },
17
+ },
18
+ } );
19
+ }, 50 );
20
+ } );
@@ -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
+ } );
@@ -1,6 +1,6 @@
1
1
  <?php
2
2
  /**
3
- * HTML for testing the directive `data-wp-bind`.
3
+ * HTML for testing the `store` function.
4
4
  *
5
5
  * @package gutenberg-test-interactive-blocks
6
6
  */
@@ -9,6 +9,7 @@ wp_enqueue_script_module( 'store-view' );
9
9
  ?>
10
10
 
11
11
  <div data-wp-interactive="test/store">
12
+ <div data-wp-text="state.0" data-testid="state-0"></div>
12
13
  <div
13
14
  data-testid="non-plain object"
14
15
  data-wp-text="state.isNotProxified"
@@ -3,18 +3,21 @@
3
3
  */
4
4
  import { store, getElement } from '@wordpress/interactivity';
5
5
 
6
+ // A non-object state should never be allowed.
7
+ store( 'test/store', { state: [ 'wrong' ] } );
6
8
 
7
9
  const { state } = store( 'test/store', {
8
10
  state: {
11
+ 0: 'right',
9
12
  get isNotProxified() {
10
13
  const { ref } = getElement();
11
14
  return state.elementRef === ref;
12
- }
15
+ },
13
16
  },
14
17
  callbacks: {
15
18
  init() {
16
19
  const { ref } = getElement();
17
20
  state.elementRef = ref; // HTMLElement
18
- }
19
- }
20
- } )
21
+ },
22
+ },
23
+ } );