@wordpress/e2e-tests 7.19.0 → 7.20.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/LICENSE.md +1 -1
  3. package/jest.config.js +0 -1
  4. package/package.json +8 -9
  5. package/plugins/iframed-block/block.json +1 -0
  6. package/plugins/iframed-inline-styles/block.json +1 -0
  7. package/plugins/iframed-masonry-block/block.json +1 -0
  8. package/plugins/iframed-multiple-stylesheets/block.json +1 -0
  9. package/plugins/interactive-blocks/directive-bind/block.json +1 -0
  10. package/plugins/interactive-blocks/directive-body/block.json +1 -0
  11. package/plugins/interactive-blocks/directive-class/block.json +1 -0
  12. package/plugins/interactive-blocks/directive-context/block.json +1 -0
  13. package/plugins/interactive-blocks/directive-init/block.json +1 -0
  14. package/plugins/interactive-blocks/directive-key/block.json +1 -0
  15. package/plugins/interactive-blocks/directive-on/block.json +1 -0
  16. package/plugins/interactive-blocks/directive-priorities/block.json +1 -0
  17. package/plugins/interactive-blocks/directive-slots/block.json +1 -0
  18. package/plugins/interactive-blocks/directive-style/block.json +1 -0
  19. package/plugins/interactive-blocks/directive-text/block.json +1 -0
  20. package/plugins/interactive-blocks/directive-watch/block.json +1 -0
  21. package/plugins/interactive-blocks/negation-operator/block.json +1 -0
  22. package/plugins/interactive-blocks/router-navigate/block.json +1 -0
  23. package/plugins/interactive-blocks/router-regions/block.json +1 -0
  24. package/plugins/interactive-blocks/store-tag/block.json +1 -0
  25. package/plugins/interactive-blocks/tovdom/block.json +1 -0
  26. package/plugins/interactive-blocks/tovdom-islands/block.json +1 -0
  27. package/plugins/interactive-blocks/tovdom-islands/render.php +12 -0
  28. package/plugins/pattern-recursion.php +22 -0
  29. package/specs/editor/various/inserting-blocks.test.js +3 -5
  30. package/specs/editor/various/__snapshots__/block-editor-keyboard-shortcuts.test.js.snap +0 -153
  31. package/specs/editor/various/allowed-patterns.test.js +0 -74
  32. package/specs/editor/various/block-editor-keyboard-shortcuts.test.js +0 -110
  33. package/specs/editor/various/block-switcher.test.js +0 -130
  34. package/specs/editor/various/core-settings.test.js +0 -42
  35. package/specs/editor/various/datepicker.test.js +0 -148
  36. package/specs/editor/various/dropdown-menu.test.js +0 -143
  37. package/specs/editor/various/editor-modes.test.js +0 -163
  38. package/specs/editor/various/invalid-block.test.js +0 -100
  39. package/specs/editor/various/nux.test.js +0 -158
  40. package/specs/editor/various/preferences.test.js +0 -62
  41. package/specs/editor/various/publish-panel.test.js +0 -82
  42. package/specs/editor/various/publishing.test.js +0 -176
  43. package/specs/editor/various/scheduling.test.js +0 -65
  44. package/specs/editor/various/sidebar.test.js +0 -171
  45. package/specs/editor/various/taxonomies.test.js +0 -251
  46. package/specs/experiments/blocks/post-comments-form.test.js +0 -53
  47. package/specs/experiments/experimental-features.js +0 -39
  48. package/specs/experiments/fixtures/menu-items-request-fixture.json +0 -84
  49. package/specs/site-editor/settings-sidebar.test.js +0 -122
  50. package/specs/widgets/editing-widgets.test.js +0 -962
@@ -1,130 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import {
5
- hasBlockSwitcher,
6
- getAvailableBlockTransforms,
7
- createNewPost,
8
- insertBlock,
9
- pressKeyWithModifier,
10
- } from '@wordpress/e2e-test-utils';
11
-
12
- describe( 'Block Switcher', () => {
13
- beforeEach( async () => {
14
- await createNewPost();
15
- } );
16
-
17
- it( 'Should show the expected block transforms on the list block when the blocks are removed', async () => {
18
- // Insert a list block.
19
- await page.keyboard.press( 'Enter' );
20
- await page.keyboard.type( '- List content' );
21
- await page.keyboard.press( 'ArrowUp' );
22
- await pressKeyWithModifier( 'alt', 'F10' );
23
-
24
- // Verify the block switcher exists.
25
- expect( await hasBlockSwitcher() ).toBeTruthy();
26
-
27
- // Verify the correct block transforms appear.
28
- expect( await getAvailableBlockTransforms() ).toEqual(
29
- expect.arrayContaining( [
30
- 'Group',
31
- 'Paragraph',
32
- 'Heading',
33
- 'Quote',
34
- 'Columns',
35
- ] )
36
- );
37
- } );
38
-
39
- it( 'Should show the expected block transforms on the list block when the quote block is removed', async () => {
40
- // Remove the quote block from the list of registered blocks.
41
- await page.evaluate( () => {
42
- wp.blocks.unregisterBlockType( 'core/quote' );
43
- } );
44
-
45
- // Insert a list block.
46
- await page.keyboard.press( 'Enter' );
47
- await page.keyboard.type( '- List content' );
48
- await page.keyboard.press( 'ArrowUp' );
49
- await pressKeyWithModifier( 'alt', 'F10' );
50
-
51
- // Verify the block switcher exists.
52
- expect( await hasBlockSwitcher() ).toBeTruthy();
53
-
54
- // Verify the correct block transforms appear.
55
- expect( await getAvailableBlockTransforms() ).toEqual(
56
- expect.arrayContaining( [
57
- 'Group',
58
- 'Paragraph',
59
- 'Heading',
60
- 'Columns',
61
- ] )
62
- );
63
- } );
64
-
65
- it( 'Should not show the block switcher if all the blocks the list block transforms into are removed', async () => {
66
- // Insert a list block.
67
- await page.keyboard.press( 'Enter' );
68
- await page.keyboard.type( '- List content' );
69
-
70
- // Remove the paragraph and quote block from the list of registered blocks.
71
- await page.evaluate( () => {
72
- [
73
- 'core/quote',
74
- 'core/pullquote',
75
- 'core/paragraph',
76
- 'core/group',
77
- 'core/heading',
78
- 'core/columns',
79
- ].forEach( ( block ) => wp.blocks.unregisterBlockType( block ) );
80
- } );
81
-
82
- await page.keyboard.press( 'ArrowUp' );
83
- await pressKeyWithModifier( 'alt', 'F10' );
84
-
85
- // Verify the block switcher exists.
86
- expect( await hasBlockSwitcher() ).toBeFalsy();
87
- // Verify the correct block transforms appear.
88
- expect( await getAvailableBlockTransforms() ).toHaveLength( 0 );
89
- } );
90
-
91
- describe( 'Conditional tranformation options', () => {
92
- describe( 'Columns tranforms', () => {
93
- it( 'Should show Columns block only if selected blocks are between limits (1-6)', async () => {
94
- await page.keyboard.press( 'Enter' );
95
- await page.keyboard.type( '- List content' );
96
- await page.keyboard.press( 'ArrowUp' );
97
- await insertBlock( 'Heading' );
98
- await page.keyboard.type( 'I am a header' );
99
- await page.keyboard.down( 'Shift' );
100
- await page.keyboard.press( 'ArrowUp' );
101
- await page.keyboard.up( 'Shift' );
102
- expect( await getAvailableBlockTransforms() ).toEqual(
103
- expect.arrayContaining( [ 'Columns' ] )
104
- );
105
- } );
106
- it( 'Should NOT show Columns transform only if selected blocks are more than max limit(6)', async () => {
107
- await page.keyboard.press( 'Enter' );
108
- await page.keyboard.type( '- List content' );
109
- await page.keyboard.press( 'ArrowUp' );
110
- await insertBlock( 'Heading' );
111
- await page.keyboard.type( 'I am a header' );
112
- await page.keyboard.press( 'Enter' );
113
- await page.keyboard.type( 'First paragraph' );
114
- await page.keyboard.press( 'Enter' );
115
- await page.keyboard.type( 'Second paragraph' );
116
- await page.keyboard.press( 'Enter' );
117
- await page.keyboard.type( 'Third paragraph' );
118
- await page.keyboard.press( 'Enter' );
119
- await page.keyboard.type( 'Fourth paragraph' );
120
- await page.keyboard.press( 'Enter' );
121
- await page.keyboard.type( 'Fifth paragraph' );
122
- await pressKeyWithModifier( 'primary', 'a' );
123
- await pressKeyWithModifier( 'primary', 'a' );
124
- expect( await getAvailableBlockTransforms() ).not.toEqual(
125
- expect.arrayContaining( [ 'Columns' ] )
126
- );
127
- } );
128
- } );
129
- } );
130
- } );
@@ -1,42 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { visitAdminPage } from '@wordpress/e2e-test-utils';
5
-
6
- async function getOptionsValues( selector ) {
7
- await visitAdminPage( 'options.php' );
8
- return page.evaluate( ( theSelector ) => {
9
- const inputs = Array.from( document.querySelectorAll( theSelector ) );
10
- return inputs.reduce( ( memo, input ) => {
11
- memo[ input.id ] = input.value;
12
- return memo;
13
- }, {} );
14
- }, selector );
15
- }
16
-
17
- // It might make sense to include a similar test in WP core (or move this one over).
18
- // See discussion here: https://github.com/WordPress/gutenberg/pull/32797#issuecomment-864192088.
19
- describe( 'Settings', () => {
20
- test( 'Regression: updating a specific option will only change its value and will not corrupt others', async () => {
21
- // We won't select the option that we updated and will also remove some
22
- // _transient options that seem to change at every update.
23
- const optionsInputsSelector =
24
- 'form#all-options table.form-table input:not([id*="_transient"]):not([id="blogdescription"])';
25
- const optionsBefore = await getOptionsValues( optionsInputsSelector );
26
-
27
- await visitAdminPage( 'options-general.php' );
28
- await page.type(
29
- 'input#blogdescription',
30
- 'Just another Gutenberg site'
31
- );
32
- await page.click( 'input#submit' );
33
-
34
- const optionsAfter = await getOptionsValues( optionsInputsSelector );
35
-
36
- Object.entries( optionsBefore ).forEach( ( optionBefore ) => {
37
- const [ id ] = optionBefore;
38
- const optionAfter = [ id, optionsAfter[ id ] ];
39
- expect( optionAfter ).toStrictEqual( optionBefore );
40
- } );
41
- } );
42
- } );
@@ -1,148 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { createNewPost, changeSiteTimezone } from '@wordpress/e2e-test-utils';
5
-
6
- async function getInputValue( selector ) {
7
- return page.$eval( selector, ( element ) => element.value );
8
- }
9
-
10
- async function getSelectedOptionLabel( selector ) {
11
- return page.$eval(
12
- selector,
13
- ( element ) => element.options[ element.selectedIndex ].text
14
- );
15
- }
16
-
17
- async function getDatePickerValues() {
18
- const year = await getInputValue(
19
- '.components-datetime__time-field-year input'
20
- );
21
- const month = await getInputValue(
22
- '.components-datetime__time-field-month select'
23
- );
24
- const monthLabel = await getSelectedOptionLabel(
25
- '.components-datetime__time-field-month select'
26
- );
27
- const day = await getInputValue(
28
- '.components-datetime__time-field-day input'
29
- );
30
- const hours = await getInputValue(
31
- '.components-datetime__time-field-hours-input input'
32
- );
33
- const minutes = await getInputValue(
34
- '.components-datetime__time-field-minutes-input input'
35
- );
36
- const amOrPm = await page.$eval(
37
- '.components-datetime__time-field-am-pm .is-primary',
38
- ( element ) => element.innerText.toLowerCase()
39
- );
40
-
41
- return { year, month, monthLabel, day, hours, minutes, amOrPm };
42
- }
43
-
44
- function trimLeadingZero( str ) {
45
- return str[ 0 ] === '0' ? str.slice( 1 ) : str;
46
- }
47
-
48
- function formatDatePickerValues(
49
- { year, monthLabel, day, hours, minutes, amOrPm },
50
- timezone
51
- ) {
52
- const dayTrimmed = trimLeadingZero( day );
53
- const hoursTrimmed = trimLeadingZero( hours );
54
- return `${ monthLabel } ${ dayTrimmed }, ${ year } ${ hoursTrimmed }:${ minutes }\xa0${ amOrPm } ${ timezone }`;
55
- }
56
-
57
- async function getPublishingDate() {
58
- return page.$eval(
59
- '.editor-post-schedule__dialog-toggle',
60
- ( dateLabel ) => dateLabel.textContent
61
- );
62
- }
63
-
64
- describe.each( [ [ 'UTC-10' ], [ 'UTC' ], [ 'UTC+10' ] ] )(
65
- `Datepicker %s`,
66
- ( timezone ) => {
67
- let oldTimezone;
68
- beforeEach( async () => {
69
- await page.emulateTimezone( 'America/New_York' ); // Set browser to a timezone that's different to `timezone`.
70
- oldTimezone = await changeSiteTimezone( timezone );
71
- await createNewPost();
72
- } );
73
- afterEach( async () => {
74
- await changeSiteTimezone( oldTimezone );
75
- await page.emulateTimezone( null );
76
- } );
77
-
78
- it( 'should show the publishing date as "Immediately" if the date is not altered', async () => {
79
- const publishingDate = await getPublishingDate();
80
-
81
- expect( publishingDate ).toEqual( 'Immediately' );
82
- } );
83
-
84
- it( 'should show the publishing date if the date is in the past', async () => {
85
- // Open the datepicker.
86
- await page.click( '.editor-post-schedule__dialog-toggle' );
87
-
88
- // Change the publishing date to a year in the past.
89
- await page.click( '.components-datetime__time-field-year' );
90
- await page.keyboard.press( 'ArrowDown' );
91
- const datePickerValues = await getDatePickerValues();
92
-
93
- // Close the datepicker.
94
- await page.click( '.editor-post-schedule__dialog-toggle' );
95
-
96
- const publishingDate = await getPublishingDate();
97
-
98
- expect( publishingDate ).toBe(
99
- formatDatePickerValues( datePickerValues, timezone )
100
- );
101
- } );
102
-
103
- it( 'should show the publishing date if the date is in the future', async () => {
104
- // Open the datepicker.
105
- await page.click( '.editor-post-schedule__dialog-toggle' );
106
-
107
- // Change the publishing date to a year in the future.
108
- await page.click( '.components-datetime__time-field-year' );
109
- await page.keyboard.press( 'ArrowUp' );
110
- const datePickerValues = await getDatePickerValues();
111
-
112
- // Close the datepicker.
113
- await page.click( '.editor-post-schedule__dialog-toggle' );
114
-
115
- const publishingDate = await getPublishingDate();
116
-
117
- expect( publishingDate ).not.toEqual( 'Immediately' );
118
- // The expected date format will be "Sep 26, 2018 11:52 pm".
119
- expect( publishingDate ).toBe(
120
- formatDatePickerValues( datePickerValues, timezone )
121
- );
122
- } );
123
-
124
- it( `should show the publishing date as "Immediately" if the date is cleared`, async () => {
125
- // Open the datepicker.
126
- await page.click( '.editor-post-schedule__dialog-toggle' );
127
-
128
- // Change the publishing date to a year in the future.
129
- await page.click( '.components-datetime__time-field-year' );
130
- await page.keyboard.press( 'ArrowUp' );
131
-
132
- // Close the datepicker.
133
- await page.click( '.editor-post-schedule__dialog-toggle' );
134
-
135
- // Open the datepicker.
136
- await page.click( '.editor-post-schedule__dialog-toggle' );
137
-
138
- // Clear the date.
139
- await page.click(
140
- '.block-editor-publish-date-time-picker button[aria-label="Now"]'
141
- );
142
-
143
- const publishingDate = await getPublishingDate();
144
-
145
- expect( publishingDate ).toEqual( 'Immediately' );
146
- } );
147
- }
148
- );
@@ -1,143 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { createNewPost, pressKeyTimes } from '@wordpress/e2e-test-utils';
5
-
6
- const moreMenuButtonSelector = '.components-button[aria-label="Options"]';
7
- const moreMenuDropdownSelector =
8
- '.components-dropdown-menu__menu[aria-label="Options"]';
9
- const menuItemsSelector = [ 'menuitem', 'menuitemcheckbox', 'menuitemradio' ]
10
- .map( ( role ) => `${ moreMenuDropdownSelector } [role="${ role }"]` )
11
- .join( ',' );
12
-
13
- describe( 'Dropdown Menu', () => {
14
- beforeEach( async () => {
15
- await createNewPost();
16
- } );
17
-
18
- it( 'allows navigation through each item using arrow keys', async () => {
19
- await page.click( moreMenuButtonSelector );
20
- const menuItems = await page.$$( menuItemsSelector );
21
-
22
- // Catch any issues with the selector, which could cause a false positive test result.
23
- expect( menuItems.length ).toBeGreaterThan( 0 );
24
-
25
- let activeElementText = await page.evaluate(
26
- () => document.activeElement.textContent
27
- );
28
- const [ firstMenuItem ] = menuItems;
29
- const firstMenuItemText = await firstMenuItem.evaluate(
30
- ( element ) => element.textContent
31
- );
32
-
33
- // Expect the first menu item to be focused.
34
- expect( activeElementText ).toBeDefined();
35
- expect( activeElementText ).toBe( firstMenuItemText );
36
-
37
- // Arrow down to the last item.
38
- await pressKeyTimes( 'ArrowDown', menuItems.length - 1 );
39
-
40
- activeElementText = await page.evaluate(
41
- () => document.activeElement.textContent
42
- );
43
-
44
- const [ lastMenuItem ] = menuItems.slice( -1 );
45
- const lastMenuItemText = await lastMenuItem.evaluate(
46
- ( element ) => element.textContent
47
- );
48
-
49
- // Expect the last menu item to be focused.
50
- expect( activeElementText ).toBeDefined();
51
- expect( activeElementText ).toBe( lastMenuItemText );
52
-
53
- // Arrow back up to the first item.
54
- await pressKeyTimes( 'ArrowUp', menuItems.length - 1 );
55
-
56
- activeElementText = await page.evaluate(
57
- () => document.activeElement.textContent
58
- );
59
-
60
- // Expect the first menu item to be focused again.
61
- expect( activeElementText ).toBeDefined();
62
- expect( activeElementText ).toBe( firstMenuItemText );
63
- } );
64
-
65
- it( 'loops to the beginning and end when navigating past the boundaries of the menu', async () => {
66
- await page.click( moreMenuButtonSelector );
67
- const menuItems = await page.$$( menuItemsSelector );
68
-
69
- // Catch any issues with the selector, which could cause a false positive test result.
70
- expect( menuItems.length ).toBeGreaterThan( 0 );
71
-
72
- let activeElementText = await page.evaluate(
73
- () => document.activeElement.textContent
74
- );
75
- const [ firstMenuItem ] = menuItems;
76
- const firstMenuItemText = await firstMenuItem.evaluate(
77
- ( element ) => element.textContent
78
- );
79
-
80
- // Expect the first menu item to be focused.
81
- expect( activeElementText ).toBeDefined();
82
- expect( activeElementText ).toBe( firstMenuItemText );
83
-
84
- // Arrow up to the last item.
85
- await page.keyboard.press( 'ArrowUp' );
86
-
87
- activeElementText = await page.evaluate(
88
- () => document.activeElement.textContent
89
- );
90
-
91
- const [ lastMenuItem ] = menuItems.slice( -1 );
92
- const lastMenuItemText = await lastMenuItem.evaluate(
93
- ( element ) => element.textContent
94
- );
95
-
96
- // Expect the last menu item to be focused.
97
- expect( activeElementText ).toBeDefined();
98
- expect( activeElementText ).toBe( lastMenuItemText );
99
-
100
- // Arrow back down to the first item.
101
- await page.keyboard.press( 'ArrowDown' );
102
-
103
- activeElementText = await page.evaluate(
104
- () => document.activeElement.textContent
105
- );
106
-
107
- // Expect the first menu item to be focused again.
108
- expect( activeElementText ).toBeDefined();
109
- expect( activeElementText ).toBe( firstMenuItemText );
110
- } );
111
-
112
- it( 'ignores arrow key navigation that is orthogonal to the orientation of the menu, but stays open', async () => {
113
- await page.click( moreMenuButtonSelector );
114
- const menuItems = await page.$$( menuItemsSelector );
115
-
116
- // Catch any issues with the selector, which could cause a false positive test result.
117
- expect( menuItems.length ).toBeGreaterThan( 0 );
118
-
119
- let activeElementText = await page.evaluate(
120
- () => document.activeElement.textContent
121
- );
122
- const [ firstMenuItem ] = menuItems;
123
- const firstMenuItemText = await firstMenuItem.evaluate(
124
- ( element ) => element.textContent
125
- );
126
-
127
- // Expect the first menu item to be focused.
128
- expect( activeElementText ).toBeDefined();
129
- expect( activeElementText ).toBe( firstMenuItemText );
130
-
131
- // Press left and right keys an arbitrary (but > 1) number of times.
132
- await pressKeyTimes( 'ArrowLeft', 5 );
133
- await pressKeyTimes( 'ArrowRight', 5 );
134
-
135
- activeElementText = await page.evaluate(
136
- () => document.activeElement.textContent
137
- );
138
-
139
- // Expect the first menu item to still be focused.
140
- expect( activeElementText ).toBeDefined();
141
- expect( activeElementText ).toBe( firstMenuItemText );
142
- } );
143
- } );
@@ -1,163 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import {
5
- clickBlockAppender,
6
- clickBlockToolbarButton,
7
- clickMenuItem,
8
- createNewPost,
9
- getCurrentPostContent,
10
- switchEditorModeTo,
11
- pressKeyTimes,
12
- pressKeyWithModifier,
13
- openTypographyToolsPanelMenu,
14
- canvas,
15
- } from '@wordpress/e2e-test-utils';
16
-
17
- describe( 'Editing modes (visual/HTML)', () => {
18
- beforeEach( async () => {
19
- await createNewPost();
20
- await clickBlockAppender();
21
- await page.keyboard.type( 'Hello world!' );
22
- } );
23
-
24
- it( 'should switch between visual and HTML modes', async () => {
25
- // This block should be in "visual" mode by default.
26
- let visualBlock = await canvas().$$( '[data-block].rich-text' );
27
- expect( visualBlock ).toHaveLength( 1 );
28
-
29
- // Change editing mode from "Visual" to "HTML".
30
- await clickBlockToolbarButton( 'Options' );
31
- await clickMenuItem( 'Edit as HTML' );
32
-
33
- // Wait for the block to be converted to HTML editing mode.
34
- const htmlBlock = await canvas().$$(
35
- '[data-block] .block-editor-block-list__block-html-textarea'
36
- );
37
- expect( htmlBlock ).toHaveLength( 1 );
38
-
39
- // Change editing mode from "HTML" back to "Visual".
40
- await clickBlockToolbarButton( 'Options' );
41
- await clickMenuItem( 'Edit visually' );
42
-
43
- // This block should be in "visual" mode by default.
44
- visualBlock = await canvas().$$( '[data-block].rich-text' );
45
- expect( visualBlock ).toHaveLength( 1 );
46
- } );
47
-
48
- it( 'should display sidebar in HTML mode', async () => {
49
- // Change editing mode from "Visual" to "HTML".
50
- await clickBlockToolbarButton( 'Options' );
51
- await clickMenuItem( 'Edit as HTML' );
52
-
53
- // The `drop cap` toggle for the paragraph block should appear, even in
54
- // HTML editing mode.
55
- await openTypographyToolsPanelMenu();
56
- await page.click( 'button[aria-label="Show Drop cap"]' );
57
-
58
- const dropCapToggle = await page.$x(
59
- "//label[contains(text(), 'Drop cap')]"
60
- );
61
-
62
- expect( dropCapToggle ).toHaveLength( 1 );
63
- } );
64
-
65
- it( 'should update HTML in HTML mode when sidebar is used', async () => {
66
- // Change editing mode from "Visual" to "HTML".
67
- await clickBlockToolbarButton( 'Options' );
68
- await clickMenuItem( 'Edit as HTML' );
69
-
70
- // Make sure the paragraph content is rendered as expected.
71
- let htmlBlockContent = await canvas().$eval(
72
- '.block-editor-block-list__layout .block-editor-block-list__block .block-editor-block-list__block-html-textarea',
73
- ( node ) => node.textContent
74
- );
75
- expect( htmlBlockContent ).toEqual( '<p>Hello world!</p>' );
76
-
77
- // Change the `drop cap` using the sidebar.
78
- await openTypographyToolsPanelMenu();
79
- await page.click( 'button[aria-label="Show Drop cap"]' );
80
-
81
- const [ dropCapToggle ] = await page.$x(
82
- "//label[contains(text(), 'Drop cap')]"
83
- );
84
- await dropCapToggle.click();
85
-
86
- // Make sure the HTML content updated.
87
- htmlBlockContent = await canvas().$eval(
88
- '.block-editor-block-list__layout .block-editor-block-list__block .block-editor-block-list__block-html-textarea',
89
- ( node ) => node.textContent
90
- );
91
- expect( htmlBlockContent ).toEqual(
92
- '<p class="has-drop-cap">Hello world!</p>'
93
- );
94
- } );
95
-
96
- it( 'the code editor should unselect blocks and disable the inserter', async () => {
97
- // The paragraph block should be selected.
98
- const title = await page.$eval(
99
- '.block-editor-block-card__title',
100
- ( element ) => element.innerText
101
- );
102
- expect( title ).toBe( 'Paragraph' );
103
-
104
- // The Block inspector should be active.
105
- let [ blockInspectorTab ] = await page.$x(
106
- '//button[@role="tab"][@aria-selected="true"][contains(text(), "Block")]'
107
- );
108
- expect( blockInspectorTab ).not.toBeNull();
109
-
110
- await switchEditorModeTo( 'Code' );
111
-
112
- // The Block inspector should not be active anymore.
113
- [ blockInspectorTab ] = await page.$x(
114
- '//button[@role="tab"][@aria-selected="true"][contains(text(), "Block")]'
115
- );
116
- expect( blockInspectorTab ).toBeUndefined();
117
-
118
- // No block is selected.
119
- const inactiveBlockInspectorTab = await page.waitForXPath(
120
- '//button[@role="tab"][contains(text(), "Block")]'
121
- );
122
- inactiveBlockInspectorTab.click();
123
- const noBlocksElement = await page.$(
124
- '.block-editor-block-inspector__no-blocks'
125
- );
126
- expect( noBlocksElement ).not.toBeNull();
127
-
128
- // The inserter is disabled.
129
- const disabledInserter = await page.$(
130
- '.edit-post-header-toolbar__inserter-toggle:disabled, .edit-post-header-toolbar__inserter-toggle[aria-disabled="true"]'
131
- );
132
- expect( disabledInserter ).not.toBeNull();
133
- } );
134
-
135
- // Test for regressions of https://github.com/WordPress/gutenberg/issues/24054.
136
- it( 'saves content when using the shortcut in the Code Editor', async () => {
137
- await switchEditorModeTo( 'Code' );
138
-
139
- const textContent = await page.evaluate(
140
- () => document.querySelector( '.editor-post-text-editor' ).value
141
- );
142
- const editPosition = textContent.indexOf( 'Hello' );
143
-
144
- // Replace the word 'Hello' with 'Hi'.
145
- await canvas().click( '.editor-post-title__input' );
146
- await page.keyboard.press( 'Tab' );
147
- await pressKeyTimes( 'ArrowRight', editPosition );
148
- await pressKeyTimes( 'Delete', 5 );
149
- await page.keyboard.type( 'Hi' );
150
-
151
- // Save the post using the shortcut.
152
- await pressKeyWithModifier( 'primary', 's' );
153
- await page.waitForSelector( '.editor-post-saved-state.is-saved' );
154
-
155
- await switchEditorModeTo( 'Visual' );
156
-
157
- expect( await getCurrentPostContent() ).toMatchInlineSnapshot( `
158
- "<!-- wp:paragraph -->
159
- <p>Hi world!</p>
160
- <!-- /wp:paragraph -->"
161
- ` );
162
- } );
163
- } );