-
Notifications
You must be signed in to change notification settings - Fork 673
Expand file tree
/
Copy pathcommon.ts
More file actions
152 lines (116 loc) · 4.31 KB
/
Copy pathcommon.ts
File metadata and controls
152 lines (116 loc) · 4.31 KB
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
import { createScreenshotsComparer } from 'devextreme-screenshot-comparer';
import HtmlEditor from 'devextreme-testcafe-models/htmlEditor';
import url from '../../../../../helpers/getPageUrl';
import { createWidget } from '../../../../../helpers/createWidget';
import { BASE64_IMAGE_1 } from './images/base64';
import { testScreenshot } from '../../../../../helpers/themeUtils';
const TEST_IMAGE_PATH_1 = './images/test-image-1.png';
fixture`HtmlEditor - common`
.page(url(__dirname, '../../../../container-extended.html'));
const ADD_IMAGE_POPUP_CONTENT_SELECTOR = '.dx-htmleditor-add-image-popup .dx-overlay-content';
test('TabPanel in HtmlEditor must have correct borders', async (t) => {
const { takeScreenshot, compareResults } = createScreenshotsComparer(t);
const htmlEditor = new HtmlEditor('#container');
await t.click(htmlEditor.toolbar.getItemByName('image').element);
await testScreenshot(t, takeScreenshot, 'tabpanel-in-htmleditor.png', {
element: ADD_IMAGE_POPUP_CONTENT_SELECTOR,
});
await t
.expect(compareResults.isValid())
.ok(compareResults.errorMessages());
}).before(async () => {
await createWidget('dxHtmlEditor', {
height: 600,
width: 800,
imageUpload: {
tabs: ['file', 'url'],
},
toolbar: { items: ['image'] },
});
});
test('Add button should be enabled after switch to url form', async (t) => {
const htmlEditor = new HtmlEditor('#container');
await t
.click(htmlEditor.toolbar.getItemByName('image').element)
.expect(htmlEditor.dialog.footerToolbar.addButton.isDisabled)
.eql(true);
await t.click(htmlEditor.dialog.tabs.getItem(1).element);
await t
.expect(htmlEditor.dialog.footerToolbar.addButton.isDisabled)
.eql(false)
.typeText(htmlEditor.dialog.addImageUrlForm.url.element, BASE64_IMAGE_1, {
paste: true,
})
.click(htmlEditor.dialog.footerToolbar.addButton.element);
}).before(async () => {
await createWidget('dxHtmlEditor', {
height: 600,
width: 800,
imageUpload: {
tabs: ['file', 'url'],
},
toolbar: { items: ['image'] },
});
});
test('Add button should be disable after switch to image upload form', async (t) => {
const htmlEditor = new HtmlEditor('#container');
await t
.click(htmlEditor.toolbar.getItemByName('image').element)
.expect(htmlEditor.dialog.footerToolbar.addButton.isDisabled)
.notOk()
.click(htmlEditor.dialog.footerToolbar.addButton.element)
.expect(htmlEditor.dialog.addImageUrlForm.url.isInvalid)
.ok();
await t.click(htmlEditor.dialog.tabs.getItem(1).element);
await t
.expect(htmlEditor.dialog.footerToolbar.addButton.isDisabled)
.ok();
const { fileUploader } = htmlEditor.dialog.addImageFileForm;
await t
.setFilesToUpload(fileUploader.input, [TEST_IMAGE_PATH_1])
.expect(htmlEditor.dialog.footerToolbar.addButton.isDisabled)
.notOk()
.click(htmlEditor.dialog.footerToolbar.addButton.element);
}).before(async () => {
await createWidget('dxHtmlEditor', {
height: 600,
width: 800,
imageUpload: {
tabs: ['url', 'file'],
},
toolbar: { items: ['image'] },
});
});
test('AddImage form shouldn\'t lead to side effects in other forms', async (t) => {
const htmlEditor = new HtmlEditor('#container');
await t
.click(htmlEditor.toolbar.getItemByName('image').element)
.expect(htmlEditor.dialog.footerToolbar.addButton.isDisabled)
.ok()
.expect(htmlEditor.dialog.footerToolbar.cancelButton.isDisabled)
.notOk()
.click(htmlEditor.dialog.footerToolbar.cancelButton.element);
await t
.click(htmlEditor.toolbar.getItemByName('link').element)
.expect(htmlEditor.dialog.footerToolbar.addButton.isDisabled)
.notOk()
.expect(htmlEditor.dialog.footerToolbar.cancelButton.isDisabled)
.notOk()
.click(htmlEditor.dialog.footerToolbar.addButton.element);
await t
.click(htmlEditor.toolbar.getItemByName('color').element)
.expect(htmlEditor.dialog.footerToolbar.addButton.isDisabled)
.notOk()
.expect(htmlEditor.dialog.footerToolbar.cancelButton.isDisabled)
.notOk()
.click(htmlEditor.dialog.footerToolbar.cancelButton.element);
}).before(async () => {
await createWidget('dxHtmlEditor', {
height: 600,
width: 800,
imageUpload: {
tabs: ['file', 'url'],
},
toolbar: { items: ['image', 'link', 'color'] },
});
});