@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,383 @@
|
|
|
1
|
+
import {
|
|
2
|
+
store,
|
|
3
|
+
withSyncEvent,
|
|
4
|
+
getContext,
|
|
5
|
+
getServerState,
|
|
6
|
+
watch,
|
|
7
|
+
} from '@wordpress/interactivity';
|
|
8
|
+
|
|
9
|
+
/*
|
|
10
|
+
* A short timeout for the `navigate (timeout)` link's action. It only needs
|
|
11
|
+
* to be short enough that a route held open indefinitely by a test triggers
|
|
12
|
+
* the router's own timeout fallback well within a test's default timeout.
|
|
13
|
+
*/
|
|
14
|
+
const NAVIGATE_TIMEOUT = 100;
|
|
15
|
+
|
|
16
|
+
/*
|
|
17
|
+
* `core/router` is *read*, never imported: this namespace is auto-created by
|
|
18
|
+
* the store proxy and later merges into the very same proxy the router
|
|
19
|
+
* module registers, once (and if) that module loads. That is what makes
|
|
20
|
+
* the router-absent page meaningful -- these
|
|
21
|
+
* getters must be safe to read before the router exists.
|
|
22
|
+
*/
|
|
23
|
+
const { state: routerState } = store( 'core/router' );
|
|
24
|
+
|
|
25
|
+
/*
|
|
26
|
+
* Both logs below live *inside* the store's reactive `state`, as plain
|
|
27
|
+
* arrays under `state._log` / `state._settlementLog`, rather than as
|
|
28
|
+
* module-scope variables: mutating a module-scope array is invisible to the
|
|
29
|
+
* signals system, so nothing would ever mark `state.log` / `state.settlementLog`
|
|
30
|
+
* dirty and their `data-wp-text` readouts would render once, at hydration,
|
|
31
|
+
* and never again. Pushing into an array that is itself part of the
|
|
32
|
+
* reactive state (the same shape `state.items.push( … )` uses in
|
|
33
|
+
* `router-regions/view.js`) does notify.
|
|
34
|
+
*/
|
|
35
|
+
let previousNavigating = false;
|
|
36
|
+
|
|
37
|
+
/*
|
|
38
|
+
* Per-region previous-`navigating` bookkeeping for the region-scoped
|
|
39
|
+
* focus demo, keyed by region id. A plain module-scope object, not `context`: `watchFocus()` below
|
|
40
|
+
* both reads and writes it in the same run, and reading it through the
|
|
41
|
+
* reactive `context` proxy would subscribe that same effect to its own
|
|
42
|
+
* write, re-triggering it. It also has to live outside any one region's
|
|
43
|
+
* DOM, since the region element it would otherwise sit on can be torn
|
|
44
|
+
* down and recreated by a client-side navigation while this module stays
|
|
45
|
+
* loaded -- the same reason `previousNavigating` above is module scope
|
|
46
|
+
* rather than an element-local variable.
|
|
47
|
+
*/
|
|
48
|
+
const focusWasNavigating = {};
|
|
49
|
+
|
|
50
|
+
/*
|
|
51
|
+
* Debounce timer for the loading-bar-equivalent demo, for the bare
|
|
52
|
+
* `watch()` registered near the bottom of this file.
|
|
53
|
+
*/
|
|
54
|
+
let debounceTimer;
|
|
55
|
+
|
|
56
|
+
/*
|
|
57
|
+
* Raw lifecycle-write log. Unlike the counted `data-wp-watch` observer, a
|
|
58
|
+
* bare `watch()` runs synchronously for each notification, so it can observe
|
|
59
|
+
* the discharge immediately before this document is replaced.
|
|
60
|
+
*/
|
|
61
|
+
const rawWriteLog = [];
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Renders a `navigating` value the same way for the counted log and for the
|
|
65
|
+
* `lifecycle navigating` readout. `undefined` (never navigated) and `false`
|
|
66
|
+
* both read "not navigating", matching the tests' own wording -- the
|
|
67
|
+
* distinction between them is only ever observable through the four
|
|
68
|
+
* directive-bound elements (`state.navigating`, the raw value), not through
|
|
69
|
+
* this human-readable form.
|
|
70
|
+
*
|
|
71
|
+
* @param {boolean|undefined} navigating
|
|
72
|
+
* @return {string} The human-readable reading.
|
|
73
|
+
*/
|
|
74
|
+
function describeNavigating( navigating ) {
|
|
75
|
+
return navigating ? 'navigating' : 'not navigating';
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Renders an `initiator` value the same way for the counted log and for the
|
|
80
|
+
* `lifecycle initiator` readout. `undefined` (never set) and `null` (an
|
|
81
|
+
* explicit "no initiator", see `{ initiator: null }`) are deliberately not
|
|
82
|
+
* distinguished here: both are the documented "absence of identity"
|
|
83
|
+
* reading.
|
|
84
|
+
*
|
|
85
|
+
* @param {string|null|undefined} initiator
|
|
86
|
+
* @return {string} The human-readable reading.
|
|
87
|
+
*/
|
|
88
|
+
function describeInitiator( initiator ) {
|
|
89
|
+
return initiator === undefined || initiator === null ? 'absent' : initiator;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const { state } = store( 'router-navigation-lifecycle', {
|
|
93
|
+
state: {
|
|
94
|
+
// Backing arrays for the two serialized logs -- see the comment
|
|
95
|
+
// above on why these must live inside `state`, not at module scope.
|
|
96
|
+
_log: [],
|
|
97
|
+
_settlementLog: [],
|
|
98
|
+
|
|
99
|
+
// Debounced-bar flag for the loading-bar-equivalent demo. Declared with an idle default and
|
|
100
|
+
// written directly (never derived), unlike `navigating`/`initiator`
|
|
101
|
+
// below -- this is *this* store's own state, not a passthrough of
|
|
102
|
+
// `core/router`'s, so none of the "don't declare" reasoning applies.
|
|
103
|
+
showBar: false,
|
|
104
|
+
|
|
105
|
+
/*
|
|
106
|
+
* Raw passthroughs of the router's own state, for the four
|
|
107
|
+
* directive-bound elements asserted before the first navigation. These need the real
|
|
108
|
+
* `boolean | undefined` value, not the human-readable text below,
|
|
109
|
+
* because their whole point is to exercise `data-wp-bind`'s and
|
|
110
|
+
* `data-wp-class`'s real boolean/undefined handling.
|
|
111
|
+
*/
|
|
112
|
+
get navigating() {
|
|
113
|
+
return routerState.navigating;
|
|
114
|
+
},
|
|
115
|
+
get initiator() {
|
|
116
|
+
return routerState.initiator;
|
|
117
|
+
},
|
|
118
|
+
|
|
119
|
+
// Human-readable readouts for `data-testid="lifecycle navigating"`
|
|
120
|
+
// and `data-testid="lifecycle initiator"`.
|
|
121
|
+
get navigatingReading() {
|
|
122
|
+
return describeNavigating( routerState.navigating );
|
|
123
|
+
},
|
|
124
|
+
get initiatorReading() {
|
|
125
|
+
return describeInitiator( routerState.initiator );
|
|
126
|
+
},
|
|
127
|
+
|
|
128
|
+
/*
|
|
129
|
+
* `true` only while a navigation *this* element's own region
|
|
130
|
+
* initiated is in flight. Context-dependent so the same getter
|
|
131
|
+
* serves every region: each region co-renders its own id into
|
|
132
|
+
* `data-wp-context`, and this getter reads it back.
|
|
133
|
+
*/
|
|
134
|
+
get isOrigin() {
|
|
135
|
+
const { regionId } = getContext();
|
|
136
|
+
return (
|
|
137
|
+
!! routerState.navigating && routerState.initiator === regionId
|
|
138
|
+
);
|
|
139
|
+
},
|
|
140
|
+
|
|
141
|
+
/*
|
|
142
|
+
* Per-block spinner demonstration: `true` only while a
|
|
143
|
+
* navigation *this* region's own element initiated is in flight.
|
|
144
|
+
* Computationally identical to `isOrigin` above -- both are the
|
|
145
|
+
* documented composition `state.navigating && state.initiator ===
|
|
146
|
+
* myRegionId` -- but kept as its own getter because it stands in
|
|
147
|
+
* for a real consumer's own per-block spinner, built from only the
|
|
148
|
+
* two public keys and `getContext()`, independent of the
|
|
149
|
+
* `isOrigin`/`is-origin` scaffolding used by the earlier identity tests.
|
|
150
|
+
*/
|
|
151
|
+
get isLoading() {
|
|
152
|
+
const { regionId } = getContext();
|
|
153
|
+
return (
|
|
154
|
+
!! routerState.navigating && routerState.initiator === regionId
|
|
155
|
+
);
|
|
156
|
+
},
|
|
157
|
+
|
|
158
|
+
/*
|
|
159
|
+
* Serialized logs. A serialized array, rather than a hand-rolled
|
|
160
|
+
* delimited string, so a spec can `JSON.parse` the readout and
|
|
161
|
+
* assert on entry count and contents structurally.
|
|
162
|
+
*/
|
|
163
|
+
get log() {
|
|
164
|
+
return JSON.stringify( state._log );
|
|
165
|
+
},
|
|
166
|
+
get settlementLog() {
|
|
167
|
+
return JSON.stringify( state._settlementLog );
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
actions: {
|
|
171
|
+
navigate: withSyncEvent( function* ( e ) {
|
|
172
|
+
e.preventDefault();
|
|
173
|
+
const { actions: router } =
|
|
174
|
+
yield import( '@wordpress/interactivity-router' );
|
|
175
|
+
yield router.navigate( e.target.href );
|
|
176
|
+
} ),
|
|
177
|
+
navigateSilent: withSyncEvent( function* ( e ) {
|
|
178
|
+
e.preventDefault();
|
|
179
|
+
const { actions: router } =
|
|
180
|
+
yield import( '@wordpress/interactivity-router' );
|
|
181
|
+
yield router.navigate( e.target.href, {
|
|
182
|
+
loadingAnimation: false,
|
|
183
|
+
screenReaderAnnouncement: false,
|
|
184
|
+
} );
|
|
185
|
+
} ),
|
|
186
|
+
refresh: withSyncEvent( function* ( e ) {
|
|
187
|
+
e.preventDefault();
|
|
188
|
+
const { actions: router } =
|
|
189
|
+
yield import( '@wordpress/interactivity-router' );
|
|
190
|
+
yield router.navigate( window.location.href, { force: true } );
|
|
191
|
+
} ),
|
|
192
|
+
navigateDeclared: withSyncEvent( function* ( e ) {
|
|
193
|
+
e.preventDefault();
|
|
194
|
+
const { actions: router } =
|
|
195
|
+
yield import( '@wordpress/interactivity-router' );
|
|
196
|
+
yield router.navigate( e.target.href, {
|
|
197
|
+
initiator: 'my-plugin/declared',
|
|
198
|
+
} );
|
|
199
|
+
} ),
|
|
200
|
+
navigateSuppressed: withSyncEvent( function* ( e ) {
|
|
201
|
+
e.preventDefault();
|
|
202
|
+
const { actions: router } =
|
|
203
|
+
yield import( '@wordpress/interactivity-router' );
|
|
204
|
+
yield router.navigate( e.target.href, { initiator: null } );
|
|
205
|
+
} ),
|
|
206
|
+
navigateTimeout: withSyncEvent( function* ( e ) {
|
|
207
|
+
e.preventDefault();
|
|
208
|
+
const { actions: router } =
|
|
209
|
+
yield import( '@wordpress/interactivity-router' );
|
|
210
|
+
yield router.navigate( e.target.href, {
|
|
211
|
+
timeout: NAVIGATE_TIMEOUT,
|
|
212
|
+
} );
|
|
213
|
+
} ),
|
|
214
|
+
prefetch: withSyncEvent( function* ( e ) {
|
|
215
|
+
e.preventDefault();
|
|
216
|
+
const { actions: router } =
|
|
217
|
+
yield import( '@wordpress/interactivity-router' );
|
|
218
|
+
yield router.prefetch( e.target.href );
|
|
219
|
+
} ),
|
|
220
|
+
},
|
|
221
|
+
callbacks: {
|
|
222
|
+
/*
|
|
223
|
+
* The counted lifecycle observer. Reads *only*
|
|
224
|
+
* `routerState.navigating` and `routerState.initiator`, so it never
|
|
225
|
+
* re-runs at the commit batch, which writes `state.url` while
|
|
226
|
+
* `navigating` is still truthy.
|
|
227
|
+
*/
|
|
228
|
+
watchLifecycle() {
|
|
229
|
+
state._log.push( {
|
|
230
|
+
navigating: describeNavigating( routerState.navigating ),
|
|
231
|
+
initiator: describeInitiator( routerState.initiator ),
|
|
232
|
+
} );
|
|
233
|
+
},
|
|
234
|
+
/*
|
|
235
|
+
* The settlement probe. Edge-triggered: appends an entry only the
|
|
236
|
+
* moment `navigating` turns falsy, recording `routerState.url`, the
|
|
237
|
+
* destination marker's text and the server-context readout's text
|
|
238
|
+
* at that moment -- both read directly from the DOM, since this
|
|
239
|
+
* watcher's whole point is to observe the *committed* page rather
|
|
240
|
+
* than any reactive value of its own.
|
|
241
|
+
*
|
|
242
|
+
* Note: `populateServerData()` merges each navigation's
|
|
243
|
+
* server state with `override: false`
|
|
244
|
+
* (`packages/interactivity/src/proxies/state.ts:378-389`), so an
|
|
245
|
+
* *existing* key such as `state.readout` is never overwritten
|
|
246
|
+
* automatically on a later navigation -- only genuinely new keys
|
|
247
|
+
* are. Binding `data-wp-text="state.readout"` and expecting it to
|
|
248
|
+
* track each destination's own server-seeded value, with no further
|
|
249
|
+
* code, looked correct through hydration and the first page but
|
|
250
|
+
* silently kept showing the *first* page's value forever after.
|
|
251
|
+
* A consumer that wants a key to track the destination's
|
|
252
|
+
* own server-seeded value must re-sync it itself from
|
|
253
|
+
* `getServerState()`, the documented pattern
|
|
254
|
+
* (`router-regions/view.js`'s `updateCounterFromServer` does the
|
|
255
|
+
* same for context). Doing that sync here, as this callback's first
|
|
256
|
+
* statement, keeps the write and the DOM read that discharges the
|
|
257
|
+
* falling edge in one synchronous callback -- `@preact/signals`'
|
|
258
|
+
* text bindings update the DOM synchronously on write, so there is
|
|
259
|
+
* no cross-watcher race to get this wrong.
|
|
260
|
+
*/
|
|
261
|
+
watchSettlement() {
|
|
262
|
+
const serverReadout = getServerState().readout;
|
|
263
|
+
if ( serverReadout !== undefined ) {
|
|
264
|
+
state.readout = serverReadout;
|
|
265
|
+
}
|
|
266
|
+
const navigating = !! routerState.navigating;
|
|
267
|
+
if ( previousNavigating && ! navigating ) {
|
|
268
|
+
const marker = document.querySelector(
|
|
269
|
+
'[data-testid="page-marker"]'
|
|
270
|
+
);
|
|
271
|
+
const readout = document.querySelector(
|
|
272
|
+
'[data-testid="server-context-readout"]'
|
|
273
|
+
);
|
|
274
|
+
state._settlementLog.push( {
|
|
275
|
+
url: routerState.url,
|
|
276
|
+
marker: marker ? marker.textContent : null,
|
|
277
|
+
serverContextReadout: readout ? readout.textContent : null,
|
|
278
|
+
} );
|
|
279
|
+
}
|
|
280
|
+
previousNavigating = navigating;
|
|
281
|
+
},
|
|
282
|
+
/*
|
|
283
|
+
* Region-scoped focus demonstration. Edge-
|
|
284
|
+
* triggered like `watchSettlement` above, but per-instance -- it
|
|
285
|
+
* lives on its own element inside *each* region (a third
|
|
286
|
+
* `data-wp-watch`, never run-counted), so it is scoped and can read
|
|
287
|
+
* its own `regionId` from context. Only fires on the falling edge
|
|
288
|
+
* when `initiator` still reads as *this* region's own id, which is
|
|
289
|
+
* what makes it refrain on a traversal (`initiator` reads absent
|
|
290
|
+
* there). No DOM reference is captured across the navigation: the
|
|
291
|
+
* target link is looked up fresh, by region id, only once the
|
|
292
|
+
* falling edge actually fires -- never stored ahead of time.
|
|
293
|
+
*/
|
|
294
|
+
watchFocus() {
|
|
295
|
+
const { regionId } = getContext();
|
|
296
|
+
const navigating = !! routerState.navigating;
|
|
297
|
+
if (
|
|
298
|
+
focusWasNavigating[ regionId ] &&
|
|
299
|
+
! navigating &&
|
|
300
|
+
routerState.initiator === regionId
|
|
301
|
+
) {
|
|
302
|
+
document
|
|
303
|
+
.querySelector(
|
|
304
|
+
`[data-wp-router-region="${ regionId }"] a`
|
|
305
|
+
)
|
|
306
|
+
?.focus();
|
|
307
|
+
}
|
|
308
|
+
focusWasNavigating[ regionId ] = navigating;
|
|
309
|
+
},
|
|
310
|
+
},
|
|
311
|
+
} );
|
|
312
|
+
|
|
313
|
+
/*
|
|
314
|
+
* Loading-bar-equivalent demonstration: a Core-loading-bar equivalent,
|
|
315
|
+
* rebuilt purely from the two public keys plus a consumer-side 400 ms
|
|
316
|
+
* debounce -- the debounced loading bar recipe from the Client-Side
|
|
317
|
+
* Navigation guide. A bare `watch()`, not a
|
|
318
|
+
* `data-wp-watch`: the timer callback writes this store's own `state`
|
|
319
|
+
* (`showBar`), not `context`, so it needs no scope at all.
|
|
320
|
+
*/
|
|
321
|
+
watch( () => {
|
|
322
|
+
if ( routerState.navigating ) {
|
|
323
|
+
debounceTimer = setTimeout( () => {
|
|
324
|
+
state.showBar = true;
|
|
325
|
+
}, 400 );
|
|
326
|
+
} else {
|
|
327
|
+
clearTimeout( debounceTimer );
|
|
328
|
+
state.showBar = false;
|
|
329
|
+
}
|
|
330
|
+
} );
|
|
331
|
+
|
|
332
|
+
watch( () => {
|
|
333
|
+
rawWriteLog.push( {
|
|
334
|
+
navigating: routerState.navigating,
|
|
335
|
+
initiator: routerState.initiator,
|
|
336
|
+
} );
|
|
337
|
+
} );
|
|
338
|
+
|
|
339
|
+
/*
|
|
340
|
+
* Persists the counted log to `localStorage` right before this document is
|
|
341
|
+
* torn down, so a test can recover the *outgoing* document's last known
|
|
342
|
+
* state after a forced full page load -- even one triggered by a
|
|
343
|
+
* `window.location.assign()` / `.reload()` call whose own network request
|
|
344
|
+
* was intercepted (held or aborted) via Playwright's `page.route()`.
|
|
345
|
+
*
|
|
346
|
+
* This exists because holding a main-frame document request open, or
|
|
347
|
+
* aborting it, are both equally unable to keep the outgoing document's
|
|
348
|
+
* execution context alive and assertable in this environment. `pagehide`
|
|
349
|
+
* and `beforeunload`, by contrast, were confirmed (by a standalone probe
|
|
350
|
+
* against this same environment) to fire reliably even when the
|
|
351
|
+
* *outgoing* navigation's own request is aborted, and `localStorage`
|
|
352
|
+
* persists across the reload because the destination is same-origin. Both
|
|
353
|
+
* events are listened for, writing the same key, because a future
|
|
354
|
+
* navigation's exact treatment of an aborted vs. held request is not a
|
|
355
|
+
* guarantee this fixture should depend on.
|
|
356
|
+
*/
|
|
357
|
+
window.addEventListener( 'pagehide', persistLogBeforeUnload );
|
|
358
|
+
window.addEventListener( 'beforeunload', persistLogBeforeUnload );
|
|
359
|
+
function persistLogBeforeUnload() {
|
|
360
|
+
try {
|
|
361
|
+
localStorage.setItem(
|
|
362
|
+
'router-navigation-lifecycle:log-before-unload',
|
|
363
|
+
state.log
|
|
364
|
+
);
|
|
365
|
+
localStorage.setItem(
|
|
366
|
+
'router-navigation-lifecycle:raw-write-log-before-unload',
|
|
367
|
+
JSON.stringify( rawWriteLog )
|
|
368
|
+
);
|
|
369
|
+
} catch {}
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/*
|
|
373
|
+
* Module-scope, no directive scope at all: dynamically imports the router
|
|
374
|
+
* and navigates from an awaited continuation, for the scope-less
|
|
375
|
+
* programmatic navigation test. The destination is read off the already-rendered `navigate`
|
|
376
|
+
* link rather than hardcoded, so this works on any page carrying a region.
|
|
377
|
+
*/
|
|
378
|
+
window.addEventListener( '_test_navigate_scopeless_', async () => {
|
|
379
|
+
const link = document.querySelector( '[data-testid="navigate"]' );
|
|
380
|
+
const { actions: router } =
|
|
381
|
+
await import( '@wordpress/interactivity-router' );
|
|
382
|
+
await router.navigate( link.href );
|
|
383
|
+
} );
|
|
@@ -32,11 +32,9 @@
|
|
|
32
32
|
<div data-wp-interactive="tovdom-islands">
|
|
33
33
|
<div data-wp-ignore>
|
|
34
34
|
<div data-wp-show-mock="state.falseValue">
|
|
35
|
-
<span
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
This should be shown because it is inside an inner
|
|
39
|
-
block of an isolated island.
|
|
35
|
+
<span data-testid="inside an element with data-wp-ignore">
|
|
36
|
+
This should not be shown because data-wp-ignore no
|
|
37
|
+
longer prevents hydration.
|
|
40
38
|
</span>
|
|
41
39
|
</div>
|
|
42
40
|
</div>
|
|
@@ -60,15 +58,14 @@
|
|
|
60
58
|
<div>
|
|
61
59
|
<div
|
|
62
60
|
data-wp-interactive="tovdom-islands"
|
|
63
|
-
data-wp-ignore
|
|
64
61
|
>
|
|
65
62
|
<div data-wp-show-mock="state.falseValue">
|
|
66
63
|
<span
|
|
67
|
-
data-testid="island inside inner
|
|
64
|
+
data-testid="island inside an inner element of another island"
|
|
68
65
|
>
|
|
69
|
-
This should not be shown because
|
|
70
|
-
|
|
71
|
-
|
|
66
|
+
This should not be shown because it is inside a
|
|
67
|
+
new island nested in an inner element of another
|
|
68
|
+
island.
|
|
72
69
|
</span>
|
|
73
70
|
</div>
|
|
74
71
|
</div>
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
?>
|
|
8
8
|
|
|
9
|
-
<div data-wp-interactive="with-scope" data-wp-context='{"asyncCounter": 0, "syncCounter": 0}' data-wp-init
|
|
9
|
+
<div data-wp-interactive="with-scope" data-wp-context='{"asyncCounter": 0, "syncCounter": 0}' data-wp-init---a='callbacks.asyncInit' data-wp-init---b='callbacks.syncInit'>
|
|
10
10
|
<p data-wp-text="context.asyncCounter" data-testid="asyncCounter">0</p>
|
|
11
11
|
<p data-wp-text="context.syncCounter" data-testid="syncCounter">0</p>
|
|
12
12
|
</div>
|
|
@@ -36,3 +36,15 @@ add_action(
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
);
|
|
39
|
+
|
|
40
|
+
add_action(
|
|
41
|
+
'send_headers',
|
|
42
|
+
function () {
|
|
43
|
+
if (
|
|
44
|
+
isset( $_GET['require_trusted_types'] ) &&
|
|
45
|
+
'true' === $_GET['require_trusted_types']
|
|
46
|
+
) {
|
|
47
|
+
header( "Content-Security-Policy: require-trusted-types-for 'script'" );
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
/**
|
|
3
|
+
* Plugin Name: Gutenberg Test Lightbox Overlay Wrapper
|
|
4
|
+
* Plugin URI: https://github.com/WordPress/gutenberg
|
|
5
|
+
* Author: Gutenberg Team
|
|
6
|
+
*
|
|
7
|
+
* @package gutenberg-test-lightbox-overlay-wrapper
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Opens a wrapper around the page, so the lightbox overlay printed on
|
|
12
|
+
* `wp_footer` is not a direct child of `<body>`.
|
|
13
|
+
*/
|
|
14
|
+
function gutenberg_test_lightbox_overlay_wrapper_open() {
|
|
15
|
+
echo '<div id="site-wrap">';
|
|
16
|
+
}
|
|
17
|
+
add_action( 'wp_body_open', 'gutenberg_test_lightbox_overlay_wrapper_open' );
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Closes the wrapper after the lightbox overlay has been printed.
|
|
21
|
+
*/
|
|
22
|
+
function gutenberg_test_lightbox_overlay_wrapper_close() {
|
|
23
|
+
echo '</div>';
|
|
24
|
+
}
|
|
25
|
+
add_action( 'wp_footer', 'gutenberg_test_lightbox_overlay_wrapper_close', 100 );
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
( function () {
|
|
2
2
|
const { registerBlockType } = wp.blocks;
|
|
3
3
|
const { useBlockProps } = wp.blockEditor;
|
|
4
|
+
const { createElement, memo } = wp.element;
|
|
4
5
|
|
|
5
6
|
// The externalized React JSX runtime (the `react-jsx-runtime` script
|
|
6
7
|
// handle). When the React 19 experiment is enabled this is React 19's
|
|
@@ -89,6 +90,23 @@
|
|
|
89
90
|
label: 'Hello from defaultProps',
|
|
90
91
|
};
|
|
91
92
|
|
|
93
|
+
// The same, wrapped in `memo()`. React 18 resolved the inner component's
|
|
94
|
+
// `defaultProps` in `updateMemoComponent`, not at element creation, so no
|
|
95
|
+
// runtime ever wrote them into the element. All three ways of creating the
|
|
96
|
+
// element are exercised — the classic `createElement`, the externalized JSX
|
|
97
|
+
// runtime, and the bundled React 18 one — because the fix has to live in
|
|
98
|
+
// the reconciler to cover the last of them.
|
|
99
|
+
function MemoGreetingBase( props ) {
|
|
100
|
+
return jsx( 'span', {
|
|
101
|
+
className: props.className,
|
|
102
|
+
children: props.label,
|
|
103
|
+
} );
|
|
104
|
+
}
|
|
105
|
+
MemoGreetingBase.defaultProps = {
|
|
106
|
+
label: 'Hello from memo defaultProps',
|
|
107
|
+
};
|
|
108
|
+
const MemoGreeting = memo( MemoGreetingBase );
|
|
109
|
+
|
|
92
110
|
registerBlockType( 'test/react-18-compat-block', {
|
|
93
111
|
apiVersion: 3,
|
|
94
112
|
edit: function Edit() {
|
|
@@ -122,6 +140,26 @@
|
|
|
122
140
|
// The `defaultProps` component, created with the
|
|
123
141
|
// externalized React runtime.
|
|
124
142
|
jsx( Greeting, {}, 'greeting' ),
|
|
143
|
+
createElement( MemoGreeting, {
|
|
144
|
+
key: 'memo-greeting',
|
|
145
|
+
className: 'react-18-compat-block__memo-greeting',
|
|
146
|
+
} ),
|
|
147
|
+
jsx(
|
|
148
|
+
MemoGreeting,
|
|
149
|
+
{
|
|
150
|
+
className:
|
|
151
|
+
'react-18-compat-block__memo-greeting-jsx',
|
|
152
|
+
},
|
|
153
|
+
'memo-greeting-jsx'
|
|
154
|
+
),
|
|
155
|
+
jsxDEV(
|
|
156
|
+
MemoGreeting,
|
|
157
|
+
{
|
|
158
|
+
className:
|
|
159
|
+
'react-18-compat-block__memo-greeting-legacy',
|
|
160
|
+
},
|
|
161
|
+
'memo-greeting-legacy'
|
|
162
|
+
),
|
|
125
163
|
],
|
|
126
164
|
} );
|
|
127
165
|
},
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Test-only WebSocket sync provider for Gutenberg RTC e2e tests.
|
|
3
3
|
*
|
|
4
4
|
* Speaks the y-websocket binary protocol against test/e2e/bin/rtc-test-ws-sync-server.mjs
|
|
5
|
-
* (which is built on
|
|
5
|
+
* (which is built on `@y/websocket-server`) so the test harness exercises the same
|
|
6
6
|
* wire format as production deployments. Exposes a small debug surface on
|
|
7
7
|
* window.__gutenbergTestWebSocketSync.rooms that the Playwright fixtures poll.
|
|
8
8
|
*/
|