Skip to content

Commit b2be014

Browse files
authored
CI optimization: reduce the number of scenarios in TestCafe testing (DateRangeBox) (#31348)
1 parent 9d42435 commit b2be014

File tree

504 files changed

+322
-333
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

504 files changed

+322
-333
lines changed

e2e/testcafe-devextreme/tests/editors/dateRangeBox/calendar.ts

Lines changed: 156 additions & 162 deletions
Large diffs are not rendered by default.

e2e/testcafe-devextreme/tests/editors/dateRangeBox/common.ts

Lines changed: 97 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ import { Selector } from 'testcafe';
33
import { createScreenshotsComparer } from 'devextreme-screenshot-comparer';
44
import Guid from 'devextreme/core/guid';
55
import DateRangeBox from 'devextreme-testcafe-models/dateRangeBox';
6+
import type { Properties as DateRangeBoxProperties } from 'devextreme/ui/date_range_box.d';
7+
import type { Properties as DropDownEditorProperties } from 'devextreme/ui/drop_down_editor/ui.drop_down_editor.d';
8+
import type { EditorStyle, LabelMode } from 'devextreme/common';
69
import {
710
insertStylesheetRulesToPage,
811
appendElementTo,
912
setAttribute,
1013
setClassAttribute,
11-
removeClassAttribute,
1214
} from '../../../helpers/domUtils';
1315
import url from '../../../helpers/getPageUrl';
1416
import { createWidget } from '../../../helpers/createWidget';
@@ -21,124 +23,104 @@ const HOVER_STATE_CLASS = 'dx-state-hover';
2123
const READONLY_STATE_CLASS = 'dx-state-readonly';
2224
const DISABLED_STATE_CLASS = 'dx-state-disabled';
2325

24-
const stylingModes = ['outlined', 'underlined', 'filled'];
25-
const labelModes = ['static', 'floating', 'hidden', 'outside'];
26+
const stylingModes: EditorStyle[] = ['outlined', 'underlined', 'filled'];
27+
const labelModes: LabelMode[] = ['static', 'floating', 'hidden', 'outside'];
2628

2729
fixture.disablePageReloads`DateRangeBox render`
2830
.page(url(__dirname, '../../container.html'));
2931

30-
stylingModes.forEach((stylingMode) => {
31-
[true, false].forEach((isValid) => {
32-
test(`DateRangeBox styles, stylingMode=${stylingMode}, isValid=${isValid}`, async (t) => {
33-
const { takeScreenshot, compareResults } = createScreenshotsComparer(t);
34-
35-
await testScreenshot(t, takeScreenshot, `DateRangeBox stylingMode=${stylingMode} isValid=${isValid}.png`, { shouldTestInCompact: true });
36-
37-
for (const state of [
38-
DROP_DOWN_EDITOR_ACTIVE_CLASS,
39-
FOCUSED_STATE_CLASS,
40-
HOVER_STATE_CLASS,
41-
READONLY_STATE_CLASS,
42-
DISABLED_STATE_CLASS,
43-
] as any[]
44-
) {
45-
for (const id of t.ctx.ids) {
46-
await setClassAttribute(Selector(`#${id}`), state);
47-
await setClassAttribute(Selector(`#${id} .dx-start-datebox`), state);
48-
}
49-
50-
await testScreenshot(t, takeScreenshot, `DateRangeBox ${state.replaceAll('dx-', '').replaceAll('dropdowneditor-', '').replaceAll('state-', '')} stylingMode=${stylingMode} isValid=${isValid}.png`, { shouldTestInCompact: true });
51-
52-
for (const id of t.ctx.ids) {
53-
await removeClassAttribute(Selector(`#${id}`), state);
54-
await removeClassAttribute(Selector(`#${id} .dx-start-datebox`), state);
55-
}
56-
}
57-
58-
await t
59-
.expect(compareResults.isValid())
60-
.ok(compareResults.errorMessages());
61-
}).before(async (t) => {
62-
t.ctx.ids = [];
63-
64-
await insertStylesheetRulesToPage(`.${DATERANGEBOX_CLASS} { display: inline-flex; margin: 5px; }`);
65-
66-
for (const rtlEnabled of [false, true]) {
67-
for (const labelMode of labelModes) {
68-
for (const value of [
69-
[null, null],
70-
[new Date(2021, 9, 17, 16, 34), new Date(2021, 9, 18, 16, 34)],
71-
]) {
72-
const id = `${`dx${new Guid()}`}`;
73-
74-
t.ctx.ids.push(id);
75-
await appendElementTo('#container', 'div', id, { });
76-
77-
const options: any = {
78-
width: 500,
79-
isValid,
80-
value,
81-
labelMode,
82-
rtlEnabled,
83-
stylingMode,
84-
endDateLabel: labelMode,
85-
startDateLabel: 'qwertyQWERTYg',
86-
showClearButton: true,
87-
};
88-
89-
await createWidget('dxDateRangeBox', options, `#${id}`);
90-
}
91-
}
92-
}
93-
});
94-
});
32+
const TEST_VALUE = [new Date(2021, 9, 17, 16, 34), new Date(2021, 9, 18, 16, 34)];
33+
34+
const createDateRangeBox = async (
35+
options?: DateRangeBoxProperties,
36+
state?: string,
37+
): Promise<string> => {
38+
const id = `${`dx${new Guid()}`}`;
39+
40+
await appendElementTo('#container', 'div', id, { });
41+
42+
const config: any = {
43+
width: 500,
44+
labelMode: 'static',
45+
endDateLabel: 'static',
46+
startDateLabel: 'qwertyQWERTYg',
47+
showClearButton: true,
48+
...options,
49+
};
50+
51+
await createWidget('dxDateRangeBox', config, `#${id}`);
52+
53+
if (state) {
54+
await setClassAttribute(Selector(`#${id}`), state);
55+
await setClassAttribute(Selector(`#${id} .dx-start-datebox`), state);
56+
}
57+
58+
return id;
59+
};
60+
61+
test('DateRangeBox styles', async (t) => {
62+
const { takeScreenshot, compareResults } = createScreenshotsComparer(t);
63+
64+
await testScreenshot(t, takeScreenshot, 'DateRangeBox styles.png', { element: '#container' });
65+
66+
await t
67+
.expect(compareResults.isValid())
68+
.ok(compareResults.errorMessages());
69+
}).before(async () => {
70+
await insertStylesheetRulesToPage(`.${DATERANGEBOX_CLASS} { display: inline-flex; margin: 5px; }`);
71+
72+
for (const stylingMode of stylingModes) {
73+
for (const state of [
74+
DROP_DOWN_EDITOR_ACTIVE_CLASS,
75+
FOCUSED_STATE_CLASS,
76+
HOVER_STATE_CLASS,
77+
READONLY_STATE_CLASS,
78+
DISABLED_STATE_CLASS,
79+
] as any[]
80+
) {
81+
await createDateRangeBox({ value: TEST_VALUE, stylingMode }, state);
82+
}
83+
}
84+
85+
await createDateRangeBox({ value: TEST_VALUE, rtlEnabled: true });
86+
await createDateRangeBox({ value: TEST_VALUE, isValid: false });
87+
});
88+
89+
test('DateRangeBox with buttons container', async (t) => {
90+
const { takeScreenshot, compareResults } = createScreenshotsComparer(t);
91+
92+
await testScreenshot(t, takeScreenshot, 'DateRangeBox with buttons container.png', { element: '#container' });
93+
94+
await t
95+
.expect(compareResults.isValid())
96+
.ok(compareResults.errorMessages());
97+
}).before(async () => {
98+
await insertStylesheetRulesToPage('#container { display: flex; flex-wrap: wrap; gap: 4px; }');
9599

96-
['static', 'floating', 'outside'].forEach((labelMode) => {
97-
test(`DateRangeBox with buttons container, stylingMode=${stylingMode}, labelMode=${labelMode}`, async (t) => {
98-
const { takeScreenshot, compareResults } = createScreenshotsComparer(t);
99-
100-
await insertStylesheetRulesToPage('#container { display: flex; flex-wrap: wrap; gap: 4px; }');
101-
102-
await testScreenshot(t, takeScreenshot, `DRB with buttons container,stMode=${stylingMode},lMode=${labelMode}.png`, { shouldTestInCompact: true });
103-
104-
await t
105-
.expect(compareResults.isValid())
106-
.ok(compareResults.errorMessages());
107-
}).before(async () => {
108-
for (const buttons of [
109-
['clear'],
110-
['clear', 'dropDown'],
111-
[{ name: 'custom', location: 'after', options: { icon: 'home' } }, 'clear', 'dropDown'],
112-
['clear', { name: 'custom', location: 'after', options: { icon: 'home' } }, 'dropDown'],
113-
['clear', 'dropDown', { name: 'custom', location: 'after', options: { icon: 'home' } }],
114-
[{ name: 'custom', location: 'before', options: { icon: 'home' } }, 'clear', 'dropDown'],
115-
['clear', { name: 'custom', location: 'before', options: { icon: 'home' } }, 'dropDown'],
116-
['clear', 'dropDown', { name: 'custom', location: 'before', options: { icon: 'home' } }],
117-
]) {
118-
for (const rtlEnabled of [false, true]) {
119-
const id = `${`dx${new Guid()}`}`;
120-
121-
await appendElementTo('#container', 'div', id, { });
122-
123-
await createWidget('dxDateRangeBox', {
124-
width: 500,
125-
value: [new Date(2021, 9, 17, 16, 34), new Date(2021, 9, 18, 16, 34)],
126-
labelMode,
127-
stylingMode,
128-
rtlEnabled,
129-
buttons,
130-
showClearButton: true,
131-
}, `#${id}`);
132-
}
133-
}
100+
const testButtons: DropDownEditorProperties['buttons'][] = [
101+
['clear'],
102+
[{ name: 'custom', location: 'after', options: { icon: 'home' } }, 'clear', 'dropDown'],
103+
['clear', { name: 'custom', location: 'after', options: { icon: 'home' } }, 'dropDown'],
104+
[{ name: 'custom', location: 'before', options: { icon: 'home' } }, 'clear', 'dropDown'],
105+
];
106+
107+
for (const buttons of testButtons) {
108+
await createDateRangeBox({
109+
value: TEST_VALUE,
110+
buttons,
134111
});
135-
});
112+
await createDateRangeBox({
113+
value: TEST_VALUE,
114+
buttons,
115+
rtlEnabled: true,
116+
});
117+
}
136118
});
137119

138120
labelModes.forEach((labelMode) => {
139-
test(`Custom placeholders and labels appearance (labelMode=${labelMode})`, async (t) => {
121+
test('Custom placeholders and labels appearance', async (t) => {
140122
const { takeScreenshot, compareResults } = createScreenshotsComparer(t);
141-
const dateRangeBox = new DateRangeBox('#dateRangeBox');
123+
const dateRangeBox = new DateRangeBox(`#${t.ctx.id}`);
142124

143125
await testScreenshot(t, takeScreenshot, `Placeholder and label by default labelMode=${labelMode}.png`, { element: '#container' });
144126

@@ -150,23 +132,23 @@ labelModes.forEach((labelMode) => {
150132
await t
151133
.click(dateRangeBox.getEndDateBox().input);
152134

153-
await testScreenshot(t, takeScreenshot, `Placeholder and label on end date input focus labelMode=${labelMode}.png`, { element: '#container' });
135+
await testScreenshot(t, takeScreenshot, `Placeholder and label on end date input labelMode=${labelMode} focus.png`, { element: '#container' });
154136

155137
await t
156138
.expect(compareResults.isValid())
157139
.ok(compareResults.errorMessages());
158-
}).before(async () => {
159-
await appendElementTo('#container', 'div', 'dateRangeBox');
140+
}).before(async (t) => {
160141
await setAttribute('#container', 'style', 'width: 800px; height: 300px; padding-top: 10px;');
161-
162-
return createWidget('dxDateRangeBox', {
142+
await insertStylesheetRulesToPage('* { caret-color: transparent !important; }');
143+
t.ctx.id = await createDateRangeBox({
163144
labelMode,
164145
width: 600,
165146
openOnFieldClick: false,
166147
startDateLabel: 'first date',
167148
endDateLabel: 'second date',
168149
startDatePlaceholder: 'enter start date',
169150
endDatePlaceholder: 'enter end date',
170-
}, '#dateRangeBox');
151+
});
152+
await appendElementTo('#container', 'div', t.ctx.id);
171153
});
172154
});
-39 Bytes
21 Bytes
8 Bytes
-35 Bytes
-20 Bytes
52 Bytes
30 Bytes

0 commit comments

Comments
 (0)