-
Notifications
You must be signed in to change notification settings - Fork 58
/
gutenberg-editor-unsupported-block-visual.test.js
96 lines (75 loc) · 2.83 KB
/
gutenberg-editor-unsupported-block-visual.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
93
94
95
96
/**
* Internal dependencies
*/
const { isAndroid, toggleDarkMode } = e2eUtils;
import { takeScreenshot } from './utils';
describe( 'Gutenberg Editor Visual test for Unsupported Block', () => {
it( 'should show the empty placeholder for the selected/unselected state', async () => {
await editorPage.initializeEditor( {
initialData: e2eTestData.unsupportedBlockHtml,
} );
const unsupportedBlock = await editorPage.getBlockAtPosition(
editorPage.blockNames.unsupported
);
await unsupportedBlock.click();
// Wait for the block to be selected
await editorPage.driver.pause( 500 );
// Visual test check
let screenshot = await takeScreenshot();
expect( screenshot ).toMatchImageSnapshot();
// Select title to unfocus the block
const titleElement = await editorPage.getTitleElement();
await titleElement.click();
await editorPage.dismissKeyboard();
// Visual test check
screenshot = await takeScreenshot();
expect( screenshot ).toMatchImageSnapshot();
} );
it( 'should show the empty placeholder for the selected/unselected state in dark mode', async () => {
await toggleDarkMode( editorPage.driver, true );
await editorPage.initializeEditor( {
initialData: e2eTestData.unsupportedBlockHtml,
} );
const unsupportedBlock = await editorPage.getBlockAtPosition(
editorPage.blockNames.unsupported
);
await unsupportedBlock.click();
// Wait for the block to be selected
await editorPage.driver.pause( 1000 );
// Visual test check
let screenshot = await takeScreenshot();
expect( screenshot ).toMatchImageSnapshot();
// Select title to unfocus the block
const titleElement = await editorPage.getTitleElement();
await titleElement.click();
await editorPage.dismissKeyboard();
// Visual test check
screenshot = await takeScreenshot();
expect( screenshot ).toMatchImageSnapshot();
await toggleDarkMode( editorPage.driver, false );
} );
it( 'should be able to open the unsupported block web view editor', async () => {
await editorPage.initializeEditor( {
initialData: e2eTestData.unsupportedBlockHtml,
} );
const unsupportedBlock = await editorPage.getBlockAtPosition(
editorPage.blockNames.unsupported
);
await unsupportedBlock.click();
const helpButton = await editorPage.getUnsupportedBlockHelpButton();
await helpButton.click();
// Wait for the modal to show
await editorPage.driver.pause( 3000 );
// Visual test check
const screenshot = await takeScreenshot();
expect( screenshot ).toMatchImageSnapshot();
// Disabled for now on Android see https://github.com/wordpress-mobile/gutenberg-mobile/issues/5321
if ( ! isAndroid() ) {
const editButton =
await editorPage.getUnsupportedBlockBottomSheetEditButton();
await editButton.click();
const webView = await editorPage.getUnsupportedBlockWebView();
await expect( webView ).toBeTruthy();
}
} );
} );