@wordpress/e2e-tests 9.21.0 → 10.0.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 +12 -0
- package/mu-plugins/e2e-fast-sync-polling.php +4 -4
- package/package.json +5 -6
- package/plugins/animated-image-subsizes.php +10 -0
- package/plugins/autosave-failures.php +144 -0
- package/plugins/block-bindings.php +5 -0
- package/plugins/entity-actions-api/close-comments.js +49 -0
- package/plugins/entity-actions-api.php +106 -0
- package/plugins/entity-fields-api/comment-status.css +24 -0
- package/plugins/entity-fields-api/comment-status.js +26 -0
- package/plugins/entity-fields-api/reading-time.css +21 -0
- package/plugins/entity-fields-api/reading-time.js +82 -0
- package/plugins/entity-fields-api.php +291 -0
- package/plugins/interactive-blocks/directive-html/block.json +15 -0
- package/plugins/interactive-blocks/directive-html/render.php +54 -0
- package/plugins/interactive-blocks/directive-html/view.asset.php +1 -0
- package/plugins/interactive-blocks/directive-html/view.js +39 -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/hydration-timing-async/view.js +1 -1
- package/plugins/interactive-blocks/router-html/block.json +19 -0
- package/plugins/interactive-blocks/router-html/render.php +64 -0
- package/plugins/interactive-blocks/router-html/view.asset.php +9 -0
- package/plugins/interactive-blocks/router-html/view.js +56 -0
- 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/interactive-blocks.php +12 -0
- package/plugins/lightbox-overlay-wrapper.php +25 -0
- package/plugins/react-18-compat-block/editor.js +38 -0
- package/plugins/rtc-websocket-provider/src/index.js +1 -1
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,303 @@
|
|
|
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
|
+
* region-based client-side navigation.
|
|
6
|
+
*
|
|
7
|
+
* This single fixture block is shared by every test of the
|
|
8
|
+
* `router-navigation-lifecycle` e2e spec, so it supports more attributes
|
|
9
|
+
* than any one test exercises. The spec's `beforeAll` lists the published
|
|
10
|
+
* pages and which attribute combination each one uses.
|
|
11
|
+
*
|
|
12
|
+
* @package gutenberg-test-interactive-blocks
|
|
13
|
+
*
|
|
14
|
+
* @phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
if ( isset( $attributes['disableNavigation'] ) && $attributes['disableNavigation'] ) {
|
|
18
|
+
wp_interactivity_config(
|
|
19
|
+
'core/router',
|
|
20
|
+
array( 'clientNavigationDisabled' => true )
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
$page = $attributes['page'] ?? '';
|
|
25
|
+
|
|
26
|
+
// Seeded into this block's own server context so `server-context-readout`
|
|
27
|
+
// below is driven by the real `parseServerData` -> `populateServerData`
|
|
28
|
+
// path rather than by static markup -- see the end-transition test and the "cascaded-commit
|
|
29
|
+
// absorption on the real server-context path" verifier it discharges.
|
|
30
|
+
wp_interactivity_state(
|
|
31
|
+
'router-navigation-lifecycle',
|
|
32
|
+
array( 'readout' => "server context for page {$page}" )
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
$next_href = $attributes['next'] ?? null;
|
|
36
|
+
$other_href = $attributes['other'] ?? null;
|
|
37
|
+
|
|
38
|
+
// Each entry describes one router region this block instance renders: its
|
|
39
|
+
// id, the href its own (unlabelled) "navigate" link targets, and whether it
|
|
40
|
+
// is the primary region -- the one that also carries the destination marker
|
|
41
|
+
// and the server-context readout.
|
|
42
|
+
$regions = array();
|
|
43
|
+
if ( isset( $attributes['regionId'] ) ) {
|
|
44
|
+
$regions[] = array(
|
|
45
|
+
'id' => $attributes['regionId'],
|
|
46
|
+
'navigate_href' => $next_href,
|
|
47
|
+
'is_primary' => true,
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
if ( isset( $attributes['secondRegionId'] ) ) {
|
|
51
|
+
$regions[] = array(
|
|
52
|
+
'id' => $attributes['secondRegionId'],
|
|
53
|
+
// The second region's own "navigate" link targets `other`, not
|
|
54
|
+
// `next` -- deliberately, so a cross-region flow has two distinct
|
|
55
|
+
// hrefs for the router's `navigatingTo` bail to separate. "Same
|
|
56
|
+
// structure as the first" stops here: every other link below keeps
|
|
57
|
+
// its usual meaning for both regions.
|
|
58
|
+
'navigate_href' => $other_href,
|
|
59
|
+
'is_primary' => false,
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
?>
|
|
63
|
+
<div data-wp-interactive="router-navigation-lifecycle">
|
|
64
|
+
<?php if ( empty( $attributes['observerOnly'] ) ) : ?>
|
|
65
|
+
<?php
|
|
66
|
+
foreach ( $regions as $region ) :
|
|
67
|
+
$region_id = $region['id'];
|
|
68
|
+
$navigate_href = $region['navigate_href'];
|
|
69
|
+
$context = wp_interactivity_data_wp_context( array( 'regionId' => $region_id ) );
|
|
70
|
+
?>
|
|
71
|
+
<?php
|
|
72
|
+
/*
|
|
73
|
+
* Note: `data-wp-interactive` is repeated here even
|
|
74
|
+
* though the outer wrapper above already carries it. Do not
|
|
75
|
+
* "simplify" this away. The directive runtime's own hydration
|
|
76
|
+
* resolves the namespace from any ancestor, so omitting it here
|
|
77
|
+
* looks like it still works on first load -- links click,
|
|
78
|
+
* `data-wp-text` renders, everything hydrates fine. What breaks
|
|
79
|
+
* is silent: `interactivity-router`'s own region-detection
|
|
80
|
+
* selector (`regionsSelector` in
|
|
81
|
+
* `packages/interactivity-router/src/index.ts`) is
|
|
82
|
+
* `[data-wp-interactive][data-wp-router-region], [data-wp-interactive] [data-wp-interactive][data-wp-router-region]`
|
|
83
|
+
* -- it requires the *region-bearing element itself* to carry
|
|
84
|
+
* `data-wp-interactive`, not merely an ancestor. Without it,
|
|
85
|
+
* `preparePage()` never registers this element under
|
|
86
|
+
* `page.regions` for *any* page, including the very first one,
|
|
87
|
+
* so every navigation resets this region's signal to `null` and
|
|
88
|
+
* never repopulates it -- the region's entire content silently
|
|
89
|
+
* disappears after the first client-side navigation.
|
|
90
|
+
*/
|
|
91
|
+
?>
|
|
92
|
+
<div
|
|
93
|
+
data-testid="region-<?php echo esc_attr( $region_id ); ?>"
|
|
94
|
+
data-wp-interactive="router-navigation-lifecycle"
|
|
95
|
+
data-wp-router-region="<?php echo esc_attr( $region_id ); ?>"
|
|
96
|
+
data-wp-class--is-origin="state.isOrigin"
|
|
97
|
+
<?php echo $context; ?>
|
|
98
|
+
>
|
|
99
|
+
<?php if ( isset( $navigate_href ) ) : ?>
|
|
100
|
+
<a
|
|
101
|
+
data-testid="navigate"
|
|
102
|
+
data-wp-on--click="actions.navigate"
|
|
103
|
+
href="<?php echo esc_url( $navigate_href ); ?>"
|
|
104
|
+
>navigate</a>
|
|
105
|
+
<?php endif; ?>
|
|
106
|
+
|
|
107
|
+
<?php
|
|
108
|
+
/*
|
|
109
|
+
* `refresh` takes its href from `window.location.href` at
|
|
110
|
+
* click time, not from an attribute, so it renders on every
|
|
111
|
+
* page regardless of `next`/`other` -- which is what lets
|
|
112
|
+
* the superseded-navigation part of the uncached-traversal
|
|
113
|
+
* test start a navigation from page 2.
|
|
114
|
+
*/
|
|
115
|
+
?>
|
|
116
|
+
<a
|
|
117
|
+
data-testid="refresh"
|
|
118
|
+
data-wp-on--click="actions.refresh"
|
|
119
|
+
href="#"
|
|
120
|
+
>refresh</a>
|
|
121
|
+
|
|
122
|
+
<?php if ( isset( $next_href ) ) : ?>
|
|
123
|
+
<a
|
|
124
|
+
data-testid="navigate (silent)"
|
|
125
|
+
data-wp-on--click="actions.navigateSilent"
|
|
126
|
+
href="<?php echo esc_url( $next_href ); ?>"
|
|
127
|
+
>navigate (silent)</a>
|
|
128
|
+
<a
|
|
129
|
+
data-testid="navigate (declared)"
|
|
130
|
+
data-wp-on--click="actions.navigateDeclared"
|
|
131
|
+
href="<?php echo esc_url( $next_href ); ?>"
|
|
132
|
+
>navigate (declared)</a>
|
|
133
|
+
<a
|
|
134
|
+
data-testid="navigate (suppressed)"
|
|
135
|
+
data-wp-on--click="actions.navigateSuppressed"
|
|
136
|
+
href="<?php echo esc_url( $next_href ); ?>"
|
|
137
|
+
>navigate (suppressed)</a>
|
|
138
|
+
<a
|
|
139
|
+
data-testid="navigate (timeout)"
|
|
140
|
+
data-wp-on--click="actions.navigateTimeout"
|
|
141
|
+
href="<?php echo esc_url( $next_href ); ?>"
|
|
142
|
+
>navigate (timeout)</a>
|
|
143
|
+
<a
|
|
144
|
+
data-testid="prefetch"
|
|
145
|
+
data-wp-on--click="actions.prefetch"
|
|
146
|
+
href="<?php echo esc_url( $next_href ); ?>"
|
|
147
|
+
>prefetch</a>
|
|
148
|
+
<?php endif; ?>
|
|
149
|
+
|
|
150
|
+
<?php if ( isset( $other_href ) ) : ?>
|
|
151
|
+
<a
|
|
152
|
+
data-testid="navigate (other)"
|
|
153
|
+
data-wp-on--click="actions.navigate"
|
|
154
|
+
href="<?php echo esc_url( $other_href ); ?>"
|
|
155
|
+
>navigate (other)</a>
|
|
156
|
+
<?php endif; ?>
|
|
157
|
+
|
|
158
|
+
<?php if ( $region['is_primary'] ) : ?>
|
|
159
|
+
<p data-testid="page-marker">page marker: <?php echo esc_html( $page ); ?></p>
|
|
160
|
+
<p
|
|
161
|
+
data-testid="server-context-readout"
|
|
162
|
+
data-wp-text="state.readout"
|
|
163
|
+
>not hydrated</p>
|
|
164
|
+
<?php endif; ?>
|
|
165
|
+
|
|
166
|
+
<?php
|
|
167
|
+
/*
|
|
168
|
+
* Per-block spinner demonstration: a per-block spinner
|
|
169
|
+
* that shows only while *this* region's own navigation is
|
|
170
|
+
* in flight. `state.isLoading` reads `getContext().regionId`
|
|
171
|
+
* the same way `state.isOrigin` above does, so one getter
|
|
172
|
+
* serves every region on the page.
|
|
173
|
+
*/
|
|
174
|
+
?>
|
|
175
|
+
<span
|
|
176
|
+
data-testid="spinner-<?php echo esc_attr( $region_id ); ?>"
|
|
177
|
+
data-wp-class--is-loading="state.isLoading"
|
|
178
|
+
></span>
|
|
179
|
+
|
|
180
|
+
<?php
|
|
181
|
+
/*
|
|
182
|
+
* Region-scoped focus demonstration: a third `data-wp-watch`
|
|
183
|
+
* (never run-counted), one per region, edge-triggered on the
|
|
184
|
+
* `navigating` reading and scoped so it can read its own
|
|
185
|
+
* `regionId` from context. See `watchFocus()` in `view.js`
|
|
186
|
+
* for why its previous-`navigating` bookkeeping is kept
|
|
187
|
+
* outside `context` rather than in it.
|
|
188
|
+
*/
|
|
189
|
+
?>
|
|
190
|
+
<span
|
|
191
|
+
data-testid="focus-watcher-<?php echo esc_attr( $region_id ); ?>"
|
|
192
|
+
data-wp-watch="callbacks.watchFocus"
|
|
193
|
+
></span>
|
|
194
|
+
</div>
|
|
195
|
+
<?php endforeach; ?>
|
|
196
|
+
|
|
197
|
+
<?php if ( ! empty( $attributes['nested'] ) ) : ?>
|
|
198
|
+
<?php
|
|
199
|
+
/*
|
|
200
|
+
* Nested-regions fixture: an `inner-region` nested inside an
|
|
201
|
+
* `outer-region`, with the `navigate` link inside the inner
|
|
202
|
+
* one, so a derivation that walks to the *outermost* region
|
|
203
|
+
* (the reading a writer might reach for "because the router
|
|
204
|
+
* treats the outer region as the update unit") reads
|
|
205
|
+
* `outer-region` instead of the correct nearest-enclosing
|
|
206
|
+
* `inner-region`. Both posts using `nested` render the same
|
|
207
|
+
* two ids, so the router updates both regions on navigation.
|
|
208
|
+
*
|
|
209
|
+
* Note (see above): both the outer and the inner
|
|
210
|
+
* region element carry `data-wp-interactive` on *themselves*,
|
|
211
|
+
* not only on an ancestor -- `regionsSelector` requires it on
|
|
212
|
+
* the region-bearing element itself.
|
|
213
|
+
*/
|
|
214
|
+
?>
|
|
215
|
+
<div
|
|
216
|
+
data-testid="region-outer-region"
|
|
217
|
+
data-wp-interactive="router-navigation-lifecycle"
|
|
218
|
+
data-wp-router-region="outer-region"
|
|
219
|
+
>
|
|
220
|
+
<div
|
|
221
|
+
data-testid="region-inner-region"
|
|
222
|
+
data-wp-interactive="router-navigation-lifecycle"
|
|
223
|
+
data-wp-router-region="inner-region"
|
|
224
|
+
>
|
|
225
|
+
<?php if ( isset( $next_href ) ) : ?>
|
|
226
|
+
<a
|
|
227
|
+
data-testid="navigate"
|
|
228
|
+
data-wp-on--click="actions.navigate"
|
|
229
|
+
href="<?php echo esc_url( $next_href ); ?>"
|
|
230
|
+
>navigate</a>
|
|
231
|
+
<?php endif; ?>
|
|
232
|
+
</div>
|
|
233
|
+
</div>
|
|
234
|
+
<?php endif; ?>
|
|
235
|
+
<?php endif; ?>
|
|
236
|
+
|
|
237
|
+
<!--
|
|
238
|
+
The observer readout: rendered on every page, including
|
|
239
|
+
`observerOnly`. The two watchers live on their own elements, each --
|
|
240
|
+
not sharing one, since directives at one priority level on one
|
|
241
|
+
element share a scope object.
|
|
242
|
+
-->
|
|
243
|
+
<p
|
|
244
|
+
data-testid="lifecycle log"
|
|
245
|
+
data-wp-watch="callbacks.watchLifecycle"
|
|
246
|
+
data-wp-text="state.log"
|
|
247
|
+
>not hydrated</p>
|
|
248
|
+
<p
|
|
249
|
+
data-testid="settlement log"
|
|
250
|
+
data-wp-watch="callbacks.watchSettlement"
|
|
251
|
+
data-wp-text="state.settlementLog"
|
|
252
|
+
>not hydrated</p>
|
|
253
|
+
<p data-testid="lifecycle navigating" data-wp-text="state.navigatingReading">not hydrated</p>
|
|
254
|
+
<p data-testid="lifecycle initiator" data-wp-text="state.initiatorReading">not hydrated</p>
|
|
255
|
+
|
|
256
|
+
<span data-testid="bind-aria-busy" data-wp-bind--aria-busy="state.navigating"></span>
|
|
257
|
+
<span data-testid="bind-class-busy" data-wp-class--busy="state.navigating"></span>
|
|
258
|
+
|
|
259
|
+
<?php
|
|
260
|
+
/*
|
|
261
|
+
* The two `hidden` bindings, deliberately opposite
|
|
262
|
+
* polarities on the same page. `bind-hidden-negated` is
|
|
263
|
+
* `!state.navigating` -- the spinner shape, visible only while
|
|
264
|
+
* navigating -- and `bind-hidden-plain` is the un-negated inverse. Do
|
|
265
|
+
* not "fix" either expression to make a failing assertion pass: a
|
|
266
|
+
* test written against an inverted expectation goes red against
|
|
267
|
+
* *correct* code here, and dropping the negation would plant the bug
|
|
268
|
+
* in the fixture instead of the test. Check polarity against
|
|
269
|
+
* `getEvaluate`/`bind.ts`'s handling of the `!` prefix and of `hidden`
|
|
270
|
+
* specifically (`packages/interactivity/src/hooks.tsx:249,283-284` and
|
|
271
|
+
* `packages/interactivity/src/directives/bind.ts:67-72`), not
|
|
272
|
+
* intuition.
|
|
273
|
+
*/
|
|
274
|
+
?>
|
|
275
|
+
<span data-testid="bind-hidden-negated" data-wp-bind--hidden="!state.navigating"></span>
|
|
276
|
+
<span data-testid="bind-hidden-plain" data-wp-bind--hidden="state.navigating"></span>
|
|
277
|
+
|
|
278
|
+
<?php
|
|
279
|
+
/*
|
|
280
|
+
* A replica of Core's WP 6.9 loading-bar markup, bound to the
|
|
281
|
+
* *public* `core/router` store's deprecated `state.navigation` getter --
|
|
282
|
+
* not the private store WP 7.0 binds instead. `data-wp-interactive` is
|
|
283
|
+
* repeated here (unlike the plain elements above) because this element
|
|
284
|
+
* switches namespace away from `router-navigation-lifecycle`, not
|
|
285
|
+
* because of the region-detection trap noted earlier in this file.
|
|
286
|
+
*/
|
|
287
|
+
?>
|
|
288
|
+
<div
|
|
289
|
+
data-testid="loading-bar"
|
|
290
|
+
data-wp-interactive="core/router"
|
|
291
|
+
data-wp-class--start-animation="state.navigation.hasStarted"
|
|
292
|
+
data-wp-class--finish-animation="state.navigation.hasFinished"
|
|
293
|
+
></div>
|
|
294
|
+
|
|
295
|
+
<?php
|
|
296
|
+
/*
|
|
297
|
+
* A Core-loading-bar equivalent, rebuilt purely from the new
|
|
298
|
+
* public keys plus a consumer-side 400 ms debounce -- see the bare
|
|
299
|
+
* `watch()` call in `view.js` that writes `state.showBar`.
|
|
300
|
+
*/
|
|
301
|
+
?>
|
|
302
|
+
<span data-testid="debounced-bar" data-wp-class--show-bar="state.showBar"></span>
|
|
303
|
+
</div>
|