@wordpress/e2e-tests 7.16.0 → 7.18.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 (72) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/package.json +8 -7
  3. package/plugins/block-icons/index.js +1 -1
  4. package/plugins/dataviews.php +25 -0
  5. package/plugins/interactive-blocks/directive-bind/render.php +3 -1
  6. package/plugins/interactive-blocks/directive-bind/view.js +32 -29
  7. package/plugins/interactive-blocks/directive-body/render.php +3 -1
  8. package/plugins/interactive-blocks/directive-body/view.js +11 -9
  9. package/plugins/interactive-blocks/directive-class/render.php +3 -1
  10. package/plugins/interactive-blocks/directive-class/view.js +20 -18
  11. package/plugins/interactive-blocks/directive-context/render.php +6 -4
  12. package/plugins/interactive-blocks/directive-context/view.js +49 -40
  13. package/plugins/interactive-blocks/directive-init/render.php +8 -6
  14. package/plugins/interactive-blocks/directive-init/view.js +59 -60
  15. package/plugins/interactive-blocks/directive-key/render.php +5 -1
  16. package/plugins/interactive-blocks/directive-key/view.js +18 -14
  17. package/plugins/interactive-blocks/directive-on/render.php +3 -1
  18. package/plugins/interactive-blocks/directive-on/view.js +27 -24
  19. package/plugins/interactive-blocks/directive-priorities/render.php +7 -2
  20. package/plugins/interactive-blocks/directive-priorities/view.js +107 -111
  21. package/plugins/interactive-blocks/directive-slots/render.php +3 -1
  22. package/plugins/interactive-blocks/directive-slots/view.js +17 -15
  23. package/plugins/interactive-blocks/directive-style/render.php +2 -1
  24. package/plugins/interactive-blocks/directive-style/view.js +21 -19
  25. package/plugins/interactive-blocks/directive-text/render.php +3 -1
  26. package/plugins/interactive-blocks/directive-text/view.js +16 -14
  27. package/plugins/interactive-blocks/{store-afterload → directive-watch}/block.json +3 -3
  28. package/plugins/interactive-blocks/{directive-effect → directive-watch}/render.php +8 -6
  29. package/plugins/interactive-blocks/directive-watch/view.js +53 -0
  30. package/plugins/interactive-blocks/negation-operator/render.php +4 -2
  31. package/plugins/interactive-blocks/negation-operator/view.js +15 -19
  32. package/plugins/interactive-blocks/router-navigate/render.php +11 -8
  33. package/plugins/interactive-blocks/router-navigate/view.js +27 -34
  34. package/plugins/interactive-blocks/router-regions/render.php +13 -3
  35. package/plugins/interactive-blocks/router-regions/view.js +37 -35
  36. package/plugins/interactive-blocks/store-tag/render.php +7 -4
  37. package/plugins/interactive-blocks/store-tag/view.js +19 -19
  38. package/plugins/interactive-blocks/tovdom/render.php +3 -1
  39. package/plugins/interactive-blocks/tovdom/view.js +5 -4
  40. package/plugins/interactive-blocks/tovdom-islands/render.php +11 -6
  41. package/plugins/interactive-blocks/tovdom-islands/view.js +24 -23
  42. package/plugins/interactive-blocks.php +4 -4
  43. package/specs/editor/various/datepicker.test.js +8 -8
  44. package/specs/editor/various/pattern-blocks.test.js +4 -4
  45. package/specs/editor/various/scheduling.test.js +1 -1
  46. package/plugins/interactive-blocks/directive-effect/block.json +0 -14
  47. package/plugins/interactive-blocks/directive-effect/view.js +0 -59
  48. package/plugins/interactive-blocks/store-afterload/render.php +0 -41
  49. package/plugins/interactive-blocks/store-afterload/view.js +0 -60
  50. package/specs/editor/plugins/__snapshots__/align-hook.test.js.snap +0 -43
  51. package/specs/editor/plugins/__snapshots__/block-directory-add.test.js.snap +0 -3
  52. package/specs/editor/plugins/__snapshots__/container-blocks.test.js.snap +0 -58
  53. package/specs/editor/plugins/__snapshots__/cpt-locking.test.js.snap +0 -147
  54. package/specs/editor/plugins/__snapshots__/inner-blocks-render-appender.test.js.snap +0 -25
  55. package/specs/editor/plugins/__snapshots__/meta-attribute-block.test.js.snap +0 -9
  56. package/specs/editor/plugins/__snapshots__/plugins-api.test.js.snap +0 -7
  57. package/specs/editor/plugins/align-hook.test.js +0 -234
  58. package/specs/editor/plugins/annotations.test.js +0 -189
  59. package/specs/editor/plugins/block-directory-add.test.js +0 -205
  60. package/specs/editor/plugins/block-icons.test.js +0 -170
  61. package/specs/editor/plugins/child-blocks.test.js +0 -66
  62. package/specs/editor/plugins/container-blocks.test.js +0 -130
  63. package/specs/editor/plugins/cpt-locking.test.js +0 -251
  64. package/specs/editor/plugins/custom-taxonomies.test.js +0 -61
  65. package/specs/editor/plugins/inner-blocks-prioritized-inserter-blocks.test.js +0 -132
  66. package/specs/editor/plugins/inner-blocks-render-appender.test.js +0 -126
  67. package/specs/editor/plugins/meta-attribute-block.test.js +0 -100
  68. package/specs/editor/plugins/meta-boxes.test.js +0 -137
  69. package/specs/editor/plugins/plugins-api.test.js +0 -189
  70. package/specs/editor/various/is-typing.test.js +0 -101
  71. package/specs/editor/various/publish-button.test.js +0 -46
  72. package/specs/editor/various/sidebar-permalink.test.js +0 -53
package/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 7.18.0 (2023-11-29)
6
+
7
+ ## 7.17.0 (2023-11-16)
8
+
5
9
  ## 7.16.0 (2023-11-02)
6
10
 
7
11
  ## 7.15.0 (2023-10-18)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/e2e-tests",
3
- "version": "7.16.0",
3
+ "version": "7.18.0",
4
4
  "description": "End-To-End (E2E) tests for WordPress.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -23,11 +23,12 @@
23
23
  "node": ">=14"
24
24
  },
25
25
  "dependencies": {
26
- "@wordpress/e2e-test-utils": "^10.16.0",
27
- "@wordpress/jest-console": "^7.16.0",
28
- "@wordpress/jest-puppeteer-axe": "^6.16.0",
29
- "@wordpress/scripts": "^26.16.0",
30
- "@wordpress/url": "^3.46.0",
26
+ "@wordpress/e2e-test-utils": "^10.18.0",
27
+ "@wordpress/interactivity": "^3.0.0",
28
+ "@wordpress/jest-console": "^7.18.0",
29
+ "@wordpress/jest-puppeteer-axe": "^6.18.0",
30
+ "@wordpress/scripts": "^26.18.0",
31
+ "@wordpress/url": "^3.48.0",
31
32
  "chalk": "^4.0.0",
32
33
  "expect-puppeteer": "^4.4.0",
33
34
  "filenamify": "^4.2.0",
@@ -45,5 +46,5 @@
45
46
  "publishConfig": {
46
47
  "access": "public"
47
48
  },
48
- "gitHead": "2a00e87b57b9c27ed2b9b0fd8d423ef3cada72c1"
49
+ "gitHead": "d98dff8ea96f29cfea045bf964269f46f040d539"
49
50
  }
@@ -55,7 +55,7 @@
55
55
  } );
56
56
 
57
57
  registerBlockType( 'test/test-dash-icon', {
58
- title: 'TestDashIcon',
58
+ title: 'TestSimpleDashIcon',
59
59
  icon: 'cart',
60
60
  category: 'text',
61
61
 
@@ -0,0 +1,25 @@
1
+ <?php
2
+ /**
3
+ * Plugin Name: Gutenberg Test DataViews
4
+ * Plugin URI: https://github.com/WordPress/gutenberg
5
+ * Author: Gutenberg Team
6
+ *
7
+ * @package gutenberg-test-dataviews
8
+ */
9
+
10
+ /**
11
+ * Disables the DataViews experiment on plugin deactivation.
12
+ */
13
+ function disable_dataviews_experiment() {
14
+ update_option( 'gutenberg-experiments', array() );
15
+ }
16
+
17
+ /**
18
+ * Enables the DataViews experiment.
19
+ */
20
+ function enable_dataviews_experiment() {
21
+ update_option( 'gutenberg-experiments', array( 'gutenberg-dataviews' => true ) );
22
+ register_deactivation_hook( __FILE__, 'disable_dataviews_experiment' );
23
+ }
24
+
25
+ add_action( 'init', 'enable_dataviews_experiment' );
@@ -5,8 +5,10 @@
5
5
  * @package gutenberg-test-interactive-blocks
6
6
  */
7
7
 
8
+ gutenberg_enqueue_module( 'directive-bind-view' );
8
9
  ?>
9
- <div data-wp-interactive>
10
+
11
+ <div data-wp-interactive='{ "namespace": "directive-bind" }'>
10
12
  <a
11
13
  data-wp-bind--href="state.url"
12
14
  data-testid="add missing href at hydration"
@@ -1,34 +1,37 @@
1
- ( ( { wp } ) => {
2
- const { store } = wp.interactivity;
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { store, getContext } from '@wordpress/interactivity';
3
5
 
4
- store( {
5
- state: {
6
- url: '/some-url',
7
- checked: true,
8
- show: false,
9
- width: 1,
6
+ const { state, foo } = store( 'directive-bind', {
7
+ state: {
8
+ url: '/some-url',
9
+ checked: true,
10
+ show: false,
11
+ width: 1,
12
+ },
13
+ foo: {
14
+ bar: 1,
15
+ },
16
+ actions: {
17
+ toggle: () => {
18
+ state.url = '/some-other-url';
19
+ state.checked = ! state.checked;
20
+ state.show = ! state.show;
21
+ state.width += foo.bar;
10
22
  },
11
- foo: {
12
- bar: 1,
13
- },
14
- actions: {
15
- toggle: ( { state, foo } ) => {
16
- state.url = '/some-other-url';
17
- state.checked = ! state.checked;
18
- state.show = ! state.show;
19
- state.width += foo.bar;
20
- },
21
- toggleValue: ( { context } ) => {
22
- const previousValue = ( 'previousValue' in context )
23
+ toggleValue: () => {
24
+ const context = getContext();
25
+ const previousValue =
26
+ 'previousValue' in context
23
27
  ? context.previousValue
24
- // Any string works here; we just want to toggle the value
25
- // to ensure Preact renders the same we are hydrating in the
26
- // first place.
27
- : 'tacocat';
28
+ : // Any string works here; we just want to toggle the value
29
+ // to ensure Preact renders the same we are hydrating in the
30
+ // first place.
31
+ 'tacocat';
28
32
 
29
- context.previousValue = context.value;
30
- context.value = previousValue;
31
- }
33
+ context.previousValue = context.value;
34
+ context.value = previousValue;
32
35
  },
33
- } );
34
- } )( window );
36
+ },
37
+ } );
@@ -5,9 +5,11 @@
5
5
  * @package gutenberg-test-interactive-blocks
6
6
  */
7
7
 
8
+ gutenberg_enqueue_module( 'directive-body-view' );
8
9
  ?>
10
+
9
11
  <div
10
- data-wp-interactive
12
+ data-wp-interactive='{ "namespace":"directive-body" }'
11
13
  data-wp-context='{"text":"text-1"}'
12
14
  >
13
15
  <div data-testid="container">
@@ -1,11 +1,13 @@
1
- ( ( { wp } ) => {
2
- const { store } = wp.interactivity;
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { store, getContext } from '@wordpress/interactivity';
3
5
 
4
- store( {
5
- actions: {
6
- toggleText: ( { context } ) => {
7
- context.text = context.text === 'text-1' ? 'text-2' : 'text-1';
8
- },
6
+ store( 'directive-body', {
7
+ actions: {
8
+ toggleText: () => {
9
+ const context = getContext();
10
+ context.text = context.text === 'text-1' ? 'text-2' : 'text-1';
9
11
  },
10
- } );
11
- } )( window );
12
+ },
13
+ } );
@@ -5,8 +5,10 @@
5
5
  * @package gutenberg-test-interactive-blocks
6
6
  */
7
7
 
8
+ gutenberg_enqueue_module( 'directive-class-view' );
8
9
  ?>
9
- <div data-wp-interactive>
10
+
11
+ <div data-wp-interactive='{"namespace": "directive-class"}'>
10
12
  <button
11
13
  data-wp-on--click="actions.toggleTrueValue"
12
14
  data-testid="toggle trueValue"
@@ -1,21 +1,23 @@
1
- ( ( { wp } ) => {
2
- const { store } = wp.interactivity;
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { store, getContext } from '@wordpress/interactivity';
3
5
 
4
- store( {
5
- state: {
6
- trueValue: true,
7
- falseValue: false,
6
+ const { state } = store( 'directive-class', {
7
+ state: {
8
+ trueValue: true,
9
+ falseValue: false,
10
+ },
11
+ actions: {
12
+ toggleTrueValue: () => {
13
+ state.trueValue = ! state.trueValue;
8
14
  },
9
- actions: {
10
- toggleTrueValue: ( { state } ) => {
11
- state.trueValue = ! state.trueValue;
12
- },
13
- toggleFalseValue: ( { state } ) => {
14
- state.falseValue = ! state.falseValue;
15
- },
16
- toggleContextFalseValue: ( { context } ) => {
17
- context.falseValue = ! context.falseValue;
18
- },
15
+ toggleFalseValue: () => {
16
+ state.falseValue = ! state.falseValue;
19
17
  },
20
- } );
21
- } )( window );
18
+ toggleContextFalseValue: () => {
19
+ const context = getContext();
20
+ context.falseValue = ! context.falseValue;
21
+ },
22
+ },
23
+ } );
@@ -5,14 +5,16 @@
5
5
  * @package gutenberg-test-interactive-blocks
6
6
  */
7
7
 
8
+ gutenberg_enqueue_module( 'directive-context-view' );
8
9
  ?>
9
- <div data-wp-interactive>
10
+
11
+ <div data-wp-interactive='{"namespace": "directive-context"}'>
10
12
  <div
11
13
  data-wp-context='{ "prop1":"parent","prop2":"parent","obj":{"prop4":"parent","prop5":"parent"},"array":[1,2,3] }'
12
14
  >
13
15
  <pre
14
16
  data-testid="parent context"
15
- data-wp-bind--children="derived.renderContext"
17
+ data-wp-bind--children="state.renderContext"
16
18
  >
17
19
  <!-- rendered during hydration -->
18
20
  </pre>
@@ -53,7 +55,7 @@
53
55
  >
54
56
  <pre
55
57
  data-testid="child context"
56
- data-wp-bind--children="derived.renderContext"
58
+ data-wp-bind--children="state.renderContext"
57
59
  >
58
60
  <!-- rendered during hydration -->
59
61
  </pre>
@@ -121,7 +123,7 @@
121
123
  </div>
122
124
 
123
125
  <div
124
- data-wp-interactive
126
+ data-wp-interactive='{"namespace": "directive-context-navigate"}'
125
127
  data-wp-navigation-id="navigation"
126
128
  data-wp-context='{ "text": "first page" }'
127
129
  >
@@ -1,9 +1,33 @@
1
- ( ( { wp } ) => {
2
- const { store, navigate } = wp.interactivity;
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { store, navigate, getContext } from '@wordpress/interactivity';
3
5
 
4
- const html = `
6
+ store( 'directive-context', {
7
+ state: {
8
+ get renderContext() {
9
+ const ctx = getContext();
10
+ return JSON.stringify( ctx, undefined, 2 );
11
+ },
12
+ },
13
+ actions: {
14
+ updateContext( event ) {
15
+ const ctx = getContext();
16
+ const { name, value } = event.target;
17
+ const [ key, ...path ] = name.split( '.' ).reverse();
18
+ const obj = path.reduceRight( ( o, k ) => o[ k ], ctx );
19
+ obj[ key ] = value;
20
+ },
21
+ toggleContextText() {
22
+ const ctx = getContext();
23
+ ctx.text = ctx.text === 'Text 1' ? 'Text 2' : 'Text 1';
24
+ },
25
+ },
26
+ } );
27
+
28
+ const html = `
5
29
  <div
6
- data-wp-interactive
30
+ data-wp-interactive='{ "namespace": "directive-context-navigate" }'
7
31
  data-wp-navigation-id="navigation"
8
32
  data-wp-context='{ "text": "second page" }'
9
33
  >
@@ -15,41 +39,26 @@
15
39
  <button data-testid="async navigate" data-wp-on--click="actions.asyncNavigate">Async Navigate</button>
16
40
  </div>`;
17
41
 
18
- store( {
19
- derived: {
20
- renderContext: ( { context } ) => {
21
- return JSON.stringify( context, undefined, 2 );
22
- },
42
+ const { actions } = store( 'directive-context-navigate', {
43
+ actions: {
44
+ toggleText() {
45
+ const ctx = getContext();
46
+ ctx.text = 'changed dynamically';
47
+ },
48
+ addNewText() {
49
+ const ctx = getContext();
50
+ ctx.newText = 'some new text';
51
+ },
52
+ navigate() {
53
+ return navigate( window.location, {
54
+ force: true,
55
+ html,
56
+ } );
23
57
  },
24
- actions: {
25
- updateContext: ( { context, event } ) => {
26
- const { name, value } = event.target;
27
- const [ key, ...path ] = name.split( '.' ).reverse();
28
- const obj = path.reduceRight( ( o, k ) => o[ k ], context );
29
- obj[ key ] = value;
30
- },
31
- toggleContextText: ( { context } ) => {
32
- context.text = context.text === 'Text 1' ? 'Text 2' : 'Text 1';
33
- },
34
- toggleText: ( { context } ) => {
35
- context.text = "changed dynamically";
36
- },
37
- addNewText: ( { context } ) => {
38
- context.newText = 'some new text';
39
- },
40
- navigate: () => {
41
- navigate( window.location, {
42
- force: true,
43
- html,
44
- } );
45
- },
46
- asyncNavigate: async ({ context }) => {
47
- await navigate( window.location, {
48
- force: true,
49
- html,
50
- } );
51
- context.newText = 'changed from async action';
52
- }
58
+ *asyncNavigate() {
59
+ yield actions.navigate();
60
+ const ctx = getContext();
61
+ ctx.newText = 'changed from async action';
53
62
  },
54
- } );
55
- } )( window );
63
+ },
64
+ } );
@@ -5,15 +5,17 @@
5
5
  * @package gutenberg-test-interactive-blocks
6
6
  */
7
7
 
8
+ gutenberg_enqueue_module( 'directive-init-view' );
8
9
  ?>
9
- <div data-wp-interactive>
10
+
11
+ <div data-wp-interactive='{ "namespace": "directive-init" }'>
10
12
  <div
11
13
  data-testid="single init"
12
14
  data-wp-context='{"isReady":[false],"calls":[0]}'
13
15
  data-wp-init="actions.initOne"
14
16
  >
15
- <p data-wp-text="selector.isReady" data-testid="isReady">false</p>
16
- <p data-wp-text="selector.calls" data-testid="calls">0</p>
17
+ <p data-wp-text="state.isReady" data-testid="isReady">false</p>
18
+ <p data-wp-text="state.calls" data-testid="calls">0</p>
17
19
  <button data-wp-on--click="actions.reset">reset</button>
18
20
  </div>
19
21
  <div
@@ -22,8 +24,8 @@
22
24
  data-wp-init--one="actions.initOne"
23
25
  data-wp-init--two="actions.initTwo"
24
26
  >
25
- <p data-wp-text="selector.isReady" data-testid="isReady">false,false</p>
26
- <p data-wp-text="selector.calls" data-testid="calls">0,0</p>
27
+ <p data-wp-text="state.isReady" data-testid="isReady">false,false</p>
28
+ <p data-wp-text="state.calls" data-testid="calls">0,0</p>
27
29
  </div>
28
30
  <div
29
31
  data-testid="init show"
@@ -35,7 +37,7 @@
35
37
  <button data-wp-on--click="actions.toggle" data-testid="toggle">
36
38
  toggle
37
39
  </button>
38
- <p data-wp-text="selector.isMounted" data-testid="isMounted">
40
+ <p data-wp-text="state.isMounted" data-testid="isMounted">
39
41
  true
40
42
  </p>
41
43
  </div>
@@ -1,63 +1,62 @@
1
- ( ( { wp } ) => {
2
- const { store, directive, useContext } = wp.interactivity;
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { store, directive, getContext } from '@wordpress/interactivity';
3
5
 
4
- // Mock `data-wp-show` directive to test when things are removed from the
5
- // DOM. Replace with `data-wp-show` when it's ready.
6
- directive(
7
- 'show-mock',
8
- ( {
9
- directives: {
10
- 'show-mock': { default: showMock },
11
- },
12
- element,
13
- evaluate,
14
- context,
15
- } ) => {
16
- const contextValue = useContext( context );
17
- if ( ! evaluate( showMock, { context: contextValue } ) ) {
18
- return null;
19
- }
20
- return element;
6
+ // Mock `data-wp-show` directive to test when things are removed from the
7
+ // DOM. Replace with `data-wp-show` when it's ready.
8
+ directive(
9
+ 'show-mock',
10
+ ( { directives: { 'show-mock': showMock }, element, evaluate } ) => {
11
+ const entry = showMock.find( ( { suffix } ) => suffix === 'default' );
12
+ if ( ! evaluate( entry ) ) {
13
+ return null;
21
14
  }
22
- );
15
+ return element;
16
+ }
17
+ );
23
18
 
24
-
25
- store( {
26
- selector: {
27
- isReady: ({ context: { isReady } }) => {
28
- return isReady
29
- .map(v => v ? 'true': 'false')
30
- .join(',');
31
- },
32
- calls: ({ context: { calls } }) => {
33
- return calls.join(',');
34
- },
35
- isMounted: ({ context }) => {
36
- return context.isMounted ? 'true' : 'false';
37
- },
38
- },
39
- actions: {
40
- initOne: ( { context: { isReady, calls } } ) => {
41
- isReady[0] = true;
42
- // Subscribe to changes in that prop.
43
- calls[0]++;
44
- },
45
- initTwo: ( { context: { isReady, calls } } ) => {
46
- isReady[1] = true;
47
- calls[1]++;
48
- },
49
- initMount: ( { context } ) => {
50
- context.isMounted = true;
51
- return () => {
52
- context.isMounted = false;
53
- }
54
- },
55
- reset: ( { context: { isReady } } ) => {
56
- isReady.fill(false);
57
- },
58
- toggle: ( { context } ) => {
59
- context.isVisible = ! context.isVisible;
60
- },
61
- },
62
- } );
63
- } )( window );
19
+ store( 'directive-init', {
20
+ state: {
21
+ get isReady() {
22
+ const { isReady } = getContext();
23
+ return isReady.map( ( v ) => ( v ? 'true' : 'false' ) ).join( ',' );
24
+ },
25
+ get calls() {
26
+ const { calls } = getContext();
27
+ return calls.join( ',' );
28
+ },
29
+ get isMounted() {
30
+ const { isMounted } = getContext();
31
+ return isMounted ? 'true' : 'false';
32
+ },
33
+ },
34
+ actions: {
35
+ initOne() {
36
+ const { isReady, calls } = getContext();
37
+ isReady[ 0 ] = true;
38
+ // Subscribe to changes in that prop.
39
+ calls[ 0 ]++;
40
+ },
41
+ initTwo() {
42
+ const { isReady, calls } = getContext();
43
+ isReady[ 1 ] = true;
44
+ calls[ 1 ]++;
45
+ },
46
+ initMount() {
47
+ const ctx = getContext();
48
+ ctx.isMounted = true;
49
+ return () => {
50
+ ctx.isMounted = false;
51
+ };
52
+ },
53
+ reset() {
54
+ const { isReady } = getContext();
55
+ isReady.fill( false );
56
+ },
57
+ toggle() {
58
+ const ctx = getContext();
59
+ ctx.isVisible = ! ctx.isVisible;
60
+ },
61
+ },
62
+ } );
@@ -5,9 +5,13 @@
5
5
  * @package gutenberg-test-interactive-blocks
6
6
  */
7
7
 
8
+ gutenberg_enqueue_module( 'directive-key-view' );
8
9
  ?>
9
10
 
10
- <div data-wp-interactive data-wp-navigation-id="some-id">
11
+ <div
12
+ data-wp-interactive='{ "namespace": "directive-key" }'
13
+ data-wp-navigation-id="some-id"
14
+ >
11
15
  <ul>
12
16
  <li data-wp-key="id-2" data-testid="first-item">2</li>
13
17
  <li data-wp-key="id-3">3</li>
@@ -1,8 +1,13 @@
1
- ( ( { wp } ) => {
2
- const { store, navigate } = wp.interactivity;
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { store, navigate } from '@wordpress/interactivity';
3
5
 
4
- const html = `
5
- <div data-wp-interactive data-wp-navigation-id="some-id">
6
+ const html = `
7
+ <div
8
+ data-wp-interactive='{ "namespace": "directive-key" }'
9
+ data-wp-navigation-id="some-id"
10
+ >
6
11
  <ul>
7
12
  <li data-wp-key="id-1">1</li>
8
13
  <li data-wp-key="id-2" data-testid="second-item">2</li>
@@ -10,14 +15,13 @@
10
15
  </ul>
11
16
  </div>`;
12
17
 
13
- store( {
14
- actions: {
15
- navigate: () => {
16
- navigate( window.location, {
17
- force: true,
18
- html,
19
- } );
20
- },
18
+ store( 'directive-key', {
19
+ actions: {
20
+ navigate() {
21
+ navigate( window.location, {
22
+ force: true,
23
+ html,
24
+ } );
21
25
  },
22
- } );
23
- } )( window );
26
+ },
27
+ } );
@@ -5,8 +5,10 @@
5
5
  * @package gutenberg-test-interactive-blocks
6
6
  */
7
7
 
8
+ gutenberg_enqueue_module( 'directive-on-view' );
8
9
  ?>
9
- <div data-wp-interactive>
10
+
11
+ <div data-wp-interactive='{ "namespace": "directive-on" }'>
10
12
  <div>
11
13
  <p data-wp-text="state.counter" data-testid="counter">0</p>
12
14
  <button