@wordpress/e2e-tests 7.9.0 → 7.11.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 (45) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/jest.config.js +1 -4
  3. package/package.json +7 -7
  4. package/plugins/iframed-enqueue-block-editor-settings.php +19 -0
  5. package/plugins/interactive-blocks/{directive-show → directive-body}/block.json +3 -3
  6. package/plugins/interactive-blocks/directive-body/render.php +22 -0
  7. package/plugins/interactive-blocks/directive-body/view.js +11 -0
  8. package/plugins/interactive-blocks/directive-class/render.php +11 -0
  9. package/plugins/interactive-blocks/directive-effect/render.php +13 -1
  10. package/plugins/interactive-blocks/directive-effect/view.js +14 -16
  11. package/plugins/interactive-blocks/directive-init/block.json +14 -0
  12. package/plugins/interactive-blocks/directive-init/render.php +42 -0
  13. package/plugins/interactive-blocks/directive-init/view.js +64 -0
  14. package/plugins/interactive-blocks/directive-on/block.json +14 -0
  15. package/plugins/interactive-blocks/directive-on/render.php +52 -0
  16. package/plugins/interactive-blocks/directive-on/view.js +27 -0
  17. package/plugins/interactive-blocks/directive-priorities/render.php +4 -0
  18. package/plugins/interactive-blocks/store-afterload/block.json +14 -0
  19. package/plugins/interactive-blocks/store-afterload/render.php +41 -0
  20. package/plugins/interactive-blocks/store-afterload/view.js +60 -0
  21. package/plugins/interactive-blocks/tovdom-islands/render.php +5 -5
  22. package/plugins/interactive-blocks/tovdom-islands/view.js +18 -1
  23. package/specs/editor/plugins/iframed-enqueue-block-editor-settings.test.js +108 -0
  24. package/specs/editor/various/__snapshots__/inserting-blocks.test.js.snap +2 -2
  25. package/specs/editor/various/__snapshots__/rich-text.test.js.snap +15 -1
  26. package/specs/editor/various/block-editor-keyboard-shortcuts.test.js +3 -3
  27. package/specs/editor/various/reusable-blocks.test.js +10 -7
  28. package/specs/editor/various/rich-text.test.js +11 -0
  29. package/specs/experiments/blocks/post-comments-form.test.js +2 -2
  30. package/specs/site-editor/settings-sidebar.test.js +1 -1
  31. package/assets/large-post.html +0 -5553
  32. package/assets/small-post-with-containers.html +0 -77
  33. package/config/performance-reporter.js +0 -177
  34. package/config/setup-performance-test.js +0 -51
  35. package/jest.performance.config.js +0 -16
  36. package/plugins/interactive-blocks/directive-show/render.php +0 -53
  37. package/plugins/interactive-blocks/directive-show/view.js +0 -24
  38. package/specs/editor/plugins/allowed-blocks.test.js +0 -59
  39. package/specs/editor/plugins/block-variations.test.js +0 -191
  40. package/specs/editor/plugins/iframed-equeue-block-assets.test.js +0 -51
  41. package/specs/performance/front-end-block-theme.test.js +0 -77
  42. package/specs/performance/front-end-classic-theme.test.js +0 -77
  43. package/specs/performance/post-editor.test.js +0 -369
  44. package/specs/performance/site-editor.test.js +0 -188
  45. package/specs/performance/utils.js +0 -146
@@ -0,0 +1,108 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import {
5
+ activatePlugin,
6
+ createNewPost,
7
+ deactivatePlugin,
8
+ canvas,
9
+ activateTheme,
10
+ } from '@wordpress/e2e-test-utils';
11
+
12
+ async function getComputedStyle( context, selector, property ) {
13
+ return await context.evaluate(
14
+ ( sel, prop ) =>
15
+ window.getComputedStyle( document.querySelector( sel ) )[ prop ],
16
+ selector,
17
+ property
18
+ );
19
+ }
20
+
21
+ describe( 'iframed block editor settings styles', () => {
22
+ beforeEach( async () => {
23
+ // Activate the empty theme (block based theme), which is iframed.
24
+ await activateTheme( 'emptytheme' );
25
+ await activatePlugin(
26
+ 'gutenberg-test-iframed-enqueue-block-editor-settings'
27
+ );
28
+ await createNewPost();
29
+ } );
30
+
31
+ afterEach( async () => {
32
+ await deactivatePlugin(
33
+ 'gutenberg-test-iframed-enqueue-block-editor-settings'
34
+ );
35
+ await activateTheme( 'twentytwentyone' );
36
+ } );
37
+
38
+ it( 'should load styles added through block editor settings', async () => {
39
+ await page.waitForSelector( 'iframe[name="editor-canvas"]' );
40
+ // Expect a red border (added in PHP).
41
+ expect( await getComputedStyle( canvas(), 'p', 'border-color' ) ).toBe(
42
+ 'rgb(255, 0, 0)'
43
+ );
44
+
45
+ await page.evaluate( () => {
46
+ const settings = window.wp.data
47
+ .select( 'core/editor' )
48
+ .getEditorSettings();
49
+ wp.data.dispatch( 'core/editor' ).updateEditorSettings( {
50
+ ...settings,
51
+ styles: [
52
+ ...settings.styles,
53
+ {
54
+ css: 'p { border-width: 2px; }',
55
+ __unstableType: 'plugin',
56
+ },
57
+ ],
58
+ } );
59
+ } );
60
+
61
+ // Expect a 2px border (added in JS).
62
+ expect( await getComputedStyle( canvas(), 'p', 'border-width' ) ).toBe(
63
+ '2px'
64
+ );
65
+ } );
66
+
67
+ it( 'should load theme styles added through block editor settings', async () => {
68
+ await page.waitForSelector( 'iframe[name="editor-canvas"]' );
69
+
70
+ await page.evaluate( () => {
71
+ // Make sure that theme styles are added even if the theme styles
72
+ // preference is off.
73
+ window.wp.data
74
+ .dispatch( 'core/edit-post' )
75
+ .toggleFeature( 'themeStyles' );
76
+ const settings = window.wp.data
77
+ .select( 'core/editor' )
78
+ .getEditorSettings();
79
+ wp.data.dispatch( 'core/editor' ).updateEditorSettings( {
80
+ ...settings,
81
+ styles: [
82
+ ...settings.styles,
83
+ {
84
+ css: 'p { border-width: 2px; }',
85
+ __unstableType: 'theme',
86
+ },
87
+ ],
88
+ } );
89
+ } );
90
+
91
+ // Expect a 1px border because theme styles are disabled.
92
+ expect( await getComputedStyle( canvas(), 'p', 'border-width' ) ).toBe(
93
+ '1px'
94
+ );
95
+
96
+ await page.evaluate( () => {
97
+ // Now enable theme styles.
98
+ window.wp.data
99
+ .dispatch( 'core/edit-post' )
100
+ .toggleFeature( 'themeStyles' );
101
+ } );
102
+
103
+ // Expect a 2px border because theme styles are enabled.
104
+ expect( await getComputedStyle( canvas(), 'p', 'border-width' ) ).toBe(
105
+ '2px'
106
+ );
107
+ } );
108
+ } );
@@ -88,8 +88,8 @@ exports[`Inserting blocks inserts a block in proper place after having clicked \
88
88
  <p>First paragraph</p>
89
89
  <!-- /wp:paragraph -->
90
90
 
91
- <!-- wp:cover {"isDark":false,"layout":{"type":"constrained"}} -->
92
- <div class="wp-block-cover is-light"><span aria-hidden="true" class="wp-block-cover__background has-background-dim-100 has-background-dim"></span><div class="wp-block-cover__inner-container"></div></div>
91
+ <!-- wp:cover {"layout":{"type":"constrained"}} -->
92
+ <div class="wp-block-cover"><span aria-hidden="true" class="wp-block-cover__background has-background-dim-100 has-background-dim"></span><div class="wp-block-cover__inner-container"></div></div>
93
93
  <!-- /wp:cover -->
94
94
 
95
95
  <!-- wp:heading -->
@@ -24,6 +24,16 @@ exports[`RichText should apply multiple formats when selection is collapsed 1`]
24
24
  <!-- /wp:paragraph -->"
25
25
  `;
26
26
 
27
+ exports[`RichText should copy/paste heading 1`] = `
28
+ "<!-- wp:heading -->
29
+ <h2 class="wp-block-heading">Heading</h2>
30
+ <!-- /wp:heading -->
31
+
32
+ <!-- wp:heading -->
33
+ <h2 class="wp-block-heading">Heading</h2>
34
+ <!-- /wp:heading -->"
35
+ `;
36
+
27
37
  exports[`RichText should handle Home and End keys 1`] = `
28
38
  "<!-- wp:paragraph -->
29
39
  <p>-<strong>12</strong>+</p>
@@ -129,7 +139,11 @@ exports[`RichText should paste paragraph contents into list 1`] = `
129
139
 
130
140
  <!-- wp:list -->
131
141
  <ul><!-- wp:list-item -->
132
- <li>1<br>2</li>
142
+ <li>1</li>
143
+ <!-- /wp:list-item -->
144
+
145
+ <!-- wp:list-item -->
146
+ <li>2</li>
133
147
  <!-- /wp:list-item --></ul>
134
148
  <!-- /wp:list -->"
135
149
  `;
@@ -90,9 +90,9 @@ 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/reusable block' );
93
+ await clickMenuItem( 'Create pattern' );
94
94
  const reusableBlockNameInputSelector =
95
- '.reusable-blocks-menu-items__convert-modal .components-text-control__input';
95
+ '.patterns-menu-items__convert-modal .components-text-control__input';
96
96
  const nameInput = await page.waitForSelector(
97
97
  reusableBlockNameInputSelector
98
98
  );
@@ -102,7 +102,7 @@ describe( 'block editor keyboard shortcuts', () => {
102
102
  await page.keyboard.press( 'ArrowLeft' );
103
103
  await page.keyboard.press( 'Delete' );
104
104
  await clickOnCloseModalButton(
105
- '.reusable-blocks-menu-items__convert-modal'
105
+ '.patterns-menu-items__convert-modal'
106
106
  );
107
107
  expect( await getEditedPostContent() ).toMatchSnapshot();
108
108
  } );
@@ -20,11 +20,11 @@ import {
20
20
  } from '@wordpress/e2e-test-utils';
21
21
 
22
22
  const reusableBlockNameInputSelector =
23
- '.reusable-blocks-menu-items__convert-modal .components-text-control__input';
23
+ '.patterns-menu-items__convert-modal .components-text-control__input';
24
24
  const reusableBlockInspectorNameInputSelector =
25
25
  '.block-editor-block-inspector .components-text-control__input';
26
26
  const syncToggleSelectorChecked =
27
- '.reusable-blocks-menu-items__convert-modal .components-form-toggle.is-checked';
27
+ '.patterns-menu-items__convert-modal .components-form-toggle.is-checked';
28
28
 
29
29
  const saveAll = async () => {
30
30
  const publishButtonSelector =
@@ -111,7 +111,8 @@ describe( 'Reusable blocks', () => {
111
111
  await insertReusableBlock( 'Surprised greeting block' );
112
112
 
113
113
  // Convert block to a regular block.
114
- await clickBlockToolbarButton( 'Detach pattern' );
114
+ await clickBlockToolbarButton( 'Options' );
115
+ await clickMenuItem( 'Detach pattern' );
115
116
 
116
117
  // Check that we have a paragraph block on the page.
117
118
  const paragraphBlock = await canvas().$(
@@ -195,7 +196,7 @@ describe( 'Reusable blocks', () => {
195
196
 
196
197
  // Convert block to a reusable block.
197
198
  await clickBlockToolbarButton( 'Options' );
198
- await clickMenuItem( 'Create pattern/reusable block' );
199
+ await clickMenuItem( 'Create pattern' );
199
200
 
200
201
  // Set title.
201
202
  const nameInput = await page.waitForSelector(
@@ -217,7 +218,8 @@ describe( 'Reusable blocks', () => {
217
218
  await insertReusableBlock( 'Multi-selection reusable block' );
218
219
 
219
220
  // Convert block to a regular block.
220
- await clickBlockToolbarButton( 'Detach patterns' );
221
+ await clickBlockToolbarButton( 'Options' );
222
+ await clickMenuItem( 'Detach patterns' );
221
223
 
222
224
  // Check that we have two paragraph blocks on the page.
223
225
  expect( await getEditedPostContent() ).toMatchSnapshot();
@@ -349,7 +351,8 @@ describe( 'Reusable blocks', () => {
349
351
 
350
352
  // Convert back to regular blocks.
351
353
  await clickBlockToolbarButton( 'Select Edited block' );
352
- await clickBlockToolbarButton( 'Detach pattern' );
354
+ await clickBlockToolbarButton( 'Options' );
355
+ await clickMenuItem( 'Detach pattern' );
353
356
  await page.waitForXPath( selector, {
354
357
  hidden: true,
355
358
  } );
@@ -379,7 +382,7 @@ describe( 'Reusable blocks', () => {
379
382
 
380
383
  // Convert to reusable.
381
384
  await clickBlockToolbarButton( 'Options' );
382
- await clickMenuItem( 'Create pattern/reusable block' );
385
+ await clickMenuItem( 'Create pattern' );
383
386
  const nameInput = await page.waitForSelector(
384
387
  reusableBlockNameInputSelector
385
388
  );
@@ -556,4 +556,15 @@ describe( 'RichText', () => {
556
556
  // Expect: <strong>1</strong>-<em>2</em>
557
557
  expect( await getEditedPostContent() ).toMatchSnapshot();
558
558
  } );
559
+
560
+ test( 'should copy/paste heading', async () => {
561
+ await insertBlock( 'Heading' );
562
+ await page.keyboard.type( 'Heading' );
563
+ await pressKeyWithModifier( 'primary', 'a' );
564
+ await pressKeyWithModifier( 'primary', 'c' );
565
+ await page.keyboard.press( 'ArrowRight' );
566
+ await page.keyboard.press( 'Enter' );
567
+ await pressKeyWithModifier( 'primary', 'v' );
568
+ expect( await getEditedPostContent() ).toMatchSnapshot();
569
+ } );
559
570
  } );
@@ -11,7 +11,7 @@ import {
11
11
  canvas,
12
12
  } from '@wordpress/e2e-test-utils';
13
13
 
14
- describe( 'Post Comments Form', () => {
14
+ describe( 'Comments Form', () => {
15
15
  let previousCommentStatus;
16
16
 
17
17
  beforeAll( async () => {
@@ -42,7 +42,7 @@ describe( 'Post Comments Form', () => {
42
42
  await enterEditMode();
43
43
 
44
44
  // Insert post comments form
45
- await insertBlock( 'Post Comments Form' );
45
+ await insertBlock( 'Comments Form' );
46
46
 
47
47
  // Ensure the placeholder is there
48
48
  await expect( canvas() ).toMatchElement(
@@ -81,7 +81,7 @@ describe( 'Settings sidebar', () => {
81
81
  expect( templateCardAfterNavigation ).toMatchObject( {
82
82
  title: 'Single Entries',
83
83
  description:
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.',
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
  } );
86
86
  } );
87
87
  } );