Skip to content

Commit a896f16

Browse files
authored
CI optimization: reduced the number of scenarios in TestCafe testing (DateBox) (#31311)
1 parent e7d7b86 commit a896f16

282 files changed

Lines changed: 148 additions & 128 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 59 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/* eslint-disable no-restricted-syntax */
2+
import type { DatePickerType, DateType, Properties } from 'devextreme/ui/date_box.d';
3+
import { EditorStyle } from 'devextreme/common';
24
import { Selector } from 'testcafe';
35
import { createScreenshotsComparer } from 'devextreme-screenshot-comparer';
46
import Guid from 'devextreme/core/guid';
@@ -15,65 +17,71 @@ const DATEBOX_CLASS = 'dx-datebox';
1517
const DROP_DOWN_EDITOR_ACTIVE_CLASS = 'dx-dropdowneditor-active';
1618
const FOCUSED_STATE_CLASS = 'dx-state-focused';
1719

18-
const stylingModes = ['outlined', 'underlined', 'filled'];
19-
const pickerTypes = ['calendar', 'list', 'native', 'rollers'];
20-
const labelModes = ['static', 'floating', 'hidden', 'outside'];
21-
const types = ['date', 'datetime', 'time'];
20+
const stylingModes: EditorStyle[] = ['outlined', 'underlined', 'filled'];
21+
const pickerTypes: DatePickerType[] = ['calendar', 'list', 'native', 'rollers'];
22+
const types: DateType[] = ['date', 'datetime', 'time'];
2223

2324
fixture.disablePageReloads`DateBox render`
2425
.page(url(__dirname, '../../container.html'));
2526

26-
stylingModes.forEach((stylingMode) => {
27-
labelModes.forEach((labelMode) => {
28-
test(`DateBox styles, stylingMode=${stylingMode}, labelMode=${labelMode}`, async (t) => {
29-
const { takeScreenshot, compareResults } = createScreenshotsComparer(t);
27+
const createDateBox = async (options?: Properties, state?: string): Promise<string> => {
28+
const id = `${`dx${new Guid()}`}`;
3029

31-
await testScreenshot(t, takeScreenshot, `Datebox stylingMode=${stylingMode}, labelMode=${labelMode}.png`, { shouldTestInCompact: true });
30+
await appendElementTo('#container', 'div', id, {});
31+
await createWidget('dxDateBox', {
32+
width: 220,
33+
label: 'label text',
34+
showClearButton: true,
35+
value: new Date(2021, 9, 17, 16, 34),
36+
...options,
37+
}, `#${id}`);
3238

33-
for (const state of [DROP_DOWN_EDITOR_ACTIVE_CLASS, FOCUSED_STATE_CLASS] as any[]) {
34-
for (const id of t.ctx.ids) {
35-
await setClassAttribute(Selector(`#${id}`), state);
36-
}
39+
if (state) {
40+
await setClassAttribute(Selector(`#${id}`), state);
41+
}
3742

38-
await testScreenshot(t, takeScreenshot, `Datebox ${state.replaceAll('dx-', '').replaceAll('dropdowneditor-', '').replaceAll('state-', '')} stylingMode=${stylingMode}, labelMode=${labelMode}.png`, { shouldTestInCompact: true });
43+
return id;
44+
};
3945

40-
for (const id of t.ctx.ids) {
41-
await removeClassAttribute(Selector(`#${id}`), state);
42-
}
43-
}
46+
test('DateBox styles', async (t) => {
47+
const { takeScreenshot, compareResults } = createScreenshotsComparer(t);
48+
49+
await testScreenshot(t, takeScreenshot, 'Datebox.png');
50+
51+
for (const state of [DROP_DOWN_EDITOR_ACTIVE_CLASS, FOCUSED_STATE_CLASS] as any[]) {
52+
for (const id of t.ctx.ids) {
53+
await setClassAttribute(Selector(`#${id}`), state);
54+
}
55+
56+
await testScreenshot(t, takeScreenshot, `Datebox ${state.replaceAll('dx-', '').replaceAll('dropdowneditor-', '').replaceAll('state-', '')}.png`);
57+
58+
for (const id of t.ctx.ids) {
59+
await removeClassAttribute(Selector(`#${id}`), state);
60+
}
61+
}
4462

45-
await t
46-
.expect(compareResults.isValid())
47-
.ok(compareResults.errorMessages());
48-
}).before(async (t) => {
49-
t.ctx.ids = [];
50-
51-
await insertStylesheetRulesToPage(`.${DATEBOX_CLASS} { display: inline-block; margin: 5px; }`);
52-
53-
for (const rtlEnabled of [true, false]) {
54-
for (const type of types) {
55-
for (const pickerType of pickerTypes) {
56-
const id = `${`dx${new Guid()}`}`;
57-
58-
t.ctx.ids.push(id);
59-
await appendElementTo('#container', 'div', id, { });
60-
61-
const options: any = {
62-
width: 220,
63-
label: 'label text',
64-
labelMode,
65-
stylingMode,
66-
showClearButton: true,
67-
pickerType,
68-
type,
69-
rtlEnabled,
70-
value: new Date(2021, 9, 17, 16, 34),
71-
};
72-
73-
await createWidget('dxDateBox', options, `#${id}`);
74-
}
75-
}
63+
await t
64+
.expect(compareResults.isValid())
65+
.ok(compareResults.errorMessages());
66+
}).before(async (t) => {
67+
t.ctx.ids = [];
68+
69+
await insertStylesheetRulesToPage(`.${DATEBOX_CLASS} { display: inline-block; margin: 5px; }`);
70+
71+
for (const stylingMode of stylingModes) {
72+
for (const type of types) {
73+
const options = {
74+
stylingMode,
75+
type,
76+
};
77+
for (const pickerType of pickerTypes) {
78+
const id = await createDateBox({ ...options, pickerType });
79+
80+
t.ctx.ids.push(id);
7681
}
77-
});
78-
});
82+
83+
const id = await createDateBox({ ...options, rtlEnabled: true });
84+
t.ctx.ids.push(id);
85+
}
86+
}
7987
});
83.3 KB
85.3 KB
83.8 KB

0 commit comments

Comments
 (0)