@wordpress/e2e-tests 9.20.1-next.v.202609171837.0 → 9.22.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 +8 -0
- package/mu-plugins/e2e-fast-sync-polling.php +4 -4
- package/package.json +5 -7
- package/plugins/block-bindings.php +5 -0
- package/plugins/interactive-blocks/directive-context/render.php +1 -1
- package/plugins/interactive-blocks/directive-html/block.json +15 -0
- package/plugins/interactive-blocks/directive-html/render.php +42 -0
- package/plugins/interactive-blocks/directive-html/view.asset.php +1 -0
- package/plugins/interactive-blocks/directive-html/view.js +20 -0
- package/plugins/interactive-blocks/directive-init/render.php +1 -1
- package/plugins/interactive-blocks/directive-on/render.php +1 -1
- package/plugins/interactive-blocks/directive-on-document/render.php +1 -1
- package/plugins/interactive-blocks/directive-on-window/render.php +1 -1
- package/plugins/interactive-blocks/directive-run/render.php +1 -1
- package/plugins/interactive-blocks/directive-run/view.js +2 -2
- package/plugins/interactive-blocks/directive-watch/render.php +1 -1
- package/plugins/interactive-blocks/router-navigation-full-page/block.json +15 -0
- package/plugins/interactive-blocks/router-navigation-full-page/render.php +120 -0
- package/plugins/interactive-blocks/router-navigation-full-page/view.asset.php +9 -0
- package/plugins/interactive-blocks/router-navigation-full-page/view.js +95 -0
- package/plugins/interactive-blocks/router-navigation-lifecycle/block.json +15 -0
- package/plugins/interactive-blocks/router-navigation-lifecycle/render.php +303 -0
- package/plugins/interactive-blocks/router-navigation-lifecycle/view.asset.php +9 -0
- package/plugins/interactive-blocks/router-navigation-lifecycle/view.js +383 -0
- package/plugins/interactive-blocks/tovdom-islands/render.php +7 -10
- package/plugins/interactive-blocks/with-scope/render.php +1 -1
- package/plugins/lightbox-overlay-wrapper.php +25 -0
- package/plugins/media-upload-filter/index.js +30 -0
- package/plugins/media-upload-filter.php +23 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 9.22.0 (2026-10-07)
|
|
6
|
+
|
|
7
|
+
### Enhancements
|
|
8
|
+
|
|
9
|
+
- Remove the unused Jest peer dependency from the fixture package ([#83502](https://github.com/WordPress/gutenberg/pull/83502)).
|
|
10
|
+
|
|
11
|
+
## 9.21.0 (2026-09-23)
|
|
12
|
+
|
|
5
13
|
## 9.20.0 (2026-09-10)
|
|
6
14
|
|
|
7
15
|
## 9.19.0 (2026-08-26)
|
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* MU-plugin: Speed up collaboration sync polling in e2e tests.
|
|
4
4
|
*
|
|
5
|
-
* The sync module reads its polling intervals via applyFilters at load time
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* The sync module reads its polling intervals via applyFilters at load time.
|
|
6
|
+
* The sync module is bundled into the wp-core-data script, so the filters
|
|
7
|
+
* must be registered before that script executes.
|
|
8
8
|
*/
|
|
9
9
|
add_action(
|
|
10
10
|
'enqueue_block_editor_assets',
|
|
11
11
|
function () {
|
|
12
12
|
wp_add_inline_script(
|
|
13
|
-
'wp-
|
|
13
|
+
'wp-core-data',
|
|
14
14
|
<<<'JS'
|
|
15
15
|
wp.hooks.addFilter(
|
|
16
16
|
'sync.pollingManager.pollingInterval',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/e2e-tests",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.22.0",
|
|
4
4
|
"description": "Test plugins and mu-plugins for E2E tests in WordPress.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -20,23 +20,21 @@
|
|
|
20
20
|
"url": "https://github.com/WordPress/gutenberg/issues"
|
|
21
21
|
},
|
|
22
22
|
"engines": {
|
|
23
|
-
"node": ">=18.12.0"
|
|
24
|
-
"npm": ">=8.19.2"
|
|
23
|
+
"node": ">=18.12.0"
|
|
25
24
|
},
|
|
26
25
|
"dependencies": {
|
|
27
|
-
"@wordpress/interactivity": "^
|
|
28
|
-
"@wordpress/interactivity-router": "^2.
|
|
26
|
+
"@wordpress/interactivity": "^7.0.0",
|
|
27
|
+
"@wordpress/interactivity-router": "^2.57.0"
|
|
29
28
|
},
|
|
30
29
|
"devDependencies": {
|
|
31
30
|
"y-websocket": "^3.0.0"
|
|
32
31
|
},
|
|
33
32
|
"peerDependencies": {
|
|
34
|
-
"jest": ">=29",
|
|
35
33
|
"react": "^18 || ^19",
|
|
36
34
|
"react-dom": "^18 || ^19"
|
|
37
35
|
},
|
|
38
36
|
"publishConfig": {
|
|
39
37
|
"access": "public"
|
|
40
38
|
},
|
|
41
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "12441e2520c78b2254a792a8cba40c34110be060"
|
|
42
40
|
}
|
|
@@ -28,6 +28,11 @@ function gutenberg_test_block_bindings_registration() {
|
|
|
28
28
|
'value' => $testing_url,
|
|
29
29
|
'type' => 'string',
|
|
30
30
|
),
|
|
31
|
+
'icon_field' => array(
|
|
32
|
+
'label' => 'Icon Field Label',
|
|
33
|
+
'value' => 'core/arrow-right',
|
|
34
|
+
'type' => 'string',
|
|
35
|
+
),
|
|
31
36
|
'empty_field' => array(
|
|
32
37
|
'label' => 'Empty Field Label',
|
|
33
38
|
'value' => '',
|
|
@@ -166,7 +166,7 @@
|
|
|
166
166
|
<button data-testid="async navigate" data-wp-on--click="actions.asyncNavigate">Async Navigate</button>
|
|
167
167
|
</div>
|
|
168
168
|
|
|
169
|
-
<!-- Count of
|
|
169
|
+
<!-- Count of successful client-side navigations -->
|
|
170
170
|
<div
|
|
171
171
|
data-testid="navigation count"
|
|
172
172
|
data-wp-interactive="directive-context-navigate"
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://schemas.wp.org/trunk/block.json",
|
|
3
|
+
"apiVersion": 3,
|
|
4
|
+
"name": "test/directive-html",
|
|
5
|
+
"title": "E2E Interactivity tests - directive html",
|
|
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,42 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
/**
|
|
3
|
+
* HTML for testing the directive `data-wp-html`.
|
|
4
|
+
*
|
|
5
|
+
* @package gutenberg-test-interactive-blocks
|
|
6
|
+
*/
|
|
7
|
+
?>
|
|
8
|
+
|
|
9
|
+
<div data-wp-interactive="directive-html">
|
|
10
|
+
<div data-wp-html="state.html" data-testid="show state html">
|
|
11
|
+
<p data-testid="fallback">Fallback content</p>
|
|
12
|
+
</div>
|
|
13
|
+
|
|
14
|
+
<button data-wp-on--click="actions.setHtml" data-testid="set html">
|
|
15
|
+
Set HTML
|
|
16
|
+
</button>
|
|
17
|
+
|
|
18
|
+
<button
|
|
19
|
+
data-wp-on--click="actions.setLoading"
|
|
20
|
+
data-testid="set loading"
|
|
21
|
+
>
|
|
22
|
+
Set Loading
|
|
23
|
+
</button>
|
|
24
|
+
|
|
25
|
+
<button
|
|
26
|
+
data-wp-on--click="actions.setPlainString"
|
|
27
|
+
data-testid="set plain string"
|
|
28
|
+
>
|
|
29
|
+
Set Plain String
|
|
30
|
+
</button>
|
|
31
|
+
|
|
32
|
+
<div data-wp-html--suffix="state.html" data-testid="ignores suffixes">
|
|
33
|
+
<span data-testid="suffix-fallback">Suffix fallback</span>
|
|
34
|
+
</div>
|
|
35
|
+
|
|
36
|
+
<div
|
|
37
|
+
data-wp-html---unique-id="state.html"
|
|
38
|
+
data-testid="ignores unique-ids"
|
|
39
|
+
>
|
|
40
|
+
<span data-testid="unique-id-fallback">Unique ID fallback</span>
|
|
41
|
+
</div>
|
|
42
|
+
</div>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<?php return array( 'dependencies' => array( '@wordpress/interactivity' ) );
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { store, asDangerousHTML } from '@wordpress/interactivity';
|
|
2
|
+
|
|
3
|
+
const { state } = store( 'directive-html', {
|
|
4
|
+
state: {
|
|
5
|
+
html: null,
|
|
6
|
+
},
|
|
7
|
+
actions: {
|
|
8
|
+
setHtml() {
|
|
9
|
+
state.html = asDangerousHTML(
|
|
10
|
+
'<strong data-testid="rendered-strong">Rendered HTML</strong>'
|
|
11
|
+
);
|
|
12
|
+
},
|
|
13
|
+
setLoading() {
|
|
14
|
+
state.html = null;
|
|
15
|
+
},
|
|
16
|
+
setPlainString() {
|
|
17
|
+
state.html = '<strong>Not rendered</strong>';
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
} );
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
<div
|
|
20
20
|
data-testid="multiple inits"
|
|
21
21
|
data-wp-context='{"isReady":[false,false],"calls":[0,0]}'
|
|
22
|
-
data-wp-init
|
|
22
|
+
data-wp-init---one="actions.initOne"
|
|
23
23
|
data-wp-init---two="actions.initTwo"
|
|
24
24
|
>
|
|
25
25
|
<p data-wp-text="state.isReady" data-testid="isReady">false,false</p>
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
<button
|
|
67
67
|
data-testid="multiple handlers button"
|
|
68
68
|
data-wp-on--click="actions.setClicked"
|
|
69
|
-
data-wp-on--click
|
|
69
|
+
data-wp-on--click---counter="actions.countClick"
|
|
70
70
|
data-wp-on--click---toggle="actions.toggle"
|
|
71
71
|
>Click me!</button>
|
|
72
72
|
</div>
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
</div>
|
|
27
27
|
<div
|
|
28
28
|
data-wp-on-document--keydown="actions.keydownHandler"
|
|
29
|
-
data-wp-on-document--keydown
|
|
29
|
+
data-wp-on-document--keydown---second="actions.keydownSecondHandler"
|
|
30
30
|
data-wp-on-document--keydown---third="actions.keydownThirdHandler"
|
|
31
31
|
>
|
|
32
32
|
<p data-wp-text="state.keydownHandler" data-testid="keydownHandler">no</p>
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
</div>
|
|
24
24
|
<div
|
|
25
25
|
data-wp-on-window--resize="actions.resizeHandler"
|
|
26
|
-
data-wp-on-window--resize
|
|
26
|
+
data-wp-on-window--resize---second="actions.resizeSecondHandler"
|
|
27
27
|
data-wp-on-window--resize---third="actions.resizeThirdHandler"
|
|
28
28
|
>
|
|
29
29
|
<p data-wp-text="state.resizeHandler" data-testid="resizeHandler">no</p>
|
|
@@ -39,8 +39,8 @@ const html = `
|
|
|
39
39
|
<div data-testid="navigated">yes</div>
|
|
40
40
|
|
|
41
41
|
<div
|
|
42
|
-
data-wp-run
|
|
43
|
-
data-wp-run
|
|
42
|
+
data-wp-run---hydrated="callbacks.updateIsHydrated"
|
|
43
|
+
data-wp-run---renderCount="callbacks.updateRenderCount"
|
|
44
44
|
data-wp-text="state.clickCount"
|
|
45
45
|
></div>
|
|
46
46
|
</div>
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
|
|
32
32
|
<div
|
|
33
33
|
data-testid="multiple watches"
|
|
34
|
-
data-wp-watch
|
|
34
|
+
data-wp-watch---one="callbacks.watch1"
|
|
35
35
|
data-wp-watch---two="callbacks.watch2"
|
|
36
36
|
data-wp-bind--data-watch-one="state.watch1"
|
|
37
37
|
data-wp-bind--data-watch-two="state.watch2"
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://schemas.wp.org/trunk/block.json",
|
|
3
|
+
"apiVersion": 3,
|
|
4
|
+
"name": "test/router-navigation-full-page",
|
|
5
|
+
"title": "E2E Interactivity tests - router navigation full-page mode",
|
|
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,120 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
/**
|
|
3
|
+
* HTML for testing the router navigation lifecycle state (`state.navigating`
|
|
4
|
+
* and `state.initiator`, published by `@wordpress/interactivity-router`) in
|
|
5
|
+
* **full-page** client-side navigation mode (the
|
|
6
|
+
* `gutenberg-full-page-client-side-navigation` experiment).
|
|
7
|
+
*
|
|
8
|
+
* Full-page mode makes the whole BODY the router region --
|
|
9
|
+
* `Gutenberg_Interactivity_API_Full_Page_Navigation::add_directives_to_body()`
|
|
10
|
+
* sets `data-wp-interactive` and `data-wp-router-region="core/body"` on the
|
|
11
|
+
* BODY tag itself, and there is no per-post switch. So, unlike
|
|
12
|
+
* `router-navigation-lifecycle`, this fixture's own wrapper declares *no*
|
|
13
|
+
* `data-wp-router-region` of its own: its own named region (`regionId`) is
|
|
14
|
+
* nested *inside* the implicit BODY region, which is what lets the "outside
|
|
15
|
+
* every block region" control below -- rendered inside this wrapper but
|
|
16
|
+
* outside that nested region -- derive `core/body` by walking up to BODY,
|
|
17
|
+
* rather than stopping at this wrapper or at some region of its own.
|
|
18
|
+
*
|
|
19
|
+
* @package gutenberg-test-interactive-blocks
|
|
20
|
+
*
|
|
21
|
+
* @phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
$page = $attributes['page'] ?? '';
|
|
25
|
+
$next_href = $attributes['next'] ?? null;
|
|
26
|
+
$region_id = $attributes['regionId'] ?? '';
|
|
27
|
+
?>
|
|
28
|
+
<div data-wp-interactive="router-navigation-full-page">
|
|
29
|
+
<?php if ( isset( $next_href ) ) : ?>
|
|
30
|
+
<!--
|
|
31
|
+
A plain <a>, outside every block region. No directive
|
|
32
|
+
handles this click, so the full-page document click listener
|
|
33
|
+
(`packages/interactivity-router/src/full-page.ts`) does -- and
|
|
34
|
+
that listener's own `actions.navigate()` call carries no ambient
|
|
35
|
+
directive scope, so it must read absent regardless of where this
|
|
36
|
+
link sits in the DOM.
|
|
37
|
+
-->
|
|
38
|
+
<a
|
|
39
|
+
data-testid="plain-link-outside-region"
|
|
40
|
+
href="<?php echo esc_url( $next_href ); ?>"
|
|
41
|
+
>plain link (outside region)</a>
|
|
42
|
+
|
|
43
|
+
<!--
|
|
44
|
+
A directive-scoped click control, also outside every
|
|
45
|
+
block region. Its own `data-wp-on--click` action *does* carry an
|
|
46
|
+
ambient scope, and this control's nearest enclosing
|
|
47
|
+
`data-wp-router-region` is the BODY the full-page PHP class marks
|
|
48
|
+
`core/body` -- not this wrapper, which declares none of its own.
|
|
49
|
+
-->
|
|
50
|
+
<a
|
|
51
|
+
data-testid="navigate-outside-region"
|
|
52
|
+
data-wp-on--click="actions.navigate"
|
|
53
|
+
href="<?php echo esc_url( $next_href ); ?>"
|
|
54
|
+
>navigate (outside region)</a>
|
|
55
|
+
<?php endif; ?>
|
|
56
|
+
|
|
57
|
+
<?php
|
|
58
|
+
/*
|
|
59
|
+
* Note (see `router-navigation-lifecycle/render.php` for the
|
|
60
|
+
* full account): `data-wp-interactive` is repeated here even though the
|
|
61
|
+
* outer wrapper above already carries it. `interactivity-router`'s own
|
|
62
|
+
* region-detection selector requires the region-bearing element itself
|
|
63
|
+
* to carry `data-wp-interactive`, not merely an ancestor -- omitting it
|
|
64
|
+
* here would hydrate fine on first load and then silently drop this
|
|
65
|
+
* region's content after the first client-side navigation.
|
|
66
|
+
*/
|
|
67
|
+
?>
|
|
68
|
+
<div
|
|
69
|
+
data-testid="region-<?php echo esc_attr( $region_id ); ?>"
|
|
70
|
+
data-wp-interactive="router-navigation-full-page"
|
|
71
|
+
data-wp-router-region="<?php echo esc_attr( $region_id ); ?>"
|
|
72
|
+
>
|
|
73
|
+
<?php if ( isset( $next_href ) ) : ?>
|
|
74
|
+
<!--
|
|
75
|
+
A plain <a>, this time *inside* the fixture's own
|
|
76
|
+
region. Still handled by the document listener, not by any
|
|
77
|
+
directive scope -- DOM containment must not change the
|
|
78
|
+
reading, which is exactly what makes this link and the one
|
|
79
|
+
above a matched pair.
|
|
80
|
+
-->
|
|
81
|
+
<a
|
|
82
|
+
data-testid="plain-link-inside-region"
|
|
83
|
+
href="<?php echo esc_url( $next_href ); ?>"
|
|
84
|
+
>plain link (inside region)</a>
|
|
85
|
+
|
|
86
|
+
<!--
|
|
87
|
+
A click handled by this block's own scoped action,
|
|
88
|
+
inside its own region -- the identical shape to
|
|
89
|
+
`router-navigation-lifecycle`'s region-mode `navigate` link,
|
|
90
|
+
so the reading it produces here must match the region-mode
|
|
91
|
+
reading exactly.
|
|
92
|
+
-->
|
|
93
|
+
<a
|
|
94
|
+
data-testid="navigate-inside-region"
|
|
95
|
+
data-wp-on--click="actions.navigate"
|
|
96
|
+
href="<?php echo esc_url( $next_href ); ?>"
|
|
97
|
+
>navigate (inside region)</a>
|
|
98
|
+
<?php endif; ?>
|
|
99
|
+
|
|
100
|
+
<p data-testid="page-marker">page marker: <?php echo esc_html( $page ); ?></p>
|
|
101
|
+
</div>
|
|
102
|
+
|
|
103
|
+
<!--
|
|
104
|
+
The observer readout -- the same shape as
|
|
105
|
+
`router-navigation-lifecycle`'s counted lifecycle observer, reading
|
|
106
|
+
`core/router` state from this block's own store namespace. Its run
|
|
107
|
+
*count* is not asserted anywhere in this fixture's tests: the
|
|
108
|
+
BODY-wide region tears this whole wrapper down and rebuilds it on
|
|
109
|
+
every navigation, so a count here is a function of reconciliation,
|
|
110
|
+
not of the lifecycle. Its *content* still is evidence, because
|
|
111
|
+
`state.log` is module state and survives the region swap.
|
|
112
|
+
-->
|
|
113
|
+
<p
|
|
114
|
+
data-testid="lifecycle log"
|
|
115
|
+
data-wp-watch="callbacks.watchLifecycle"
|
|
116
|
+
data-wp-text="state.log"
|
|
117
|
+
>not hydrated</p>
|
|
118
|
+
<p data-testid="lifecycle navigating" data-wp-text="state.navigatingReading">not hydrated</p>
|
|
119
|
+
<p data-testid="lifecycle initiator" data-wp-text="state.initiatorReading">not hydrated</p>
|
|
120
|
+
</div>
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { store, withSyncEvent } from '@wordpress/interactivity';
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* `core/router` is *read*, never imported -- same rationale as
|
|
5
|
+
* `router-navigation-lifecycle/view.js`: this namespace is auto-created by
|
|
6
|
+
* the store proxy and later merges into the router's own store once (and
|
|
7
|
+
* if) that module loads.
|
|
8
|
+
*/
|
|
9
|
+
const { state: routerState } = store( 'core/router' );
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Renders a `navigating` value the same way as
|
|
13
|
+
* `router-navigation-lifecycle/view.js`'s `describeNavigating`.
|
|
14
|
+
*
|
|
15
|
+
* @param {boolean|undefined} navigating
|
|
16
|
+
* @return {string} The human-readable reading.
|
|
17
|
+
*/
|
|
18
|
+
function describeNavigating( navigating ) {
|
|
19
|
+
return navigating ? 'navigating' : 'not navigating';
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Renders an `initiator` value the same way as
|
|
24
|
+
* `router-navigation-lifecycle/view.js`'s `describeInitiator`. `undefined`
|
|
25
|
+
* (never set) and `null` (no enclosing region, or explicitly suppressed) are
|
|
26
|
+
* deliberately not distinguished here -- both are the documented "absence of
|
|
27
|
+
* identity" reading (Requirement 11).
|
|
28
|
+
*
|
|
29
|
+
* @param {string|null|undefined} initiator
|
|
30
|
+
* @return {string} The human-readable reading.
|
|
31
|
+
*/
|
|
32
|
+
function describeInitiator( initiator ) {
|
|
33
|
+
return initiator === undefined || initiator === null ? 'absent' : initiator;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const { state } = store( 'router-navigation-full-page', {
|
|
37
|
+
state: {
|
|
38
|
+
/*
|
|
39
|
+
* The backing array lives inside `state`, not at module scope, for
|
|
40
|
+
* the same reason as `router-navigation-lifecycle/view.js`: a
|
|
41
|
+
* module-scope mutation is invisible to the signals system, so
|
|
42
|
+
* nothing would ever mark `state.log`'s `data-wp-text` readout dirty.
|
|
43
|
+
*/
|
|
44
|
+
_log: [],
|
|
45
|
+
|
|
46
|
+
get navigatingReading() {
|
|
47
|
+
return describeNavigating( routerState.navigating );
|
|
48
|
+
},
|
|
49
|
+
get initiatorReading() {
|
|
50
|
+
return describeInitiator( routerState.initiator );
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
/*
|
|
54
|
+
* A serialized array, so a spec can `JSON.parse` the readout and
|
|
55
|
+
* assert on its *content*. This is the only instrument the full-page
|
|
56
|
+
* tests use for "a transition fired at all": the whole BODY is one
|
|
57
|
+
* router region in full-page mode, so this element -- and its
|
|
58
|
+
* `data-wp-watch` -- is torn down and re-created on every
|
|
59
|
+
* navigation, and its run *count* is therefore not a transition
|
|
60
|
+
* record. `state.log` itself is module state and survives the swap.
|
|
61
|
+
*/
|
|
62
|
+
get log() {
|
|
63
|
+
return JSON.stringify( state._log );
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
actions: {
|
|
67
|
+
navigate: withSyncEvent( function* ( e ) {
|
|
68
|
+
/*
|
|
69
|
+
* `e.preventDefault()` is not optional here either: without it,
|
|
70
|
+
* every click also performs a full page load, and the full-page
|
|
71
|
+
* document listener (`full-page.ts`) would also see the event,
|
|
72
|
+
* since it gates on `! event.defaultPrevented` -- which is what
|
|
73
|
+
* the block-action test relies on.
|
|
74
|
+
*/
|
|
75
|
+
e.preventDefault();
|
|
76
|
+
const { actions: router } =
|
|
77
|
+
yield import( '@wordpress/interactivity-router' );
|
|
78
|
+
yield router.navigate( e.target.href );
|
|
79
|
+
} ),
|
|
80
|
+
},
|
|
81
|
+
callbacks: {
|
|
82
|
+
/*
|
|
83
|
+
* The counted lifecycle observer, same shape as
|
|
84
|
+
* `router-navigation-lifecycle/view.js`'s `watchLifecycle`: reads
|
|
85
|
+
* *only* `routerState.navigating` and `routerState.initiator`, one
|
|
86
|
+
* entry per run.
|
|
87
|
+
*/
|
|
88
|
+
watchLifecycle() {
|
|
89
|
+
state._log.push( {
|
|
90
|
+
navigating: describeNavigating( routerState.navigating ),
|
|
91
|
+
initiator: describeInitiator( routerState.initiator ),
|
|
92
|
+
} );
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
} );
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://schemas.wp.org/trunk/block.json",
|
|
3
|
+
"apiVersion": 3,
|
|
4
|
+
"name": "test/router-navigation-lifecycle",
|
|
5
|
+
"title": "E2E Interactivity tests - router navigation lifecycle",
|
|
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
|
+
}
|