-
Notifications
You must be signed in to change notification settings - Fork 4.3k
/
Copy pathwp-editor-meta-box.spec.js
45 lines (36 loc) · 1.4 KB
/
wp-editor-meta-box.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
/**
* WordPress dependencies
*/
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' );
test.describe( 'WP Editor Meta Boxes', () => {
test.beforeAll( async ( { requestUtils } ) => {
await requestUtils.activatePlugin(
'gutenberg-test-plugin-wp-editor-meta-box'
);
} );
test.afterAll( async ( { requestUtils } ) => {
await requestUtils.deactivatePlugin(
'gutenberg-test-plugin-wp-editor-meta-box'
);
} );
test( 'Should save the changes', async ( { admin, editor, page } ) => {
await admin.createNewPost();
// Add title to enable valid non-empty post save.
await editor.canvas
.locator( 'role=textbox[name="Add title"i]' )
.type( 'Hello Meta' );
// Switch tinymce to Text mode, first waiting for it to initialize
// because otherwise it will flip back to Visual mode once initialized.
await page.locator( '#test_tinymce_id_ifr' ).waitFor();
await page.locator( 'role=button[name="Code"i]' ).click();
// Type something in the tinymce Text mode textarea.
const metaBoxField = page.locator( '#test_tinymce_id' );
await metaBoxField.type( 'Typing in a metabox' );
// Switch tinymce back to Visual mode.
await page.locator( 'role=button[name="Visual"i]' ).click();
await editor.publishPost();
await page.reload();
// Expect the typed text in the tinymce Text mode textarea.
await expect( metaBoxField ).toHaveValue( 'Typing in a metabox' );
} );
} );