@wordpress/e2e-tests 9.2.0 → 9.2.1-next.ba3aee3a2.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,8 +2,6 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
- ## 9.2.0 (2025-12-23)
6
-
7
5
  ## 9.1.0 (2025-11-26)
8
6
 
9
7
  ## 9.0.0 (2025-11-12)
package/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ## Gutenberg
2
2
 
3
- Copyright 2016-2025 by the contributors
3
+ Copyright 2016-2026 by the contributors
4
4
 
5
5
  **License for Contributions (on and after April 15, 2021)**
6
6
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/e2e-tests",
3
- "version": "9.2.0",
3
+ "version": "9.2.1-next.ba3aee3a2.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,11 +24,17 @@
24
24
  "npm": ">=8.19.2"
25
25
  },
26
26
  "dependencies": {
27
- "@wordpress/interactivity": "^6.37.0",
28
- "@wordpress/interactivity-router": "^2.37.0"
27
+ "@wordpress/interactivity": "^6.37.2-next.ba3aee3a2.0",
28
+ "@wordpress/interactivity-router": "^2.37.1-next.ba3aee3a2.0"
29
+ },
30
+ "peerDependencies": {
31
+ "jest": ">=29",
32
+ "puppeteer-core": ">=23",
33
+ "react": "^18.0.0",
34
+ "react-dom": "^18.0.0"
29
35
  },
30
36
  "publishConfig": {
31
37
  "access": "public"
32
38
  },
33
- "gitHead": "2cf13ec6cf86153c9b3cf369bf5c59046f5cd950"
39
+ "gitHead": "67d2e486fcd40c753591cf911ca0659132f519ca"
34
40
  }
@@ -84,7 +84,6 @@ const withBlockBindingsInspectorControl = createHigherOrderComponent(
84
84
  { title: 'Bindings' },
85
85
  el( TextControl, {
86
86
  __next40pxDefaultSize: true,
87
- __nextHasNoMarginBottom: true,
88
87
  label: 'Content',
89
88
  value: props.attributes.content,
90
89
  onChange: ( content ) =>
@@ -48,7 +48,7 @@ class Test_Widget extends WP_Widget {
48
48
  ?>
49
49
  <p>
50
50
  <label for="<?php echo $this->get_field_id( 'title' ); ?>">Title:</label>
51
- <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( isset( $instance['title'] ) ? $instance['title'] : '' ); ?>" />
51
+ <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $instance['title'] ?? '' ); ?>" />
52
52
  </p>
53
53
  <?php
54
54
  }
@@ -3,88 +3,115 @@
3
3
  const PanelBody = wp.components.PanelBody;
4
4
  const select = wp.data.select;
5
5
  const dispatch = wp.data.dispatch;
6
+ const useSelect = wp.data.useSelect;
7
+ const useDispatch = wp.data.useDispatch;
6
8
  const Fragment = wp.element.Fragment;
7
9
  const el = wp.element.createElement;
8
- const Component = wp.element.Component;
10
+ const useState = wp.element.useState;
11
+ const useEffect = wp.element.useEffect;
9
12
  const __ = wp.i18n.__;
10
13
  const registerPlugin = wp.plugins.registerPlugin;
11
14
  const PluginSidebar = wp.editor.PluginSidebar;
12
15
  const PluginSidebarMoreMenuItem = wp.editor.PluginSidebarMoreMenuItem;
13
16
 
14
- class SidebarContents extends Component {
15
- constructor( props ) {
16
- super( props );
17
+ function SidebarContents() {
18
+ const [ range, setRange ] = useState( { start: 0, end: 0 } );
17
19
 
18
- this.state = {
19
- start: 0,
20
- end: 0,
21
- };
22
- }
20
+ const blocks = useSelect( ( sel ) => {
21
+ return sel( 'core/block-editor' ).getBlocks();
22
+ } );
23
23
 
24
- render() {
25
- return el(
26
- PanelBody,
27
- {},
28
- el( 'input', {
29
- type: 'number',
30
- id: 'annotations-tests-range-start',
31
- onChange: ( reactEvent ) => {
32
- this.setState( {
33
- start: reactEvent.target.value,
34
- } );
35
- },
36
- value: this.state.start,
37
- } ),
38
- el( 'input', {
39
- type: 'number',
40
- id: 'annotations-tests-range-end',
41
- onChange: ( reactEvent ) => {
42
- this.setState( {
43
- end: reactEvent.target.value,
44
- } );
45
- },
46
- value: this.state.end,
47
- } ),
48
- el(
49
- Button,
50
- {
51
- variant: 'primary',
52
- onClick: () => {
53
- dispatch(
54
- 'core/annotations'
55
- ).__experimentalAddAnnotation( {
56
- source: 'e2e-tests',
57
- blockClientId:
58
- select(
59
- 'core/block-editor'
60
- ).getBlockOrder()[ 0 ],
61
- richTextIdentifier: 'content',
62
- range: {
63
- start: parseInt( this.state.start, 10 ),
64
- end: parseInt( this.state.end, 10 ),
65
- },
66
- } );
24
+ const { __experimentalAddAnnotation: addAnnotation } =
25
+ useDispatch( 'core/annotations' );
26
+
27
+ const allBlocks = blocks
28
+ .filter( ( block ) => block.name === 'core/paragraph' )
29
+ .map( ( block ) => [
30
+ block.clientId,
31
+ block.attributes.content.text,
32
+ ] );
33
+
34
+ useEffect( () => {
35
+ allBlocks.forEach( ( [ clientId, content ] ) => {
36
+ const applePosition = content.indexOf( 'apple' );
37
+ if ( applePosition !== -1 ) {
38
+ addAnnotation( {
39
+ source: 'test-annotation',
40
+ blockClientId: clientId,
41
+ richTextIdentifier: 'content',
42
+ range: {
43
+ start: applePosition,
44
+ end: applePosition + 5,
67
45
  },
46
+ } );
47
+ }
48
+ } );
49
+ } );
50
+
51
+ return el(
52
+ PanelBody,
53
+ {},
54
+ el( 'input', {
55
+ type: 'number',
56
+ id: 'annotations-tests-range-start',
57
+ onChange: ( reactEvent ) => {
58
+ setRange( {
59
+ ...range,
60
+ start: reactEvent.target.value,
61
+ } );
62
+ },
63
+ value: range.start,
64
+ } ),
65
+ el( 'input', {
66
+ type: 'number',
67
+ id: 'annotations-tests-range-end',
68
+ onChange: ( reactEvent ) => {
69
+ setRange( {
70
+ ...range,
71
+ end: reactEvent.target.value,
72
+ } );
73
+ },
74
+ value: range.end,
75
+ } ),
76
+ el(
77
+ Button,
78
+ {
79
+ variant: 'primary',
80
+ onClick: () => {
81
+ dispatch(
82
+ 'core/annotations'
83
+ ).__experimentalAddAnnotation( {
84
+ source: 'e2e-tests',
85
+ blockClientId:
86
+ select(
87
+ 'core/block-editor'
88
+ ).getBlockOrder()[ 0 ],
89
+ richTextIdentifier: 'content',
90
+ range: {
91
+ start: parseInt( range.start, 10 ),
92
+ end: parseInt( range.end, 10 ),
93
+ },
94
+ } );
68
95
  },
69
- __( 'Add annotation' )
70
- ),
71
- el(
72
- Button,
73
- {
74
- variant: 'primary',
75
- onClick: () => {
76
- dispatch(
77
- 'core/annotations'
78
- ).__experimentalRemoveAnnotationsBySource(
79
- 'e2e-tests'
80
- );
81
- },
96
+ },
97
+ __( 'Add annotation' )
98
+ ),
99
+ el(
100
+ Button,
101
+ {
102
+ variant: 'primary',
103
+ onClick: () => {
104
+ dispatch(
105
+ 'core/annotations'
106
+ ).__experimentalRemoveAnnotationsBySource(
107
+ 'e2e-tests'
108
+ );
82
109
  },
110
+ },
83
111
 
84
- __( 'Remove annotations' )
85
- )
86
- );
87
- }
112
+ __( 'Remove annotations' )
113
+ )
114
+ );
88
115
  }
89
116
 
90
117
  function AnnotationsSidebar() {
@@ -86,5 +86,85 @@ add_action(
86
86
  },
87
87
  )
88
88
  );
89
+
90
+ // PHP-only block with auto-generated controls from various attribute types
91
+ register_block_type(
92
+ 'test/auto-register-with-controls',
93
+ array(
94
+ 'title' => 'Auto Register With Controls',
95
+ 'icon' => 'admin-generic',
96
+ 'category' => 'widgets',
97
+ 'description' => 'A test block for auto-generated inspector controls',
98
+ 'keywords' => array( 'autoregister', 'controls', 'dataform' ),
99
+ // Labels are translatable via __() in real plugins.
100
+ 'attributes' => array(
101
+ 'title' => array(
102
+ 'type' => 'string',
103
+ 'default' => 'My Emoji Collection',
104
+ 'label' => 'Title',
105
+ ),
106
+ 'count' => array(
107
+ 'type' => 'integer',
108
+ 'default' => 5,
109
+ 'label' => 'Count',
110
+ ),
111
+ 'spacing' => array(
112
+ 'type' => 'number',
113
+ 'default' => 0.1,
114
+ 'label' => 'Spacing',
115
+ ),
116
+ 'showEmojis' => array(
117
+ 'type' => 'boolean',
118
+ 'default' => true,
119
+ 'label' => 'Show Emojis',
120
+ ),
121
+ 'emoji' => array(
122
+ 'type' => 'string',
123
+ 'enum' => array( '⭐', '❤️', '🎉', '🚀', '🌈' ),
124
+ 'default' => '⭐',
125
+ 'label' => 'Emoji',
126
+ ),
127
+ // Should NOT get a control (has source - HTML-derived)
128
+ 'content' => array(
129
+ 'type' => 'string',
130
+ 'source' => 'html',
131
+ ),
132
+ // Should NOT get a control (role: local - internal state)
133
+ 'internalState' => array(
134
+ 'type' => 'string',
135
+ 'role' => 'local',
136
+ 'default' => 'internal',
137
+ ),
138
+ ),
139
+ 'render_callback' => static function ( $attributes ) {
140
+ $wrapper_attributes = get_block_wrapper_attributes(
141
+ array(
142
+ 'style' => 'padding: 20px; text-align: center; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); border-radius: 8px;',
143
+ )
144
+ );
145
+ $title = esc_html( $attributes['title'] );
146
+ $count = min( 20, max( 0, absint( $attributes['count'] ) ) );
147
+ $spacing = floatval( $attributes['spacing'] );
148
+ $show_emojis = $attributes['showEmojis'];
149
+ $emoji = $attributes['emoji'];
150
+
151
+ $emoji_display = $show_emojis ? str_repeat( $emoji . ' ', $count ) : '<em>Emojis hidden</em>';
152
+
153
+ return sprintf(
154
+ '<div %s>
155
+ <h2 style="color: white; margin: 0 0 10px 0;">%s</h2>
156
+ <div style="font-size: 2em; line-height: 1.5; letter-spacing: %sem;">%s</div>
157
+ </div>',
158
+ $wrapper_attributes,
159
+ $title,
160
+ $spacing,
161
+ $emoji_display
162
+ );
163
+ },
164
+ 'supports' => array(
165
+ 'auto_register' => true,
166
+ ),
167
+ )
168
+ );
89
169
  }
90
170
  );