-
Notifications
You must be signed in to change notification settings - Fork 4.3k
/
push-to-global-styles.spec.js
98 lines (82 loc) · 2.74 KB
/
push-to-global-styles.spec.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
93
94
95
96
97
98
/**
* WordPress dependencies
*/
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' );
test.describe( 'Push to Global Styles button', () => {
test.beforeAll( async ( { requestUtils } ) => {
await requestUtils.activateTheme( 'emptytheme' );
} );
test.afterAll( async ( { requestUtils } ) => {
await requestUtils.activateTheme( 'twentytwentyone' );
} );
test.beforeEach( async ( { admin, editor } ) => {
await admin.visitSiteEditor( {
postId: 'emptytheme//index',
postType: 'wp_template',
} );
await editor.canvas.click( 'body' );
} );
test( 'should apply Heading block styles to all Heading blocks', async ( {
page,
editor,
} ) => {
// Add a Heading block.
await editor.insertBlock( { name: 'core/heading' } );
await page.keyboard.type( 'A heading' );
const topBar = page.getByRole( 'region', { name: 'Editor top bar' } );
// Navigate to Styles -> Blocks -> Heading -> Typography
await topBar.getByRole( 'button', { name: 'Styles' } ).click();
await page.getByRole( 'button', { name: 'Blocks styles' } ).click();
await page
.getByRole( 'button', { name: 'Heading block styles' } )
.click();
// Headings should not have uppercase
await expect(
page.getByRole( 'button', { name: 'Uppercase' } )
).toHaveAttribute( 'aria-pressed', 'false' );
// Go to block settings and open the Advanced panel
await topBar.getByRole( 'button', { name: 'Settings' } ).click();
await page.getByRole( 'button', { name: 'Advanced' } ).click();
// Push button should be disabled
await expect(
page.getByRole( 'button', {
name: 'Apply globally',
} )
).toBeDisabled();
// Make the Heading block uppercase
await page.getByRole( 'button', { name: 'Uppercase' } ).click();
// Push button should now be enabled
await expect(
page.getByRole( 'button', {
name: 'Apply globally',
} )
).toBeEnabled();
// Press the Push button
await page.getByRole( 'button', { name: 'Apply globally' } ).click();
// Snackbar notification should appear
await expect(
page.getByRole( 'button', {
name: 'Dismiss this notice',
text: 'Heading styles applied.',
} )
).toBeVisible();
// Push button should be disabled again
await expect(
page.getByRole( 'button', {
name: 'Apply globally',
} )
).toBeDisabled();
// Navigate again to Styles -> Blocks -> Heading -> Typography
await page
.getByRole( 'button', { name: 'Styles', exact: true } )
.click();
await page.getByRole( 'button', { name: 'Blocks styles' } ).click();
await page
.getByRole( 'button', { name: 'Heading block styles' } )
.click();
// Headings should now have uppercase
await expect(
page.getByRole( 'button', { name: 'Uppercase' } )
).toHaveAttribute( 'aria-pressed', 'true' );
} );
} );