@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.
- package/CHANGELOG.md +2 -0
- package/LICENSE.md +1 -1
- package/jest.config.js +0 -1
- package/package.json +8 -9
- package/plugins/iframed-block/block.json +1 -0
- package/plugins/iframed-inline-styles/block.json +1 -0
- package/plugins/iframed-masonry-block/block.json +1 -0
- package/plugins/iframed-multiple-stylesheets/block.json +1 -0
- package/plugins/interactive-blocks/directive-bind/block.json +1 -0
- package/plugins/interactive-blocks/directive-body/block.json +1 -0
- package/plugins/interactive-blocks/directive-class/block.json +1 -0
- package/plugins/interactive-blocks/directive-context/block.json +1 -0
- package/plugins/interactive-blocks/directive-init/block.json +1 -0
- package/plugins/interactive-blocks/directive-key/block.json +1 -0
- package/plugins/interactive-blocks/directive-on/block.json +1 -0
- package/plugins/interactive-blocks/directive-priorities/block.json +1 -0
- package/plugins/interactive-blocks/directive-slots/block.json +1 -0
- package/plugins/interactive-blocks/directive-style/block.json +1 -0
- package/plugins/interactive-blocks/directive-text/block.json +1 -0
- package/plugins/interactive-blocks/directive-watch/block.json +1 -0
- package/plugins/interactive-blocks/negation-operator/block.json +1 -0
- package/plugins/interactive-blocks/router-navigate/block.json +1 -0
- package/plugins/interactive-blocks/router-regions/block.json +1 -0
- package/plugins/interactive-blocks/store-tag/block.json +1 -0
- package/plugins/interactive-blocks/tovdom/block.json +1 -0
- package/plugins/interactive-blocks/tovdom-islands/block.json +1 -0
- package/plugins/interactive-blocks/tovdom-islands/render.php +12 -0
- package/plugins/pattern-recursion.php +22 -0
- package/specs/editor/various/inserting-blocks.test.js +3 -5
- package/specs/editor/various/__snapshots__/block-editor-keyboard-shortcuts.test.js.snap +0 -153
- package/specs/editor/various/allowed-patterns.test.js +0 -74
- package/specs/editor/various/block-editor-keyboard-shortcuts.test.js +0 -110
- package/specs/editor/various/block-switcher.test.js +0 -130
- package/specs/editor/various/core-settings.test.js +0 -42
- package/specs/editor/various/datepicker.test.js +0 -148
- package/specs/editor/various/dropdown-menu.test.js +0 -143
- package/specs/editor/various/editor-modes.test.js +0 -163
- package/specs/editor/various/invalid-block.test.js +0 -100
- package/specs/editor/various/nux.test.js +0 -158
- package/specs/editor/various/preferences.test.js +0 -62
- package/specs/editor/various/publish-panel.test.js +0 -82
- package/specs/editor/various/publishing.test.js +0 -176
- package/specs/editor/various/scheduling.test.js +0 -65
- package/specs/editor/various/sidebar.test.js +0 -171
- package/specs/editor/various/taxonomies.test.js +0 -251
- package/specs/experiments/blocks/post-comments-form.test.js +0 -53
- package/specs/experiments/experimental-features.js +0 -39
- package/specs/experiments/fixtures/menu-items-request-fixture.json +0 -84
- package/specs/site-editor/settings-sidebar.test.js +0 -122
- package/specs/widgets/editing-widgets.test.js +0 -962
@@ -1,100 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import {
|
5
|
-
clickMenuItem,
|
6
|
-
createNewPost,
|
7
|
-
clickBlockAppender,
|
8
|
-
clickBlockToolbarButton,
|
9
|
-
setPostContent,
|
10
|
-
canvas,
|
11
|
-
} from '@wordpress/e2e-test-utils';
|
12
|
-
|
13
|
-
describe( 'invalid blocks', () => {
|
14
|
-
beforeEach( async () => {
|
15
|
-
await createNewPost();
|
16
|
-
} );
|
17
|
-
|
18
|
-
it( 'Should show an invalid block message with clickable options', async () => {
|
19
|
-
// Create an empty paragraph with the focus in the block.
|
20
|
-
await clickBlockAppender();
|
21
|
-
await page.keyboard.type( 'hello' );
|
22
|
-
|
23
|
-
await clickBlockToolbarButton( 'Options' );
|
24
|
-
|
25
|
-
// Change to HTML mode and close the options.
|
26
|
-
await clickMenuItem( 'Edit as HTML' );
|
27
|
-
|
28
|
-
// Focus on the textarea and enter an invalid paragraph
|
29
|
-
await canvas().click(
|
30
|
-
'.block-editor-block-list__layout .block-editor-block-list__block .block-editor-block-list__block-html-textarea'
|
31
|
-
);
|
32
|
-
await page.keyboard.type( '<p>invalid paragraph' );
|
33
|
-
|
34
|
-
// Takes the focus away from the block so the invalid warning is triggered
|
35
|
-
await page.click( '.editor-post-save-draft' );
|
36
|
-
|
37
|
-
// Click on the 'three-dots' menu toggle.
|
38
|
-
await canvas().click(
|
39
|
-
'.block-editor-warning__actions button[aria-label="More options"]'
|
40
|
-
);
|
41
|
-
|
42
|
-
await clickMenuItem( 'Resolve' );
|
43
|
-
|
44
|
-
// Check we get the resolve modal with the appropriate contents.
|
45
|
-
const htmlBlockContent = await page.$eval(
|
46
|
-
'.block-editor-block-compare__html',
|
47
|
-
( node ) => node.textContent
|
48
|
-
);
|
49
|
-
expect( htmlBlockContent ).toEqual(
|
50
|
-
'<p>hello</p><p>invalid paragraph'
|
51
|
-
);
|
52
|
-
} );
|
53
|
-
|
54
|
-
it( 'should strip potentially malicious on* attributes', async () => {
|
55
|
-
let hasAlert = false;
|
56
|
-
|
57
|
-
page.on( 'dialog', () => {
|
58
|
-
hasAlert = true;
|
59
|
-
} );
|
60
|
-
|
61
|
-
// The paragraph block contains invalid HTML, which causes it to be an
|
62
|
-
// invalid block.
|
63
|
-
await setPostContent(
|
64
|
-
`
|
65
|
-
<!-- wp:paragraph -->
|
66
|
-
<p>aaaa <img src onerror=alert(1)></x dde></x>1
|
67
|
-
<!-- /wp:paragraph -->
|
68
|
-
`
|
69
|
-
);
|
70
|
-
|
71
|
-
// Give the browser time to show the alert.
|
72
|
-
await page.evaluate( () => new Promise( window.requestIdleCallback ) );
|
73
|
-
|
74
|
-
expect( console ).toHaveWarned();
|
75
|
-
expect( console ).toHaveErrored();
|
76
|
-
expect( hasAlert ).toBe( false );
|
77
|
-
} );
|
78
|
-
|
79
|
-
it( 'should not trigger malicious script tags when using a shortcode block', async () => {
|
80
|
-
let hasAlert = false;
|
81
|
-
|
82
|
-
page.on( 'dialog', () => {
|
83
|
-
hasAlert = true;
|
84
|
-
} );
|
85
|
-
|
86
|
-
// The shortcode block contains invalid HTML, which causes it to be an
|
87
|
-
// invalid block.
|
88
|
-
await setPostContent(
|
89
|
-
`
|
90
|
-
<!-- wp:shortcode -->
|
91
|
-
<animate onbegin=alert(1) attributeName=x dur=1s><script>alert("EVIL");</script><style>@keyframes x{}</style><a style="animation-name:x" onanimationstart="alert(2)"></a>
|
92
|
-
<!-- /wp:shortcode -->
|
93
|
-
`
|
94
|
-
);
|
95
|
-
|
96
|
-
// Give the browser time to show the alert.
|
97
|
-
await page.evaluate( () => new Promise( window.requestIdleCallback ) );
|
98
|
-
expect( hasAlert ).toBe( false );
|
99
|
-
} );
|
100
|
-
} );
|
@@ -1,158 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import {
|
5
|
-
createNewPost,
|
6
|
-
clickOnMoreMenuItem,
|
7
|
-
canvas,
|
8
|
-
} from '@wordpress/e2e-test-utils';
|
9
|
-
|
10
|
-
describe( 'New User Experience (NUX)', () => {
|
11
|
-
it( 'should show the guide to first-time users', async () => {
|
12
|
-
let welcomeGuideText, welcomeGuide;
|
13
|
-
|
14
|
-
// Create a new post as a first-time user.
|
15
|
-
await createNewPost( { showWelcomeGuide: true } );
|
16
|
-
|
17
|
-
// Guide should be on page 1 of 4
|
18
|
-
welcomeGuideText = await page.$eval(
|
19
|
-
'.edit-post-welcome-guide',
|
20
|
-
( element ) => element.innerText
|
21
|
-
);
|
22
|
-
expect( welcomeGuideText ).toContain( 'Welcome to the block editor' );
|
23
|
-
|
24
|
-
// Click on the 'Next' button.
|
25
|
-
const [ nextButton ] = await page.$x(
|
26
|
-
'//button[contains(text(), "Next")]'
|
27
|
-
);
|
28
|
-
await nextButton.click();
|
29
|
-
|
30
|
-
// Guide should be on page 2 of 4
|
31
|
-
welcomeGuideText = await page.$eval(
|
32
|
-
'.edit-post-welcome-guide',
|
33
|
-
( element ) => element.innerText
|
34
|
-
);
|
35
|
-
expect( welcomeGuideText ).toContain( 'Make each block your own' );
|
36
|
-
|
37
|
-
// Click on the 'Previous' button.
|
38
|
-
const [ previousButton ] = await page.$x(
|
39
|
-
'//button[contains(text(), "Previous")]'
|
40
|
-
);
|
41
|
-
await previousButton.click();
|
42
|
-
|
43
|
-
// Guide should be on page 1 of 4
|
44
|
-
welcomeGuideText = await page.$eval(
|
45
|
-
'.edit-post-welcome-guide',
|
46
|
-
( element ) => element.innerText
|
47
|
-
);
|
48
|
-
expect( welcomeGuideText ).toContain( 'Welcome to the block editor' );
|
49
|
-
|
50
|
-
// Press the button for Page 2.
|
51
|
-
await page.click( 'button[aria-label="Page 2 of 4"]' );
|
52
|
-
await page.waitForXPath(
|
53
|
-
'//h1[contains(text(), "Make each block your own")]'
|
54
|
-
);
|
55
|
-
// This shouldn't be necessary
|
56
|
-
// eslint-disable-next-line no-restricted-syntax
|
57
|
-
await page.waitForTimeout( 500 );
|
58
|
-
|
59
|
-
// Press the right arrow key for Page 3.
|
60
|
-
await page.keyboard.press( 'ArrowRight' );
|
61
|
-
await page.waitForXPath(
|
62
|
-
'//h1[contains(text(), "Get to know the block library")]'
|
63
|
-
);
|
64
|
-
|
65
|
-
// Press the right arrow key for Page 4.
|
66
|
-
await page.keyboard.press( 'ArrowRight' );
|
67
|
-
await page.waitForXPath(
|
68
|
-
'//h1[contains(text(), "Learn how to use the block editor")]'
|
69
|
-
);
|
70
|
-
|
71
|
-
// Click on the *visible* 'Get started' button. There are two in the DOM
|
72
|
-
// but only one is shown depending on viewport size.
|
73
|
-
let getStartedButton;
|
74
|
-
for ( const buttonHandle of await page.$x(
|
75
|
-
'//button[contains(text(), "Get started")]'
|
76
|
-
) ) {
|
77
|
-
if (
|
78
|
-
await page.evaluate(
|
79
|
-
( button ) => button.style.display !== 'none',
|
80
|
-
buttonHandle
|
81
|
-
)
|
82
|
-
) {
|
83
|
-
getStartedButton = buttonHandle;
|
84
|
-
}
|
85
|
-
}
|
86
|
-
await getStartedButton.click();
|
87
|
-
|
88
|
-
// Guide should be closed
|
89
|
-
welcomeGuide = await page.$( '.edit-post-welcome-guide' );
|
90
|
-
expect( welcomeGuide ).toBeNull();
|
91
|
-
|
92
|
-
// Reload the editor.
|
93
|
-
await page.reload();
|
94
|
-
await page.waitForSelector( '.edit-post-layout' );
|
95
|
-
|
96
|
-
// Guide should be closed
|
97
|
-
welcomeGuide = await page.$( '.edit-post-welcome-guide' );
|
98
|
-
expect( welcomeGuide ).toBeNull();
|
99
|
-
} );
|
100
|
-
|
101
|
-
it( 'should not show the welcome guide again if it is dismissed', async () => {
|
102
|
-
let welcomeGuide;
|
103
|
-
|
104
|
-
// Create a new post as a first-time user.
|
105
|
-
await createNewPost( { showWelcomeGuide: true } );
|
106
|
-
|
107
|
-
// Guide should be open
|
108
|
-
welcomeGuide = await page.$( '.edit-post-welcome-guide' );
|
109
|
-
expect( welcomeGuide ).not.toBeNull();
|
110
|
-
|
111
|
-
// Close the guide
|
112
|
-
await page.click( '[role="dialog"] button[aria-label="Close"]' );
|
113
|
-
|
114
|
-
// Reload the editor.
|
115
|
-
await page.reload();
|
116
|
-
await page.waitForSelector( '.edit-post-layout' );
|
117
|
-
|
118
|
-
// Guide should be closed
|
119
|
-
welcomeGuide = await page.$( '.edit-post-welcome-guide' );
|
120
|
-
expect( welcomeGuide ).toBeNull();
|
121
|
-
} );
|
122
|
-
|
123
|
-
it( 'should focus post title field after welcome guide is dismissed and post is empty', async () => {
|
124
|
-
// Create a new post as a first-time user.
|
125
|
-
await createNewPost( { showWelcomeGuide: true } );
|
126
|
-
|
127
|
-
// Guide should be open.
|
128
|
-
const welcomeGuide = await page.$( '.edit-post-welcome-guide' );
|
129
|
-
expect( welcomeGuide ).not.toBeNull();
|
130
|
-
|
131
|
-
// Close the guide.
|
132
|
-
await page.click( '[role="dialog"] button[aria-label="Close"]' );
|
133
|
-
|
134
|
-
// Focus should be in post title field.
|
135
|
-
const postTitle = await canvas().waitForSelector(
|
136
|
-
'h1[aria-label="Add title"'
|
137
|
-
);
|
138
|
-
await expect( postTitle ).toHaveFocus();
|
139
|
-
} );
|
140
|
-
|
141
|
-
it( 'should show the welcome guide if it is manually opened', async () => {
|
142
|
-
let welcomeGuide;
|
143
|
-
|
144
|
-
// Create a new post as a returning user.
|
145
|
-
await createNewPost();
|
146
|
-
|
147
|
-
// Guide should be closed
|
148
|
-
welcomeGuide = await page.$( '.edit-post-welcome-guide' );
|
149
|
-
expect( welcomeGuide ).toBeNull();
|
150
|
-
|
151
|
-
// Manually open the guide
|
152
|
-
await clickOnMoreMenuItem( 'Welcome Guide' );
|
153
|
-
|
154
|
-
// Guide should be open
|
155
|
-
welcomeGuide = await page.$( '.edit-post-welcome-guide' );
|
156
|
-
expect( welcomeGuide ).not.toBeNull();
|
157
|
-
} );
|
158
|
-
} );
|
@@ -1,62 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import { createNewPost } from '@wordpress/e2e-test-utils';
|
5
|
-
|
6
|
-
describe( 'preferences', () => {
|
7
|
-
beforeAll( async () => {
|
8
|
-
await createNewPost();
|
9
|
-
} );
|
10
|
-
|
11
|
-
/**
|
12
|
-
* Returns a promise which resolves to the text content of the active
|
13
|
-
* editor sidebar tab, or null if there is no active sidebar tab (closed).
|
14
|
-
*
|
15
|
-
* @return {Promise} Promise resolving to active tab.
|
16
|
-
*/
|
17
|
-
async function getActiveSidebarTabText() {
|
18
|
-
try {
|
19
|
-
return await page.$eval(
|
20
|
-
'div[aria-label="Editor settings"] [role="tab"][aria-selected="true"]',
|
21
|
-
( node ) => node.textContent
|
22
|
-
);
|
23
|
-
} catch ( error ) {
|
24
|
-
// page.$eval throws when it does not find the selector, which we
|
25
|
-
// can intentionally intercept and consider as there being no
|
26
|
-
// active sidebar tab (no sidebar).
|
27
|
-
return null;
|
28
|
-
}
|
29
|
-
}
|
30
|
-
|
31
|
-
it( 'remembers sidebar dismissal between sessions', async () => {
|
32
|
-
const blockTab = await page.waitForXPath(
|
33
|
-
`//button[@role="tab"][contains(text(), 'Block')]`
|
34
|
-
);
|
35
|
-
|
36
|
-
// Open by default.
|
37
|
-
expect( await getActiveSidebarTabText() ).toBe( 'Post' );
|
38
|
-
|
39
|
-
// Change to "Block" tab.
|
40
|
-
await blockTab.click();
|
41
|
-
expect( await getActiveSidebarTabText() ).toBe( 'Block' );
|
42
|
-
|
43
|
-
// Regression test: Reload resets to document tab.
|
44
|
-
//
|
45
|
-
// See: https://github.com/WordPress/gutenberg/issues/6377
|
46
|
-
// See: https://github.com/WordPress/gutenberg/pull/8995
|
47
|
-
await page.reload();
|
48
|
-
await page.waitForSelector( '.edit-post-layout' );
|
49
|
-
expect( await getActiveSidebarTabText() ).toBe( 'Post' );
|
50
|
-
|
51
|
-
// Dismiss.
|
52
|
-
await page.click(
|
53
|
-
'div[aria-label="Editor settings"] div[role="tablist"] + button[aria-label="Close Settings"]'
|
54
|
-
);
|
55
|
-
expect( await getActiveSidebarTabText() ).toBe( null );
|
56
|
-
|
57
|
-
// Remember after reload.
|
58
|
-
await page.reload();
|
59
|
-
await page.waitForSelector( '.edit-post-layout' );
|
60
|
-
expect( await getActiveSidebarTabText() ).toBe( null );
|
61
|
-
} );
|
62
|
-
} );
|
@@ -1,82 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import {
|
5
|
-
arePrePublishChecksEnabled,
|
6
|
-
disablePrePublishChecks,
|
7
|
-
enablePrePublishChecks,
|
8
|
-
createNewPost,
|
9
|
-
openPublishPanel,
|
10
|
-
pressKeyWithModifier,
|
11
|
-
publishPost,
|
12
|
-
canvas,
|
13
|
-
} from '@wordpress/e2e-test-utils';
|
14
|
-
|
15
|
-
describe( 'PostPublishPanel', () => {
|
16
|
-
let werePrePublishChecksEnabled;
|
17
|
-
beforeEach( async () => {
|
18
|
-
await createNewPost();
|
19
|
-
werePrePublishChecksEnabled = await arePrePublishChecksEnabled();
|
20
|
-
if ( ! werePrePublishChecksEnabled ) {
|
21
|
-
await enablePrePublishChecks();
|
22
|
-
}
|
23
|
-
} );
|
24
|
-
|
25
|
-
afterEach( async () => {
|
26
|
-
if ( ! werePrePublishChecksEnabled ) {
|
27
|
-
await disablePrePublishChecks();
|
28
|
-
}
|
29
|
-
} );
|
30
|
-
|
31
|
-
it( 'PrePublish: publish button should have the focus', async () => {
|
32
|
-
await canvas().type( '.editor-post-title__input', 'E2E Test Post' );
|
33
|
-
await openPublishPanel();
|
34
|
-
|
35
|
-
const focusedElementClassList = await page.$eval(
|
36
|
-
':focus',
|
37
|
-
( focusedElement ) => {
|
38
|
-
return Object.values( focusedElement.classList );
|
39
|
-
}
|
40
|
-
);
|
41
|
-
expect( focusedElementClassList ).toContain(
|
42
|
-
'editor-post-publish-button'
|
43
|
-
);
|
44
|
-
} );
|
45
|
-
|
46
|
-
it( 'PostPublish: post link should have the focus', async () => {
|
47
|
-
const postTitle = 'E2E Test Post';
|
48
|
-
await canvas().type( '.editor-post-title__input', postTitle );
|
49
|
-
await publishPost();
|
50
|
-
|
51
|
-
const focusedElementTag = await page.$eval(
|
52
|
-
':focus',
|
53
|
-
( focusedElement ) => {
|
54
|
-
return focusedElement.tagName.toLowerCase();
|
55
|
-
}
|
56
|
-
);
|
57
|
-
const focusedElementText = await page.$eval(
|
58
|
-
':focus',
|
59
|
-
( focusedElement ) => {
|
60
|
-
return focusedElement.text;
|
61
|
-
}
|
62
|
-
);
|
63
|
-
expect( focusedElementTag ).toBe( 'a' );
|
64
|
-
expect( focusedElementText ).toBe( postTitle );
|
65
|
-
} );
|
66
|
-
|
67
|
-
it( 'should retain focus within the panel', async () => {
|
68
|
-
await canvas().type( '.editor-post-title__input', 'E2E Test Post' );
|
69
|
-
await openPublishPanel();
|
70
|
-
await pressKeyWithModifier( 'shift', 'Tab' );
|
71
|
-
|
72
|
-
const focusedElementClassList = await page.$eval(
|
73
|
-
':focus',
|
74
|
-
( focusedElement ) => {
|
75
|
-
return Object.values( focusedElement.classList );
|
76
|
-
}
|
77
|
-
);
|
78
|
-
expect( focusedElementClassList ).toContain(
|
79
|
-
'components-checkbox-control__input'
|
80
|
-
);
|
81
|
-
} );
|
82
|
-
} );
|
@@ -1,176 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import {
|
5
|
-
createNewPost,
|
6
|
-
publishPost,
|
7
|
-
publishPostWithPrePublishChecksDisabled,
|
8
|
-
enablePrePublishChecks,
|
9
|
-
disablePrePublishChecks,
|
10
|
-
arePrePublishChecksEnabled,
|
11
|
-
setBrowserViewport,
|
12
|
-
openPublishPanel,
|
13
|
-
pressKeyWithModifier,
|
14
|
-
canvas,
|
15
|
-
} from '@wordpress/e2e-test-utils';
|
16
|
-
|
17
|
-
describe( 'Publishing', () => {
|
18
|
-
describe.each( [ 'post', 'page' ] )(
|
19
|
-
'%s locking prevent saving',
|
20
|
-
( postType ) => {
|
21
|
-
beforeEach( async () => {
|
22
|
-
await createNewPost( postType );
|
23
|
-
} );
|
24
|
-
|
25
|
-
it( `disables the publish button when a ${ postType } is locked`, async () => {
|
26
|
-
await canvas().type(
|
27
|
-
'.editor-post-title__input',
|
28
|
-
'E2E Test Post lock check publish button'
|
29
|
-
);
|
30
|
-
await page.evaluate( () =>
|
31
|
-
wp.data
|
32
|
-
.dispatch( 'core/editor' )
|
33
|
-
.lockPostSaving( 'futurelock' )
|
34
|
-
);
|
35
|
-
|
36
|
-
await openPublishPanel();
|
37
|
-
|
38
|
-
expect(
|
39
|
-
await page.$(
|
40
|
-
'.editor-post-publish-button[aria-disabled="true"]'
|
41
|
-
)
|
42
|
-
).not.toBeNull();
|
43
|
-
} );
|
44
|
-
|
45
|
-
it( `disables the save shortcut when a ${ postType } is locked`, async () => {
|
46
|
-
await canvas().type(
|
47
|
-
'.editor-post-title__input',
|
48
|
-
'E2E Test Post check save shortcut'
|
49
|
-
);
|
50
|
-
await page.evaluate( () =>
|
51
|
-
wp.data
|
52
|
-
.dispatch( 'core/editor' )
|
53
|
-
.lockPostSaving( 'futurelock' )
|
54
|
-
);
|
55
|
-
await pressKeyWithModifier( 'primary', 'S' );
|
56
|
-
|
57
|
-
expect( await page.$( '.editor-post-saved-state' ) ).toBeNull();
|
58
|
-
expect(
|
59
|
-
await page.$( '.editor-post-save-draft' )
|
60
|
-
).not.toBeNull();
|
61
|
-
} );
|
62
|
-
}
|
63
|
-
);
|
64
|
-
|
65
|
-
describe.each( [ 'post', 'page' ] )( 'a %s', ( postType ) => {
|
66
|
-
let werePrePublishChecksEnabled;
|
67
|
-
|
68
|
-
beforeEach( async () => {
|
69
|
-
await createNewPost( postType );
|
70
|
-
werePrePublishChecksEnabled = await arePrePublishChecksEnabled();
|
71
|
-
if ( ! werePrePublishChecksEnabled ) {
|
72
|
-
await enablePrePublishChecks();
|
73
|
-
}
|
74
|
-
} );
|
75
|
-
|
76
|
-
afterEach( async () => {
|
77
|
-
if ( ! werePrePublishChecksEnabled ) {
|
78
|
-
await disablePrePublishChecks();
|
79
|
-
}
|
80
|
-
} );
|
81
|
-
|
82
|
-
it( `should publish the ${ postType } and close the panel once we start editing again.`, async () => {
|
83
|
-
await canvas().type( '.editor-post-title__input', 'E2E Test Post' );
|
84
|
-
|
85
|
-
await publishPost();
|
86
|
-
|
87
|
-
// The post-publishing panel is visible.
|
88
|
-
expect(
|
89
|
-
await page.$( '.editor-post-publish-panel' )
|
90
|
-
).not.toBeNull();
|
91
|
-
|
92
|
-
// Start editing again.
|
93
|
-
await canvas().type( '.editor-post-title__input', ' (Updated)' );
|
94
|
-
|
95
|
-
// The post-publishing panel is not visible anymore.
|
96
|
-
expect( await page.$( '.editor-post-publish-panel' ) ).toBeNull();
|
97
|
-
} );
|
98
|
-
} );
|
99
|
-
|
100
|
-
describe.each( [ 'post', 'page' ] )(
|
101
|
-
'a %s with pre-publish checks disabled',
|
102
|
-
( postType ) => {
|
103
|
-
let werePrePublishChecksEnabled;
|
104
|
-
|
105
|
-
beforeEach( async () => {
|
106
|
-
await createNewPost( postType );
|
107
|
-
werePrePublishChecksEnabled =
|
108
|
-
await arePrePublishChecksEnabled();
|
109
|
-
if ( werePrePublishChecksEnabled ) {
|
110
|
-
await disablePrePublishChecks();
|
111
|
-
}
|
112
|
-
} );
|
113
|
-
|
114
|
-
afterEach( async () => {
|
115
|
-
if ( werePrePublishChecksEnabled ) {
|
116
|
-
await enablePrePublishChecks();
|
117
|
-
}
|
118
|
-
} );
|
119
|
-
|
120
|
-
it( `should publish the ${ postType } without opening the post-publish sidebar.`, async () => {
|
121
|
-
await canvas().type(
|
122
|
-
'.editor-post-title__input',
|
123
|
-
'E2E Test Post'
|
124
|
-
);
|
125
|
-
|
126
|
-
// The "Publish" button should be shown instead of the "Publish..." toggle.
|
127
|
-
expect(
|
128
|
-
await page.$( '.editor-post-publish-panel__toggle' )
|
129
|
-
).toBeNull();
|
130
|
-
expect(
|
131
|
-
await page.$( '.editor-post-publish-button' )
|
132
|
-
).not.toBeNull();
|
133
|
-
|
134
|
-
await publishPostWithPrePublishChecksDisabled();
|
135
|
-
|
136
|
-
// The post-publishing panel should have been not shown.
|
137
|
-
expect(
|
138
|
-
await page.$( '.editor-post-publish-panel' )
|
139
|
-
).toBeNull();
|
140
|
-
} );
|
141
|
-
}
|
142
|
-
);
|
143
|
-
|
144
|
-
describe.each( [ 'post', 'page' ] )(
|
145
|
-
'a %s in small viewports',
|
146
|
-
( postType ) => {
|
147
|
-
let werePrePublishChecksEnabled;
|
148
|
-
|
149
|
-
beforeEach( async () => {
|
150
|
-
await createNewPost( postType );
|
151
|
-
werePrePublishChecksEnabled =
|
152
|
-
await arePrePublishChecksEnabled();
|
153
|
-
if ( werePrePublishChecksEnabled ) {
|
154
|
-
await disablePrePublishChecks();
|
155
|
-
}
|
156
|
-
await setBrowserViewport( 'small' );
|
157
|
-
} );
|
158
|
-
|
159
|
-
afterEach( async () => {
|
160
|
-
await setBrowserViewport( 'large' );
|
161
|
-
if ( werePrePublishChecksEnabled ) {
|
162
|
-
await enablePrePublishChecks();
|
163
|
-
}
|
164
|
-
} );
|
165
|
-
|
166
|
-
it( `should ignore the pre-publish checks and show the Publish... toggle instead of the Publish button`, async () => {
|
167
|
-
expect(
|
168
|
-
await page.$( '.editor-post-publish-panel__toggle' )
|
169
|
-
).not.toBeNull();
|
170
|
-
expect(
|
171
|
-
await page.$( '.editor-post-publish-button' )
|
172
|
-
).toBeNull();
|
173
|
-
} );
|
174
|
-
}
|
175
|
-
);
|
176
|
-
} );
|
@@ -1,65 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WordPress dependencies
|
3
|
-
*/
|
4
|
-
import { createNewPost, changeSiteTimezone } from '@wordpress/e2e-test-utils';
|
5
|
-
|
6
|
-
async function getPublishButtonText() {
|
7
|
-
return page.$eval(
|
8
|
-
'.editor-post-publish-button__button',
|
9
|
-
( element ) => element.textContent
|
10
|
-
);
|
11
|
-
}
|
12
|
-
|
13
|
-
describe( 'Scheduling', () => {
|
14
|
-
const isDateTimeComponentFocused = () => {
|
15
|
-
return page.evaluate( () => {
|
16
|
-
const dateTimeElement = document.querySelector(
|
17
|
-
'.components-datetime__date'
|
18
|
-
);
|
19
|
-
if ( ! dateTimeElement || ! document.activeElement ) {
|
20
|
-
return false;
|
21
|
-
}
|
22
|
-
return dateTimeElement.contains( document.activeElement );
|
23
|
-
} );
|
24
|
-
};
|
25
|
-
|
26
|
-
describe.each( [ [ 'UTC-10' ], [ 'UTC' ], [ 'UTC+10' ] ] )(
|
27
|
-
`Timezone %s`,
|
28
|
-
( timezone ) => {
|
29
|
-
let oldTimezone;
|
30
|
-
beforeEach( async () => {
|
31
|
-
oldTimezone = await changeSiteTimezone( timezone );
|
32
|
-
await createNewPost();
|
33
|
-
} );
|
34
|
-
afterEach( async () => {
|
35
|
-
await changeSiteTimezone( oldTimezone );
|
36
|
-
} );
|
37
|
-
|
38
|
-
it( `should change publishing button text from "Publish" to "Schedule"`, async () => {
|
39
|
-
expect( await getPublishButtonText() ).toBe( 'Publish' );
|
40
|
-
|
41
|
-
// Open the datepicker.
|
42
|
-
await page.click( '*[aria-label^="Change date"]' );
|
43
|
-
|
44
|
-
// Change the publishing date to a year in the future.
|
45
|
-
await page.click( '.components-datetime__time-field-year' );
|
46
|
-
await page.keyboard.press( 'ArrowUp' );
|
47
|
-
|
48
|
-
// Close the datepicker.
|
49
|
-
await page.click( '.editor-post-schedule__dialog-toggle' );
|
50
|
-
|
51
|
-
expect( await getPublishButtonText() ).toBe( 'Schedule…' );
|
52
|
-
} );
|
53
|
-
}
|
54
|
-
);
|
55
|
-
|
56
|
-
it( 'Should keep date time UI focused when the previous and next month buttons are clicked', async () => {
|
57
|
-
await createNewPost();
|
58
|
-
|
59
|
-
await page.click( '*[aria-label^="Change date"]' );
|
60
|
-
await page.click( '*[aria-label="View previous month"]' );
|
61
|
-
expect( await isDateTimeComponentFocused() ).toBe( true );
|
62
|
-
await page.click( '*[aria-label="View next month"]' );
|
63
|
-
expect( await isDateTimeComponentFocused() ).toBe( true );
|
64
|
-
} );
|
65
|
-
} );
|