-
Notifications
You must be signed in to change notification settings - Fork 4.2k
/
document-settings.test.js
92 lines (76 loc) · 2.65 KB
/
document-settings.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/**
* WordPress dependencies
*/
import { trashAllPosts, activateTheme } from '@wordpress/e2e-test-utils';
/**
* Internal dependencies
*/
import { siteEditor } from '../../experimental-features';
async function getDocumentSettingsTitle() {
const titleElement = await page.waitForSelector(
'.edit-site-document-actions__title'
);
return titleElement.evaluate( ( el ) => el.innerText );
}
async function getDocumentSettingsSecondaryTitle() {
const secondaryTitleElement = await page.waitForSelector(
'.edit-site-document-actions__secondary-item'
);
return secondaryTitleElement.evaluate( ( el ) => el.innerText );
}
describe( 'Document Settings', () => {
beforeAll( async () => {
await activateTheme( 'tt1-blocks' );
await trashAllPosts( 'wp_template' );
await trashAllPosts( 'wp_template_part' );
} );
afterAll( async () => {
await activateTheme( 'twentytwentyone' );
} );
beforeEach( async () => {
await siteEditor.visit();
await siteEditor.disableWelcomeGuide();
} );
describe( 'when a template is selected from the navigation sidebar', () => {
it( 'should display the selected templates name in the document header', async () => {
// Navigate to a template
await siteEditor.visit( {
postId: 'tt1-blocks//index',
postType: 'wp_template',
} );
// Evaluate the document settings title
const actual = await getDocumentSettingsTitle();
expect( actual ).toEqual( 'Index' );
} );
describe( 'and a template part is clicked in the template', () => {
it.skip( "should display the selected template part's name in the document header", async () => {
// Select the header template part via list view.
await page.click(
'.edit-post-header-toolbar__list-view-toggle'
);
const headerTemplatePartListViewButton = await page.waitForXPath(
'//a[contains(@class, "block-editor-list-view-block-select-button")][contains(., "Header")]'
);
headerTemplatePartListViewButton.click();
await page.click(
'button[aria-label="Close list view sidebar"]'
);
// Evaluate the document settings secondary title
const actual = await getDocumentSettingsSecondaryTitle();
expect( actual ).toEqual( 'Header' );
} );
} );
} );
describe( 'when a template part is selected from the navigation sidebar', () => {
it( "should display the selected template part's name in the document header", async () => {
// Navigate to a template part
await siteEditor.visit( {
postId: 'tt1-blocks//header',
postType: 'wp_template_part',
} );
// Evaluate the document settings title
const actual = await getDocumentSettingsTitle();
expect( actual ).toEqual( 'header' );
} );
} );
} );