@wordpress/e2e-tests 8.8.1 → 8.8.3

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": "8.8.1",
3
+ "version": "8.8.3",
4
4
  "description": "End-To-End (E2E) tests for WordPress.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -25,11 +25,11 @@
25
25
  },
26
26
  "dependencies": {
27
27
  "@wordpress/e2e-test-utils": "^11.8.1",
28
- "@wordpress/interactivity": "^6.8.1",
29
- "@wordpress/interactivity-router": "^2.8.1",
28
+ "@wordpress/interactivity": "^6.8.2",
29
+ "@wordpress/interactivity-router": "^2.8.2",
30
30
  "@wordpress/jest-console": "^8.8.1",
31
31
  "@wordpress/jest-puppeteer-axe": "^7.8.1",
32
- "@wordpress/scripts": "^30.0.1",
32
+ "@wordpress/scripts": "^30.0.3",
33
33
  "@wordpress/url": "^4.8.1",
34
34
  "chalk": "^4.0.0",
35
35
  "expect-puppeteer": "^4.4.0",
@@ -47,5 +47,5 @@
47
47
  "publishConfig": {
48
48
  "access": "public"
49
49
  },
50
- "gitHead": "cf707c1f25a2716e310cc8f9afcc8554405c79ac"
50
+ "gitHead": "51204ac9382d0551d8fdebd3c8d4623dabfa9f3c"
51
51
  }
@@ -41,13 +41,13 @@ directive(
41
41
  'test-context',
42
42
  ( { context: { Provider }, props: { children } } ) => {
43
43
  executionProof( 'context' );
44
- const value = {
44
+ const client = {
45
45
  [ namespace ]: proxifyState( namespace, {
46
46
  attribute: 'from context',
47
47
  text: 'from context',
48
48
  } ),
49
49
  };
50
- return h( Provider, { value }, children );
50
+ return h( Provider, { value: { client } }, children );
51
51
  },
52
52
  { priority: 8 }
53
53
  );
@@ -0,0 +1,15 @@
1
+ {
2
+ "$schema": "https://schemas.wp.org/trunk/block.json",
3
+ "apiVersion": 2,
4
+ "name": "test/get-server-context",
5
+ "title": "E2E Interactivity tests - getServerContext",
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,51 @@
1
+ <?php
2
+ /**
3
+ * HTML for testing the getServerContext() function.
4
+ *
5
+ * @package gutenberg-test-interactive-blocks
6
+ *
7
+ * @phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable
8
+ */
9
+
10
+ $link1 = $attributes['links']['modified'];
11
+ $link2 = $attributes['links']['newProps'];
12
+ $parent_ctx = $attributes['parentContext'];
13
+ $child_ctx = $attributes['childContext'];
14
+ ?>
15
+
16
+ <nav
17
+ data-testid="navigate"
18
+ data-wp-interactive="test/get-server-context"
19
+ data-wp-on--click="actions.navigate"
20
+ >
21
+ <a data-testid="modified" href="<?php echo esc_url( $link1 ); ?>">modified</a>
22
+ <a data-testid="newProps" href="<?php echo esc_url( $link2 ); ?>">newProps</a>
23
+ </nav>
24
+
25
+ <div
26
+ data-wp-interactive="test/get-server-context"
27
+ data-wp-router-region="server-context"
28
+ data-wp-watch="callbacks.updateServerContextParent"
29
+ <?php echo wp_interactivity_data_wp_context( $parent_ctx ); ?>
30
+ >
31
+ <div
32
+ data-wp-watch="callbacks.updateServerContextChild"
33
+ <?php echo wp_interactivity_data_wp_context( $child_ctx ); ?>
34
+ >
35
+ <div data-testid="prop" data-wp-text="context.prop"></div>
36
+ <div data-testid="nested.prop" data-wp-text="context.nested.prop"></div>
37
+ <div data-testid="newProp" data-wp-text="context.newProp"></div>
38
+ <div data-testid="nested.newProp" data-wp-text="context.nested.newProp"></div>
39
+ <div data-testid="inherited.prop" data-wp-text="context.inherited.prop"></div>
40
+ <div data-testid="inherited.newProp" data-wp-text="context.inherited.newProp"></div>
41
+
42
+ <button
43
+ data-testid="tryToModifyServerContext"
44
+ <?php echo wp_interactivity_data_wp_context( array( 'result' => 'modify' ) ); ?>
45
+ data-wp-on--click="actions.attemptModification"
46
+ data-wp-text="context.result">
47
+ >
48
+ modify
49
+ </button>
50
+ </div>
51
+ </div>
@@ -0,0 +1,9 @@
1
+ <?php return array(
2
+ 'dependencies' => array(
3
+ '@wordpress/interactivity',
4
+ array(
5
+ 'id' => '@wordpress/interactivity-router',
6
+ 'import' => 'dynamic',
7
+ ),
8
+ ),
9
+ );
@@ -0,0 +1,46 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { store, getContext, getServerContext } from '@wordpress/interactivity';
5
+
6
+ store( 'test/get-server-context', {
7
+ actions: {
8
+ *navigate( e ) {
9
+ e.preventDefault();
10
+ const { actions } = yield import(
11
+ '@wordpress/interactivity-router'
12
+ );
13
+ yield actions.navigate( e.target.href );
14
+ },
15
+ attemptModification() {
16
+ try {
17
+ getServerContext().prop = 'updated from client';
18
+ getContext().result = 'unexpectedly modified ❌';
19
+ } catch ( e ) {
20
+ getContext().result = 'not modified ✅';
21
+ }
22
+ },
23
+ },
24
+ callbacks: {
25
+ updateServerContextParent() {
26
+ const ctx = getContext();
27
+ const { prop, newProp, nested, inherited } = getServerContext();
28
+ ctx.prop = prop;
29
+ ctx.newProp = newProp;
30
+ ctx.nested.prop = nested.prop;
31
+ ctx.nested.newProp = nested.newProp;
32
+ ctx.inherited.prop = inherited.prop;
33
+ ctx.inherited.newProp = inherited.newProp;
34
+ },
35
+ updateServerContextChild() {
36
+ const ctx = getContext();
37
+ const { prop, newProp, nested, inherited } = getServerContext();
38
+ ctx.prop = prop;
39
+ ctx.newProp = newProp;
40
+ ctx.nested.prop = nested.prop;
41
+ ctx.nested.newProp = nested.newProp;
42
+ ctx.inherited.prop = inherited.prop;
43
+ ctx.inherited.newProp = inherited.newProp;
44
+ },
45
+ },
46
+ } );
@@ -0,0 +1,15 @@
1
+ {
2
+ "$schema": "https://schemas.wp.org/trunk/block.json",
3
+ "apiVersion": 2,
4
+ "name": "test/get-server-state",
5
+ "title": "E2E Interactivity tests - getServerState",
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,50 @@
1
+ <?php
2
+ /**
3
+ * HTML for testing the getServerState() function.
4
+ *
5
+ * @package gutenberg-test-interactive-blocks
6
+ *
7
+ * @phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable
8
+ */
9
+
10
+ if ( isset( $attributes['state'] ) ) {
11
+ wp_interactivity_state( 'test/get-server-state', $attributes['state'] );
12
+ }
13
+ ?>
14
+
15
+ <div
16
+ data-wp-interactive="test/get-server-state"
17
+ data-wp-watch="callbacks.updateState"
18
+ >
19
+ <div data-testid="prop" data-wp-text="state.prop"></div>
20
+ <div data-testid="nested.prop" data-wp-text="state.nested.prop"></div>
21
+ <div data-testid="newProp" data-wp-text="state.newProp"></div>
22
+ <div data-testid="nested.newProp" data-wp-text="state.nested.newProp"></div>
23
+
24
+ <button
25
+ data-testid="tryToModifyServerState"
26
+ <?php echo wp_interactivity_data_wp_context( array( 'result' => 'modify' ) ); ?>
27
+ data-wp-on--click="actions.attemptModification"
28
+ data-wp-text="context.result">
29
+ >
30
+ modify
31
+ </button>
32
+
33
+
34
+ <nav>
35
+ <?php
36
+ if ( isset( $attributes['links'] ) ) {
37
+ foreach ( $attributes['links'] as $key => $link ) {
38
+ $i = $key += 1;
39
+ echo <<<HTML
40
+ <a
41
+ data-testid="link $i"
42
+ data-wp-on--click="actions.navigate"
43
+ href="$link"
44
+ >link $i</a>
45
+ HTML;
46
+ }
47
+ }
48
+ ?>
49
+ </nav>
50
+ </div>
@@ -0,0 +1,9 @@
1
+ <?php return array(
2
+ 'dependencies' => array(
3
+ '@wordpress/interactivity',
4
+ array(
5
+ 'id' => '@wordpress/interactivity-router',
6
+ 'import' => 'dynamic',
7
+ ),
8
+ ),
9
+ );
@@ -0,0 +1,33 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { store, getServerState, getContext } from '@wordpress/interactivity';
5
+
6
+ const { state } = store( 'test/get-server-state', {
7
+ actions: {
8
+ *navigate( e ) {
9
+ e.preventDefault();
10
+ const { actions } = yield import(
11
+ '@wordpress/interactivity-router'
12
+ );
13
+ yield actions.navigate( e.target.href );
14
+ },
15
+ attemptModification() {
16
+ try {
17
+ getServerState().prop = 'updated from client';
18
+ getContext().result = 'unexpectedly modified ❌';
19
+ } catch ( e ) {
20
+ getContext().result = 'not modified ✅';
21
+ }
22
+ },
23
+ },
24
+ callbacks: {
25
+ updateState() {
26
+ const { prop, newProp, nested } = getServerState();
27
+ state.prop = prop;
28
+ state.newProp = newProp;
29
+ state.nested.prop = nested.prop;
30
+ state.nested.newProp = nested.newProp;
31
+ },
32
+ },
33
+ } );