@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.
- package/CHANGELOG.md +4 -0
- package/package.json +8 -7
- package/plugins/block-icons/index.js +1 -1
- package/plugins/dataviews.php +25 -0
- package/plugins/interactive-blocks/directive-bind/render.php +3 -1
- package/plugins/interactive-blocks/directive-bind/view.js +32 -29
- package/plugins/interactive-blocks/directive-body/render.php +3 -1
- package/plugins/interactive-blocks/directive-body/view.js +11 -9
- package/plugins/interactive-blocks/directive-class/render.php +3 -1
- package/plugins/interactive-blocks/directive-class/view.js +20 -18
- package/plugins/interactive-blocks/directive-context/render.php +6 -4
- package/plugins/interactive-blocks/directive-context/view.js +49 -40
- package/plugins/interactive-blocks/directive-init/render.php +8 -6
- package/plugins/interactive-blocks/directive-init/view.js +59 -60
- package/plugins/interactive-blocks/directive-key/render.php +5 -1
- package/plugins/interactive-blocks/directive-key/view.js +18 -14
- package/plugins/interactive-blocks/directive-on/render.php +3 -1
- package/plugins/interactive-blocks/directive-on/view.js +27 -24
- package/plugins/interactive-blocks/directive-priorities/render.php +7 -2
- package/plugins/interactive-blocks/directive-priorities/view.js +107 -111
- package/plugins/interactive-blocks/directive-slots/render.php +3 -1
- package/plugins/interactive-blocks/directive-slots/view.js +17 -15
- package/plugins/interactive-blocks/directive-style/render.php +2 -1
- package/plugins/interactive-blocks/directive-style/view.js +21 -19
- package/plugins/interactive-blocks/directive-text/render.php +3 -1
- package/plugins/interactive-blocks/directive-text/view.js +16 -14
- package/plugins/interactive-blocks/{store-afterload → directive-watch}/block.json +3 -3
- package/plugins/interactive-blocks/{directive-effect → directive-watch}/render.php +8 -6
- package/plugins/interactive-blocks/directive-watch/view.js +53 -0
- package/plugins/interactive-blocks/negation-operator/render.php +4 -2
- package/plugins/interactive-blocks/negation-operator/view.js +15 -19
- package/plugins/interactive-blocks/router-navigate/render.php +11 -8
- package/plugins/interactive-blocks/router-navigate/view.js +27 -34
- package/plugins/interactive-blocks/router-regions/render.php +13 -3
- package/plugins/interactive-blocks/router-regions/view.js +37 -35
- package/plugins/interactive-blocks/store-tag/render.php +7 -4
- package/plugins/interactive-blocks/store-tag/view.js +19 -19
- package/plugins/interactive-blocks/tovdom/render.php +3 -1
- package/plugins/interactive-blocks/tovdom/view.js +5 -4
- package/plugins/interactive-blocks/tovdom-islands/render.php +11 -6
- package/plugins/interactive-blocks/tovdom-islands/view.js +24 -23
- package/plugins/interactive-blocks.php +4 -4
- package/specs/editor/various/datepicker.test.js +8 -8
- package/specs/editor/various/pattern-blocks.test.js +4 -4
- package/specs/editor/various/scheduling.test.js +1 -1
- package/plugins/interactive-blocks/directive-effect/block.json +0 -14
- package/plugins/interactive-blocks/directive-effect/view.js +0 -59
- package/plugins/interactive-blocks/store-afterload/render.php +0 -41
- package/plugins/interactive-blocks/store-afterload/view.js +0 -60
- package/specs/editor/plugins/__snapshots__/align-hook.test.js.snap +0 -43
- package/specs/editor/plugins/__snapshots__/block-directory-add.test.js.snap +0 -3
- package/specs/editor/plugins/__snapshots__/container-blocks.test.js.snap +0 -58
- package/specs/editor/plugins/__snapshots__/cpt-locking.test.js.snap +0 -147
- package/specs/editor/plugins/__snapshots__/inner-blocks-render-appender.test.js.snap +0 -25
- package/specs/editor/plugins/__snapshots__/meta-attribute-block.test.js.snap +0 -9
- package/specs/editor/plugins/__snapshots__/plugins-api.test.js.snap +0 -7
- package/specs/editor/plugins/align-hook.test.js +0 -234
- package/specs/editor/plugins/annotations.test.js +0 -189
- package/specs/editor/plugins/block-directory-add.test.js +0 -205
- package/specs/editor/plugins/block-icons.test.js +0 -170
- package/specs/editor/plugins/child-blocks.test.js +0 -66
- package/specs/editor/plugins/container-blocks.test.js +0 -130
- package/specs/editor/plugins/cpt-locking.test.js +0 -251
- package/specs/editor/plugins/custom-taxonomies.test.js +0 -61
- package/specs/editor/plugins/inner-blocks-prioritized-inserter-blocks.test.js +0 -132
- package/specs/editor/plugins/inner-blocks-render-appender.test.js +0 -126
- package/specs/editor/plugins/meta-attribute-block.test.js +0 -100
- package/specs/editor/plugins/meta-boxes.test.js +0 -137
- package/specs/editor/plugins/plugins-api.test.js +0 -189
- package/specs/editor/various/is-typing.test.js +0 -101
- package/specs/editor/various/publish-button.test.js +0 -46
- package/specs/editor/various/sidebar-permalink.test.js +0 -53
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@wordpress/e2e-tests",
|
3
|
-
"version": "7.
|
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.
|
27
|
-
"@wordpress/
|
28
|
-
"@wordpress/jest-
|
29
|
-
"@wordpress/
|
30
|
-
"@wordpress/
|
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": "
|
49
|
+
"gitHead": "d98dff8ea96f29cfea045bf964269f46f040d539"
|
49
50
|
}
|
@@ -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
|
-
|
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
|
-
|
2
|
-
|
1
|
+
/**
|
2
|
+
* WordPress dependencies
|
3
|
+
*/
|
4
|
+
import { store, getContext } from '@wordpress/interactivity';
|
3
5
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
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
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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
|
-
|
26
|
-
|
27
|
-
|
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
|
-
|
30
|
-
|
31
|
-
}
|
33
|
+
context.previousValue = context.value;
|
34
|
+
context.value = previousValue;
|
32
35
|
},
|
33
|
-
}
|
34
|
-
} )
|
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
|
-
|
2
|
-
|
1
|
+
/**
|
2
|
+
* WordPress dependencies
|
3
|
+
*/
|
4
|
+
import { store, getContext } from '@wordpress/interactivity';
|
3
5
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
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
|
-
} )
|
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
|
-
|
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
|
-
|
2
|
-
|
1
|
+
/**
|
2
|
+
* WordPress dependencies
|
3
|
+
*/
|
4
|
+
import { store, getContext } from '@wordpress/interactivity';
|
3
5
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
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
|
-
|
10
|
-
|
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
|
-
|
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
|
-
|
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="
|
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="
|
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
|
-
|
2
|
-
|
1
|
+
/**
|
2
|
+
* WordPress dependencies
|
3
|
+
*/
|
4
|
+
import { store, navigate, getContext } from '@wordpress/interactivity';
|
3
5
|
|
4
|
-
|
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
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
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
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
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
|
-
} )
|
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
|
-
|
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="
|
16
|
-
<p data-wp-text="
|
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="
|
26
|
-
<p data-wp-text="
|
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="
|
40
|
+
<p data-wp-text="state.isMounted" data-testid="isMounted">
|
39
41
|
true
|
40
42
|
</p>
|
41
43
|
</div>
|
@@ -1,63 +1,62 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
/**
|
2
|
+
* WordPress dependencies
|
3
|
+
*/
|
4
|
+
import { store, directive, getContext } from '@wordpress/interactivity';
|
3
5
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
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
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
}
|
32
|
-
calls
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
},
|
62
|
-
|
63
|
-
|
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
|
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
|
-
|
2
|
-
|
1
|
+
/**
|
2
|
+
* WordPress dependencies
|
3
|
+
*/
|
4
|
+
import { store, navigate } from '@wordpress/interactivity';
|
3
5
|
|
4
|
-
|
5
|
-
<div
|
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
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
},
|
18
|
+
store( 'directive-key', {
|
19
|
+
actions: {
|
20
|
+
navigate() {
|
21
|
+
navigate( window.location, {
|
22
|
+
force: true,
|
23
|
+
html,
|
24
|
+
} );
|
21
25
|
},
|
22
|
-
}
|
23
|
-
} )
|
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
|
-
|
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
|