@wordpress/e2e-tests 7.28.0 → 8.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 CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 8.0.0 (2024-05-31)
6
+
7
+ ### Breaking Changes
8
+
9
+ - Variables like `process.env.IS_GUTENBERG_PLUGIN` have been replaced by `globalThis.IS_GUTENBERG_PLUGIN`. Build systems using `process.env` should be updated ([#61486](https://github.com/WordPress/gutenberg/pull/61486)).
10
+ - Increase the minimum required Node.js version to v18.12.0 matching long-term support releases ([#31270](https://github.com/WordPress/gutenberg/pull/61930)). Learn more about [Node.js releases](https://nodejs.org/en/about/previous-releases).
11
+
12
+ ## 7.29.0 (2024-05-16)
13
+
5
14
  ## 7.28.0 (2024-05-02)
6
15
 
7
16
  ## 7.27.0 (2024-04-19)
@@ -62,7 +71,7 @@
62
71
 
63
72
  ### Breaking Changes
64
73
 
65
- - Started requiring Jest v29 instead of v27 as a peer dependency. See [breaking changes in Jest 28](https://jestjs.io/blog/2022/04/25/jest-28) and [in jest 29](https://jestjs.io/blog/2022/08/25/jest-29) ([#47388](https://github.com/WordPress/gutenberg/pull/47388))
74
+ - Started requiring Jest v29 instead of v27 as a peer dependency. See [breaking changes in Jest 28](https://jestjs.io/blog/2022/04/25/jest-28) and [in jest 29](https://jestjs.io/blog/2022/08/25/jest-29) ([#47388](https://github.com/WordPress/gutenberg/pull/47388))
66
75
 
67
76
  ## 6.5.0 (2023-03-01)
68
77
 
package/README.md CHANGED
@@ -80,7 +80,7 @@ Debugging in a Chrome browser can be replaced with `vscode`'s debugger by adding
80
80
 
81
81
  This will run jest, targetting the spec file currently open in the editor. `vscode`'s debugger can now be used to add breakpoints and inspect tests as you would in Chrome DevTools.
82
82
 
83
- **Note**: This package requires Node.js 14.0.0 or later. It is not compatible with older versions.
83
+ **Note**: This package requires Node.js version with long-term support status (check [Active LTS or Maintenance LTS releases](https://nodejs.org/en/about/previous-releases)). It is not compatible with older versions.
84
84
 
85
85
  ## Contributing to this package
86
86
 
@@ -1,6 +1,3 @@
1
- global.process.env = {
2
- ...global.process.env,
3
- // Inject the `IS_GUTENBERG_PLUGIN` global, used for feature flagging.
4
- // eslint-disable-next-line @wordpress/is-gutenberg-plugin
5
- IS_GUTENBERG_PLUGIN: process.env.npm_package_config_IS_GUTENBERG_PLUGIN,
6
- };
1
+ // eslint-disable-next-line @wordpress/wp-global-usage
2
+ globalThis.IS_GUTENBERG_PLUGIN =
3
+ process.env.npm_package_config_IS_GUTENBERG_PLUGIN === 'true';
@@ -0,0 +1,91 @@
1
+ <?php
2
+
3
+ add_filter(
4
+ 'template_include',
5
+ static function ( $template ) {
6
+
7
+ global $timestart, $wpdb;
8
+
9
+ $server_timing_values = array();
10
+ $template_start = microtime( true );
11
+
12
+ $server_timing_values['wpBeforeTemplate'] = $template_start - $timestart;
13
+
14
+ ob_start();
15
+
16
+ add_action(
17
+ 'shutdown',
18
+ static function () use ( $server_timing_values, $template_start, $wpdb ) {
19
+ $output = ob_get_clean();
20
+
21
+ $server_timing_values['wpTemplate'] = microtime( true ) - $template_start;
22
+
23
+ $server_timing_values['wpTotal'] = $server_timing_values['wpBeforeTemplate'] + $server_timing_values['wpTemplate'];
24
+
25
+ /*
26
+ * While values passed via Server-Timing are intended to be durations,
27
+ * any numeric value can actually be passed.
28
+ * This is a nice little trick as it allows to easily get this information in JS.
29
+ */
30
+ $server_timing_values['wpMemoryUsage'] = memory_get_usage();
31
+ $server_timing_values['wpDbQueries'] = $wpdb->num_queries;
32
+
33
+ $header_values = array();
34
+ foreach ( $server_timing_values as $slug => $value ) {
35
+ if ( is_float( $value ) ) {
36
+ $value = round( $value * 1000.0, 2 );
37
+ }
38
+ $header_values[] = sprintf( '%1$s;dur=%2$s', $slug, $value );
39
+ }
40
+ header( 'Server-Timing: ' . implode( ', ', $header_values ) );
41
+
42
+ echo $output;
43
+ },
44
+ PHP_INT_MIN
45
+ );
46
+
47
+ return $template;
48
+ },
49
+ PHP_INT_MAX
50
+ );
51
+
52
+ add_action(
53
+ 'admin_init',
54
+ static function () {
55
+ global $timestart, $wpdb;
56
+
57
+ ob_start();
58
+
59
+ add_action(
60
+ 'shutdown',
61
+ static function () use ( $wpdb, $timestart ) {
62
+ $output = ob_get_clean();
63
+
64
+ $server_timing_values = array();
65
+
66
+ $server_timing_values['wpTotal'] = microtime( true ) - $timestart;
67
+
68
+ /*
69
+ * While values passed via Server-Timing are intended to be durations,
70
+ * any numeric value can actually be passed.
71
+ * This is a nice little trick as it allows to easily get this information in JS.
72
+ */
73
+ $server_timing_values['wpMemoryUsage'] = memory_get_usage();
74
+ $server_timing_values['wpDbQueries'] = $wpdb->num_queries;
75
+
76
+ $header_values = array();
77
+ foreach ( $server_timing_values as $slug => $value ) {
78
+ if ( is_float( $value ) ) {
79
+ $value = round( $value * 1000.0, 2 );
80
+ }
81
+ $header_values[] = sprintf( '%1$s;dur=%2$s', $slug, $value );
82
+ }
83
+ header( 'Server-Timing: ' . implode( ', ', $header_values ) );
84
+
85
+ echo $output;
86
+ },
87
+ PHP_INT_MIN
88
+ );
89
+ },
90
+ PHP_INT_MAX
91
+ );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/e2e-tests",
3
- "version": "7.28.0",
3
+ "version": "8.0.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",
@@ -20,16 +20,17 @@
20
20
  "url": "https://github.com/WordPress/gutenberg/issues"
21
21
  },
22
22
  "engines": {
23
- "node": ">=14"
23
+ "node": ">=18.12.0",
24
+ "npm": ">=8.19.2"
24
25
  },
25
26
  "dependencies": {
26
- "@wordpress/e2e-test-utils": "^10.28.0",
27
- "@wordpress/interactivity": "^5.6.0",
28
- "@wordpress/interactivity-router": "^1.7.0",
29
- "@wordpress/jest-console": "^7.28.0",
30
- "@wordpress/jest-puppeteer-axe": "^6.28.0",
31
- "@wordpress/scripts": "^27.8.0",
32
- "@wordpress/url": "^3.58.0",
27
+ "@wordpress/e2e-test-utils": "^11.0.0",
28
+ "@wordpress/interactivity": "^6.0.0",
29
+ "@wordpress/interactivity-router": "^2.0.0",
30
+ "@wordpress/jest-console": "^8.0.0",
31
+ "@wordpress/jest-puppeteer-axe": "^7.0.0",
32
+ "@wordpress/scripts": "^28.0.0",
33
+ "@wordpress/url": "^4.0.0",
33
34
  "chalk": "^4.0.0",
34
35
  "expect-puppeteer": "^4.4.0",
35
36
  "filenamify": "^4.2.0",
@@ -46,5 +47,5 @@
46
47
  "publishConfig": {
47
48
  "access": "public"
48
49
  },
49
- "gitHead": "581d8a5580dba8f600b7268d51eb554771ae482c"
50
+ "gitHead": "2f30cddff15723ac7017fd009fc5913b7b419400"
50
51
  }
@@ -17,7 +17,6 @@
17
17
  {
18
18
  className: 'e2e-reset-block-button',
19
19
  variant: "secondary",
20
- isLarge: true,
21
20
  onClick() {
22
21
  const emptyBlock = createBlock( props.name );
23
22
  props.onReplace( emptyBlock );
@@ -92,7 +92,7 @@
92
92
 
93
93
  edit: function InnerBlocksUpdateLockedTemplateEdit( props ) {
94
94
  const hasUpdatedTemplated = props.attributes.hasUpdatedTemplate;
95
- return el( 'div', null, [
95
+ return el( 'div', null,
96
96
  el(
97
97
  'button',
98
98
  {
@@ -108,7 +108,7 @@
108
108
  : TEMPLATE,
109
109
  templateLock: 'all',
110
110
  } ) ),
111
- ] );
111
+ );
112
112
  },
113
113
 
114
114
  save,
@@ -16,5 +16,5 @@ document.addEventListener( 'DOMContentLoaded', () => {
16
16
  },
17
17
  },
18
18
  } );
19
- }, 50 );
19
+ }, 100 );
20
20
  } );
@@ -93,6 +93,7 @@
93
93
  <button
94
94
  data-testid="toggle value"
95
95
  data-wp-on--click="actions.toggleValue"
96
+ data-wp-bind--data-toggle-count="context.count"
96
97
  >Toggle</button>
97
98
  </div>
98
99
  <?php endforeach; ?>
@@ -32,6 +32,7 @@ const { state, foo } = store( 'directive-bind', {
32
32
 
33
33
  context.previousValue = context.value;
34
34
  context.value = previousValue;
35
+ context.count = ( context.count ?? 0 ) + 1;
35
36
  },
36
37
  },
37
38
  } );
@@ -6,7 +6,8 @@
6
6
  */
7
7
  ?>
8
8
 
9
- <div data-wp-interactive="directive-on">
9
+ <?php // A wrong directive name like "data-wp-on--" should not kill the interactivity. ?>
10
+ <div data-wp-interactive="directive-on" data-wp-on--="">
10
11
  <div>
11
12
  <p data-wp-text="state.counter" data-testid="counter">0</p>
12
13
  <button
@@ -24,4 +24,8 @@
24
24
  <p data-wp-text="state.counter" data-testid="counter">0</p>
25
25
  </div>
26
26
  </div>
27
+ <div data-wp-on-document--keydown="actions.keydownHandler" data-wp-on-document--keydown--second="actions.keydownSecondHandler">
28
+ <p data-wp-text="state.keydownHandler" data-testid="keydownHandler">no</p>
29
+ <p data-wp-text="state.keydownSecondHandler" data-testid="keydownSecondHandler">no</p>
30
+ </div>
27
31
  </div>
@@ -25,6 +25,8 @@ const { state } = store( 'directive-on-document', {
25
25
  counter: 0,
26
26
  isVisible: true,
27
27
  isEventAttached: 'no',
28
+ keydownHandler: 'no',
29
+ keydownSecondHandler: 'no',
28
30
  },
29
31
  callbacks: {
30
32
  keydownHandler() {
@@ -39,5 +41,11 @@ const { state } = store( 'directive-on-document', {
39
41
  state.isEventAttached = 'no';
40
42
  state.isVisible = ! state.isVisible;
41
43
  },
44
+ keydownHandler: () => {
45
+ state.keydownHandler = 'yes';
46
+ },
47
+ keydownSecondHandler: () => {
48
+ state.keydownSecondHandler = 'yes';
49
+ }
42
50
  }
43
51
  } );
@@ -21,4 +21,8 @@
21
21
  <p data-wp-text="state.counter" data-testid="counter">0</p>
22
22
  </div>
23
23
  </div>
24
+ <div data-wp-on-window--resize="actions.resizeHandler" data-wp-on-window--resize--second="actions.resizeSecondHandler">
25
+ <p data-wp-text="state.resizeHandler" data-testid="resizeHandler">no</p>
26
+ <p data-wp-text="state.resizeSecondHandler" data-testid="resizeSecondHandler">no</p>
27
+ </div>
24
28
  </div>
@@ -25,6 +25,8 @@ const { state } = store( 'directive-on-window', {
25
25
  counter: 0,
26
26
  isVisible: true,
27
27
  isEventAttached: 'no',
28
+ resizeHandler: 'no',
29
+ resizeSecondHandler: 'no',
28
30
  },
29
31
  callbacks: {
30
32
  resizeHandler() {
@@ -39,5 +41,11 @@ const { state } = store( 'directive-on-window', {
39
41
  state.isEventAttached = 'no';
40
42
  state.isVisible = ! state.isVisible;
41
43
  },
44
+ resizeHandler: () => {
45
+ state.resizeHandler = 'yes';
46
+ },
47
+ resizeSecondHandler: () => {
48
+ state.resizeSecondHandler = 'yes';
49
+ }
42
50
  }
43
51
  } );
@@ -0,0 +1,15 @@
1
+ {
2
+ "$schema": "https://schemas.wp.org/trunk/block.json",
3
+ "apiVersion": 2,
4
+ "name": "test-namespace/directive-bind",
5
+ "title": "E2E Interactivity tests - directive bind",
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,45 @@
1
+ <?php
2
+ /**
3
+ * HTML for testing the directive `data-wp-bind`.
4
+ *
5
+ * @package gutenberg-test-interactive-blocks
6
+ */
7
+ ?>
8
+
9
+ <div data-wp-interactive="">
10
+ <a data-wp-bind--href="state.url" data-testid="empty namespace"></a>
11
+ </div>
12
+
13
+ <div data-wp-interactive="namespace">
14
+ <a data-wp-bind--href="state.url" data-testid="correct namespace"></a>
15
+ </div>
16
+
17
+ <div data-wp-interactive="{}">
18
+ <a data-wp-bind--href="state.url" data-testid="object namespace"></a>
19
+ </div>
20
+
21
+ <div data-wp-interactive="null">
22
+ <a data-wp-bind--href="state.url" data-testid="null namespace"></a>
23
+ </div>
24
+
25
+ <div data-wp-interactive="2">
26
+ <a data-wp-bind--href="state.url" data-testid="number namespace"></a>
27
+ </div>
28
+
29
+ <div data-wp-interactive>
30
+ <a data-wp-bind--href="other::state.url" data-testid="other namespace"></a>
31
+ </div>
32
+
33
+ <div data-wp-interactive="true">
34
+ <a data-wp-bind--href="state.url" data-testid="true namespace"></a>
35
+ </div>
36
+
37
+ <div data-wp-interactive="false">
38
+ <a data-wp-bind--href="state.url" data-testid="false namespace"></a>
39
+ </div>
40
+ <div data-wp-interactive="[]">
41
+ <a data-wp-bind--href="state.url" data-testid="[] namespace"></a>
42
+ </div>
43
+ <div data-wp-interactive='"quoted string"'>
44
+ <a data-wp-bind--href="state.url" data-testid="quoted namespace"></a>
45
+ </div>
@@ -0,0 +1 @@
1
+ <?php return array( 'dependencies' => array( '@wordpress/interactivity' ) );
@@ -0,0 +1,70 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { store } from '@wordpress/interactivity';
5
+
6
+
7
+ store( '', {
8
+ state: {
9
+ url: '/empty-string-url',
10
+ },
11
+ } );
12
+
13
+ store( 'namespace', {
14
+ state: {
15
+ url: '/namespace-url',
16
+ },
17
+ } );
18
+
19
+ store( 'other', {
20
+ state: {
21
+ url: '/other-store-url',
22
+ },
23
+ } );
24
+
25
+ store( 'null', {
26
+ state: {
27
+ url: '/null-url',
28
+ },
29
+ } );
30
+
31
+ store( '2', {
32
+ state: {
33
+ url: '/number-url',
34
+ },
35
+ } );
36
+
37
+ store( '{}', {
38
+ state: {
39
+ url: '/object-url',
40
+ },
41
+ } );
42
+
43
+ store( 'true', {
44
+ state: {
45
+ url: '/true-url',
46
+ },
47
+ } );
48
+
49
+ store( 'false', {
50
+ state: {
51
+ url: '/false-url',
52
+ },
53
+ } );
54
+
55
+ store( '[]', {
56
+ state: {
57
+ url: '/array-url',
58
+ },
59
+ } );
60
+
61
+ store( '"quoted string"', {
62
+ state: {
63
+ url: '/quoted-url',
64
+ },
65
+ } );
66
+
67
+
68
+
69
+
70
+
@@ -29,11 +29,7 @@ add_action(
29
29
  // Ensure the interactivity API is loaded.
30
30
  wp_interactivity();
31
31
  // But remove the server directive processing.
32
- remove_filter(
33
- 'render_block_data',
34
- 'wp_interactivity_process_directives_of_interactive_blocks',
35
- 100
36
- );
32
+ add_filter( 'interactivity_process_directives', '__return_false' );
37
33
  }
38
34
  }
39
35
  );
@@ -0,0 +1,26 @@
1
+ <?php
2
+ /**
3
+ * Plugin Name: Lightbox Allow Editing False Enabled False
4
+ * Plugin URI: https://github.com/WordPress/gutenberg
5
+ * Author: Gutenberg Team
6
+ *
7
+ * @package gutenberg-lightbox-allow-editing-false-enabled-false
8
+ */
9
+
10
+ function filter_theme_json_theme( $theme_json ) {
11
+ $new_data = array(
12
+ 'version' => 2,
13
+ 'settings' => array(
14
+ 'blocks' => array(
15
+ 'core/image' => array(
16
+ 'lightbox' => array(
17
+ 'allowEditing' => false,
18
+ 'enabled' => false,
19
+ ),
20
+ ),
21
+ ),
22
+ ),
23
+ );
24
+ return $theme_json->update_with( $new_data );
25
+ }
26
+ add_filter( 'wp_theme_json_data_theme', 'filter_theme_json_theme' );