@wordpress/e2e-tests 3.0.1-next.33ec3857e2.0 → 3.0.4

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 (59) hide show
  1. package/CHANGELOG.md +2 -1
  2. package/LICENSE.md +1 -1
  3. package/README.md +31 -19
  4. package/config/is-gutenberg-plugin.js +6 -0
  5. package/jest.config.js +1 -1
  6. package/jest.performance.config.js +1 -1
  7. package/mu-plugins/enable-templates-ui.php +24 -0
  8. package/package.json +9 -9
  9. package/plugins/plugins-api/error-boundary.js +11 -0
  10. package/plugins/plugins-error-boundary.php +27 -0
  11. package/plugins/query-block.php +2 -2
  12. package/specs/editor/blocks/__snapshots__/image.test.js.snap +6 -6
  13. package/specs/editor/blocks/__snapshots__/navigation.test.js.snap +4 -2
  14. package/specs/editor/blocks/__snapshots__/spacer.test.js.snap +1 -1
  15. package/specs/editor/blocks/classic.test.js +5 -2
  16. package/specs/editor/blocks/cover.test.js +7 -3
  17. package/specs/editor/blocks/gallery.test.js +6 -1
  18. package/specs/editor/blocks/heading.test.js +1 -11
  19. package/specs/editor/blocks/navigation.test.js +279 -240
  20. package/specs/editor/plugins/__snapshots__/plugins-api.test.js.snap +2 -2
  21. package/specs/editor/plugins/block-variations.test.js +3 -3
  22. package/specs/editor/plugins/iframed-inline-styles.test.js +0 -6
  23. package/specs/editor/plugins/iframed-multiple-block-stylesheets.test.js +0 -4
  24. package/specs/editor/plugins/plugins-api.test.js +30 -0
  25. package/specs/editor/plugins/templates.test.js +1 -7
  26. package/specs/editor/various/__snapshots__/block-editor-keyboard-shortcuts.test.js.snap +38 -24
  27. package/specs/editor/various/__snapshots__/inserting-blocks.test.js.snap +1 -1
  28. package/specs/editor/various/__snapshots__/keep-styles-on-block-transforms.test.js.snap +35 -0
  29. package/specs/editor/various/block-editor-keyboard-shortcuts.test.js +43 -3
  30. package/specs/editor/various/font-size-picker.test.js +57 -11
  31. package/specs/editor/various/fullscreen-mode.test.js +1 -1
  32. package/specs/editor/various/keep-styles-on-block-transforms.test.js +81 -0
  33. package/specs/editor/various/post-editor-template-mode.test.js +1 -1
  34. package/specs/editor/various/post-visibility.test.js +54 -0
  35. package/specs/editor/various/preview.test.js +66 -1
  36. package/specs/editor/various/reusable-blocks.test.js +52 -5
  37. package/specs/editor/various/style-variation.test.js +9 -5
  38. package/specs/editor/various/undo.test.js +21 -0
  39. package/specs/performance/site-editor.test.js +3 -4
  40. package/specs/site-editor/document-settings.test.js +12 -14
  41. package/specs/site-editor/multi-entity-editing.test.js +14 -16
  42. package/specs/site-editor/multi-entity-saving.test.js +18 -27
  43. package/specs/site-editor/settings-sidebar.test.js +7 -12
  44. package/specs/site-editor/site-editor-export.test.js +9 -10
  45. package/specs/site-editor/site-editor-inserter.test.js +7 -9
  46. package/specs/site-editor/style-variations.test.js +211 -0
  47. package/specs/site-editor/template-part.test.js +14 -22
  48. package/specs/site-editor/template-revert.test.js +31 -37
  49. package/specs/widgets/customizing-widgets.test.js +3 -23
  50. package/specs/widgets/editing-widgets.test.js +36 -12
  51. package/themes/style-variations/block-templates/index.html +11 -0
  52. package/themes/style-variations/index.php +0 -0
  53. package/themes/style-variations/style.css +15 -0
  54. package/themes/style-variations/styles/pink.json +33 -0
  55. package/themes/style-variations/styles/yellow.json +12 -0
  56. package/themes/style-variations/theme.json +8 -0
  57. package/config/gutenberg-phase.js +0 -9
  58. package/specs/editor/various/__snapshots__/style-variation.test.js.snap +0 -7
  59. package/specs/site-editor/utils.js +0 -153
@@ -16,6 +16,7 @@ import {
16
16
  openGlobalBlockInserter,
17
17
  searchForBlock,
18
18
  closeGlobalBlockInserter,
19
+ setBrowserViewport,
19
20
  } from '@wordpress/e2e-test-utils';
20
21
 
21
22
  /**
@@ -25,10 +26,6 @@ import {
25
26
  import { find, findAll } from 'puppeteer-testing-library';
26
27
  import { groupBy, mapValues } from 'lodash';
27
28
 
28
- const twentyTwentyError = `Stylesheet twentytwenty-block-editor-styles-css was not properly added.
29
- For blocks, use the block API's style (https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#style) or editorStyle (https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#editor-style).
30
- For themes, use add_editor_style (https://developer.wordpress.org/block-editor/how-to-guides/themes/theme-support/#editor-styles).`;
31
-
32
29
  describe( 'Widgets screen', () => {
33
30
  beforeEach( async () => {
34
31
  await visitWidgetsScreen();
@@ -232,8 +229,6 @@ describe( 'Widgets screen', () => {
232
229
  </div></div>",
233
230
  }
234
231
  ` );
235
-
236
- expect( console ).toHaveWarned( twentyTwentyError );
237
232
  } );
238
233
 
239
234
  it.skip( 'Should insert content using the inline inserter', async () => {
@@ -601,8 +596,6 @@ describe( 'Widgets screen', () => {
601
596
  initialSerializedWidgetAreas[ 'sidebar-1' ],
602
597
  ].join( '\n' )
603
598
  );
604
-
605
- expect( console ).toHaveWarned( twentyTwentyError );
606
599
  } );
607
600
 
608
601
  it.skip( 'Should display legacy widgets', async () => {
@@ -777,8 +770,6 @@ describe( 'Widgets screen', () => {
777
770
  </div></div>",
778
771
  }
779
772
  ` );
780
-
781
- expect( console ).toHaveWarned( twentyTwentyError );
782
773
  } );
783
774
 
784
775
  it( 'Allows widget deletion to be undone', async () => {
@@ -838,8 +829,6 @@ describe( 'Widgets screen', () => {
838
829
  </div></div>",
839
830
  }
840
831
  ` );
841
-
842
- expect( console ).toHaveWarned( twentyTwentyError );
843
832
  } );
844
833
 
845
834
  it( 'can toggle sidebar list view', async () => {
@@ -854,6 +843,41 @@ describe( 'Widgets screen', () => {
854
843
  expect( listItems.length >= widgetAreas.length ).toEqual( true );
855
844
  await closeListView();
856
845
  } );
846
+
847
+ // Check for regressions of https://github.com/WordPress/gutenberg/issues/38002.
848
+ it( 'allows blocks to be added on mobile viewports', async () => {
849
+ await setBrowserViewport( 'small' );
850
+ const [ firstWidgetArea ] = await findAll( {
851
+ role: 'document',
852
+ name: 'Block: Widget Area',
853
+ } );
854
+
855
+ const addParagraphBlock = await getBlockInGlobalInserter( 'Paragraph' );
856
+ await addParagraphBlock.click();
857
+
858
+ const addedParagraphBlockInFirstWidgetArea = await find(
859
+ {
860
+ name: /^Empty block/,
861
+ selector: '[data-block][data-type="core/paragraph"]',
862
+ },
863
+ {
864
+ root: firstWidgetArea,
865
+ }
866
+ );
867
+ await addedParagraphBlockInFirstWidgetArea.focus();
868
+ await page.keyboard.type( 'First Paragraph' );
869
+ const updatedParagraphBlockInFirstWidgetArea = await find(
870
+ {
871
+ name: 'Paragraph block',
872
+ value: 'First Paragraph',
873
+ },
874
+ {
875
+ root: firstWidgetArea,
876
+ }
877
+ );
878
+
879
+ expect( updatedParagraphBlockInFirstWidgetArea ).toBeTruthy();
880
+ } );
857
881
  } );
858
882
 
859
883
  /**
@@ -0,0 +1,11 @@
1
+ <!-- wp:query {"queryId":1,"query":{"offset":0,"postType":"post","order":"desc","orderBy":"date","author":"","search":"","sticky":""}} -->
2
+ <div class="wp-block-query">
3
+ <!-- wp:post-template -->
4
+ <!-- wp:post-title {"isLink":true} /-->
5
+ <!-- wp:post-excerpt /-->
6
+ <!-- /wp:post-template -->
7
+ </div>
8
+ <!-- /wp:query -->
9
+ <!-- wp:paragraph -->
10
+ <p>My awesome paragraph</p>
11
+ <!-- /wp:paragraph -->
File without changes
@@ -0,0 +1,15 @@
1
+ /*
2
+ Theme Name: Style variations
3
+ Theme URI: https://github.com/wordpress/theme-experiments/
4
+ Author: the WordPress team
5
+ Description: Style variations test theme.
6
+ Requires at least: 5.3
7
+ Tested up to: 5.5
8
+ Requires PHP: 5.6
9
+ Version: 1.0
10
+ License: GNU General Public License v2 or later
11
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
+ Text Domain: style-variations
13
+ Style variations WordPress Theme, (C) 2021 WordPress.org
14
+ Style variations is distributed under the terms of the GNU GPL.
15
+ */
@@ -0,0 +1,33 @@
1
+ {
2
+ "version": 2,
3
+ "settings": {
4
+ "color": {
5
+ "palette": [
6
+ {
7
+ "slug": "foreground",
8
+ "color": "#4a074a",
9
+ "name": "Foreground"
10
+ },
11
+ {
12
+ "slug": "background",
13
+ "color": "#ca69d3",
14
+ "name": "Background"
15
+ },
16
+ {
17
+ "slug": "awesome-pink",
18
+ "color": "#cc00ffc4",
19
+ "name": "Awesome pink"
20
+ }
21
+ ]
22
+ }
23
+ },
24
+ "styles": {
25
+ "color": {
26
+ "background": "var(--wp--preset--color--background)",
27
+ "text": "var(--wp--preset--color--foreground)"
28
+ },
29
+ "typography": {
30
+ "fontSize": "var(--wp--preset--font-size--medium)"
31
+ }
32
+ }
33
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "version": 2,
3
+ "styles": {
4
+ "color": {
5
+ "background": "#ffef0b",
6
+ "text": "#191911"
7
+ },
8
+ "typography": {
9
+ "fontSize": "15px"
10
+ }
11
+ }
12
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "version": 2,
3
+ "styles": {
4
+ "color": {
5
+ "background": "red"
6
+ }
7
+ }
8
+ }
@@ -1,9 +0,0 @@
1
- global.process.env = {
2
- ...global.process.env,
3
- // Inject the `GUTENBERG_PHASE` global, used for feature flagging.
4
- // eslint-disable-next-line @wordpress/gutenberg-phase
5
- GUTENBERG_PHASE: parseInt(
6
- process.env.npm_package_config_GUTENBERG_PHASE,
7
- 10
8
- ),
9
- };
@@ -1,7 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`adding blocks Should switch to the large style of the quote block 1`] = `
4
- "<!-- wp:quote {\\"className\\":\\"is-style-large\\"} -->
5
- <blockquote class=\\"wp-block-quote is-style-large\\"><p>Quote content</p></blockquote>
6
- <!-- /wp:quote -->"
7
- `;
@@ -1,153 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { addQueryArgs } from '@wordpress/url';
5
- import { visitAdminPage } from '@wordpress/e2e-test-utils';
6
-
7
- export const navigationPanel = {
8
- async open() {
9
- const isOpen = !! ( await page.$(
10
- '.edit-site-navigation-toggle.is-open'
11
- ) );
12
-
13
- if ( ! isOpen ) {
14
- await page.click( '.edit-site-navigation-toggle__button' );
15
- await page.waitForSelector( '.edit-site-navigation-panel' );
16
- }
17
- },
18
-
19
- async close() {
20
- const isOpen = !! ( await page.$(
21
- '.edit-site-navigation-toggle.is-open'
22
- ) );
23
-
24
- if ( isOpen ) {
25
- await page.click( '.edit-site-navigation-toggle__button' );
26
- }
27
- },
28
-
29
- async isRoot() {
30
- const isBackToDashboardButtonVisible = !! ( await page.$(
31
- '.edit-site-navigation-panel .edit-site-navigation-panel__back-to-dashboard'
32
- ) );
33
-
34
- return isBackToDashboardButtonVisible;
35
- },
36
-
37
- async back() {
38
- await page.click( '.components-navigation__back-button' );
39
- },
40
-
41
- async navigate( menus ) {
42
- if ( ! Array.isArray( menus ) ) {
43
- menus = [ menus ];
44
- }
45
-
46
- for ( const menu of menus ) {
47
- ( await this.getItemByText( menu ) ).click();
48
- }
49
- },
50
-
51
- async backToRoot() {
52
- while ( ! ( await this.isRoot() ) ) {
53
- await this.back();
54
- }
55
- },
56
-
57
- async getItemByText( text ) {
58
- const item = await page.waitForXPath(
59
- `//div[contains(@class, "edit-site-navigation-panel")]//button[.//*[text()="${ text }"]]`,
60
- { visible: true }
61
- );
62
- return item;
63
- },
64
-
65
- async clickItemByText( text ) {
66
- const item = await this.getItemByText( text );
67
- await item.click();
68
- },
69
- };
70
-
71
- export const siteEditor = {
72
- async visit( query ) {
73
- query = addQueryArgs( '', {
74
- page: 'gutenberg-edit-site',
75
- ...query,
76
- } ).slice( 1 );
77
- await visitAdminPage( 'themes.php', query );
78
- await page.waitForSelector( '.edit-site-visual-editor iframe' );
79
- },
80
-
81
- async toggleMoreMenu() {
82
- // eslint-disable-next-line jest/no-standalone-expect
83
- await expect( page ).toClick(
84
- '.edit-site-more-menu [aria-label="More tools & options"]'
85
- );
86
- },
87
-
88
- async clickOnMoreMenuItem( buttonLabel ) {
89
- await this.toggleMoreMenu();
90
- const moreMenuContainerSelector =
91
- '//*[contains(concat(" ", @class, " "), " edit-site-more-menu__content ")]';
92
- const elementToClick = (
93
- await page.$x(
94
- `${ moreMenuContainerSelector }//span[contains(concat(" ", @class, " "), " components-menu-item__item ")][contains(text(), "${ buttonLabel }")]`
95
- )
96
- )[ 0 ];
97
-
98
- await elementToClick.click();
99
- },
100
-
101
- async getEditedPostContent() {
102
- return page.evaluate( async () => {
103
- const postId = window.wp.data
104
- .select( 'core/edit-site' )
105
- .getEditedPostId();
106
- const postType = window.wp.data
107
- .select( 'core/edit-site' )
108
- .getEditedPostType();
109
- const record = window.wp.data
110
- .select( 'core' )
111
- .getEditedEntityRecord( 'postType', postType, postId );
112
- if ( record ) {
113
- if ( typeof record.content === 'function' ) {
114
- return record.content( record );
115
- } else if ( record.blocks ) {
116
- return window.wp.blocks.__unstableSerializeAndClean(
117
- record.blocks
118
- );
119
- } else if ( record.content ) {
120
- return record.content;
121
- }
122
- }
123
- return '';
124
- } );
125
- },
126
-
127
- async disableWelcomeGuide() {
128
- const isWelcomeGuideActive = await page.evaluate( () =>
129
- wp.data.select( 'core/edit-site' ).isFeatureActive( 'welcomeGuide' )
130
- );
131
- const isWelcomeGuideStyesActive = await page.evaluate( () =>
132
- wp.data
133
- .select( 'core/edit-site' )
134
- .isFeatureActive( 'welcomeGuideStyles' )
135
- );
136
-
137
- if ( isWelcomeGuideActive ) {
138
- await page.evaluate( () =>
139
- wp.data
140
- .dispatch( 'core/edit-site' )
141
- .toggleFeature( 'welcomeGuide' )
142
- );
143
- }
144
-
145
- if ( isWelcomeGuideStyesActive ) {
146
- await page.evaluate( () =>
147
- wp.data
148
- .dispatch( 'core/edit-site' )
149
- .toggleFeature( 'welcomeGuideStyles' )
150
- );
151
- }
152
- },
153
- };