Skip to content

Commit 8b5bbbb

Browse files
Scheduler: Test for grouping css auto width (#30944)
1 parent 89d3587 commit 8b5bbbb

File tree

5 files changed

+172
-0
lines changed

5 files changed

+172
-0
lines changed
64.5 KB
Loading
67 KB
Loading
41.6 KB
Loading
45.7 KB
Loading
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
import { createScreenshotsComparer } from 'devextreme-screenshot-comparer';
2+
import { extend } from 'devextreme/core/utils/extend';
3+
import Scheduler from 'devextreme-testcafe-models/scheduler';
4+
import { insertStylesheetRulesToPage, removeStylesheetRulesFromPage } from '../../../../helpers/domUtils';
5+
import { createWidget } from '../../../../helpers/createWidget';
6+
import url from '../../../../helpers/getPageUrl';
7+
8+
const SCHEDULER_SELECTOR = '#container';
9+
10+
const resources = [
11+
{
12+
text: 'Very Long Priority Name for High Priority Tasks and Urgent Matters',
13+
id: 1,
14+
color: '#ff9747',
15+
},
16+
{
17+
text: 'Extremely Long Priority Name for Medium Priority Tasks and Regular Work',
18+
id: 2,
19+
color: '#24ff50',
20+
},
21+
{
22+
text: 'Super Long Priority Name for Low Priority Tasks and Background Activities',
23+
id: 3,
24+
color: '#3366ff',
25+
},
26+
];
27+
28+
const dataSource = [
29+
{
30+
text: 'Team Meeting',
31+
startDate: new Date(2021, 3, 21, 10, 0),
32+
endDate: new Date(2021, 3, 21, 11, 30),
33+
priorityId: 1,
34+
},
35+
{
36+
text: 'Code Review',
37+
startDate: new Date(2021, 3, 21, 14, 0),
38+
endDate: new Date(2021, 3, 21, 15, 0),
39+
priorityId: 2,
40+
},
41+
{
42+
text: 'Planning Session',
43+
startDate: new Date(2021, 3, 22, 9, 0),
44+
endDate: new Date(2021, 3, 22, 12, 0),
45+
priorityId: 3,
46+
},
47+
];
48+
49+
const DEFAULT_OPTIONS = {
50+
currentDate: new Date(2021, 3, 21),
51+
height: 600,
52+
width: 1000,
53+
startDayHour: 9,
54+
endDayHour: 16,
55+
crossScrollingEnabled: true,
56+
showCurrentTimeIndicator: false,
57+
showAllDayPanel: false,
58+
groups: ['priorityId'],
59+
views: [{
60+
type: 'workWeek',
61+
name: 'Vertical Grouping',
62+
groupOrientation: 'vertical',
63+
cellDuration: 60,
64+
intervalCount: 2,
65+
},
66+
{
67+
type: 'workWeek',
68+
name: 'Horizontal Grouping',
69+
groupOrientation: 'horizontal',
70+
cellDuration: 30,
71+
intervalCount: 2,
72+
}, {
73+
type: 'month',
74+
name: 'Group By Date',
75+
groupOrientation: 'horizontal',
76+
}, 'agenda'],
77+
resources: [{
78+
fieldExpr: 'priorityId',
79+
allowMultiple: false,
80+
dataSource: resources,
81+
label: 'Priority',
82+
}],
83+
dataSource,
84+
};
85+
86+
const CELL_SIZE_CSS = `
87+
#container .dx-scheduler-group-header {
88+
width: auto;
89+
}
90+
#container .dx-scheduler-group-flex-container,
91+
#container .dx-scheduler-work-space-vertical-group-table,
92+
#container .dx-scheduler-sidebar-scrollable {
93+
flex: 0 0 auto;
94+
}
95+
`;
96+
97+
const createScheduler = async (options = {}): Promise<void> => createWidget('dxScheduler', extend(DEFAULT_OPTIONS, options));
98+
99+
fixture.disablePageReloads`Scheduler: Group Header CSS for Long Resource Names`
100+
.page(url(__dirname, '../../../container.html'));
101+
102+
test('Group header CSS should work with vertical grouping and long resource names', async (t) => {
103+
const scheduler = new Scheduler(SCHEDULER_SELECTOR);
104+
const { takeScreenshot, compareResults } = createScreenshotsComparer(t);
105+
106+
await t.expect(scheduler.element.find('.dx-scheduler-group-header').exists)
107+
.ok('Group headers should exist');
108+
109+
await takeScreenshot('group-header-css-vertical-grouping-long-names.png', scheduler.element);
110+
111+
await t.expect(compareResults.isValid())
112+
.ok(compareResults.errorMessages());
113+
}).before(async () => {
114+
await insertStylesheetRulesToPage(CELL_SIZE_CSS);
115+
await createScheduler({ currentView: 'Vertical Grouping' });
116+
}).after(async () => {
117+
await removeStylesheetRulesFromPage();
118+
});
119+
120+
test('Group header CSS should work with horizontal grouping and long resource names', async (t) => {
121+
const scheduler = new Scheduler(SCHEDULER_SELECTOR);
122+
const { takeScreenshot, compareResults } = createScreenshotsComparer(t);
123+
124+
await t.expect(scheduler.element.find('.dx-scheduler-group-header').exists)
125+
.ok('Group headers should exist');
126+
127+
await takeScreenshot('group-header-css-horizontal-grouping-long-names.png', scheduler.element);
128+
129+
await t.expect(compareResults.isValid())
130+
.ok(compareResults.errorMessages());
131+
}).before(async () => {
132+
await insertStylesheetRulesToPage(CELL_SIZE_CSS);
133+
await createScheduler({ currentView: 'Horizontal Grouping' });
134+
}).after(async () => {
135+
await removeStylesheetRulesFromPage();
136+
});
137+
138+
test('Group header CSS should work with group by date and long resource names', async (t) => {
139+
const scheduler = new Scheduler(SCHEDULER_SELECTOR);
140+
const { takeScreenshot, compareResults } = createScreenshotsComparer(t);
141+
142+
await t.expect(scheduler.element.find('.dx-scheduler-group-header').exists)
143+
.ok('Group headers should exist');
144+
145+
await takeScreenshot('group-header-css-group-by-date-long-names.png', scheduler.element);
146+
147+
await t.expect(compareResults.isValid())
148+
.ok(compareResults.errorMessages());
149+
}).before(async () => {
150+
await insertStylesheetRulesToPage(CELL_SIZE_CSS);
151+
await createScheduler({ currentView: 'Group By Date', groupByDate: true });
152+
}).after(async () => {
153+
await removeStylesheetRulesFromPage();
154+
});
155+
156+
test('Group header CSS should work with agenda view and long resource names', async (t) => {
157+
const scheduler = new Scheduler(SCHEDULER_SELECTOR);
158+
const { takeScreenshot, compareResults } = createScreenshotsComparer(t);
159+
160+
await t.expect(scheduler.element.find('.dx-scheduler-group-header').exists)
161+
.ok('Group headers should exist');
162+
163+
await takeScreenshot('group-header-css-agenda-view-long-names.png', scheduler.element);
164+
165+
await t.expect(compareResults.isValid())
166+
.ok(compareResults.errorMessages());
167+
}).before(async () => {
168+
await insertStylesheetRulesToPage(CELL_SIZE_CSS);
169+
await createScheduler({ currentView: 'agenda' });
170+
}).after(async () => {
171+
await removeStylesheetRulesFromPage();
172+
});

0 commit comments

Comments
 (0)