-
Notifications
You must be signed in to change notification settings - Fork 673
Expand file tree
/
Copy pathaddImageFromDevice.ts
More file actions
140 lines (104 loc) · 3.9 KB
/
Copy pathaddImageFromDevice.ts
File metadata and controls
140 lines (104 loc) · 3.9 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
import { createScreenshotsComparer } from 'devextreme-screenshot-comparer';
import HtmlEditor from 'devextreme-testcafe-models/htmlEditor';
import url from '../../../../../helpers/getPageUrl';
import { createWidget } from '../../../../../helpers/createWidget';
import { testScreenshot } from '../../../../../helpers/themeUtils';
const TEST_IMAGE_PATH_1 = './images/test-image-1.png';
const TEST_IMAGE_PATH_2 = './images/test-image-2.png';
fixture`HtmlEditor - upload image from device`
.page(url(__dirname, '../../../../container-extended.html'));
test('Image from device should be inserted', async (t) => {
const { takeScreenshot, compareResults } = createScreenshotsComparer(t);
const htmlEditor = new HtmlEditor('#container');
await t.click(htmlEditor.toolbar.getItemByName('image').element);
await t
.expect(htmlEditor.dialog.footerToolbar.addButton.isDisabled)
.eql(true);
const { fileUploader } = htmlEditor.dialog.addImageFileForm;
await t
.setFilesToUpload(fileUploader.input, [TEST_IMAGE_PATH_1]);
const file = fileUploader.getFile();
await t
.expect(file.fileName)
.eql('test-image-1.png')
.expect(file.fileSize)
.eql('7 KB')
.expect(file.statusMessage)
.eql('Ready to upload');
await t.click(fileUploader.getFile().cancelButton.element);
await t.expect(fileUploader.fileCount).eql(0);
await t
.expect(htmlEditor.dialog.footerToolbar.addButton.isDisabled)
.eql(true);
await t
.setFilesToUpload(fileUploader.input, [TEST_IMAGE_PATH_2]);
await testScreenshot(t, takeScreenshot, 'editor-before-click-add-button-from-device.png');
await t
.expect(htmlEditor.dialog.footerToolbar.addButton.isDisabled)
.eql(false);
await t.click(htmlEditor.dialog.footerToolbar.addButton.element);
await testScreenshot(t, takeScreenshot, 'editor-after-add-image-from-device.png', { element: htmlEditor.content });
await t.expect(compareResults.isValid())
.ok(compareResults.errorMessages());
}).before(async () => {
await createWidget('dxHtmlEditor', {
height: 600,
width: 800,
imageUpload: {
tabs: ['file'],
},
toolbar: { items: ['image'] },
});
});
test('Image should be validated and inserted from device', async (t) => {
const { takeScreenshot, compareResults } = createScreenshotsComparer(t);
const htmlEditor = new HtmlEditor('#container');
await t.click(htmlEditor.toolbar.getItemByName('image').element);
const { fileUploader } = htmlEditor.dialog.addImageFileForm;
await t
.setFilesToUpload(fileUploader.input, [TEST_IMAGE_PATH_2]);
const file = fileUploader.getFile();
await t
.expect(file.fileName)
.eql('test-image-2.png')
.expect(file.fileSize)
.eql('10 KB')
.expect(file.validationMessage)
.eql('File is too large');
await t
.click(fileUploader.getFile().cancelButton.element)
.expect(fileUploader.fileCount)
.eql(0);
await t
.expect(htmlEditor.dialog.footerToolbar.addButton.isDisabled)
.eql(true);
await t
.setFilesToUpload(fileUploader.input, [TEST_IMAGE_PATH_1]);
await t
.expect(file.fileName)
.eql('test-image-1.png')
.expect(file.fileSize)
.eql('7 KB')
.expect(file.statusMessage)
.eql('Ready to upload');
await testScreenshot(t, takeScreenshot, 'editor-before-click-add-button-and-validation.png');
await t
.expect(htmlEditor.dialog.footerToolbar.addButton.isDisabled)
.eql(false);
await t.click(htmlEditor.dialog.footerToolbar.addButton.element);
await testScreenshot(t, takeScreenshot, 'editor-after-click-add-button-and-validation.png', { element: htmlEditor.content });
await t.expect(compareResults.isValid())
.ok(compareResults.errorMessages());
}).before(async () => {
await createWidget('dxHtmlEditor', {
height: 600,
width: 800,
imageUpload: {
tabs: ['file'],
fileUploaderOptions: {
maxFileSize: 8500,
},
},
toolbar: { items: ['image'] },
});
});