@wordpress/e2e-tests 2.4.1-next.253d9b6e21.0 → 2.5.1

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 (49) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +62 -0
  3. package/config/flaky-tests-reporter.js +94 -0
  4. package/config/setup-test-framework.js +10 -0
  5. package/jest.config.js +11 -1
  6. package/package.json +8 -7
  7. package/plugins/class-test-widget.php +5 -2
  8. package/plugins/iframed-block/block.json +16 -0
  9. package/plugins/iframed-block/editor.css +6 -0
  10. package/plugins/iframed-block/editor.js +18 -0
  11. package/plugins/iframed-block/jquery.test.js +7 -0
  12. package/plugins/iframed-block/script.js +7 -0
  13. package/plugins/iframed-block/style.css +9 -0
  14. package/plugins/iframed-block.php +46 -0
  15. package/specs/editor/blocks/buttons.test.js +30 -0
  16. package/specs/editor/blocks/post-title.test.js +1 -1
  17. package/specs/editor/plugins/__snapshots__/iframed-block.test.js.snap +7 -0
  18. package/specs/editor/plugins/align-hook.test.js +116 -105
  19. package/specs/editor/plugins/annotations.test.js +3 -3
  20. package/specs/editor/plugins/iframed-block.test.js +58 -0
  21. package/specs/editor/various/__snapshots__/copy-cut-paste-whole-blocks.test.js.snap +28 -0
  22. package/specs/editor/various/__snapshots__/rich-text.test.js.snap +15 -3
  23. package/specs/editor/various/a11y.test.js +1 -1
  24. package/specs/editor/various/block-deletion.test.js +2 -2
  25. package/specs/editor/various/block-grouping.test.js +2 -2
  26. package/specs/editor/various/block-mover.test.js +1 -1
  27. package/specs/editor/various/change-detection.test.js +2 -1
  28. package/specs/editor/various/copy-cut-paste-whole-blocks.test.js +92 -0
  29. package/specs/editor/various/embedding.test.js +1 -1
  30. package/specs/editor/various/inserting-blocks.test.js +23 -0
  31. package/specs/editor/various/keyboard-navigable-blocks.test.js +2 -2
  32. package/specs/editor/various/multi-block-selection.test.js +23 -0
  33. package/specs/editor/various/new-post.test.js +6 -3
  34. package/specs/editor/various/preview.test.js +5 -1
  35. package/specs/editor/various/rich-text.test.js +29 -1
  36. package/specs/editor/various/splitting-merging.test.js +48 -2
  37. package/specs/editor/various/writing-flow.test.js +14 -13
  38. package/specs/experiments/__snapshots__/navigation-editor.test.js.snap +27 -33
  39. package/specs/experiments/blocks/__snapshots__/navigation.test.js.snap +35 -25
  40. package/specs/experiments/blocks/navigation.test.js +93 -17
  41. package/specs/experiments/fixtures/menu-items-request-fixture.json +84 -0
  42. package/specs/experiments/navigation-editor.test.js +341 -231
  43. package/specs/experiments/template-part.test.js +6 -3
  44. package/specs/experiments/template-revert.test.js +1 -1
  45. package/specs/performance/post-editor.test.js +108 -80
  46. package/specs/performance/site-editor.test.js +2 -17
  47. package/specs/widgets/customizing-widgets.test.js +118 -7
  48. package/specs/widgets/editing-widgets.test.js +52 -88
  49. package/plugins/classic-widgets.php +0 -11
@@ -292,6 +292,9 @@ describe( 'Template Part', () => {
292
292
  const confirmTitleButton = await page.waitForSelector(
293
293
  confirmTitleButtonSelector
294
294
  );
295
+ await page.keyboard.press( 'Tab' );
296
+ await page.keyboard.press( 'Tab' );
297
+ await page.keyboard.type( 'Create New' );
295
298
  await confirmTitleButton.click();
296
299
 
297
300
  const newTemplatePart = await page.waitForSelector(
@@ -313,9 +316,9 @@ describe( 'Template Part', () => {
313
316
  chooseExistingButtonSelector
314
317
  );
315
318
  await chooseExistingButton.click();
316
- const preview = await page.waitForXPath( testContentSelector );
317
- expect( preview ).toBeTruthy();
318
-
319
+ const preview = await page.waitForSelector(
320
+ '[aria-label="Create New"]'
321
+ );
319
322
  await preview.click();
320
323
  await page.waitForSelector( activatedTemplatePartSelector );
321
324
  const templatePartContent = await page.waitForXPath(
@@ -67,7 +67,7 @@ const save = async () => {
67
67
 
68
68
  const revertTemplate = async () => {
69
69
  await page.click( '.edit-site-document-actions__get-info' );
70
- await page.click( '.edit-site-template-details__revert button' );
70
+ await page.click( '.edit-site-template-details__revert-button' );
71
71
  await waitForNotice();
72
72
  await assertSaveButtonIsEnabled();
73
73
  };
@@ -31,18 +31,18 @@ import {
31
31
  jest.setTimeout( 1000000 );
32
32
 
33
33
  describe( 'Post Editor Performance', () => {
34
- it( 'Loading, typing and selecting blocks', async () => {
35
- const traceFile = __dirname + '/trace.json';
36
- let traceResults;
37
- const results = {
38
- load: [],
39
- type: [],
40
- focus: [],
41
- inserterOpen: [],
42
- inserterHover: [],
43
- inserterSearch: [],
44
- };
34
+ const results = {
35
+ load: [],
36
+ type: [],
37
+ focus: [],
38
+ inserterOpen: [],
39
+ inserterHover: [],
40
+ inserterSearch: [],
41
+ };
42
+ const traceFile = __dirname + '/trace.json';
43
+ let traceResults;
45
44
 
45
+ beforeAll( async () => {
46
46
  const html = readFile(
47
47
  join( __dirname, '../../assets/large-post.html' )
48
48
  );
@@ -63,7 +63,30 @@ describe( 'Post Editor Performance', () => {
63
63
  dispatch( 'core/block-editor' ).resetBlocks( blocks );
64
64
  }, html );
65
65
  await saveDraft();
66
+ } );
67
+
68
+ afterAll( async () => {
69
+ const resultsFilename = basename( __filename, '.js' ) + '.results.json';
70
+ writeFileSync(
71
+ join( __dirname, resultsFilename ),
72
+ JSON.stringify( results, null, 2 )
73
+ );
74
+ deleteFile( traceFile );
75
+ } );
66
76
 
77
+ beforeEach( async () => {
78
+ // Disable auto-save to avoid impacting the metrics.
79
+ await page.evaluate( () => {
80
+ window.wp.data
81
+ .dispatch( 'core/edit-post' )
82
+ .__experimentalUpdateLocalAutosaveInterval( 100000000000 );
83
+ window.wp.data
84
+ .dispatch( 'core/editor' )
85
+ .updateEditorSettings( { autosaveInterval: 100000000000 } );
86
+ } );
87
+ } );
88
+
89
+ it( 'Loading', async () => {
67
90
  // Measuring loading time
68
91
  let i = 5;
69
92
  while ( i-- ) {
@@ -72,7 +95,77 @@ describe( 'Post Editor Performance', () => {
72
95
  await page.waitForSelector( '.wp-block' );
73
96
  results.load.push( new Date() - startTime );
74
97
  }
98
+ } );
99
+
100
+ it( 'Typing', async () => {
101
+ // Measuring typing performance
102
+ await insertBlock( 'Paragraph' );
103
+ let i = 20;
104
+ await page.tracing.start( {
105
+ path: traceFile,
106
+ screenshots: false,
107
+ categories: [ 'devtools.timeline' ],
108
+ } );
109
+ while ( i-- ) {
110
+ // Wait for the browser to be idle before starting the monitoring.
111
+ // The timeout should be big enough to allow all async tasks tor run.
112
+ // And also to allow Rich Text to mark the change as persistent.
113
+ // eslint-disable-next-line no-restricted-syntax
114
+ await page.waitForTimeout( 2000 );
115
+ await page.keyboard.type( 'x' );
116
+ }
117
+ await page.tracing.stop();
118
+ traceResults = JSON.parse( readFile( traceFile ) );
119
+ const [
120
+ keyDownEvents,
121
+ keyPressEvents,
122
+ keyUpEvents,
123
+ ] = getTypingEventDurations( traceResults );
124
+ if (
125
+ keyDownEvents.length === keyPressEvents.length &&
126
+ keyPressEvents.length === keyUpEvents.length
127
+ ) {
128
+ // The first character typed triggers a longer time (isTyping change)
129
+ // It can impact the stability of the metric, so we exclude it.
130
+ for ( let j = 1; j < keyDownEvents.length; j++ ) {
131
+ results.type.push(
132
+ keyDownEvents[ j ] + keyPressEvents[ j ] + keyUpEvents[ j ]
133
+ );
134
+ }
135
+ }
136
+ } );
137
+
138
+ it( 'Selecting blocks', async () => {
139
+ // Measuring block selection performance
140
+ await createNewPost();
141
+ await page.evaluate( () => {
142
+ const { createBlock } = window.wp.blocks;
143
+ const { dispatch } = window.wp.data;
144
+ const blocks = window.lodash
145
+ .times( 1000 )
146
+ .map( () => createBlock( 'core/paragraph' ) );
147
+ dispatch( 'core/block-editor' ).resetBlocks( blocks );
148
+ } );
149
+ const paragraphs = await page.$$( '.wp-block' );
150
+ await page.tracing.start( {
151
+ path: traceFile,
152
+ screenshots: false,
153
+ categories: [ 'devtools.timeline' ],
154
+ } );
155
+ await paragraphs[ 0 ].click();
156
+ for ( let j = 1; j <= 10; j++ ) {
157
+ // Wait for the browser to be idle before starting the monitoring.
158
+ // eslint-disable-next-line no-restricted-syntax
159
+ await page.waitForTimeout( 1000 );
160
+ await paragraphs[ j ].click();
161
+ }
162
+ await page.tracing.stop();
163
+ traceResults = JSON.parse( readFile( traceFile ) );
164
+ const [ focusEvents ] = getSelectionEventDurations( traceResults );
165
+ results.focus = focusEvents;
166
+ } );
75
167
 
168
+ it( 'Opening the inserter', async () => {
76
169
  // Measure time to open inserter
77
170
  await page.waitForSelector( '.edit-post-layout' );
78
171
  for ( let j = 0; j < 10; j++ ) {
@@ -90,7 +183,9 @@ describe( 'Post Editor Performance', () => {
90
183
  }
91
184
  await closeGlobalBlockInserter();
92
185
  }
186
+ } );
93
187
 
188
+ it( 'Searching the inserter', async () => {
94
189
  // Measure time to search the inserter and get results
95
190
  await openGlobalBlockInserter();
96
191
  for ( let j = 0; j < 10; j++ ) {
@@ -123,7 +218,9 @@ describe( 'Post Editor Performance', () => {
123
218
  await page.keyboard.press( 'Backspace' );
124
219
  }
125
220
  await closeGlobalBlockInserter();
221
+ } );
126
222
 
223
+ it( 'Hovering Inserter Items', async () => {
127
224
  // Measure inserter hover performance
128
225
  const paragraphBlockItem =
129
226
  '.block-editor-inserter__menu .editor-block-list-item-paragraph';
@@ -157,74 +254,5 @@ describe( 'Post Editor Performance', () => {
157
254
  }
158
255
  }
159
256
  await closeGlobalBlockInserter();
160
-
161
- // Measuring typing performance
162
- await insertBlock( 'Paragraph' );
163
- i = 20;
164
- await page.tracing.start( {
165
- path: traceFile,
166
- screenshots: false,
167
- categories: [ 'devtools.timeline' ],
168
- } );
169
- while ( i-- ) {
170
- // Wait for the browser to be idle before starting the monitoring.
171
- // eslint-disable-next-line no-restricted-syntax
172
- await page.waitForTimeout( 200 );
173
- await page.keyboard.type( 'x' );
174
- }
175
- await page.tracing.stop();
176
- traceResults = JSON.parse( readFile( traceFile ) );
177
- const [
178
- keyDownEvents,
179
- keyPressEvents,
180
- keyUpEvents,
181
- ] = getTypingEventDurations( traceResults );
182
- if (
183
- keyDownEvents.length === keyPressEvents.length &&
184
- keyPressEvents.length === keyUpEvents.length
185
- ) {
186
- for ( let j = 0; j < keyDownEvents.length; j++ ) {
187
- results.type.push(
188
- keyDownEvents[ j ] + keyPressEvents[ j ] + keyUpEvents[ j ]
189
- );
190
- }
191
- }
192
-
193
- // Measuring block selection performance
194
- await createNewPost();
195
- await page.evaluate( () => {
196
- const { createBlock } = window.wp.blocks;
197
- const { dispatch } = window.wp.data;
198
- const blocks = window.lodash
199
- .times( 1000 )
200
- .map( () => createBlock( 'core/paragraph' ) );
201
- dispatch( 'core/block-editor' ).resetBlocks( blocks );
202
- } );
203
- const paragraphs = await page.$$( '.wp-block' );
204
- await page.tracing.start( {
205
- path: traceFile,
206
- screenshots: false,
207
- categories: [ 'devtools.timeline' ],
208
- } );
209
- await paragraphs[ 0 ].click();
210
- for ( let j = 1; j <= 10; j++ ) {
211
- // Wait for the browser to be idle before starting the monitoring.
212
- // eslint-disable-next-line no-restricted-syntax
213
- await page.waitForTimeout( 200 );
214
- await paragraphs[ j ].click();
215
- }
216
- await page.tracing.stop();
217
- traceResults = JSON.parse( readFile( traceFile ) );
218
- const [ focusEvents ] = getSelectionEventDurations( traceResults );
219
- results.focus = focusEvents;
220
-
221
- const resultsFilename = basename( __filename, '.js' ) + '.results.json';
222
- writeFileSync(
223
- join( __dirname, resultsFilename ),
224
- JSON.stringify( results, null, 2 )
225
- );
226
- deleteFile( traceFile );
227
-
228
- expect( true ).toBe( true );
229
257
  } );
230
258
  } );
@@ -114,24 +114,9 @@ describe( 'Site Editor Performance', () => {
114
114
  keyUpEvents,
115
115
  ] = getTypingEventDurations( traceResults );
116
116
 
117
- // Both keydown and keypress events are bubbled from the iframe to the
118
- // main frame, which must be ignored. These will be the odd values in
119
- // the array.
120
- const _keyDownEvents = keyDownEvents.filter(
121
- ( v, ii ) => ii % 2 === 0
122
- );
123
- const _keyPressEvents = keyPressEvents.filter(
124
- ( v, ii ) => ii % 2 === 0
125
- );
126
-
127
- expect(
128
- _keyDownEvents.length === _keyPressEvents.length &&
129
- _keyPressEvents.length === keyUpEvents.length
130
- ).toBe( true );
131
-
132
- for ( let j = 0; j < _keyDownEvents.length; j++ ) {
117
+ for ( let j = 0; j < keyDownEvents.length; j++ ) {
133
118
  results.type.push(
134
- _keyDownEvents[ j ] + _keyPressEvents[ j ] + keyUpEvents[ j ]
119
+ keyDownEvents[ j ] + keyPressEvents[ j ] + keyUpEvents[ j ]
135
120
  );
136
121
  }
137
122
 
@@ -2,9 +2,9 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import {
5
- activatePlugin,
5
+ __experimentalActivatePlugin as activatePlugin,
6
6
  activateTheme,
7
- deactivatePlugin,
7
+ __experimentalDeactivatePlugin as deactivatePlugin,
8
8
  visitAdminPage,
9
9
  showBlockToolbar,
10
10
  clickBlockToolbarButton,
@@ -16,7 +16,12 @@ import {
16
16
  * External dependencies
17
17
  */
18
18
  // eslint-disable-next-line no-restricted-imports
19
- import { find } from 'puppeteer-testing-library';
19
+ import { find, findAll } from 'puppeteer-testing-library';
20
+ import { first } from 'lodash';
21
+
22
+ const twentyTwentyError = `Stylesheet twentytwenty-block-editor-styles-css was not properly added.
23
+ 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).
24
+ For themes, use add_editor_style (https://developer.wordpress.org/block-editor/how-to-guides/themes/theme-support/#editor-styles).`;
20
25
 
21
26
  describe( 'Widgets Customizer', () => {
22
27
  beforeEach( async () => {
@@ -26,14 +31,14 @@ describe( 'Widgets Customizer', () => {
26
31
  // Disable welcome guide if it is enabled.
27
32
  const isWelcomeGuideActive = await page.evaluate( () =>
28
33
  wp.data
29
- .select( 'core/customize-widgets' )
30
- .__unstableIsFeatureActive( 'welcomeGuide' )
34
+ .select( 'core/interface' )
35
+ .isFeatureActive( 'core/customize-widgets', 'welcomeGuide' )
31
36
  );
32
37
  if ( isWelcomeGuideActive ) {
33
38
  await page.evaluate( () =>
34
39
  wp.data
35
- .dispatch( 'core/customize-widgets' )
36
- .__unstableToggleFeature( 'welcomeGuide' )
40
+ .dispatch( 'core/interface' )
41
+ .toggleFeature( 'core/customize-widgets', 'welcomeGuide' )
37
42
  );
38
43
  }
39
44
  } );
@@ -158,6 +163,8 @@ describe( 'Widgets Customizer', () => {
158
163
  name: 'My Search',
159
164
  selector: '.widget-content *',
160
165
  } ).toBeFound( findOptions );
166
+
167
+ expect( console ).toHaveErrored( twentyTwentyError );
161
168
  } );
162
169
 
163
170
  it( 'should open the inspector panel', async () => {
@@ -243,6 +250,8 @@ describe( 'Widgets Customizer', () => {
243
250
  } ).toBeFound();
244
251
 
245
252
  await expect( inspectorHeading ).not.toBeVisible();
253
+
254
+ expect( console ).toHaveErrored( twentyTwentyError );
246
255
  } );
247
256
 
248
257
  it( 'should handle the inserter outer section', async () => {
@@ -350,6 +359,8 @@ describe( 'Widgets Customizer', () => {
350
359
  name: 'Add a block',
351
360
  level: 2,
352
361
  } ).not.toBeFound();
362
+
363
+ expect( console ).toHaveErrored( twentyTwentyError );
353
364
  } );
354
365
 
355
366
  it( 'should move focus to the block', async () => {
@@ -445,6 +456,8 @@ describe( 'Widgets Customizer', () => {
445
456
  text: 'First Heading',
446
457
  } );
447
458
  await expect( headingBlock ).toHaveFocus();
459
+
460
+ expect( console ).toHaveErrored( twentyTwentyError );
448
461
  } );
449
462
 
450
463
  it( 'should clear block selection', async () => {
@@ -507,6 +520,8 @@ describe( 'Widgets Customizer', () => {
507
520
  role: 'toolbar',
508
521
  name: 'Block tools',
509
522
  } ).not.toBeFound();
523
+
524
+ expect( console ).toHaveErrored( twentyTwentyError );
510
525
  } );
511
526
 
512
527
  it( 'should handle legacy widgets', async () => {
@@ -685,6 +700,8 @@ describe( 'Widgets Customizer', () => {
685
700
  selector: '*[aria-live="polite"][aria-relevant="additions text"]',
686
701
  } ).toBeFound();
687
702
  await expect( paragraphBlock ).toBeVisible();
703
+
704
+ expect( console ).toHaveErrored( twentyTwentyError );
688
705
  } );
689
706
 
690
707
  it( 'should move (inner) blocks to another sidebar', async () => {
@@ -744,6 +761,100 @@ describe( 'Widgets Customizer', () => {
744
761
  await expect( movedParagraphBlockQuery ).toBeFound();
745
762
  const movedParagraphBlock = await find( movedParagraphBlockQuery );
746
763
  await expect( movedParagraphBlock ).toHaveFocus();
764
+
765
+ expect( console ).toHaveErrored( twentyTwentyError );
766
+ } );
767
+
768
+ it( 'should not render Block Settings sections', async () => {
769
+ // We add Block Settings as a section, but it shouldn't display to
770
+ // the user as a section on the main menu. It's simply how we
771
+ // integrate the G sidebar inside the customizer.
772
+ const findAllBlockSettingsHeader = findAll(
773
+ {
774
+ role: 'heading',
775
+ name: /Block Settings/,
776
+ level: 3,
777
+ },
778
+ { timeout: 0 }
779
+ );
780
+ await expect( findAllBlockSettingsHeader ).toThrowQueryEmptyError();
781
+ } );
782
+
783
+ it( 'should stay in block settings after making a change in that area', async () => {
784
+ // Open footer block widgets
785
+ const widgetsPanel = await find( {
786
+ role: 'heading',
787
+ name: /Widgets/,
788
+ level: 3,
789
+ } );
790
+ await widgetsPanel.click();
791
+
792
+ const footer1Section = await find( {
793
+ role: 'heading',
794
+ name: /^Footer #1/,
795
+ level: 3,
796
+ } );
797
+ await footer1Section.click();
798
+
799
+ // Add a block to make the publish button active.
800
+ await addBlock( 'Paragraph' );
801
+ await page.keyboard.type( 'First Paragraph' );
802
+
803
+ await waitForPreviewIframe();
804
+
805
+ // Click Publish
806
+ const publishButton = await find( {
807
+ role: 'button',
808
+ name: 'Publish',
809
+ } );
810
+ await publishButton.click();
811
+
812
+ // Wait for publishing to finish.
813
+ await page.waitForResponse( createURL( '/wp-admin/admin-ajax.php' ) );
814
+ await expect( publishButton ).toMatchQuery( {
815
+ disabled: true,
816
+ } );
817
+
818
+ // Select the paragraph block
819
+ const paragraphBlock = await find( {
820
+ role: 'document',
821
+ name: 'Paragraph block',
822
+ } );
823
+ await paragraphBlock.focus();
824
+
825
+ // Click the three dots button, then click "Show More Settings".
826
+ await showBlockToolbar();
827
+ await clickBlockToolbarButton( 'Options' );
828
+ const showMoreSettingsButton = await find( {
829
+ role: 'menuitem',
830
+ name: 'Show more settings',
831
+ } );
832
+ await showMoreSettingsButton.click();
833
+
834
+ // Change font size (Any change made in this section is sufficient; not required to be font size)
835
+ const CUSTOM_FONT_SIZE_LABEL_SELECTOR =
836
+ "//fieldset[legend[contains(text(),'Font size')]]//label[contains(text(), 'Custom')]";
837
+ await first( await page.$x( CUSTOM_FONT_SIZE_LABEL_SELECTOR ) ).click();
838
+ await page.keyboard.type( '23' );
839
+ await page.keyboard.press( 'Enter' );
840
+
841
+ // Now that we've made a change:
842
+ // (1) Publish button should be active
843
+ // (2) We should still be in the "Block Settings" area
844
+ await find( {
845
+ role: 'button',
846
+ name: 'Publish',
847
+ } );
848
+
849
+ // This fails on 539cea09 and earlier; we get kicked back to the widgets area.
850
+ // We expect to stay in block settings.
851
+ await find( {
852
+ role: 'heading',
853
+ name: 'Customizing ▸ Widgets ▸ Footer #1 Block Settings',
854
+ level: 3,
855
+ } );
856
+
857
+ expect( console ).toHaveErrored( twentyTwentyError );
747
858
  } );
748
859
  } );
749
860