@wordpress/e2e-tests 8.17.0 → 8.19.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.
Files changed (35) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/package.json +9 -9
  3. package/plugins/block-hooks.php +74 -0
  4. package/plugins/interactive-blocks/directive-each/view.js +6 -1
  5. package/plugins/interactive-blocks/directive-init/view.js +5 -1
  6. package/plugins/interactive-blocks/directive-on-document/view.js +5 -1
  7. package/plugins/interactive-blocks/directive-on-window/view.js +5 -1
  8. package/plugins/interactive-blocks/directive-priorities/view.js +22 -4
  9. package/plugins/interactive-blocks/directive-run/view.js +5 -3
  10. package/plugins/interactive-blocks/directive-watch/view.js +5 -1
  11. package/plugins/interactive-blocks/get-server-context/view.js +8 -3
  12. package/plugins/interactive-blocks/get-server-state/view.js +8 -3
  13. package/plugins/interactive-blocks/router-navigate/view.js +3 -3
  14. package/plugins/interactive-blocks/router-regions/view.js +3 -3
  15. package/plugins/interactive-blocks/tovdom-islands/view.js +5 -1
  16. package/plugins/interactive-blocks/router-styles-blue/assets/10x10_e2e_test_image_blue.png +0 -0
  17. package/plugins/interactive-blocks/router-styles-blue/block.json +0 -15
  18. package/plugins/interactive-blocks/router-styles-blue/render.php +0 -35
  19. package/plugins/interactive-blocks/router-styles-blue/style-from-link.css +0 -7
  20. package/plugins/interactive-blocks/router-styles-blue/style.css +0 -4
  21. package/plugins/interactive-blocks/router-styles-green/assets/10x10_e2e_test_image_green.png +0 -0
  22. package/plugins/interactive-blocks/router-styles-green/block.json +0 -15
  23. package/plugins/interactive-blocks/router-styles-green/render.php +0 -35
  24. package/plugins/interactive-blocks/router-styles-green/style-from-link.css +0 -7
  25. package/plugins/interactive-blocks/router-styles-green/style.css +0 -4
  26. package/plugins/interactive-blocks/router-styles-red/assets/10x10_e2e_test_image_red.png +0 -0
  27. package/plugins/interactive-blocks/router-styles-red/block.json +0 -15
  28. package/plugins/interactive-blocks/router-styles-red/render.php +0 -35
  29. package/plugins/interactive-blocks/router-styles-red/style-from-link.css +0 -7
  30. package/plugins/interactive-blocks/router-styles-red/style.css +0 -4
  31. package/plugins/interactive-blocks/router-styles-wrapper/block.json +0 -16
  32. package/plugins/interactive-blocks/router-styles-wrapper/render.php +0 -70
  33. package/plugins/interactive-blocks/router-styles-wrapper/style.css +0 -3
  34. package/plugins/interactive-blocks/router-styles-wrapper/view.asset.php +0 -9
  35. package/plugins/interactive-blocks/router-styles-wrapper/view.js +0 -20
package/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 8.19.0 (2025-02-28)
6
+
7
+ ## 8.18.0 (2025-02-12)
8
+
5
9
  ## 8.17.0 (2025-01-29)
6
10
 
7
11
  ## 8.16.0 (2025-01-15)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/e2e-tests",
3
- "version": "8.17.0",
3
+ "version": "8.19.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",
@@ -24,13 +24,13 @@
24
24
  "npm": ">=8.19.2"
25
25
  },
26
26
  "dependencies": {
27
- "@wordpress/e2e-test-utils": "^11.17.0",
28
- "@wordpress/interactivity": "^6.17.0",
29
- "@wordpress/interactivity-router": "^2.17.0",
30
- "@wordpress/jest-console": "^8.17.0",
31
- "@wordpress/jest-puppeteer-axe": "^7.17.0",
32
- "@wordpress/scripts": "^30.10.0",
33
- "@wordpress/url": "^4.17.0",
27
+ "@wordpress/e2e-test-utils": "^11.19.0",
28
+ "@wordpress/interactivity": "^6.19.0",
29
+ "@wordpress/interactivity-router": "^2.19.0",
30
+ "@wordpress/jest-console": "^8.19.0",
31
+ "@wordpress/jest-puppeteer-axe": "^7.19.0",
32
+ "@wordpress/scripts": "^30.12.0",
33
+ "@wordpress/url": "^4.19.0",
34
34
  "chalk": "^4.0.0",
35
35
  "expect-puppeteer": "^4.4.0",
36
36
  "filenamify": "^4.2.0",
@@ -47,5 +47,5 @@
47
47
  "publishConfig": {
48
48
  "access": "public"
49
49
  },
50
- "gitHead": "68a831c3178197fe87db284d4b94e5743bfb6b6c"
50
+ "gitHead": "d6b0b20fa927b110140dc7fdd906a7e0bf662004"
51
51
  }
@@ -0,0 +1,74 @@
1
+ <?php
2
+ /**
3
+ * Plugin Name: Gutenberg Test Block Hooks
4
+ * Plugin URI: https://github.com/WordPress/gutenberg
5
+ * Author: Gutenberg Team
6
+ *
7
+ * @package gutenberg-test-block-hooks
8
+ */
9
+
10
+ defined( 'ABSPATH' ) || exit;
11
+
12
+ function gutenberg_test_insert_hooked_blocks( $hooked_blocks, $position, $anchor_block, $context ) {
13
+ if ( ! $context instanceof WP_Post ) {
14
+ return $hooked_blocks;
15
+ }
16
+
17
+ if (
18
+ ( 'core/heading' === $anchor_block && 'after' === $position ) ||
19
+ ( 'core/post-content' === $anchor_block && 'last_child' === $position ) ||
20
+ ( 'core/block' === $anchor_block && 'last_child' === $position )
21
+ ) {
22
+ $hooked_blocks[] = 'core/paragraph';
23
+ }
24
+
25
+ if ( 'core/navigation' === $anchor_block && 'first_child' === $position ) {
26
+ $hooked_blocks[] = 'core/home-link';
27
+ }
28
+
29
+ if ( 'core/navigation-link' === $anchor_block && 'after' === $position ) {
30
+ $hooked_blocks[] = 'core/page-list';
31
+ }
32
+
33
+ return $hooked_blocks;
34
+ }
35
+ add_filter( 'hooked_block_types', 'gutenberg_test_insert_hooked_blocks', 10, 4 );
36
+
37
+ function gutenberg_test_set_hooked_block_inner_html( $hooked_block, $hooked_block_type, $relative_position, $anchor_block ) {
38
+ if (
39
+ ( 'core/heading' === $anchor_block['blockName'] && 'after' === $relative_position ) ||
40
+ ( 'core/post-content' === $anchor_block['blockName'] && 'last_child' === $relative_position ) ||
41
+ ( 'core/block' === $anchor_block['blockName'] && 'last_child' === $relative_position )
42
+ ) {
43
+ $hooked_block['attrs'] = array(
44
+ 'className' => "hooked-block-{$relative_position}-" . str_replace( 'core/', '', $anchor_block['blockName'] ),
45
+ );
46
+ $hooked_block['innerContent'] = array(
47
+ sprintf(
48
+ '<p class="%1$s">This block was inserted by the Block Hooks API in the <code>%2$s</code> position next to the <code>%3$s</code> anchor block.</p>',
49
+ $hooked_block['attrs']['className'],
50
+ $relative_position,
51
+ $anchor_block['blockName']
52
+ ),
53
+ );
54
+ }
55
+
56
+ return $hooked_block;
57
+ }
58
+ add_filter( 'hooked_block_core/paragraph', 'gutenberg_test_set_hooked_block_inner_html', 10, 4 );
59
+
60
+ function gutenberg_register_wp_ignored_hooked_blocks_meta() {
61
+ register_post_meta(
62
+ 'post',
63
+ '_wp_ignored_hooked_blocks',
64
+ array(
65
+ 'show_in_rest' => true,
66
+ 'single' => true,
67
+ 'type' => 'string',
68
+ 'auth_callback' => function () {
69
+ return current_user_can( 'edit_posts' );
70
+ },
71
+ )
72
+ );
73
+ }
74
+ add_action( 'rest_api_init', 'gutenberg_register_wp_ignored_hooked_blocks_meta' );
@@ -240,7 +240,12 @@ directive(
240
240
  'priority-2-init',
241
241
  ( { directives: { 'priority-2-init': init }, evaluate } ) => {
242
242
  init.forEach( ( entry ) => {
243
- useInit( () => evaluate( entry ) );
243
+ useInit( () => {
244
+ const result = evaluate( entry );
245
+ if ( typeof result === 'function' ) {
246
+ result();
247
+ }
248
+ } );
244
249
  } );
245
250
  },
246
251
  { priority: 2 }
@@ -13,7 +13,11 @@ directive(
13
13
  'show-mock',
14
14
  ( { directives: { 'show-mock': showMock }, element, evaluate } ) => {
15
15
  const entry = showMock.find( ( { suffix } ) => suffix === null );
16
- if ( ! evaluate( entry ) ) {
16
+ const result = evaluate( entry );
17
+ if ( ! result ) {
18
+ return null;
19
+ }
20
+ if ( typeof result === 'function' && ! result() ) {
17
21
  return null;
18
22
  }
19
23
  return element;
@@ -13,7 +13,11 @@ directive(
13
13
  'show-mock',
14
14
  ( { directives: { 'show-mock': showMock }, element, evaluate } ) => {
15
15
  const entry = showMock.find( ( { suffix } ) => suffix === null );
16
- if ( ! evaluate( entry ) ) {
16
+ const result = evaluate( entry );
17
+ if ( ! result ) {
18
+ return null;
19
+ }
20
+ if ( typeof result === 'function' && ! result() ) {
17
21
  return null;
18
22
  }
19
23
  return element;
@@ -13,7 +13,11 @@ directive(
13
13
  'show-mock',
14
14
  ( { directives: { 'show-mock': showMock }, element, evaluate } ) => {
15
15
  const entry = showMock.find( ( { suffix } ) => suffix === null );
16
- if ( ! evaluate( entry ) ) {
16
+ const result = evaluate( entry );
17
+ if ( ! result ) {
18
+ return null;
19
+ }
20
+ if ( typeof result === 'function' && ! result() ) {
17
21
  return null;
18
22
  }
19
23
  return element;
@@ -58,10 +58,13 @@ directive(
58
58
  */
59
59
  directive( 'test-attribute', ( { evaluate, element } ) => {
60
60
  executionProof( 'attribute' );
61
- const attributeValue = evaluate( {
61
+ let attributeValue = evaluate( {
62
62
  namespace,
63
63
  value: 'context.attribute',
64
64
  } );
65
+ if ( typeof attributeValue === 'function' ) {
66
+ attributeValue = attributeValue();
67
+ }
65
68
  useEffect( () => {
66
69
  element.ref.current.setAttribute( 'data-attribute', attributeValue );
67
70
  }, [] );
@@ -76,7 +79,10 @@ directive(
76
79
  'test-text',
77
80
  ( { evaluate, element } ) => {
78
81
  executionProof( 'text' );
79
- const textValue = evaluate( { namespace, value: 'context.text' } );
82
+ let textValue = evaluate( { namespace, value: 'context.text' } );
83
+ if ( typeof textValue === 'function' ) {
84
+ textValue = textValue();
85
+ }
80
86
  element.props.children = h( 'p', { 'data-testid': 'text' }, textValue );
81
87
  },
82
88
  { priority: 12 }
@@ -92,10 +98,22 @@ directive(
92
98
  ( { evaluate, element } ) => {
93
99
  executionProof( 'children' );
94
100
  const updateAttribute = () => {
95
- evaluate( { namespace, value: 'actions.updateAttribute' } );
101
+ const result = evaluate( {
102
+ namespace,
103
+ value: 'actions.updateAttribute',
104
+ } );
105
+ if ( typeof result === 'function' ) {
106
+ result();
107
+ }
96
108
  };
97
109
  const updateText = () => {
98
- evaluate( { namespace, value: 'actions.updateText' } );
110
+ const result = evaluate( {
111
+ namespace,
112
+ value: 'actions.updateText',
113
+ } );
114
+ if ( typeof result === 'function' ) {
115
+ result();
116
+ }
99
117
  };
100
118
  element.props.children = h(
101
119
  'div',
@@ -22,9 +22,11 @@ directive(
22
22
  evaluate,
23
23
  } ) => {
24
24
  const entry = showChildren.find( ( { suffix } ) => suffix === null );
25
- return evaluate( entry )
26
- ? element
27
- : cloneElement( element, { children: null } );
25
+ let result = evaluate( entry );
26
+ if ( typeof result === 'function' ) {
27
+ result = result();
28
+ }
29
+ return result ? element : cloneElement( element, { children: null } );
28
30
  },
29
31
  { priority: 9 }
30
32
  );
@@ -13,7 +13,11 @@ directive(
13
13
  'show-mock',
14
14
  ( { directives: { 'show-mock': showMock }, element, evaluate } ) => {
15
15
  const entry = showMock.find( ( { suffix } ) => suffix === null );
16
- if ( ! evaluate( entry ) ) {
16
+ const result = evaluate( entry );
17
+ if ( ! result ) {
18
+ return null;
19
+ }
20
+ if ( typeof result === 'function' && ! result() ) {
17
21
  return null;
18
22
  }
19
23
  return element;
@@ -1,17 +1,22 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { store, getContext, getServerContext } from '@wordpress/interactivity';
4
+ import {
5
+ store,
6
+ getContext,
7
+ getServerContext,
8
+ withSyncEvent,
9
+ } from '@wordpress/interactivity';
5
10
 
6
11
  store( 'test/get-server-context', {
7
12
  actions: {
8
- *navigate( e ) {
13
+ navigate: withSyncEvent( function* ( e ) {
9
14
  e.preventDefault();
10
15
  const { actions } = yield import(
11
16
  '@wordpress/interactivity-router'
12
17
  );
13
18
  yield actions.navigate( e.target.href );
14
- },
19
+ } ),
15
20
  attemptModification() {
16
21
  try {
17
22
  getServerContext().prop = 'updated from client';
@@ -1,17 +1,22 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { store, getServerState, getContext } from '@wordpress/interactivity';
4
+ import {
5
+ store,
6
+ getServerState,
7
+ getContext,
8
+ withSyncEvent,
9
+ } from '@wordpress/interactivity';
5
10
 
6
11
  const { state } = store( 'test/get-server-state', {
7
12
  actions: {
8
- *navigate( e ) {
13
+ navigate: withSyncEvent( function* ( e ) {
9
14
  e.preventDefault();
10
15
  const { actions } = yield import(
11
16
  '@wordpress/interactivity-router'
12
17
  );
13
18
  yield actions.navigate( e.target.href );
14
- },
19
+ } ),
15
20
  attemptModification() {
16
21
  try {
17
22
  getServerState().prop = 'updated from client';
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { store } from '@wordpress/interactivity';
4
+ import { store, withSyncEvent } from '@wordpress/interactivity';
5
5
 
6
6
  const { state } = store( 'router', {
7
7
  state: {
@@ -18,7 +18,7 @@ const { state } = store( 'router', {
18
18
  },
19
19
  },
20
20
  actions: {
21
- *navigate( e ) {
21
+ navigate: withSyncEvent( function* ( e ) {
22
22
  e.preventDefault();
23
23
 
24
24
  state.navigations.count += 1;
@@ -38,7 +38,7 @@ const { state } = store( 'router', {
38
38
  if ( state.navigations.pending === 0 ) {
39
39
  state.status = 'idle';
40
40
  }
41
- },
41
+ } ),
42
42
  toggleTimeout() {
43
43
  state.timeout = state.timeout === 10000 ? 0 : 10000;
44
44
  },
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { store, getContext } from '@wordpress/interactivity';
4
+ import { store, getContext, withSyncEvent } from '@wordpress/interactivity';
5
5
 
6
6
  const { state } = store( 'router-regions', {
7
7
  state: {
@@ -17,13 +17,13 @@ const { state } = store( 'router-regions', {
17
17
  },
18
18
  actions: {
19
19
  router: {
20
- *navigate( e ) {
20
+ navigate: withSyncEvent( function* ( e ) {
21
21
  e.preventDefault();
22
22
  const { actions } = yield import(
23
23
  '@wordpress/interactivity-router'
24
24
  );
25
25
  yield actions.navigate( e.target.href );
26
- },
26
+ } ),
27
27
  back() {
28
28
  history.back();
29
29
  },
@@ -14,7 +14,11 @@ directive(
14
14
  ( { directives: { 'show-mock': showMock }, element, evaluate } ) => {
15
15
  const entry = showMock.find( ( { suffix } ) => suffix === null );
16
16
 
17
- if ( ! evaluate( entry ) ) {
17
+ let result = evaluate( entry );
18
+ if ( typeof result === 'function' ) {
19
+ result = result();
20
+ }
21
+ if ( ! result ) {
18
22
  element.props.children = h(
19
23
  'template',
20
24
  null,
@@ -1,15 +0,0 @@
1
- {
2
- "$schema": "https://schemas.wp.org/trunk/block.json",
3
- "apiVersion": 2,
4
- "name": "test/router-styles-blue",
5
- "title": "E2E Interactivity tests - router styles - Blue",
6
- "category": "text",
7
- "icon": "heart",
8
- "description": "",
9
- "supports": {
10
- "interactivity": true
11
- },
12
- "textdomain": "e2e-interactivity",
13
- "viewStyle": "file:./style.css",
14
- "render": "file:./render.php"
15
- }
@@ -1,35 +0,0 @@
1
- <?php
2
- /**
3
- * HTML for testing the iAPI's style assets management.
4
- *
5
- * @package gutenberg-test-interactive-blocks
6
- *
7
- * @phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable
8
- */
9
-
10
- add_action(
11
- 'wp_enqueue_scripts',
12
- function () {
13
- wp_enqueue_style(
14
- 'blue-from-link',
15
- plugin_dir_url( __FILE__ ) . 'style-from-link.css',
16
- array()
17
- );
18
-
19
- $custom_css = '
20
- .blue-from-inline {
21
- color: rgb(0, 0, 255);
22
- }
23
- ';
24
-
25
- wp_register_style( 'test-router-styles', false );
26
- wp_enqueue_style( 'test-router-styles' );
27
- wp_add_inline_style( 'test-router-styles', $custom_css );
28
- }
29
- );
30
-
31
- $wrapper_attributes = get_block_wrapper_attributes(
32
- array( 'data-testid' => 'blue-block' )
33
- );
34
- ?>
35
- <p <?php echo $wrapper_attributes; ?>>Blue</p>
@@ -1,7 +0,0 @@
1
- .blue-from-link {
2
- color: rgb(0, 0, 255);
3
- }
4
-
5
- .background-from-link {
6
- background-image: url('./assets/10x10_e2e_test_image_blue.png');
7
- }
@@ -1,4 +0,0 @@
1
- .wp-block-test-router-styles-blue,
2
- .blue {
3
- color: rgb(0, 0, 255);
4
- }
@@ -1,15 +0,0 @@
1
- {
2
- "$schema": "https://schemas.wp.org/trunk/block.json",
3
- "apiVersion": 2,
4
- "name": "test/router-styles-green",
5
- "title": "E2E Interactivity tests - router styles - Green",
6
- "category": "text",
7
- "icon": "heart",
8
- "description": "",
9
- "supports": {
10
- "interactivity": true
11
- },
12
- "textdomain": "e2e-interactivity",
13
- "viewStyle": "file:./style.css",
14
- "render": "file:./render.php"
15
- }
@@ -1,35 +0,0 @@
1
- <?php
2
- /**
3
- * HTML for testing the iAPI's style assets management.
4
- *
5
- * @package gutenberg-test-interactive-blocks
6
- *
7
- * @phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable
8
- */
9
-
10
- add_action(
11
- 'wp_enqueue_scripts',
12
- function () {
13
- wp_enqueue_style(
14
- 'green-from-link',
15
- plugin_dir_url( __FILE__ ) . 'style-from-link.css',
16
- array()
17
- );
18
-
19
- $custom_css = '
20
- .green-from-inline {
21
- color: rgb(0, 255, 0);
22
- }
23
- ';
24
-
25
- wp_register_style( 'test-router-styles', false );
26
- wp_enqueue_style( 'test-router-styles' );
27
- wp_add_inline_style( 'test-router-styles', $custom_css );
28
- }
29
- );
30
-
31
- $wrapper_attributes = get_block_wrapper_attributes(
32
- array( 'data-testid' => 'green-block' )
33
- );
34
- ?>
35
- <p <?php echo $wrapper_attributes; ?>>Green</p>
@@ -1,7 +0,0 @@
1
- .green-from-link {
2
- color: rgb(0, 255, 0);
3
- }
4
-
5
- .background-from-link {
6
- background-image: url('./assets/10x10_e2e_test_image_green.png');
7
- }
@@ -1,4 +0,0 @@
1
- .wp-block-test-router-styles-green,
2
- .green {
3
- color: rgb(0, 255, 0);
4
- }
@@ -1,15 +0,0 @@
1
- {
2
- "$schema": "https://schemas.wp.org/trunk/block.json",
3
- "apiVersion": 2,
4
- "name": "test/router-styles-red",
5
- "title": "E2E Interactivity tests - router styles - Red",
6
- "category": "text",
7
- "icon": "heart",
8
- "description": "",
9
- "supports": {
10
- "interactivity": true
11
- },
12
- "textdomain": "e2e-interactivity",
13
- "viewStyle": "file:./style.css",
14
- "render": "file:./render.php"
15
- }
@@ -1,35 +0,0 @@
1
- <?php
2
- /**
3
- * HTML for testing the iAPI's style assets management.
4
- *
5
- * @package gutenberg-test-interactive-blocks
6
- *
7
- * @phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable
8
- */
9
-
10
- add_action(
11
- 'wp_enqueue_scripts',
12
- function () {
13
- wp_enqueue_style(
14
- 'red-from-link',
15
- plugin_dir_url( __FILE__ ) . 'style-from-link.css',
16
- array()
17
- );
18
-
19
- $custom_css = '
20
- .red-from-inline {
21
- color: rgb(255, 0, 0);
22
- }
23
- ';
24
-
25
- wp_register_style( 'test-router-styles', false );
26
- wp_enqueue_style( 'test-router-styles' );
27
- wp_add_inline_style( 'test-router-styles', $custom_css );
28
- }
29
- );
30
-
31
- $wrapper_attributes = get_block_wrapper_attributes(
32
- array( 'data-testid' => 'red-block' )
33
- );
34
- ?>
35
- <p <?php echo $wrapper_attributes; ?>>Red</p>
@@ -1,7 +0,0 @@
1
- .red-from-link {
2
- color: rgb(255, 0, 0);
3
- }
4
-
5
- .background-from-link {
6
- background-image: url('./assets/10x10_e2e_test_image_red.png');
7
- }
@@ -1,4 +0,0 @@
1
- .wp-block-test-router-styles-red,
2
- .red {
3
- color: rgb(255, 0, 0);
4
- }
@@ -1,16 +0,0 @@
1
- {
2
- "$schema": "https://schemas.wp.org/trunk/block.json",
3
- "apiVersion": 2,
4
- "name": "test/router-styles-wrapper",
5
- "title": "E2E Interactivity tests - router styles - Wrapper",
6
- "category": "text",
7
- "icon": "heart",
8
- "description": "",
9
- "supports": {
10
- "interactivity": true
11
- },
12
- "textdomain": "e2e-interactivity",
13
- "viewScriptModule": "file:./view.js",
14
- "viewStyle": "file:./style.css",
15
- "render": "file:./render.php"
16
- }
@@ -1,70 +0,0 @@
1
- <?php
2
- /**
3
- * HTML for testing the iAPI's style assets management.
4
- *
5
- * @package gutenberg-test-interactive-blocks
6
- *
7
- * @phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable
8
- */
9
-
10
- $wrapper_attributes = get_block_wrapper_attributes();
11
- ?>
12
- <div <?php echo $wrapper_attributes; ?>>
13
- <!-- These get colored when the corresponding block is present. -->
14
- <fieldset>
15
- <legend>Styles from block styles</legend>
16
- <p data-testid="red" class="red">Red</p>
17
- <p data-testid="green" class="green">Green</p>
18
- <p data-testid="blue" class="blue">Blue</p>
19
- <p data-testid="all" class="red green blue">All</p>
20
- </fieldset>
21
-
22
- <!-- These get colored when the corresponding block enqueues a referenced stylesheet. -->
23
- <fieldset>
24
- <legend>Styles from referenced style sheets</legend>
25
- <p data-testid="red-from-link" class="red-from-link">Red from link</p>
26
- <p data-testid="green-from-link" class="green-from-link">Green from link</p>
27
- <p data-testid="blue-from-link" class="blue-from-link">Blue from link</p>
28
- <p data-testid="all-from-link" class="red-from-link green-from-link blue-from-link">All from link</p>
29
- <div data-testid="background-from-link"class="background-from-link" style="width: 10px; height: 10px"></div>
30
- </fieldset>
31
-
32
- <!-- These get colored when the corresponding block adds inline style. -->
33
- <fieldset>
34
- <legend>Styles from inline styles</legend>
35
- <p data-testid="red-from-inline" class="red-from-inline">Red</p>
36
- <p data-testid="green-from-inline" class="green-from-inline">Green</p>
37
- <p data-testid="blue-from-inline" class="blue-from-inline">Blue</p>
38
- <p data-testid="all-from-inline" class="red-from-inline green-from-inline blue-from-inline">All</p>
39
- </fieldset>
40
-
41
- <!-- Links to pages with different blocks combination. -->
42
- <nav data-wp-interactive="test/router-styles">
43
- <?php foreach ( $attributes['links'] as $label => $link ) : ?>
44
- <a
45
- data-testid="link <?php echo $label; ?>"
46
- data-wp-on--click="actions.navigate"
47
- href="<?php echo $link; ?>"
48
- >
49
- <?php echo $label; ?>
50
- </a>
51
- <?php endforeach; ?>
52
- </nav>
53
-
54
- <!-- HTML updated on navigation. -->
55
- <div
56
- data-wp-interactive="test/router-styles"
57
- data-wp-router-region="router-styles"
58
- >
59
- <?php echo $content; ?>
60
- </div>
61
-
62
- <!-- Text to check whether a navigation was client-side. -->
63
- <div
64
- data-testid="client-side navigation"
65
- data-wp-interactive="test/router-styles"
66
- data-wp-bind--hidden="!state.clientSideNavigation"
67
- >
68
- Client-side navigation
69
- </div>
70
- </div>
@@ -1,3 +0,0 @@
1
- .wp-block-test-router-styles-wrapper {
2
- color: rgb(160, 12, 60);
3
- }
@@ -1,9 +0,0 @@
1
- <?php return array(
2
- 'dependencies' => array(
3
- '@wordpress/interactivity',
4
- array(
5
- 'id' => '@wordpress/interactivity-router',
6
- 'import' => 'dynamic',
7
- ),
8
- ),
9
- );
@@ -1,20 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { store } from '@wordpress/interactivity';
5
-
6
- const { state } = store( 'test/router-styles', {
7
- state: {
8
- clientSideNavigation: false,
9
- },
10
- actions: {
11
- *navigate( e ) {
12
- e.preventDefault();
13
- const { actions } = yield import(
14
- '@wordpress/interactivity-router'
15
- );
16
- yield actions.navigate( e.target.href );
17
- state.clientSideNavigation = true;
18
- },
19
- },
20
- } );