@wordpress/e2e-tests 8.0.2 → 8.2.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 (32) hide show
  1. package/CHANGELOG.md +7 -3
  2. package/package.json +9 -9
  3. package/plugins/class-test-widget.php +2 -1
  4. package/plugins/deprecated-node-matcher/index.js +1 -1
  5. package/plugins/hooks-api/index.js +1 -1
  6. package/plugins/iframed-block/jquery.test.js +2 -2
  7. package/plugins/iframed-block/script.js +0 -1
  8. package/plugins/iframed-enqueue-block-assets/script.js +2 -1
  9. package/plugins/iframed-masonry-block/editor.js +9 -3
  10. package/plugins/iframed-masonry-block/script.js +0 -1
  11. package/plugins/iframed-multiple-stylesheets/block.json +5 -1
  12. package/plugins/inner-blocks-allowed-blocks/index.js +10 -6
  13. package/plugins/inner-blocks-prioritized-inserter-blocks/index.js +36 -36
  14. package/plugins/inner-blocks-templates/index.js +63 -40
  15. package/plugins/interactive-blocks/deferred-store/view.js +6 -4
  16. package/plugins/interactive-blocks/directive-context/view.js +3 -4
  17. package/plugins/interactive-blocks/directive-each/view.js +44 -35
  18. package/plugins/interactive-blocks/directive-key/view.js +1 -1
  19. package/plugins/interactive-blocks/directive-on-document/view.js +2 -2
  20. package/plugins/interactive-blocks/directive-on-window/view.js +3 -3
  21. package/plugins/interactive-blocks/directive-priorities/view.js +6 -3
  22. package/plugins/interactive-blocks/directive-run/view.js +22 -18
  23. package/plugins/interactive-blocks/directive-text/view.js +2 -3
  24. package/plugins/interactive-blocks/directive-watch/view.js +3 -1
  25. package/plugins/interactive-blocks/namespace/view.js +0 -6
  26. package/plugins/interactive-blocks/router-navigate/view.js +3 -3
  27. package/plugins/interactive-blocks/router-regions/view.js +1 -1
  28. package/plugins/interactive-blocks/tovdom/cdata.js +1 -3
  29. package/plugins/interactive-blocks/with-scope/view.js +11 -7
  30. package/plugins/plugins-api/annotations-sidebar.js +6 -5
  31. package/plugins/plugins-api/error-boundary.js +1 -1
  32. package/plugins/test-autocompleter/index.js +4 -6
package/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 8.2.0 (2024-06-26)
6
+
7
+ ## 8.1.0 (2024-06-15)
8
+
5
9
  ## 8.0.0 (2024-05-31)
6
10
 
7
11
  ### Breaking Changes
@@ -97,7 +101,7 @@
97
101
 
98
102
  ## 5.3.0 (2022-10-05)
99
103
 
100
- ### New features
104
+ ### New Features
101
105
 
102
106
  - Added Autocomplete Component e2e test suite. [#42905](https://github.com/WordPress/gutenberg/pull/42905).
103
107
 
@@ -105,7 +109,7 @@
105
109
 
106
110
  ## 5.0.0 (2022-08-24)
107
111
 
108
- ### Breaking Change
112
+ ### Breaking Changes
109
113
 
110
114
  - Increase the minimum Node.js version to 14 ([#43141](https://github.com/WordPress/gutenberg/pull/43141)).
111
115
 
@@ -156,7 +160,7 @@
156
160
 
157
161
  ## 1.2.0 (2019-05-21)
158
162
 
159
- ### New features
163
+ ### New Features
160
164
 
161
165
  - Added Axe (the Accessibility Engine) API integration with e2e tests suite.
162
166
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/e2e-tests",
3
- "version": "8.0.2",
3
+ "version": "8.2.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.0.1",
28
- "@wordpress/interactivity": "^6.0.2",
29
- "@wordpress/interactivity-router": "^2.0.2",
30
- "@wordpress/jest-console": "^8.0.1",
31
- "@wordpress/jest-puppeteer-axe": "^7.0.1",
32
- "@wordpress/scripts": "^28.0.1",
33
- "@wordpress/url": "^4.0.1",
27
+ "@wordpress/e2e-test-utils": "^11.2.0",
28
+ "@wordpress/interactivity": "^6.2.0",
29
+ "@wordpress/interactivity-router": "^2.2.0",
30
+ "@wordpress/jest-console": "^8.2.0",
31
+ "@wordpress/jest-puppeteer-axe": "^7.2.0",
32
+ "@wordpress/scripts": "^28.2.0",
33
+ "@wordpress/url": "^4.2.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": "9dd5f8dcfa4fc7242e5d48be20ee789ad087b432"
50
+ "gitHead": "aa5b14bb5bdbb8d8a02914e154c3bc1c2f18ace6"
51
51
  }
@@ -56,12 +56,13 @@ class Test_Widget extends WP_Widget {
56
56
  /**
57
57
  * Handles updating settings for the current widget instance.
58
58
  *
59
+ * @since 4.8.1
60
+ *
59
61
  * @param array $new_instance New settings for this instance as input by the user via
60
62
  * WP_Widget::form().
61
63
  * @param array $old_instance Old settings for this instance.
62
64
  *
63
65
  * @return array Settings to save or bool false to cancel saving.
64
- * @since 4.8.1
65
66
  */
66
67
  // @codingStandardsIgnoreStart – to prevent phpcs from complaining about unused function argument.
67
68
  public function update( $new_instance, $old_instance ) {
@@ -70,7 +70,7 @@
70
70
  } );
71
71
  },
72
72
  } )
73
- )
73
+ );
74
74
  },
75
75
  save( { attributes } ) {
76
76
  return el(
@@ -16,7 +16,7 @@
16
16
  Button,
17
17
  {
18
18
  className: 'e2e-reset-block-button',
19
- variant: "secondary",
19
+ variant: 'secondary',
20
20
  onClick() {
21
21
  const emptyBlock = createBlock( props.name );
22
22
  props.onReplace( emptyBlock );
@@ -1,6 +1,6 @@
1
1
  ( ( $ ) => {
2
- $.fn.test = function() {
3
- return this.each( function() {
2
+ $.fn.test = function () {
3
+ return this.each( function () {
4
4
  $( this ).text( 'Iframed Block (set with jQuery)' );
5
5
  } );
6
6
  };
@@ -4,4 +4,3 @@
4
4
  $( '.wp-block-test-iframed-block' ).test();
5
5
  } );
6
6
  } )( window );
7
-
@@ -1,3 +1,4 @@
1
1
  window.addEventListener( 'load', () => {
2
- document.body.dataset.iframedEnqueueBlockAssetsL10n = window.iframedEnqueueBlockAssetsL10n.test;
2
+ document.body.dataset.iframedEnqueueBlockAssetsL10n =
3
+ window.iframedEnqueueBlockAssetsL10n.test;
3
4
  } );
@@ -6,18 +6,24 @@
6
6
 
7
7
  const content = [
8
8
  el( 'div', { className: 'grid-item' } ),
9
- el( 'div', { className: 'grid-item grid-item--width2 grid-item--height2' } ),
9
+ el( 'div', {
10
+ className: 'grid-item grid-item--width2 grid-item--height2',
11
+ } ),
10
12
  el( 'div', { className: 'grid-item grid-item--height3' } ),
11
13
  el( 'div', { className: 'grid-item grid-item--height2' } ),
12
14
  el( 'div', { className: 'grid-item grid-item--width3' } ),
13
15
  el( 'div', { className: 'grid-item' } ),
14
16
  el( 'div', { className: 'grid-item' } ),
15
17
  el( 'div', { className: 'grid-item grid-item--height2' } ),
16
- el( 'div', { className: 'grid-item grid-item--width2 grid-item--height3' } ),
18
+ el( 'div', {
19
+ className: 'grid-item grid-item--width2 grid-item--height3',
20
+ } ),
17
21
  el( 'div', { className: 'grid-item' } ),
18
22
  el( 'div', { className: 'grid-item grid-item--height2' } ),
19
23
  el( 'div', { className: 'grid-item' } ),
20
- el( 'div', { className: 'grid-item grid-item--width2 grid-item--height2' } ),
24
+ el( 'div', {
25
+ className: 'grid-item grid-item--width2 grid-item--height2',
26
+ } ),
21
27
  el( 'div', { className: 'grid-item grid-item--width2' } ),
22
28
  el( 'div', { className: 'grid-item' } ),
23
29
  el( 'div', { className: 'grid-item grid-item--height2' } ),
@@ -10,4 +10,3 @@
10
10
  } );
11
11
  } );
12
12
  } )( window );
13
-
@@ -12,5 +12,9 @@
12
12
  "textdomain": "iframed-multiple-stylesheets",
13
13
  "editorScript": "iframed-multiple-stylesheets-editor-script",
14
14
  "editorStyle": "file:./editor.css",
15
- "style": [ "iframed-multiple-stylesheets-style", "iframed-multiple-stylesheets-style2", "file:./style3.css" ]
15
+ "style": [
16
+ "iframed-multiple-stylesheets-style",
17
+ "iframed-multiple-stylesheets-style2",
18
+ "file:./style3.css"
19
+ ]
16
20
  }
@@ -10,7 +10,11 @@
10
10
 
11
11
  const allowedBlocksWhenSingleEmptyChild = [ 'core/image', 'core/list' ];
12
12
  const allowedBlocksWhenTwoChildren = [ 'core/gallery', 'core/video' ];
13
- const allowedBlocksWhenTreeOrMoreChildren = [ 'core/gallery', 'core/video', 'core/list' ];
13
+ const allowedBlocksWhenTreeOrMoreChildren = [
14
+ 'core/gallery',
15
+ 'core/video',
16
+ 'core/list',
17
+ ];
14
18
 
15
19
  registerBlockType( 'test/allowed-blocks-dynamic', {
16
20
  apiVersion: 3,
@@ -26,15 +30,15 @@
26
30
  },
27
31
  [ props.clientId ]
28
32
  );
29
- const blockProps = useBlockProps({
33
+ const blockProps = useBlockProps( {
30
34
  ...divProps,
31
35
  'data-number-of-children': numberOfChildren,
32
- });
36
+ } );
33
37
 
34
38
  let allowedBlocks = allowedBlocksWhenSingleEmptyChild;
35
39
  if ( numberOfChildren === 2 ) {
36
40
  allowedBlocks = allowedBlocksWhenTwoChildren;
37
- } else if( numberOfChildren > 2 ){
41
+ } else if ( numberOfChildren > 2 ) {
38
42
  allowedBlocks = allowedBlocksWhenTreeOrMoreChildren;
39
43
  }
40
44
 
@@ -42,12 +46,12 @@
42
46
  'div',
43
47
  blockProps,
44
48
  el( InnerBlocks, {
45
- allowedBlocks
49
+ allowedBlocks,
46
50
  } )
47
51
  );
48
52
  },
49
53
  save() {
50
54
  return el( 'div', divProps, el( InnerBlocks.Content ) );
51
- }
55
+ },
52
56
  } );
53
57
  } )();
@@ -3,16 +3,14 @@
3
3
  const { createElement: el } = wp.element;
4
4
  const { InnerBlocks } = wp.blockEditor;
5
5
 
6
- const divProps = {
6
+ const divProps = {
7
7
  className: 'product',
8
8
  style: { outline: '1px solid gray', padding: 5 },
9
9
  };
10
10
 
11
- // without a placeholder within the inner blocks it can be difficult to select the block using e2e tests
12
- // especially using Puppeteer, so we use an image block which has a placeholder.
13
- const template = [
14
- [ 'core/image' ],
15
- ];
11
+ // without a placeholder within the inner blocks it can be difficult to select the block using e2e tests
12
+ // especially using Puppeteer, so we use an image block which has a placeholder.
13
+ const template = [ [ 'core/image' ] ];
16
14
 
17
15
  const save = function () {
18
16
  return el( 'div', divProps, el( InnerBlocks.Content ) );
@@ -38,11 +36,11 @@
38
36
  'div',
39
37
  divProps,
40
38
  el( InnerBlocks, {
41
- template,
39
+ template,
42
40
  prioritizedInserterBlocks: [
43
- 'core/audio',
41
+ 'core/audio',
44
42
  'core/spacer',
45
- 'core/code',
43
+ 'core/code',
46
44
  ],
47
45
  } )
48
46
  );
@@ -51,32 +49,34 @@
51
49
  save,
52
50
  } );
53
51
 
54
- registerBlockType( 'test/prioritized-inserter-blocks-set-with-conflicting-allowed-blocks', {
55
- title: 'Prioritized Inserter Blocks Set With Conflicting Allowed Blocks',
56
- icon: 'carrot',
57
- category: 'text',
58
- edit() {
59
- return el(
60
- 'div',
61
- divProps,
62
- el( InnerBlocks, {
63
- template,
64
- allowedBlocks: [
65
- 'core/spacer',
66
- 'core/code',
67
- 'core/paragraph',
68
- 'core/heading'
69
- ],
70
- prioritizedInserterBlocks: [
71
- 'core/audio', // this is **not** in the allowedBlocks list
72
- 'core/spacer',
73
- 'core/code',
74
- ],
75
- } )
76
- );
77
- },
78
-
79
- save,
80
- } );
52
+ registerBlockType(
53
+ 'test/prioritized-inserter-blocks-set-with-conflicting-allowed-blocks',
54
+ {
55
+ title: 'Prioritized Inserter Blocks Set With Conflicting Allowed Blocks',
56
+ icon: 'carrot',
57
+ category: 'text',
58
+ edit() {
59
+ return el(
60
+ 'div',
61
+ divProps,
62
+ el( InnerBlocks, {
63
+ template,
64
+ allowedBlocks: [
65
+ 'core/spacer',
66
+ 'core/code',
67
+ 'core/paragraph',
68
+ 'core/heading',
69
+ ],
70
+ prioritizedInserterBlocks: [
71
+ 'core/audio', // this is **not** in the allowedBlocks list
72
+ 'core/spacer',
73
+ 'core/code',
74
+ ],
75
+ } )
76
+ );
77
+ },
81
78
 
79
+ save,
80
+ }
81
+ );
82
82
  } )();
@@ -53,9 +53,13 @@
53
53
  category: 'text',
54
54
 
55
55
  edit: function InnerBlocksNoLockingEdit() {
56
- return el( 'div', useBlockProps(), el( InnerBlocks, {
57
- template: TEMPLATE,
58
- } ) );
56
+ return el(
57
+ 'div',
58
+ useBlockProps(),
59
+ el( InnerBlocks, {
60
+ template: TEMPLATE,
61
+ } )
62
+ );
59
63
  },
60
64
 
61
65
  save,
@@ -68,10 +72,14 @@
68
72
  category: 'text',
69
73
 
70
74
  edit: function InnerBlocksBlocksLockingAllEdit() {
71
- return el( 'div', useBlockProps(), el( InnerBlocks, {
72
- template: TEMPLATE,
73
- templateLock: 'all',
74
- } ) );
75
+ return el(
76
+ 'div',
77
+ useBlockProps(),
78
+ el( InnerBlocks, {
79
+ template: TEMPLATE,
80
+ templateLock: 'all',
81
+ } )
82
+ );
75
83
  },
76
84
 
77
85
  save,
@@ -92,7 +100,9 @@
92
100
 
93
101
  edit: function InnerBlocksUpdateLockedTemplateEdit( props ) {
94
102
  const hasUpdatedTemplated = props.attributes.hasUpdatedTemplate;
95
- return el( 'div', null,
103
+ return el(
104
+ 'div',
105
+ null,
96
106
  el(
97
107
  'button',
98
108
  {
@@ -102,12 +112,16 @@
102
112
  },
103
113
  'Update template'
104
114
  ),
105
- el( 'div', useBlockProps(), el( InnerBlocks, {
106
- template: hasUpdatedTemplated
107
- ? TEMPLATE_TWO_PARAGRAPHS
108
- : TEMPLATE,
109
- templateLock: 'all',
110
- } ) ),
115
+ el(
116
+ 'div',
117
+ useBlockProps(),
118
+ el( InnerBlocks, {
119
+ template: hasUpdatedTemplated
120
+ ? TEMPLATE_TWO_PARAGRAPHS
121
+ : TEMPLATE,
122
+ templateLock: 'all',
123
+ } )
124
+ )
111
125
  );
112
126
  },
113
127
 
@@ -121,10 +135,14 @@
121
135
  category: 'text',
122
136
 
123
137
  edit: function InnerBlocksParagraphPlaceholderEdit() {
124
- return el( 'div', useBlockProps(), el( InnerBlocks, {
125
- template: TEMPLATE_PARAGRAPH_PLACEHOLDER,
126
- templateInsertUpdatesSelection: true,
127
- } ) );
138
+ return el(
139
+ 'div',
140
+ useBlockProps(),
141
+ el( InnerBlocks, {
142
+ template: TEMPLATE_PARAGRAPH_PLACEHOLDER,
143
+ templateInsertUpdatesSelection: true,
144
+ } )
145
+ );
128
146
  },
129
147
 
130
148
  save,
@@ -171,36 +189,41 @@
171
189
  },
172
190
 
173
191
  edit: function InnerBlocksTransformerTargetEdit() {
174
- return el( 'div', useBlockProps(), el( InnerBlocks, {
175
- template: TEMPLATE,
176
- } ) );
192
+ return el(
193
+ 'div',
194
+ useBlockProps(),
195
+ el( InnerBlocks, {
196
+ template: TEMPLATE,
197
+ } )
198
+ );
177
199
  },
178
200
 
179
201
  save,
180
202
  } );
181
203
 
182
- registerBlockType(
183
- 'test/test-inner-blocks-async-template',
184
- {
185
- apiVersion: 3,
186
- title: 'Test Inner Blocks Async Template',
187
- icon: 'cart',
188
- category: 'text',
204
+ registerBlockType( 'test/test-inner-blocks-async-template', {
205
+ apiVersion: 3,
206
+ title: 'Test Inner Blocks Async Template',
207
+ icon: 'cart',
208
+ category: 'text',
189
209
 
190
- edit: function InnerBlocksAsyncTemplateEdit() {
191
- const [ template, setTemplate ] = useState( [] );
210
+ edit: function InnerBlocksAsyncTemplateEdit() {
211
+ const [ template, setTemplate ] = useState( [] );
192
212
 
193
- setInterval( () => {
194
- setTemplate( TEMPLATE_TWO_PARAGRAPHS );
195
- }, 1000 );
213
+ setInterval( () => {
214
+ setTemplate( TEMPLATE_TWO_PARAGRAPHS );
215
+ }, 1000 );
196
216
 
197
- return el('div', useBlockProps(), el( InnerBlocks, {
217
+ return el(
218
+ 'div',
219
+ useBlockProps(),
220
+ el( InnerBlocks, {
198
221
  template,
199
- } ) );
200
- },
222
+ } )
223
+ );
224
+ },
201
225
 
202
- // Purposely do not save inner blocks so that it's possible to test template resolution.
203
- save() {},
204
- }
205
- );
226
+ // Purposely do not save inner blocks so that it's possible to test template resolution.
227
+ save() {},
228
+ } );
206
229
  } )();
@@ -3,8 +3,9 @@
3
3
  */
4
4
  import { store, getContext } from '@wordpress/interactivity';
5
5
 
6
- document.addEventListener( 'DOMContentLoaded', () => {
7
- setTimeout( () => {
6
+ window.addEventListener(
7
+ '_test_proceed_',
8
+ () => {
8
9
  store( 'test/deferred-store', {
9
10
  state: {
10
11
  reversedText() {
@@ -16,5 +17,6 @@ document.addEventListener( 'DOMContentLoaded', () => {
16
17
  },
17
18
  },
18
19
  } );
19
- }, 100 );
20
- } );
20
+ },
21
+ { once: true }
22
+ );
@@ -21,7 +21,7 @@ store( 'directive-context', {
21
21
  get isProxyPreservedOnCopy() {
22
22
  const { obj, obj2 } = getContext();
23
23
  return obj === obj2;
24
- }
24
+ },
25
25
  },
26
26
  actions: {
27
27
  updateContext( event ) {
@@ -47,7 +47,7 @@ store( 'directive-context', {
47
47
  copyObj() {
48
48
  const ctx = getContext();
49
49
  ctx.obj2 = ctx.obj;
50
- }
50
+ },
51
51
  },
52
52
  } );
53
53
 
@@ -92,7 +92,6 @@ const { actions } = store( 'directive-context-navigate', {
92
92
  return routerActions.navigate( url, { force: true, html } );
93
93
  }
94
94
  );
95
-
96
95
  },
97
96
  *asyncNavigate() {
98
97
  yield actions.navigate();
@@ -118,4 +117,4 @@ store( 'directive-context-watch', {
118
117
  ctx.changes = ctx.changes + 1;
119
118
  },
120
119
  },
121
- });
120
+ } );
@@ -1,7 +1,12 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { store, getContext, useInit, privateApis } from '@wordpress/interactivity';
4
+ import {
5
+ store,
6
+ getContext,
7
+ useInit,
8
+ privateApis,
9
+ } from '@wordpress/interactivity';
5
10
 
6
11
  const { state } = store( 'directive-each' );
7
12
 
@@ -16,8 +21,8 @@ store( 'directive-each', {
16
21
  fruits: [ 'avocado', 'banana', 'cherimoya' ],
17
22
  get fruitId() {
18
23
  const { idPrefix, fruit } = getContext();
19
- return `${idPrefix}${fruit}`;
20
- }
24
+ return `${ idPrefix }${ fruit }`;
25
+ },
21
26
  },
22
27
  actions: {
23
28
  removeFruit() {
@@ -43,17 +48,17 @@ store( 'directive-each', {
43
48
  {
44
49
  title: 'A Game of Thrones',
45
50
  author: 'George R.R. Martin',
46
- isbn: "9780553588484",
51
+ isbn: '9780553588484',
47
52
  },
48
53
  {
49
54
  title: 'A Clash of Kings',
50
55
  author: 'George R.R. Martin',
51
- isbn: "9780553381696",
56
+ isbn: '9780553381696',
52
57
  },
53
58
  {
54
59
  title: 'A Storm of Swords',
55
60
  author: 'George R.R. Martin',
56
- isbn: "9780553573428",
61
+ isbn: '9780553573428',
57
62
  },
58
63
  ],
59
64
  },
@@ -70,7 +75,7 @@ store( 'directive-each', {
70
75
  const book = {
71
76
  title: 'A Feast for Crows',
72
77
  author: 'George R.R. Martin',
73
- isbn: "9780553582024",
78
+ isbn: '9780553582024',
74
79
  };
75
80
  state.books.splice( 0, 0, book );
76
81
  },
@@ -78,7 +83,7 @@ store( 'directive-each', {
78
83
  const book = {
79
84
  title: 'A Feast for Crows',
80
85
  author: 'George R.R. Martin',
81
- isbn: "9780553582024",
86
+ isbn: '9780553582024',
82
87
  };
83
88
  state.books.splice( 0, 1, book );
84
89
  },
@@ -101,58 +106,63 @@ store( 'directive-each', {
101
106
  if ( state.numbers.length > 0 ) {
102
107
  state.numbers.unshift( state.numbers[ 0 ] - 1 );
103
108
  }
104
- }
109
+ },
105
110
  },
106
111
  } );
107
112
 
108
113
  store( 'directive-each', {
109
114
  state: {
110
- emptyList: []
115
+ emptyList: [],
111
116
  },
112
117
  actions: {
113
118
  addItem() {
114
119
  state.emptyList.push( `item ${ state.emptyList.length }` );
115
- }
120
+ },
116
121
  },
117
122
  } );
118
123
 
119
124
  store( 'directive-each', {
120
125
  state: {
121
126
  numbersAndNames: [
122
- { name: "two", value: 2 },
123
- { name: "three", value: 3 },
127
+ { name: 'two', value: 2 },
128
+ { name: 'three', value: 3 },
124
129
  ],
125
130
  },
126
131
  actions: {
127
132
  unshiftNumberAndName() {
128
- state.numbersAndNames.unshift( { name: "one", value: 1 } );
129
- }
133
+ state.numbersAndNames.unshift( { name: 'one', value: 1 } );
134
+ },
130
135
  },
131
136
  } );
132
137
 
133
138
  store( 'directive-each', {
134
139
  state: {
135
140
  animalBreeds: [
136
- { name: "Dog", breeds: [ 'chihuahua', 'rottweiler' ] },
137
- { name: "Cat", breeds: [ 'sphynx', 'siamese' ] },
141
+ { name: 'Dog', breeds: [ 'chihuahua', 'rottweiler' ] },
142
+ { name: 'Cat', breeds: [ 'sphynx', 'siamese' ] },
138
143
  ],
139
144
  },
140
145
  actions: {
141
146
  addAnimal() {
142
147
  state.animalBreeds.unshift( {
143
- name: "Rat", breeds: [ 'dumbo', 'rex' ]
148
+ name: 'Rat',
149
+ breeds: [ 'dumbo', 'rex' ],
144
150
  } );
145
151
  },
146
152
  addBreeds() {
147
- state
148
- .animalBreeds
149
- .forEach( ( { name, breeds } ) => {
150
- if ( name === 'Dog') {breeds.unshift( 'german shepherd' );}
151
- if ( name === 'Cat') {breeds.unshift( 'maine coon' );}
152
- if ( name === 'Rat') {breeds.unshift( 'satin' );}
153
- } );
154
- }
155
- }
153
+ state.animalBreeds.forEach( ( { name, breeds } ) => {
154
+ if ( name === 'Dog' ) {
155
+ breeds.unshift( 'german shepherd' );
156
+ }
157
+ if ( name === 'Cat' ) {
158
+ breeds.unshift( 'maine coon' );
159
+ }
160
+ if ( name === 'Rat' ) {
161
+ breeds.unshift( 'satin' );
162
+ }
163
+ } );
164
+ },
165
+ },
156
166
  } );
157
167
 
158
168
  const html = `
@@ -180,14 +190,14 @@ store( 'directive-each', {
180
190
  actions: {
181
191
  *navigate() {
182
192
  const { actions } = yield import(
183
- "@wordpress/interactivity-router"
193
+ '@wordpress/interactivity-router'
184
194
  );
185
195
  return actions.navigate( window.location, {
186
196
  force: true,
187
197
  html,
188
198
  } );
189
199
  },
190
- }
200
+ },
191
201
  } );
192
202
 
193
203
  const { directive } = privateApis(
@@ -208,12 +218,11 @@ directive(
208
218
  { priority: 2 }
209
219
  );
210
220
 
211
- store('directive-each', {
212
- callbacks: {
221
+ store( 'directive-each', {
222
+ callbacks: {
213
223
  updateCallbackRunCount() {
214
224
  const ctx = getContext();
215
225
  ctx.callbackRunCount += 1;
216
- }
217
- },
218
- });
219
-
226
+ },
227
+ },
228
+ } );
@@ -19,7 +19,7 @@ store( 'directive-key', {
19
19
  actions: {
20
20
  *navigate() {
21
21
  const { actions } = yield import(
22
- "@wordpress/interactivity-router"
22
+ '@wordpress/interactivity-router'
23
23
  );
24
24
  return actions.navigate( window.location, {
25
25
  force: true,
@@ -46,6 +46,6 @@ const { state } = store( 'directive-on-document', {
46
46
  },
47
47
  keydownSecondHandler: () => {
48
48
  state.keydownSecondHandler = 'yes';
49
- }
50
- }
49
+ },
50
+ },
51
51
  } );
@@ -34,7 +34,7 @@ const { state } = store( 'directive-on-window', {
34
34
  },
35
35
  init() {
36
36
  state.isEventAttached = 'yes';
37
- }
37
+ },
38
38
  },
39
39
  actions: {
40
40
  visibilityHandler: () => {
@@ -46,6 +46,6 @@ const { state } = store( 'directive-on-window', {
46
46
  },
47
47
  resizeSecondHandler: () => {
48
48
  state.resizeSecondHandler = 'yes';
49
- }
50
- }
49
+ },
50
+ },
51
51
  } );
@@ -5,7 +5,7 @@ import {
5
5
  store,
6
6
  getContext,
7
7
  useEffect,
8
- privateApis
8
+ privateApis,
9
9
  } from '@wordpress/interactivity';
10
10
 
11
11
  const { directive, deepSignal, h } = privateApis(
@@ -24,8 +24,11 @@ const namespace = 'directive-priorities';
24
24
  */
25
25
  const executionProof = ( n ) => {
26
26
  const el = document.querySelector( '[data-testid="execution order"]' );
27
- if ( ! el.textContent ) {el.textContent = n;}
28
- else {el.textContent += `, ${ n }`;}
27
+ if ( ! el.textContent ) {
28
+ el.textContent = n;
29
+ } else {
30
+ el.textContent += `, ${ n }`;
31
+ }
29
32
  };
30
33
 
31
34
  /**
@@ -6,7 +6,7 @@ import {
6
6
  useInit,
7
7
  useWatch,
8
8
  getElement,
9
- privateApis
9
+ privateApis,
10
10
  } from '@wordpress/interactivity';
11
11
 
12
12
  const { directive, cloneElement } = privateApis(
@@ -16,7 +16,11 @@ const { directive, cloneElement } = privateApis(
16
16
  // Custom directive to show hide the content elements in which it is placed.
17
17
  directive(
18
18
  'show-children',
19
- ( { directives: { 'show-children': showChildren }, element, evaluate } ) => {
19
+ ( {
20
+ directives: { 'show-children': showChildren },
21
+ element,
22
+ evaluate,
23
+ } ) => {
20
24
  const entry = showChildren.find(
21
25
  ( { suffix } ) => suffix === 'default'
22
26
  );
@@ -51,7 +55,7 @@ const { state } = store( 'directive-run', {
51
55
  isHydrated: 'no',
52
56
  isMounted: 'no',
53
57
  renderCount: 0,
54
- clickCount: 0
58
+ clickCount: 0,
55
59
  },
56
60
  actions: {
57
61
  toggle() {
@@ -62,7 +66,7 @@ const { state } = store( 'directive-run', {
62
66
  },
63
67
  *navigate() {
64
68
  const { actions } = yield import(
65
- "@wordpress/interactivity-router"
69
+ '@wordpress/interactivity-router'
66
70
  );
67
71
  return actions.navigate( window.location, {
68
72
  force: true,
@@ -84,13 +88,13 @@ const { state } = store( 'directive-run', {
84
88
  // Runs only on first render.
85
89
  useInit( () => {
86
90
  const { ref } = getElement();
87
- ref
88
- .closest( '[data-testid="wp-run hooks results"]')
89
- .setAttribute( 'data-init', 'initialized' );
91
+ ref.closest(
92
+ '[data-testid="wp-run hooks results"]'
93
+ ).setAttribute( 'data-init', 'initialized' );
90
94
  return () => {
91
- ref
92
- .closest( '[data-testid="wp-run hooks results"]')
93
- .setAttribute( 'data-init', 'cleaned up' );
95
+ ref.closest(
96
+ '[data-testid="wp-run hooks results"]'
97
+ ).setAttribute( 'data-init', 'cleaned up' );
94
98
  };
95
99
  } );
96
100
 
@@ -99,15 +103,15 @@ const { state } = store( 'directive-run', {
99
103
  useWatch( () => {
100
104
  const { ref } = getElement();
101
105
  const { clickCount } = state;
102
- ref
103
- .closest( '[data-testid="wp-run hooks results"]')
104
- .setAttribute( 'data-watch', clickCount );
106
+ ref.closest(
107
+ '[data-testid="wp-run hooks results"]'
108
+ ).setAttribute( 'data-watch', clickCount );
105
109
  return () => {
106
- ref
107
- .closest( '[data-testid="wp-run hooks results"]')
108
- .setAttribute( 'data-watch', 'cleaned up' );
110
+ ref.closest(
111
+ '[data-testid="wp-run hooks results"]'
112
+ ).setAttribute( 'data-watch', 'cleaned up' );
109
113
  };
110
114
  } );
111
- }
112
- }
115
+ },
116
+ },
113
117
  } );
@@ -7,13 +7,12 @@ const { h } = privateApis(
7
7
  'I acknowledge that using private APIs means my theme or plugin will inevitably break in the next version of WordPress.'
8
8
  );
9
9
 
10
-
11
10
  const { state } = store( 'directive-context', {
12
11
  state: {
13
12
  text: 'Text 1',
14
- component: () => ( h( 'div', {}, state.text ) ),
13
+ component: () => h( 'div', {}, state.text ),
15
14
  number: 1,
16
- boolean: true
15
+ boolean: true,
17
16
  },
18
17
  actions: {
19
18
  toggleStateText() {
@@ -13,7 +13,9 @@ directive(
13
13
  'show-mock',
14
14
  ( { directives: { 'show-mock': showMock }, element, evaluate } ) => {
15
15
  const entry = showMock.find( ( { suffix } ) => suffix === 'default' );
16
- if ( ! evaluate( entry ) ) {return null;}
16
+ if ( ! evaluate( entry ) ) {
17
+ return null;
18
+ }
17
19
  return element;
18
20
  }
19
21
  );
@@ -3,7 +3,6 @@
3
3
  */
4
4
  import { store } from '@wordpress/interactivity';
5
5
 
6
-
7
6
  store( '', {
8
7
  state: {
9
8
  url: '/empty-string-url',
@@ -63,8 +62,3 @@ store( '"quoted string"', {
63
62
  url: '/quoted-url',
64
63
  },
65
64
  } );
66
-
67
-
68
-
69
-
70
-
@@ -14,8 +14,8 @@ const { state } = store( 'router', {
14
14
  data: {
15
15
  get getterProp() {
16
16
  return `value from getter (${ state.data.prop1 })`;
17
- }
18
- }
17
+ },
18
+ },
19
19
  },
20
20
  actions: {
21
21
  *navigate( e ) {
@@ -29,7 +29,7 @@ const { state } = store( 'router', {
29
29
  const { timeout } = state;
30
30
 
31
31
  const { actions } = yield import(
32
- "@wordpress/interactivity-router"
32
+ '@wordpress/interactivity-router'
33
33
  );
34
34
  yield actions.navigate( e.target.href, { force, timeout } );
35
35
 
@@ -20,7 +20,7 @@ const { state } = store( 'router-regions', {
20
20
  *navigate( e ) {
21
21
  e.preventDefault();
22
22
  const { actions } = yield import(
23
- "@wordpress/interactivity-router"
23
+ '@wordpress/interactivity-router'
24
24
  );
25
25
  yield actions.navigate( e.target.href );
26
26
  },
@@ -10,6 +10,4 @@ const cdata = `
10
10
  const cdataElement = new DOMParser()
11
11
  .parseFromString( cdata, 'text/xml' )
12
12
  .querySelector( 'div' );
13
- document
14
- .getElementById( 'replace-with-cdata' )
15
- .replaceWith( cdataElement );
13
+ document.getElementById( 'replace-with-cdata' ).replaceWith( cdataElement );
@@ -6,15 +6,19 @@ import { store, getContext, withScope } from '@wordpress/interactivity';
6
6
  store( 'with-scope', {
7
7
  callbacks: {
8
8
  asyncInit: () => {
9
- setTimeout( withScope(function*() {
10
- yield new Promise(resolve => setTimeout(resolve, 1));
11
- const context = getContext()
12
- context.asyncCounter += 1;
13
- }, 1 ));
9
+ setTimeout(
10
+ withScope( function* () {
11
+ yield new Promise( ( resolve ) =>
12
+ setTimeout( resolve, 1 )
13
+ );
14
+ const context = getContext();
15
+ context.asyncCounter += 1;
16
+ }, 1 )
17
+ );
14
18
  },
15
19
  syncInit: () => {
16
- const context = getContext()
20
+ const context = getContext();
17
21
  context.syncCounter += 1;
18
- }
22
+ },
19
23
  },
20
24
  } );
@@ -48,15 +48,16 @@
48
48
  el(
49
49
  Button,
50
50
  {
51
- variant: "primary",
51
+ variant: 'primary',
52
52
  onClick: () => {
53
53
  dispatch(
54
54
  'core/annotations'
55
55
  ).__experimentalAddAnnotation( {
56
56
  source: 'e2e-tests',
57
- blockClientId: select(
58
- 'core/block-editor'
59
- ).getBlockOrder()[ 0 ],
57
+ blockClientId:
58
+ select(
59
+ 'core/block-editor'
60
+ ).getBlockOrder()[ 0 ],
60
61
  richTextIdentifier: 'content',
61
62
  range: {
62
63
  start: parseInt( this.state.start, 10 ),
@@ -70,7 +71,7 @@
70
71
  el(
71
72
  Button,
72
73
  {
73
- variant: "primary",
74
+ variant: 'primary',
74
75
  onClick: () => {
75
76
  dispatch(
76
77
  'core/annotations'
@@ -2,7 +2,7 @@
2
2
  const registerPlugin = wp.plugins.registerPlugin;
3
3
 
4
4
  function MyErrorPlugin() {
5
- throw new Error('Whoops!');
5
+ throw new Error( 'Whoops!' );
6
6
  }
7
7
 
8
8
  registerPlugin( 'my-error-plugin', {
@@ -1,4 +1,4 @@
1
- (function () {
1
+ ( function () {
2
2
  const fruits = {
3
3
  name: 'fruit',
4
4
  // The prefix that triggers this completer
@@ -20,9 +20,7 @@
20
20
  // Declares that the Grapes option is disabled
21
21
  isOptionDisabled: ( option ) => option.name === 'Grapes',
22
22
  // Declares completions should be inserted as abbreviations
23
- getOptionCompletion: ( option ) => (
24
- option.visual
25
- ),
23
+ getOptionCompletion: ( option ) => option.visual,
26
24
  };
27
25
 
28
26
  function duplicateUserMentions( completers ) {
@@ -43,7 +41,7 @@
43
41
  ? [ ...completers, fruits, copiedUsers ]
44
42
  : completers;
45
43
  }
46
-
44
+
47
45
  // Adding the filter with a priority of 11
48
46
  // to ensure it fires after the default user mentions are added.
49
47
  wp.hooks.addFilter(
@@ -52,4 +50,4 @@
52
50
  appendTestCompleters,
53
51
  11
54
52
  );
55
- })()
53
+ } )();