-
Notifications
You must be signed in to change notification settings - Fork 673
Expand file tree
/
Copy pathcommon.ts
More file actions
80 lines (65 loc) · 2.83 KB
/
Copy pathcommon.ts
File metadata and controls
80 lines (65 loc) · 2.83 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
import { createScreenshotsComparer } from 'devextreme-screenshot-comparer';
import HtmlEditor from 'devextreme-testcafe-models/htmlEditor';
import { Selector } from 'testcafe';
import { createWidget } from '../../../helpers/createWidget';
import url from '../../../helpers/getPageUrl';
import { testScreenshot } from '../../../helpers/themeUtils';
import { appendElementTo, setStyleAttribute } from '../../../helpers/domUtils';
const MENU_ITEM_CLASS = 'dx-menu-item';
const SUBMENU_CLASS = 'dx-submenu';
fixture`HtmlEditor`
.page(url(__dirname, '../../container-extended.html'));
[false, true].forEach((toolbar) => {
const selector = toolbar ? '#otherContainer' : '#container';
const clickTarget = toolbar ? '#otherContainer .dx-bold-format' : '#container';
const baseScreenName = toolbar ? 'htmleditor-with-toolbar' : 'htmleditor-without-toolbar';
test(`T1025549 - ${baseScreenName}`, async (t) => {
const { takeScreenshot, compareResults } = createScreenshotsComparer(t);
await testScreenshot(t, takeScreenshot, `${baseScreenName}.png`, { element: selector });
await t
.click(Selector(clickTarget));
await testScreenshot(t, takeScreenshot, `${baseScreenName}-focused.png`, { element: selector });
await t
.expect(compareResults.isValid())
.ok(compareResults.errorMessages());
}).before(async () => {
await setStyleAttribute(Selector('#container'), 'box-sizing: border-box; height: 200px; width: 200px');
await setStyleAttribute(Selector('#otherContainer'), 'box-sizing: border-box; height: 200px; width: 200px');
await appendElementTo('#container', 'div', 'editor');
await appendElementTo('#otherContainer', 'div', 'editorWithToolbar');
await createWidget('dxHtmlEditor', {
height: 200,
width: '100%',
value: Array(100).fill('string').join('\n'),
}, '#editor');
await createWidget('dxHtmlEditor', {
height: 200,
width: '100%',
value: Array(100).fill('string').join('\n'),
toolbar: {
items: ['bold', 'color'],
},
}, '#editorWithToolbar');
});
});
test('AI toolbar item', async (t) => {
const { takeScreenshot, compareResults } = createScreenshotsComparer(t);
const htmlEditor = new HtmlEditor('#container');
await testScreenshot(t, takeScreenshot, 'htmleditor-ai-toolbar-item.png', { element: '#container' });
await t
.click(htmlEditor.toolbar.getItemByName('ai').element)
.click(Selector(`.${SUBMENU_CLASS}`).find(`.${MENU_ITEM_CLASS}`).nth(5));
await testScreenshot(t, takeScreenshot, 'htmleditor-ai-toolbar-item-expanded.png', { element: '#container' });
await t
.expect(compareResults.isValid())
.ok(compareResults.errorMessages());
}).before(async () => {
await createWidget('dxHtmlEditor', {
height: 500,
width: 350,
aiIntegration: {},
toolbar: {
items: ['ai'],
},
});
});