@wordpress/e2e-tests 7.11.0 → 7.12.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,8 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 7.12.0 (2023-08-31)
6
+
5
7
  ## 7.11.0 (2023-08-16)
6
8
 
7
9
  ## 7.10.0 (2023-08-10)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/e2e-tests",
3
- "version": "7.11.0",
3
+ "version": "7.12.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",
@@ -23,16 +23,16 @@
23
23
  "node": ">=14"
24
24
  },
25
25
  "dependencies": {
26
- "@wordpress/e2e-test-utils": "^10.11.0",
27
- "@wordpress/jest-console": "^7.11.0",
28
- "@wordpress/jest-puppeteer-axe": "^6.11.0",
29
- "@wordpress/scripts": "^26.11.0",
30
- "@wordpress/url": "^3.41.0",
26
+ "@wordpress/e2e-test-utils": "^10.12.0",
27
+ "@wordpress/jest-console": "^7.12.0",
28
+ "@wordpress/jest-puppeteer-axe": "^6.12.0",
29
+ "@wordpress/scripts": "^26.12.0",
30
+ "@wordpress/url": "^3.42.0",
31
31
  "chalk": "^4.0.0",
32
32
  "expect-puppeteer": "^4.4.0",
33
33
  "filenamify": "^4.2.0",
34
- "jest-message-util": "^29.5.0",
35
- "jest-snapshot": "^29.5.0",
34
+ "jest-message-util": "^29.6.2",
35
+ "jest-snapshot": "^29.6.2",
36
36
  "puppeteer-testing-library": "^0.5.0",
37
37
  "uuid": "^8.3.0"
38
38
  },
@@ -45,5 +45,5 @@
45
45
  "publishConfig": {
46
46
  "access": "public"
47
47
  },
48
- "gitHead": "78a288d55b83a713b2f7d98d5a855c0771a2afc6"
48
+ "gitHead": "5eac1734bcdca2301fdd37ec8cfe2a45e722a2c4"
49
49
  }
@@ -56,4 +56,44 @@
56
56
  >
57
57
  Some Text
58
58
  </p>
59
+
60
+ <?php
61
+ $hydration_cases = array(
62
+ 'false' => '{ "value": false }',
63
+ 'true' => '{ "value": true }',
64
+ 'null' => '{ "value": null }',
65
+ 'undef' => '{ "__any": "any" }',
66
+ 'emptyString' => '{ "value": "" }',
67
+ 'anyString' => '{ "value": "any" }',
68
+ 'number' => '{ "value": 10 }',
69
+ );
70
+ ?>
71
+
72
+ <?php foreach ( $hydration_cases as $type => $context ) : ?>
73
+ <div
74
+ data-testid='hydrating <?php echo $type; ?>'
75
+ data-wp-context='<?php echo $context; ?>'
76
+ >
77
+ <img
78
+ alt="Red dot"
79
+ data-testid="image"
80
+ data-wp-bind--width="context.value"
81
+ src="data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUA
82
+ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
83
+ 9TXL0Y4OHwAAAABJRU5ErkJggg=="
84
+ >
85
+ <input
86
+ type="text"
87
+ data-testid="input"
88
+ data-wp-bind--name="context.value"
89
+ data-wp-bind--value="context.value"
90
+ data-wp-bind--disabled="context.value"
91
+ data-wp-bind--aria-disabled="context.value"
92
+ >
93
+ <button
94
+ data-testid="toggle value"
95
+ data-wp-on--click="actions.toggleValue"
96
+ >Toggle</button>
97
+ </div>
98
+ <?php endforeach; ?>
59
99
  </div>
@@ -18,6 +18,17 @@
18
18
  state.show = ! state.show;
19
19
  state.width += foo.bar;
20
20
  },
21
+ toggleValue: ( { context } ) => {
22
+ const previousValue = ( 'previousValue' in context )
23
+ ? context.previousValue
24
+ // Any string works here; we just want to toggle the value
25
+ // to ensure Preact renders the same we are hydrating in the
26
+ // first place.
27
+ : 'tacocat';
28
+
29
+ context.previousValue = context.value;
30
+ context.value = previousValue;
31
+ }
21
32
  },
22
33
  } );
23
34
  } )( window );
@@ -119,3 +119,16 @@
119
119
  </button>
120
120
  </div>
121
121
  </div>
122
+
123
+ <div
124
+ data-wp-interactive
125
+ data-wp-navigation-id="navigation"
126
+ data-wp-context='{ "text": "first page" }'
127
+ >
128
+ <div data-testid="navigation text" data-wp-text="context.text"></div>
129
+ <div data-testid="navigation new text" data-wp-text="context.newText"></div>
130
+ <button data-testid="toggle text" data-wp-on--click="actions.toggleText">Toggle Text</button>
131
+ <button data-testid="add new text" data-wp-on--click="actions.addNewText">Add New Text</button>
132
+ <button data-testid="navigate" data-wp-on--click="actions.navigate">Navigate</button>
133
+ <button data-testid="async navigate" data-wp-on--click="actions.asyncNavigate">Async Navigate</button>
134
+ </div>
@@ -1,5 +1,19 @@
1
1
  ( ( { wp } ) => {
2
- const { store } = wp.interactivity;
2
+ const { store, navigate } = wp.interactivity;
3
+
4
+ const html = `
5
+ <div
6
+ data-wp-interactive
7
+ data-wp-navigation-id="navigation"
8
+ data-wp-context='{ "text": "second page" }'
9
+ >
10
+ <div data-testid="navigation text" data-wp-text="context.text"></div>
11
+ <div data-testid="navigation new text" data-wp-text="context.newText"></div>
12
+ <button data-testid="toggle text" data-wp-on--click="actions.toggleText">Toggle Text</button>
13
+ <button data-testid="add new text" data-wp-on--click="actions.addNewText">Add new text</button>
14
+ <button data-testid="navigate" data-wp-on--click="actions.navigate">Navigate</button>
15
+ <button data-testid="async navigate" data-wp-on--click="actions.asyncNavigate">Async Navigate</button>
16
+ </div>`;
3
17
 
4
18
  store( {
5
19
  derived: {
@@ -17,6 +31,25 @@
17
31
  toggleContextText: ( { context } ) => {
18
32
  context.text = context.text === 'Text 1' ? 'Text 2' : 'Text 1';
19
33
  },
34
+ toggleText: ( { context } ) => {
35
+ context.text = "changed dynamically";
36
+ },
37
+ addNewText: ( { context } ) => {
38
+ context.newText = 'some new text';
39
+ },
40
+ navigate: () => {
41
+ navigate( window.location, {
42
+ force: true,
43
+ html,
44
+ } );
45
+ },
46
+ asyncNavigate: async ({ context }) => {
47
+ await navigate( window.location, {
48
+ force: true,
49
+ html,
50
+ } );
51
+ context.newText = 'changed from async action';
52
+ }
20
53
  },
21
54
  } );
22
55
  } )( window );
@@ -0,0 +1,14 @@
1
+ {
2
+ "apiVersion": 2,
3
+ "name": "test/directive-key",
4
+ "title": "E2E Interactivity tests - directive key",
5
+ "category": "text",
6
+ "icon": "heart",
7
+ "description": "",
8
+ "supports": {
9
+ "interactivity": true
10
+ },
11
+ "textdomain": "e2e-interactivity",
12
+ "viewScript": "directive-key-view",
13
+ "render": "file:./render.php"
14
+ }
@@ -0,0 +1,18 @@
1
+ <?php
2
+ /**
3
+ * HTML for testing the directive `data-wp-key`.
4
+ *
5
+ * @package gutenberg-test-interactive-blocks
6
+ */
7
+
8
+ ?>
9
+
10
+ <div data-wp-interactive data-wp-navigation-id="some-id">
11
+ <ul>
12
+ <li data-wp-key="id-2" data-testid="first-item">2</li>
13
+ <li data-wp-key="id-3">3</li>
14
+ </ul>
15
+ <button data-testid="navigate" data-wp-on--click="actions.navigate">
16
+ Navigate
17
+ </button>
18
+ </div>
@@ -0,0 +1,23 @@
1
+ ( ( { wp } ) => {
2
+ const { store, navigate } = wp.interactivity;
3
+
4
+ const html = `
5
+ <div data-wp-interactive data-wp-navigation-id="some-id">
6
+ <ul>
7
+ <li data-wp-key="id-1">1</li>
8
+ <li data-wp-key="id-2" data-testid="second-item">2</li>
9
+ <li data-wp-key="id-3">3</li>
10
+ </ul>
11
+ </div>`;
12
+
13
+ store( {
14
+ actions: {
15
+ navigate: () => {
16
+ navigate( window.location, {
17
+ force: true,
18
+ html,
19
+ } );
20
+ },
21
+ },
22
+ } );
23
+ } )( window );
@@ -0,0 +1,14 @@
1
+ {
2
+ "apiVersion": 2,
3
+ "name": "test/directive-slots",
4
+ "title": "E2E Interactivity tests - directive slots",
5
+ "category": "text",
6
+ "icon": "heart",
7
+ "description": "",
8
+ "supports": {
9
+ "interactivity": true
10
+ },
11
+ "textdomain": "e2e-interactivity",
12
+ "viewScript": "directive-slots-view",
13
+ "render": "file:./render.php"
14
+ }
@@ -0,0 +1,67 @@
1
+ <?php
2
+ /**
3
+ * HTML for testing the directive `data-wp-bind`.
4
+ *
5
+ * @package gutenberg-test-interactive-blocks
6
+ */
7
+
8
+ ?>
9
+ <div
10
+ data-wp-interactive
11
+ data-wp-slot-provider
12
+ data-wp-context='{ "text": "fill" }'
13
+ >
14
+ <div data-testid="slots" data-wp-context='{ "text": "fill inside slots" }'>
15
+ <div
16
+ data-testid="slot-1"
17
+ data-wp-key="slot-1"
18
+ data-wp-slot="slot-1"
19
+ data-wp-context='{ "text": "fill inside slot 1" }'
20
+ >[1]</div>
21
+ <div
22
+ data-testid="slot-2"
23
+ data-wp-key="slot-2"
24
+ data-wp-slot='{ "name": "slot-2", "position": "before" }'
25
+ data-wp-context='{ "text": "[2]" }'
26
+ data-wp-text='context.text'
27
+ data-wp-on--click="actions.updateSlotText"
28
+ >[2]</div>
29
+ <div
30
+ data-testid="slot-3"
31
+ data-wp-key="slot-3"
32
+ data-wp-slot='{ "name": "slot-3", "position": "after" }'
33
+ data-wp-context='{ "text": "[3]" }'
34
+ data-wp-text='context.text'
35
+ data-wp-on--click="actions.updateSlotText"
36
+ >[3]</div>
37
+ <div
38
+ data-testid="slot-4"
39
+ data-wp-key="slot-4"
40
+ data-wp-slot='{ "name": "slot-4", "position": "children" }'
41
+ data-wp-context='{ "text": "fill inside slot 4" }'
42
+ >[4]</div>
43
+ <div
44
+ data-testid="slot-5"
45
+ data-wp-key="slot-5"
46
+ data-wp-slot='{ "name": "slot-5", "position": "replace" }'
47
+ data-wp-context='{ "text": "fill inside slot 5" }'
48
+ >[5]</div>
49
+ </div>
50
+
51
+ <div data-testid="fill-container">
52
+ <span
53
+ data-testid="fill"
54
+ data-wp-fill="state.slot"
55
+ data-wp-text="context.text"
56
+ >initial</span>
57
+ </div>
58
+
59
+ <div data-wp-on--click="actions.changeSlot">
60
+ <button data-testid="slot-1-button" data-slot="slot-1">slot-1</button>
61
+ <button data-testid="slot-2-button" data-slot="slot-2">slot-2</button>
62
+ <button data-testid="slot-3-button" data-slot="slot-3">slot-3</button>
63
+ <button data-testid="slot-4-button" data-slot="slot-4">slot-4</button>
64
+ <button data-testid="slot-5-button" data-slot="slot-5">slot-5</button>
65
+ <button data-testid="reset" data-slot="">reset</button>
66
+ </div>
67
+ </div>
@@ -0,0 +1,18 @@
1
+ ( ( { wp } ) => {
2
+ const { store } = wp.interactivity;
3
+
4
+ store( {
5
+ state: {
6
+ slot: ''
7
+ },
8
+ actions: {
9
+ changeSlot: ( { state, event } ) => {
10
+ state.slot = event.target.dataset.slot;
11
+ },
12
+ updateSlotText: ( { context } ) => {
13
+ const n = context.text[1];
14
+ context.text = `[${n} updated]`;
15
+ },
16
+ },
17
+ } );
18
+ } )( window );
@@ -0,0 +1,14 @@
1
+ {
2
+ "apiVersion": 2,
3
+ "name": "test/router-regions",
4
+ "title": "E2E Interactivity tests - router regions",
5
+ "category": "text",
6
+ "icon": "heart",
7
+ "description": "",
8
+ "supports": {
9
+ "interactivity": true
10
+ },
11
+ "textdomain": "e2e-interactivity",
12
+ "viewScript": "router-regions-view",
13
+ "render": "file:./render.php"
14
+ }
@@ -0,0 +1,89 @@
1
+ <?php
2
+ /**
3
+ * HTML for testing the hydration of router regions.
4
+ *
5
+ * @package gutenberg-test-interactive-blocks
6
+ * @phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable
7
+ */
8
+
9
+ ?>
10
+
11
+ <section>
12
+ <h2>Region 1</h2>
13
+ <div data-wp-interactive data-wp-navigation-id="region-1">
14
+ <p
15
+ data-testid="region-1-text"
16
+ data-wp-text="state.region1.text"
17
+ >not hydrated</p>
18
+ <p
19
+ data-testid="region-1-ssr"
20
+ >content from page <?php echo $attributes['page']; ?></p>
21
+
22
+ <button
23
+ data-testid="state-counter"
24
+ data-wp-text="state.counter.value"
25
+ data-wp-on--click="actions.counter.increment"
26
+ >NaN</button>
27
+
28
+ <?php if ( isset( $attributes['next'] ) ) : ?>
29
+ <a
30
+ data-testid="next"
31
+ data-wp-on--click="actions.router.navigate"
32
+ href="<?php echo $attributes['next']; ?>"
33
+ >Next</a>
34
+ <?php else : ?>
35
+ <a
36
+ data-testid="back"
37
+ data-wp-on--click="actions.router.back"
38
+ href="#"
39
+ >Back</a>
40
+ <?php endif; ?>
41
+ </div>
42
+ </section>
43
+
44
+ <div>
45
+ <p
46
+ data-testid="no-region-text-1"
47
+ data-wp-text="state.region1.text"
48
+ >not hydrated</p>
49
+ </div>
50
+
51
+
52
+ <section>
53
+ <h2>Region 2</h2>
54
+ <div data-wp-interactive data-wp-navigation-id="region-2">
55
+ <p
56
+ data-testid="region-2-text"
57
+ data-wp-text="state.region2.text"
58
+ >not hydrated</p>
59
+ <p
60
+ data-testid="region-2-ssr"
61
+ >content from page <?php echo $attributes['page']; ?></p>
62
+
63
+ <button
64
+ data-testid="context-counter"
65
+ data-wp-context='{ "counter": { "initialValue": 0 } }'
66
+ data-wp-init="actions.counter.init"
67
+ data-wp-text="context.counter.value"
68
+ data-wp-on--click="actions.counter.increment"
69
+ >NaN</button>
70
+
71
+ <div data-wp-ignore>
72
+ <div>
73
+ <p
74
+ data-testid="no-region-text-2"
75
+ data-wp-text="state.region2.text"
76
+ >not hydrated</p>
77
+ </div>
78
+
79
+ <section>
80
+ <h2>Nested region</h2>
81
+ <div data-wp-interactive data-wp-navigation-id="nested-region">
82
+ <p
83
+ data-testid="nested-region-ssr"
84
+ >content from page <?php echo $attributes['page']; ?></p>
85
+ </div>
86
+ </section>
87
+ </div>
88
+ </div>
89
+ </section>
@@ -0,0 +1,43 @@
1
+ ( ( { wp } ) => {
2
+ /**
3
+ * WordPress dependencies
4
+ */
5
+ const { store, navigate } = wp.interactivity;
6
+
7
+ store( {
8
+ state: {
9
+ region1: {
10
+ text: 'hydrated'
11
+ },
12
+ region2: {
13
+ text: 'hydrated'
14
+ },
15
+ counter: {
16
+ value: 0,
17
+ },
18
+ },
19
+ actions: {
20
+ router: {
21
+ navigate: async ( { event: e } ) => {
22
+ e.preventDefault();
23
+ await navigate( e.target.href );
24
+ },
25
+ back: () => history.back(),
26
+ },
27
+ counter: {
28
+ increment: ( { state, context } ) => {
29
+ if ( context.counter ) {
30
+ context.counter.value += 1;
31
+ } else {
32
+ state.counter.value += 1;
33
+ }
34
+ },
35
+ init: ( { context } ) => {
36
+ if ( context.counter ) {
37
+ context.counter.value = context.counter.initialValue;
38
+ }
39
+ }
40
+ },
41
+ },
42
+ } );
43
+ } )( window );
@@ -1,47 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import {
5
- createNewPost,
6
- clickOnMoreMenuItem,
7
- clickOnCloseModalButton,
8
- pressKeyWithModifier,
9
- } from '@wordpress/e2e-test-utils';
10
-
11
- describe( 'keyboard shortcut help modal', () => {
12
- beforeAll( async () => {
13
- await createNewPost();
14
- } );
15
-
16
- it( 'displays the shortcut help modal when opened using the menu item in the more menu', async () => {
17
- await clickOnMoreMenuItem( 'Keyboard shortcuts' );
18
- const shortcutHelpModalElements = await page.$$(
19
- '.edit-post-keyboard-shortcut-help-modal'
20
- );
21
- expect( shortcutHelpModalElements ).toHaveLength( 1 );
22
- } );
23
-
24
- it( 'closes the shortcut help modal when the close icon is clicked', async () => {
25
- await clickOnCloseModalButton();
26
- const shortcutHelpModalElements = await page.$$(
27
- '.edit-post-keyboard-shortcut-help-modal'
28
- );
29
- expect( shortcutHelpModalElements ).toHaveLength( 0 );
30
- } );
31
-
32
- it( 'displays the shortcut help modal when opened using the shortcut key (access+h)', async () => {
33
- await pressKeyWithModifier( 'access', 'h' );
34
- const shortcutHelpModalElements = await page.$$(
35
- '.edit-post-keyboard-shortcut-help-modal'
36
- );
37
- expect( shortcutHelpModalElements ).toHaveLength( 1 );
38
- } );
39
-
40
- it( 'closes the shortcut help modal when the shortcut key (access+h) is pressed again', async () => {
41
- await pressKeyWithModifier( 'access', 'h' );
42
- const shortcutHelpModalElements = await page.$$(
43
- '.edit-post-keyboard-shortcut-help-modal'
44
- );
45
- expect( shortcutHelpModalElements ).toHaveLength( 0 );
46
- } );
47
- } );