@wordpress/e2e-tests 9.20.0 → 9.20.1-next.v.202609171837.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.
@@ -0,0 +1,29 @@
1
+ <?php
2
+ /**
3
+ * MU-plugin: Speed up collaboration sync polling in e2e tests.
4
+ *
5
+ * The sync module reads its polling intervals via applyFilters at load time,
6
+ * so the filters must be registered before the wp-sync script executes.
7
+ * Hooked to admin_init so the wp-sync handle is already registered.
8
+ */
9
+ add_action(
10
+ 'enqueue_block_editor_assets',
11
+ function () {
12
+ wp_add_inline_script(
13
+ 'wp-sync',
14
+ <<<'JS'
15
+ wp.hooks.addFilter(
16
+ 'sync.pollingManager.pollingInterval',
17
+ 'e2e-tests',
18
+ () => 500
19
+ );
20
+ wp.hooks.addFilter(
21
+ 'sync.pollingManager.pollingIntervalWithCollaborators',
22
+ 'e2e-tests',
23
+ () => 100
24
+ );
25
+ JS,
26
+ 'before'
27
+ );
28
+ }
29
+ );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/e2e-tests",
3
- "version": "9.20.0",
3
+ "version": "9.20.1-next.v.202609171837.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",
@@ -24,8 +24,8 @@
24
24
  "npm": ">=8.19.2"
25
25
  },
26
26
  "dependencies": {
27
- "@wordpress/interactivity": "^6.55.0",
28
- "@wordpress/interactivity-router": "^2.55.0"
27
+ "@wordpress/interactivity": "^6.55.1-next.v.202609171837.0",
28
+ "@wordpress/interactivity-router": "^2.55.1-next.v.202609171837.0"
29
29
  },
30
30
  "devDependencies": {
31
31
  "y-websocket": "^3.0.0"
@@ -38,5 +38,5 @@
38
38
  "publishConfig": {
39
39
  "access": "public"
40
40
  },
41
- "gitHead": "485f42ae8a1c58ceea18371a507fd4acfa86fbd8"
41
+ "gitHead": "7fc9f6676debc888d2f071d17cb71837040d4b48"
42
42
  }
@@ -9,11 +9,11 @@
9
9
  * @package gutenberg-test-connectors-empty-state
10
10
  */
11
11
 
12
- // Remove the Gutenberg filter that provides default connector data.
12
+ // Remove the filter that provides default connector data.
13
13
  add_action(
14
14
  'init',
15
15
  static function () {
16
- remove_filter( 'script_module_data_options-connectors-wp-admin', '_gutenberg_get_connector_script_module_data' );
16
+ remove_filter( 'script_module_data_options-connectors-wp-admin', '_wp_connectors_get_connector_script_module_data' );
17
17
  },
18
18
  PHP_INT_MAX
19
19
  );
@@ -23,9 +23,9 @@ const { state, foo } = store( 'directive-bind', {
23
23
  'previousValue' in context
24
24
  ? context.previousValue
25
25
  : // Any string works here; we just want to toggle the value
26
- // to ensure Preact renders the same we are hydrating in the
27
- // first place.
28
- 'tacocat';
26
+ // to ensure Preact renders the same we are hydrating in the
27
+ // first place.
28
+ 'tacocat';
29
29
 
30
30
  context.previousValue = context.value;
31
31
  context.value = previousValue;
@@ -224,9 +224,8 @@ store( 'directive-each', {
224
224
  },
225
225
  actions: {
226
226
  *navigate() {
227
- const { actions } = yield import(
228
- '@wordpress/interactivity-router'
229
- );
227
+ const { actions } =
228
+ yield import( '@wordpress/interactivity-router' );
230
229
  return actions.navigate( window.location, {
231
230
  force: true,
232
231
  html,
@@ -15,9 +15,8 @@ const html = `
15
15
  store( 'directive-key', {
16
16
  actions: {
17
17
  *navigate() {
18
- const { actions } = yield import(
19
- '@wordpress/interactivity-router'
20
- );
18
+ const { actions } =
19
+ yield import( '@wordpress/interactivity-router' );
21
20
  return actions.navigate( window.location, {
22
21
  force: true,
23
22
  html,
@@ -62,9 +62,8 @@ const { state } = store( 'directive-run', {
62
62
  state.clickCount = state.clickCount + 1;
63
63
  },
64
64
  *navigate() {
65
- const { actions } = yield import(
66
- '@wordpress/interactivity-router'
67
- );
65
+ const { actions } =
66
+ yield import( '@wordpress/interactivity-router' );
68
67
  return actions.navigate( window.location, {
69
68
  force: true,
70
69
  html,
@@ -14,9 +14,8 @@ store( 'test/get-server-context', {
14
14
  actions: {
15
15
  navigate: withSyncEvent( function* ( e ) {
16
16
  e.preventDefault();
17
- const { actions } = yield import(
18
- '@wordpress/interactivity-router'
19
- );
17
+ const { actions } =
18
+ yield import( '@wordpress/interactivity-router' );
20
19
  yield actions.navigate( e.target.href );
21
20
  } ),
22
21
  attemptModification() {
@@ -9,9 +9,8 @@ const { state } = store( 'test/get-server-state', {
9
9
  actions: {
10
10
  navigate: withSyncEvent( function* ( e ) {
11
11
  e.preventDefault();
12
- const { actions } = yield import(
13
- '@wordpress/interactivity-router'
14
- );
12
+ const { actions } =
13
+ yield import( '@wordpress/interactivity-router' );
15
14
  yield actions.navigate( e.target.href );
16
15
  } ),
17
16
  attemptModification() {
@@ -25,9 +25,8 @@ const { state } = store( 'router', {
25
25
  const force = e.target.dataset.forceNavigation === 'true';
26
26
  const { timeout } = state;
27
27
 
28
- const { actions } = yield import(
29
- '@wordpress/interactivity-router'
30
- );
28
+ const { actions } =
29
+ yield import( '@wordpress/interactivity-router' );
31
30
 
32
31
  try {
33
32
  yield actions.navigate( e.target.href, { force, timeout } );
@@ -23,9 +23,8 @@ const { state } = store( 'router-regions', {
23
23
  router: {
24
24
  navigate: withSyncEvent( function* ( e ) {
25
25
  e.preventDefault();
26
- const { actions } = yield import(
27
- '@wordpress/interactivity-router'
28
- );
26
+ const { actions } =
27
+ yield import( '@wordpress/interactivity-router' );
29
28
  yield actions.navigate( e.target.href );
30
29
  } ),
31
30
  back: withSyncEvent( function* ( e ) {
@@ -9,17 +9,15 @@ const { state } = store( 'test/router-script-modules', {
9
9
  *navigate( e ) {
10
10
  e.preventDefault();
11
11
  state.clientSideNavigation = false;
12
- const { actions } = yield import(
13
- '@wordpress/interactivity-router'
14
- );
12
+ const { actions } =
13
+ yield import( '@wordpress/interactivity-router' );
15
14
  yield actions.navigate( e.target.href );
16
15
  state.clientSideNavigation = true;
17
16
  },
18
17
  *prefetch() {
19
18
  const { ref } = getElement();
20
- const { actions } = yield import(
21
- '@wordpress/interactivity-router'
22
- );
19
+ const { actions } =
20
+ yield import( '@wordpress/interactivity-router' );
23
21
  yield actions.prefetch( ref.href );
24
22
  },
25
23
  pushName( name ) {
@@ -10,27 +10,24 @@ const { state } = store( 'test/router-styles', {
10
10
  navigate: withSyncEvent( function* ( e ) {
11
11
  e.preventDefault();
12
12
  state.clientSideNavigation = false;
13
- const { actions } = yield import(
14
- '@wordpress/interactivity-router'
15
- );
13
+ const { actions } =
14
+ yield import( '@wordpress/interactivity-router' );
16
15
  yield actions.navigate( e.target.href );
17
16
  state.clientSideNavigation = true;
18
17
  } ),
19
18
  navigateForce: withSyncEvent( function* ( e ) {
20
19
  e.preventDefault();
21
20
  state.clientSideNavigation = false;
22
- const { actions } = yield import(
23
- '@wordpress/interactivity-router'
24
- );
21
+ const { actions } =
22
+ yield import( '@wordpress/interactivity-router' );
25
23
  yield actions.navigate( e.target.href, { force: true } );
26
24
  state.clientSideNavigation = true;
27
25
  } ),
28
26
  *prefetch() {
29
27
  state.prefetching = true;
30
28
  const { ref } = getElement();
31
- const { actions } = yield import(
32
- '@wordpress/interactivity-router'
33
- );
29
+ const { actions } =
30
+ yield import( '@wordpress/interactivity-router' );
34
31
  yield actions.prefetch( ref.href );
35
32
  state.prefetching = false;
36
33
  },
@@ -8,6 +8,7 @@
8
8
  */
9
9
 
10
10
  import { WebsocketProvider } from 'y-websocket';
11
+ import { setYjsModule } from './yjs-external';
11
12
 
12
13
  const TEST_PROVIDER_NAMESPACE = 'gutenberg-test/rtc-websocket-provider';
13
14
  const DEFAULT_URL = 'ws://127.0.0.1:18991';
@@ -37,7 +38,11 @@ function updateDebugState( room, patch ) {
37
38
  }
38
39
 
39
40
  function createWebSocketProvider() {
40
- return async ( { awareness, objectType, objectId, ydoc } ) => {
41
+ return async ( { awareness, objectType, objectId, ydoc, Y } ) => {
42
+ // Point the bundled y-websocket and y-protocols modules at the Yjs
43
+ // instance used by the editor. See yjs-external.js.
44
+ setYjsModule( Y );
45
+
41
46
  const room = objectId ? `${ objectType }:${ objectId }` : objectType;
42
47
 
43
48
  updateDebugState( room, {
@@ -1,15 +1,19 @@
1
1
  /**
2
- * Re-export Yjs symbols from wp.sync.Y so the bundled y-websocket and
3
- * y-protocols modules share the same Yjs instance as @wordpress/sync.
4
- * Two Yjs instances on the same page cause silent data corruption:
5
- * https://github.com/yjs/yjs/issues/438
2
+ * Shared-Yjs shim for the bundled y-websocket and y-protocols modules.
3
+ *
4
+ * The plugin build aliases the `yjs` module specifier to this file, so the
5
+ * bundled y-websocket and y-protocols modules resolve Yjs symbols here
6
+ * instead of bundling their own copy. Two Yjs instances on the same page
7
+ * cause silent data corruption: https://github.com/yjs/yjs/issues/438
6
8
  *
7
9
  * Only the symbols actually referenced by y-websocket and y-protocols
8
10
  * need to be re-exported here.
9
11
  */
10
- const Y = window.wp.sync.Y;
12
+ export let Doc;
13
+ export let applyUpdate;
14
+ export let encodeStateAsUpdate;
15
+ export let encodeStateVector;
11
16
 
12
- export const Doc = Y.Doc;
13
- export const applyUpdate = Y.applyUpdate;
14
- export const encodeStateAsUpdate = Y.encodeStateAsUpdate;
15
- export const encodeStateVector = Y.encodeStateVector;
17
+ export function setYjsModule( Y ) {
18
+ ( { Doc, applyUpdate, encodeStateAsUpdate, encodeStateVector } = Y );
19
+ }
@@ -40,7 +40,7 @@ function gutenberg_test_rtc_websocket_provider_enqueue() {
40
40
  wp_enqueue_script(
41
41
  'gutenberg-test-rtc-websocket-provider',
42
42
  plugins_url( 'rtc-websocket-provider/build/index.js', __FILE__ ),
43
- array( 'wp-hooks', 'wp-sync' ),
43
+ array( 'wp-hooks' ),
44
44
  filemtime( $script_path ),
45
45
  true
46
46
  );
@@ -0,0 +1,64 @@
1
+ <?php
2
+ /**
3
+ * Plugin Name: Gutenberg Test Starter Page Patterns
4
+ * Plugin URI: https://github.com/WordPress/gutenberg
5
+ * Author: Gutenberg Team
6
+ *
7
+ * @package gutenberg-test-starter-page-patterns
8
+ */
9
+
10
+ register_block_pattern_category(
11
+ 'test-about',
12
+ array( 'label' => 'Test About' )
13
+ );
14
+ register_block_pattern_category(
15
+ 'test-services',
16
+ array( 'label' => 'Test Services' )
17
+ );
18
+ register_block_pattern_category(
19
+ 'test-post-only',
20
+ array( 'label' => 'Test Post Only' )
21
+ );
22
+
23
+ register_block_pattern(
24
+ 'starter-page-patterns/about',
25
+ array(
26
+ 'title' => 'About page',
27
+ 'categories' => array( 'test-about' ),
28
+ 'blockTypes' => array( 'core/post-content' ),
29
+ 'postTypes' => array( 'page' ),
30
+ 'content' => '<!-- wp:heading --><h2 class="wp-block-heading">About us</h2><!-- /wp:heading --><!-- wp:paragraph --><p>We build websites.</p><!-- /wp:paragraph -->',
31
+ )
32
+ );
33
+
34
+ register_block_pattern(
35
+ 'starter-page-patterns/services',
36
+ array(
37
+ 'title' => 'Services page',
38
+ 'categories' => array( 'test-services' ),
39
+ 'blockTypes' => array( 'core/post-content' ),
40
+ 'postTypes' => array( 'page' ),
41
+ 'content' => '<!-- wp:heading --><h2 class="wp-block-heading">Our services</h2><!-- /wp:heading -->',
42
+ )
43
+ );
44
+
45
+ register_block_pattern(
46
+ 'starter-page-patterns/no-category',
47
+ array(
48
+ 'title' => 'Plain page',
49
+ 'blockTypes' => array( 'core/post-content' ),
50
+ 'postTypes' => array( 'page' ),
51
+ 'content' => '<!-- wp:paragraph --><p>A plain start.</p><!-- /wp:paragraph -->',
52
+ )
53
+ );
54
+
55
+ register_block_pattern(
56
+ 'starter-page-patterns/post-only',
57
+ array(
58
+ 'title' => 'Post call to action',
59
+ 'categories' => array( 'test-post-only' ),
60
+ 'blockTypes' => array( 'core/post-content' ),
61
+ 'postTypes' => array( 'post' ),
62
+ 'content' => '<!-- wp:paragraph --><p>Posts only.</p><!-- /wp:paragraph -->',
63
+ )
64
+ );