@wordpress/e2e-tests 7.7.0 → 7.8.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 (50) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/package.json +7 -7
  3. package/plugins/block-api/index.js +5 -2
  4. package/plugins/block-api.php +2 -0
  5. package/plugins/deprecated-node-matcher/index.js +12 -16
  6. package/plugins/deprecated-node-matcher.php +0 -1
  7. package/plugins/inner-blocks-allowed-blocks/index.js +1 -0
  8. package/plugins/inner-blocks-templates/index.js +33 -30
  9. package/plugins/interactive-blocks/directive-bind/block.json +14 -0
  10. package/plugins/interactive-blocks/directive-bind/render.php +59 -0
  11. package/plugins/interactive-blocks/directive-bind/view.js +23 -0
  12. package/plugins/interactive-blocks/directive-class/block.json +14 -0
  13. package/plugins/interactive-blocks/directive-class/render.php +75 -0
  14. package/plugins/interactive-blocks/directive-class/view.js +21 -0
  15. package/plugins/interactive-blocks/directive-context/block.json +14 -0
  16. package/plugins/interactive-blocks/directive-context/render.php +121 -0
  17. package/plugins/interactive-blocks/directive-context/view.js +22 -0
  18. package/plugins/interactive-blocks/directive-effect/block.json +14 -0
  19. package/plugins/interactive-blocks/directive-effect/render.php +27 -0
  20. package/plugins/interactive-blocks/directive-effect/view.js +61 -0
  21. package/plugins/interactive-blocks/directive-priorities/block.json +14 -0
  22. package/plugins/interactive-blocks/directive-priorities/render.php +20 -0
  23. package/plugins/interactive-blocks/directive-priorities/view.js +121 -0
  24. package/plugins/interactive-blocks/directive-show/block.json +14 -0
  25. package/plugins/interactive-blocks/directive-show/render.php +53 -0
  26. package/plugins/interactive-blocks/directive-show/view.js +24 -0
  27. package/plugins/interactive-blocks/directive-text/block.json +14 -0
  28. package/plugins/interactive-blocks/directive-text/render.php +35 -0
  29. package/plugins/interactive-blocks/directive-text/view.js +17 -0
  30. package/plugins/interactive-blocks/negation-operator/block.json +14 -0
  31. package/plugins/interactive-blocks/negation-operator/render.php +26 -0
  32. package/plugins/interactive-blocks/negation-operator/view.js +22 -0
  33. package/plugins/interactive-blocks/store-tag/block.json +14 -0
  34. package/plugins/interactive-blocks/store-tag/render.php +64 -0
  35. package/plugins/interactive-blocks/store-tag/view.js +24 -0
  36. package/plugins/interactive-blocks/tovdom/block.json +14 -0
  37. package/plugins/interactive-blocks/tovdom/cdata.js +15 -0
  38. package/plugins/interactive-blocks/tovdom/processing-instructions.js +16 -0
  39. package/plugins/interactive-blocks/tovdom/render.php +33 -0
  40. package/plugins/interactive-blocks/tovdom/view.js +5 -0
  41. package/plugins/interactive-blocks/tovdom-islands/block.json +14 -0
  42. package/plugins/interactive-blocks/tovdom-islands/render.php +66 -0
  43. package/plugins/interactive-blocks/tovdom-islands/view.js +9 -0
  44. package/plugins/interactive-blocks.php +48 -0
  45. package/specs/editor/plugins/container-blocks.test.js +2 -1
  46. package/specs/editor/various/block-editor-keyboard-shortcuts.test.js +1 -1
  47. package/specs/editor/various/links.test.js +18 -11
  48. package/specs/editor/various/reusable-blocks.test.js +5 -5
  49. package/specs/experiments/blocks/post-comments-form.test.js +1 -1
  50. package/specs/site-editor/settings-sidebar.test.js +1 -1
@@ -0,0 +1,33 @@
1
+ <?php
2
+ /**
3
+ * HTML for testing the vDOM generation.
4
+ *
5
+ * @package gutenberg-test-interactive-blocks
6
+ */
7
+
8
+ $plugin_url = plugin_dir_url( __DIR__ );
9
+ $src_proc_ins = $plugin_url . 'tovdom/processing-instructions.js';
10
+ $src_cdata = $plugin_url . 'tovdom/cdata.js';
11
+ ?>
12
+
13
+ <div data-wp-interactive>
14
+ <div data-testid="it should delete comments">
15
+ <!-- ##1## -->
16
+ <div data-testid="it should keep this node between comments">
17
+ Comments inner node
18
+ <!-- ##2## -->
19
+ </div>
20
+ </div>
21
+
22
+ <div data-testid="it should delete processing instructions">
23
+ <div id="replace-with-processing-instructions"></div>
24
+ </div>
25
+
26
+ <script src="<?php echo $src_proc_ins; ?>"></script>
27
+
28
+ <div data-testid="it should replace CDATA with text nodes">
29
+ <div id="replace-with-cdata"></div>
30
+ </div>
31
+
32
+ <script src="<?php echo $src_cdata; ?>"></script>
33
+ </div>
@@ -0,0 +1,5 @@
1
+ ( ( { wp } ) => {
2
+ const { store } = wp.interactivity;
3
+
4
+ store( {} );
5
+ } )( window );
@@ -0,0 +1,14 @@
1
+ {
2
+ "apiVersion": 2,
3
+ "name": "test/tovdom-islands",
4
+ "title": "E2E Interactivity tests - tovdom islands",
5
+ "category": "text",
6
+ "icon": "heart",
7
+ "description": "",
8
+ "supports": {
9
+ "interactivity": true
10
+ },
11
+ "textdomain": "e2e-interactivity",
12
+ "viewScript": "tovdom-islands-view",
13
+ "render": "file:./render.php"
14
+ }
@@ -0,0 +1,66 @@
1
+ <?php
2
+ /**
3
+ * HTML for testing the directive `data-wp-interactive`.
4
+ *
5
+ * @package gutenberg-test-interactive-blocks
6
+ */
7
+
8
+ ?>
9
+ <div>
10
+ <div data-wp-show="state.falseValue">
11
+ <span data-testid="not inside an island">
12
+ This should be shown because it is inside an island.
13
+ </span>
14
+ </div>
15
+
16
+ <div data-wp-interactive>
17
+ <div data-wp-show="state.falseValue">
18
+ <span data-testid="inside an island">
19
+ This should not be shown because it is inside an island.
20
+ </span>
21
+ </div>
22
+ </div>
23
+
24
+ <div data-wp-interactive>
25
+ <div data-wp-ignore>
26
+ <div data-wp-show="state.falseValue">
27
+ <span
28
+ data-testid="inside an inner block of an isolated island"
29
+ >
30
+ This should be shown because it is inside an inner
31
+ block of an isolated island.
32
+ </span>
33
+ </div>
34
+ </div>
35
+ </div>
36
+
37
+ <div data-wp-interactive>
38
+ <div data-wp-interactive>
39
+ <div
40
+ data-wp-show="state.falseValue"
41
+ data-testid="island inside another island"
42
+ >
43
+ <span>
44
+ This should not have two template wrappers because
45
+ that means we hydrated twice.
46
+ </span>
47
+ </div>
48
+ </div>
49
+ </div>
50
+
51
+ <div data-wp-interactive>
52
+ <div>
53
+ <div data-wp-interactive data-wp-ignore>
54
+ <div data-wp-show="state.falseValue">
55
+ <span
56
+ data-testid="island inside inner block of isolated island"
57
+ >
58
+ This should not be shown because even though it
59
+ is inside an inner block of an isolated island,
60
+ it's inside an new island.
61
+ </span>
62
+ </div>
63
+ </div>
64
+ </div>
65
+ </div>
66
+ </div>
@@ -0,0 +1,9 @@
1
+ ( ( { wp } ) => {
2
+ const { store } = wp.interactivity;
3
+
4
+ store( {
5
+ state: {
6
+ falseValue: false,
7
+ },
8
+ } );
9
+ } )( window );
@@ -0,0 +1,48 @@
1
+ <?php
2
+ /**
3
+ * Plugin Name: Gutenberg Test Interactive Blocks
4
+ * Plugin URI: https://github.com/WordPress/gutenberg
5
+ * Author: Gutenberg Team
6
+ *
7
+ * @package gutenberg-test-interactive-blocks
8
+ */
9
+
10
+ add_action(
11
+ 'init',
12
+ function() {
13
+ // Register all blocks found in the `interactive-blocks` folder.
14
+ if ( file_exists( __DIR__ . '/interactive-blocks/' ) ) {
15
+ $block_json_files = glob( __DIR__ . '/interactive-blocks/**/block.json' );
16
+
17
+ // Auto register all blocks that were found.
18
+ foreach ( $block_json_files as $filename ) {
19
+ $block_folder = dirname( $filename );
20
+ $name = basename( $block_folder );
21
+
22
+ $view_file = plugin_dir_url( $block_folder ) . $name . '/' . 'view.js';
23
+
24
+ wp_register_script(
25
+ $name . '-view',
26
+ $view_file,
27
+ array( 'wp-interactivity' ),
28
+ filemtime( $view_file ),
29
+ true
30
+ );
31
+
32
+ register_block_type_from_metadata( $block_folder );
33
+ };
34
+ };
35
+
36
+ // Temporary fix to disable SSR of directives during E2E testing. This
37
+ // is required at this moment, as SSR for directives is not stabilized
38
+ // yet and we need to ensure hydration works, even when the rendered
39
+ // HTML is not correct or malformed.
40
+ if ( 'true' === $_GET['disable_directives_ssr'] ) {
41
+ remove_filter(
42
+ 'render_block',
43
+ 'gutenberg_interactivity_process_directives_in_root_blocks'
44
+ );
45
+ }
46
+
47
+ }
48
+ );
@@ -9,6 +9,7 @@ import {
9
9
  insertBlock,
10
10
  switchEditorModeTo,
11
11
  pressKeyWithModifier,
12
+ canvas,
12
13
  } from '@wordpress/e2e-test-utils';
13
14
 
14
15
  describe( 'InnerBlocks Template Sync', () => {
@@ -75,7 +76,7 @@ describe( 'InnerBlocks Template Sync', () => {
75
76
  expect( await getEditedPostContent() ).toMatchSnapshot();
76
77
 
77
78
  // Trigger a template update and assert that a second block is now present.
78
- const [ button ] = await page.$x(
79
+ const [ button ] = await canvas().$x(
79
80
  `//button[contains(text(), 'Update template')]`
80
81
  );
81
82
  await button.click();
@@ -90,7 +90,7 @@ describe( 'block editor keyboard shortcuts', () => {
90
90
  } );
91
91
  it( 'should prevent deleting multiple selected blocks from inputs', async () => {
92
92
  await clickBlockToolbarButton( 'Options' );
93
- await clickMenuItem( 'Create pattern' );
93
+ await clickMenuItem( 'Create pattern/reusable block' );
94
94
  const reusableBlockNameInputSelector =
95
95
  '.reusable-blocks-menu-items__convert-modal .components-text-control__input';
96
96
  const nameInput = await page.waitForSelector(
@@ -105,7 +105,8 @@ describe( 'Links', () => {
105
105
  await waitForURLFieldAutoFocus();
106
106
 
107
107
  const urlInputValue = await page.evaluate(
108
- () => document.querySelector( '[aria-label="URL"]' ).value
108
+ () =>
109
+ document.querySelector( '.block-editor-url-input__input' ).value
109
110
  );
110
111
 
111
112
  expect( urlInputValue ).toBe( '' );
@@ -496,7 +497,7 @@ describe( 'Links', () => {
496
497
  await pressKeyWithModifier( 'primary', 'K' );
497
498
 
498
499
  const [ settingsToggle ] = await page.$x(
499
- '//button[contains(@aria-label, "Link Settings")]'
500
+ '//button[contains(text(), "Advanced")]'
500
501
  );
501
502
  await settingsToggle.click();
502
503
 
@@ -528,7 +529,7 @@ describe( 'Links', () => {
528
529
 
529
530
  await waitForURLFieldAutoFocus();
530
531
 
531
- await page.keyboard.press( 'Tab' );
532
+ await pressKeyWithModifier( 'shift', 'Tab' );
532
533
 
533
534
  // Tabbing should land us in the text input.
534
535
  const { isTextInput, textValue } = await page.evaluate( () => {
@@ -585,8 +586,10 @@ describe( 'Links', () => {
585
586
 
586
587
  await editButton.click();
587
588
 
588
- // Tabbing forward should land us in the "Text" input.
589
- await page.keyboard.press( 'Tab' );
589
+ await waitForURLFieldAutoFocus();
590
+
591
+ // Tabbing backward should land us in the "Text" input.
592
+ await pressKeyWithModifier( 'shift', 'Tab' );
590
593
 
591
594
  const textInputValue = await page.evaluate(
592
595
  () => document.activeElement.value
@@ -614,8 +617,9 @@ describe( 'Links', () => {
614
617
  );
615
618
  await editButton.click();
616
619
 
617
- // tab forward to the text input.
618
- await page.keyboard.press( 'Tab' );
620
+ await waitForURLFieldAutoFocus();
621
+
622
+ await pressKeyWithModifier( 'shift', 'Tab' );
619
623
 
620
624
  const textInputValue = await page.evaluate(
621
625
  () => document.activeElement.value
@@ -661,7 +665,7 @@ describe( 'Links', () => {
661
665
  await waitForURLFieldAutoFocus();
662
666
 
663
667
  const [ settingsToggle ] = await page.$x(
664
- '//button[contains(@aria-label, "Link Settings")]'
668
+ '//button[contains(text(), "Advanced")]'
665
669
  );
666
670
  await settingsToggle.click();
667
671
 
@@ -679,7 +683,7 @@ describe( 'Links', () => {
679
683
  await pressKeyWithModifier( 'shift', 'ArrowRight' );
680
684
 
681
685
  // Move back to the text input.
682
- await pressKeyTimes( 'Tab', 2 );
686
+ await pressKeyTimes( 'Tab', 1 );
683
687
 
684
688
  // Tabbing back should land us in the text input.
685
689
  const textInputValue = await page.evaluate(
@@ -879,8 +883,11 @@ describe( 'Links', () => {
879
883
 
880
884
  await waitForURLFieldAutoFocus();
881
885
 
882
- // Move to Link Text field.
883
- await page.keyboard.press( 'Tab' );
886
+ // Move to "Text" field.
887
+ await pressKeyWithModifier( 'shift', 'Tab' );
888
+
889
+ // Delete existing value from "Text" field
890
+ await page.keyboard.press( 'Delete' );
884
891
 
885
892
  // Change text to "z"
886
893
  await page.keyboard.type( 'z' );
@@ -113,7 +113,7 @@ describe( 'Reusable blocks', () => {
113
113
  await insertReusableBlock( 'Surprised greeting block' );
114
114
 
115
115
  // Convert block to a regular block.
116
- await clickBlockToolbarButton( 'Convert to regular block' );
116
+ await clickBlockToolbarButton( 'Detach pattern' );
117
117
 
118
118
  // Check that we have a paragraph block on the page.
119
119
  const paragraphBlock = await canvas().$(
@@ -197,7 +197,7 @@ describe( 'Reusable blocks', () => {
197
197
 
198
198
  // Convert block to a reusable block.
199
199
  await clickBlockToolbarButton( 'Options' );
200
- await clickMenuItem( 'Create pattern' );
200
+ await clickMenuItem( 'Create pattern/reusable block' );
201
201
 
202
202
  // Set title.
203
203
  const nameInput = await page.waitForSelector(
@@ -221,7 +221,7 @@ describe( 'Reusable blocks', () => {
221
221
  await insertReusableBlock( 'Multi-selection reusable block' );
222
222
 
223
223
  // Convert block to a regular block.
224
- await clickBlockToolbarButton( 'Convert to regular blocks' );
224
+ await clickBlockToolbarButton( 'Detach patterns' );
225
225
 
226
226
  // Check that we have two paragraph blocks on the page.
227
227
  expect( await getEditedPostContent() ).toMatchSnapshot();
@@ -353,7 +353,7 @@ describe( 'Reusable blocks', () => {
353
353
 
354
354
  // Convert back to regular blocks.
355
355
  await clickBlockToolbarButton( 'Select Pattern' );
356
- await clickBlockToolbarButton( 'Convert to regular block' );
356
+ await clickBlockToolbarButton( 'Detach pattern' );
357
357
  await page.waitForXPath( selector, {
358
358
  hidden: true,
359
359
  } );
@@ -383,7 +383,7 @@ describe( 'Reusable blocks', () => {
383
383
 
384
384
  // Convert to reusable.
385
385
  await clickBlockToolbarButton( 'Options' );
386
- await clickMenuItem( 'Create pattern' );
386
+ await clickMenuItem( 'Create pattern/reusable block' );
387
387
  const nameInput = await page.waitForSelector(
388
388
  reusableBlockNameInputSelector
389
389
  );
@@ -37,7 +37,7 @@ describe( 'Post Comments Form', () => {
37
37
  );
38
38
  await expect( page ).toClick(
39
39
  '.edit-site-sidebar-navigation-item',
40
- { text: /singular/i }
40
+ { text: /single entries/i }
41
41
  );
42
42
  await enterEditMode();
43
43
 
@@ -79,7 +79,7 @@ describe( 'Settings sidebar', () => {
79
79
  'Used as a fallback template for all pages when a more specific template is not defined.',
80
80
  } );
81
81
  expect( templateCardAfterNavigation ).toMatchObject( {
82
- title: 'Singular',
82
+ title: 'Single Entries',
83
83
  description:
84
84
  'Displays any single entry, such as a post or a page. This template will serve as a fallback when a more specific template (e.g., Single Post, Page, or Attachment) cannot be found.',
85
85
  } );