|
1 | | -// import Scheduler from 'devextreme-testcafe-models/scheduler'; |
2 | | -// import { createWidget } from '../../../helpers/createWidget'; |
3 | | -// import url from '../../../helpers/getPageUrl'; |
| 1 | +import Scheduler from 'devextreme-testcafe-models/scheduler'; |
| 2 | +import { createWidget } from '../../../helpers/createWidget'; |
| 3 | +import url from '../../../helpers/getPageUrl'; |
4 | 4 |
|
5 | | -// fixture.disablePageReloads`Scheduler - Status` |
6 | | -// .page(url(__dirname, '../../container.html')); |
| 5 | +fixture.disablePageReloads`Scheduler - Status` |
| 6 | + .page(url(__dirname, '../../container.html')); |
7 | 7 |
|
8 | | -// const today = '2025-04-30T15:00:00.000Z'; |
9 | | -// const appointments = [ |
10 | | -// { |
11 | | -// startDate: '2025-04-25T21:30:00.000Z', |
12 | | -// endDate: '2025-04-25T23:30:00.000Z', |
13 | | -// recurrenceRule: 'FREQ=HOURLY;INTERVAL=15;COUNT=15', |
14 | | -// }, { |
15 | | -// startDate: '2025-04-30T15:00:00.000Z', |
16 | | -// endDate: '2025-04-30T16:00:00.000Z', |
17 | | -// }, { |
18 | | -// startDate: '2025-04-26T00:30:00.000Z', |
19 | | -// endDate: '2025-04-26T02:30:00.000Z', |
20 | | -// recurrenceRule: 'FREQ=HOURLY;INTERVAL=15;COUNT=15', |
21 | | -// }, { |
22 | | -// startDate: '2025-05-02T15:00:00.000Z', |
23 | | -// endDate: '2025-05-02T16:00:00.000Z', |
24 | | -// }, |
25 | | -// ]; |
| 8 | +const today = '2025-04-30T15:00:00.000Z'; |
| 9 | +const appointments = [ |
| 10 | + { |
| 11 | + startDate: '2025-04-25T21:30:00.000Z', |
| 12 | + endDate: '2025-04-25T23:30:00.000Z', |
| 13 | + recurrenceRule: 'FREQ=HOURLY;INTERVAL=15;COUNT=15', |
| 14 | + }, { |
| 15 | + startDate: '2025-04-30T15:00:00.000Z', |
| 16 | + endDate: '2025-04-30T16:00:00.000Z', |
| 17 | + }, { |
| 18 | + startDate: '2025-04-26T00:30:00.000Z', |
| 19 | + endDate: '2025-04-26T02:30:00.000Z', |
| 20 | + recurrenceRule: 'FREQ=HOURLY;INTERVAL=15;COUNT=15', |
| 21 | + }, { |
| 22 | + startDate: '2025-05-02T15:00:00.000Z', |
| 23 | + endDate: '2025-05-02T16:00:00.000Z', |
| 24 | + }, |
| 25 | +]; |
26 | 26 |
|
27 | | -// const statusCheck = async (t: TestController, scheduler: Scheduler, status: string) => { |
28 | | -// await t.expect(scheduler.element.getAttribute('aria-label')).contains(status); |
29 | | -// await t.expect(scheduler.getGeneralStatusContainer().textContent).contains(status); |
30 | | -// }; |
31 | | -// const statusCheckEql = async (t: TestController, scheduler: Scheduler, status: string) => { |
32 | | -// await t.expect(scheduler.element.getAttribute('aria-label')).match(new RegExp(status)); |
33 | | -// await t.expect(scheduler.getGeneralStatusContainer().textContent).match(new RegExp(status)); |
34 | | -// }; |
| 27 | +const statusCheck = async (t: TestController, scheduler: Scheduler, status: string) => { |
| 28 | + await t.expect(scheduler.element.getAttribute('aria-label')).contains(status); |
| 29 | + await t.expect(scheduler.getGeneralStatusContainer().textContent).contains(status); |
| 30 | +}; |
| 31 | +const statusCheckEql = async (t: TestController, scheduler: Scheduler, status: string) => { |
| 32 | + await t.expect(scheduler.element.getAttribute('aria-label')).match(new RegExp(status)); |
| 33 | + await t.expect(scheduler.getGeneralStatusContainer().textContent).match(new RegExp(status)); |
| 34 | +}; |
35 | 35 |
|
36 | | -// const options = [ |
37 | | -// ['agenda', 'Agenda view: from April 30, 2025 to May 6, 2025', [0, 9, 19]], |
38 | | -// ['day', 'Day view: April 30, 2025', [0, 3, 5]], |
39 | | -// ['month', 'Month view: from March 2025 to May 2025', [0, 17, 35]], |
40 | | -// ['timelineDay', 'Timeline Day view: April 30, 2025', [0, 3, 5]], |
41 | | -// ['timelineMonth', 'Timeline Month view: April 2025', [0, 11, 21]], |
42 | | -// ['timelineWeek', 'Timeline Week view: from April 27, 2025 to May 3, 2025', [0, 12, 25]], |
43 | | -// ['timelineWorkWeek', 'Timeline Work Week view: from April 28, 2025 to May 2, 2025', [0, 9, 18]], |
44 | | -// ['week', 'Week view: from April 27, 2025 to May 3, 2025', [0, 13, 27]], |
45 | | -// ['workWeek', 'Work Week view: from April 28, 2025 to May 2, 2025', [0, 10, 20]], |
46 | | -// ['Two Weeks', 'Two Weeks view: from April 27, 2025 to May 10, 2025', [0, 14, 29]], |
47 | | -// ] as const; |
48 | | -// const indicatorOnView = 'The current time indicator is visible in the view'; |
49 | | -// const indicatorNotOnView = 'The current time indicator is not visible on the screen'; |
| 36 | +const options = [ |
| 37 | + ['agenda', 'Agenda view: from April 30, 2025 to May 6, 2025', [0, 9, 19]], |
| 38 | + ['day', 'Day view: April 30, 2025', [0, 3, 5]], |
| 39 | + ['month', 'Month view: from March 2025 to May 2025', [0, 17, 35]], |
| 40 | + ['timelineDay', 'Timeline Day view: April 30, 2025', [0, 3, 5]], |
| 41 | + ['timelineMonth', 'Timeline Month view: April 2025', [0, 11, 21]], |
| 42 | + ['timelineWeek', 'Timeline Week view: from April 27, 2025 to May 3, 2025', [0, 12, 25]], |
| 43 | + ['timelineWorkWeek', 'Timeline Work Week view: from April 28, 2025 to May 2, 2025', [0, 9, 18]], |
| 44 | + ['week', 'Week view: from April 27, 2025 to May 3, 2025', [0, 13, 27]], |
| 45 | + ['workWeek', 'Work Week view: from April 28, 2025 to May 2, 2025', [0, 10, 20]], |
| 46 | + ['Two Weeks', 'Two Weeks view: from April 27, 2025 to May 10, 2025', [0, 14, 29]], |
| 47 | +] as const; |
| 48 | +const indicatorOnView = 'The current time indicator is visible in the view'; |
| 49 | +const indicatorNotOnView = 'The current time indicator is not visible on the screen'; |
50 | 50 |
|
51 | | -// options.forEach(([currentView, title, counts]) => { |
52 | | -// counts.forEach((appointmentsCount, index) => { |
53 | | -// const schedulerConfig = { |
54 | | -// timeZone: 'America/Los_Angeles', |
55 | | -// dataSource: appointments.slice(0, 2 * index), |
56 | | -// views: [ |
57 | | -// 'agenda', 'day', 'month', 'timelineDay', 'timelineMonth', 'timelineWeek', 'timelineWorkWeek', 'week', 'workWeek', { |
58 | | -// name: 'Two Weeks', |
59 | | -// type: 'week', |
60 | | -// intervalCount: 2, |
61 | | -// }, |
62 | | -// ], |
63 | | -// currentView, |
64 | | -// indicatorTime: today, |
65 | | -// currentDate: today, |
66 | | -// }; |
67 | | -// // TODO(2): use `appointmentsCount` here |
68 | | -// const generalStatus = `Scheduler. ${title} with ${index === 0 ? 0 : '\\d*'} appointments`; |
| 51 | +options.forEach(([currentView, title, counts]) => { |
| 52 | + counts.forEach((appointmentsCount, index) => { |
| 53 | + const schedulerConfig = { |
| 54 | + timeZone: 'America/Los_Angeles', |
| 55 | + dataSource: appointments.slice(0, 2 * index), |
| 56 | + views: [ |
| 57 | + 'agenda', 'day', 'month', 'timelineDay', 'timelineMonth', 'timelineWeek', 'timelineWorkWeek', 'week', 'workWeek', { |
| 58 | + name: 'Two Weeks', |
| 59 | + type: 'week', |
| 60 | + intervalCount: 2, |
| 61 | + }, |
| 62 | + ], |
| 63 | + currentView, |
| 64 | + indicatorTime: today, |
| 65 | + currentDate: today, |
| 66 | + }; |
| 67 | + // TODO(2): use `appointmentsCount` here |
| 68 | + const generalStatus = `Scheduler. ${title} with ${index === 0 ? 0 : '\\d*'} appointments`; |
69 | 69 |
|
70 | | -// test(`Scheduler should have correct status message [view=${currentView}, count=${appointmentsCount}, indicator=false]`, async (t) => { |
71 | | -// const scheduler = new Scheduler('#container'); |
| 70 | + test(`Scheduler should have correct status message [view=${currentView}, count=${appointmentsCount}, indicator=false]`, async (t) => { |
| 71 | + const scheduler = new Scheduler('#container'); |
72 | 72 |
|
73 | | -// await statusCheckEql(t, scheduler, generalStatus); |
74 | | -// }).before(async () => { |
75 | | -// await createWidget('dxScheduler', { ...schedulerConfig, showCurrentTimeIndicator: false }); |
76 | | -// }); |
| 73 | + await statusCheckEql(t, scheduler, generalStatus); |
| 74 | + }).before(async () => { |
| 75 | + await createWidget('dxScheduler', { ...schedulerConfig, showCurrentTimeIndicator: false }); |
| 76 | + }); |
77 | 77 |
|
78 | | -// test(`Scheduler should have correct status message [view=${currentView}, count=${appointmentsCount}, indicator=true]`, async (t) => { |
79 | | -// const scheduler = new Scheduler('#container'); |
| 78 | + test(`Scheduler should have correct status message [view=${currentView}, count=${appointmentsCount}, indicator=true]`, async (t) => { |
| 79 | + const scheduler = new Scheduler('#container'); |
80 | 80 |
|
81 | | -// await t.click(scheduler.toolbar.navigator.nextButton); |
82 | | -// await statusCheck(t, scheduler, currentView === 'month' ? indicatorOnView : indicatorNotOnView); |
| 81 | + await t.click(scheduler.toolbar.navigator.nextButton); |
| 82 | + await statusCheck(t, scheduler, currentView === 'month' ? indicatorOnView : indicatorNotOnView); |
83 | 83 |
|
84 | | -// await t.click(scheduler.toolbar.navigator.prevButton); |
85 | | -// await statusCheckEql(t, scheduler, `${generalStatus}. ${indicatorOnView}`); |
| 84 | + await t.click(scheduler.toolbar.navigator.prevButton); |
| 85 | + await statusCheckEql(t, scheduler, `${generalStatus}. ${indicatorOnView}`); |
86 | 86 |
|
87 | | -// await t.click(scheduler.toolbar.navigator.prevButton); |
88 | | -// await statusCheck(t, scheduler, indicatorNotOnView); |
89 | | -// }).before(async () => { |
90 | | -// await createWidget('dxScheduler', { ...schedulerConfig, showCurrentTimeIndicator: true }); |
91 | | -// }); |
92 | | -// }); |
93 | | -// }); |
| 87 | + await t.click(scheduler.toolbar.navigator.prevButton); |
| 88 | + await statusCheck(t, scheduler, indicatorNotOnView); |
| 89 | + }).before(async () => { |
| 90 | + await createWidget('dxScheduler', { ...schedulerConfig, showCurrentTimeIndicator: true }); |
| 91 | + }); |
| 92 | + }); |
| 93 | +}); |
94 | 94 |
|
95 | | -// [ |
96 | | -// ['timelineWeek', 'Scheduler. Timeline Week view: from April 27, 2025 to May 3, 2025 with 5 appointments'], |
97 | | -// ['week', 'Scheduler. Week view: from April 27, 2025 to May 3, 2025 with 5 appointments'], |
98 | | -// ].forEach(([currentView, title]) => { |
99 | | -// test(`Scheduler should have correct status message if the appointments are partial [view=${currentView}]`, async (t) => { |
100 | | -// const scheduler = new Scheduler('#container'); |
| 95 | +[ |
| 96 | + ['timelineWeek', 'Scheduler. Timeline Week view: from April 27, 2025 to May 3, 2025 with 5 appointments'], |
| 97 | + ['week', 'Scheduler. Week view: from April 27, 2025 to May 3, 2025 with 5 appointments'], |
| 98 | +].forEach(([currentView, title]) => { |
| 99 | + test(`Scheduler should have correct status message if the appointments are partial [view=${currentView}]`, async (t) => { |
| 100 | + const scheduler = new Scheduler('#container'); |
101 | 101 |
|
102 | | -// await statusCheckEql(t, scheduler, title); |
103 | | -// }).before(async () => { |
104 | | -// await createWidget('dxScheduler', { |
105 | | -// timeZone: 'America/Los_Angeles', |
106 | | -// dataSource: [{ |
107 | | -// startDate: '2025-04-29T23:18:00.000Z', |
108 | | -// endDate: '2025-04-30T16:12:00.000Z', |
109 | | -// }, { |
110 | | -// startDate: '2025-04-26T23:18:00.000Z', |
111 | | -// endDate: '2025-04-27T12:12:00.000Z', |
112 | | -// recurrenceRule: 'FREQ=DAILY;INTERVAL=2;COUNT=5', |
113 | | -// }], |
114 | | -// views: ['timelineWeek', 'week'], |
115 | | -// currentView, |
116 | | -// indicatorTime: today, |
117 | | -// currentDate: today, |
118 | | -// }); |
119 | | -// }); |
120 | | -// }); |
| 102 | + await statusCheckEql(t, scheduler, title); |
| 103 | + }).before(async () => { |
| 104 | + await createWidget('dxScheduler', { |
| 105 | + timeZone: 'America/Los_Angeles', |
| 106 | + dataSource: [{ |
| 107 | + startDate: '2025-04-29T23:18:00.000Z', |
| 108 | + endDate: '2025-04-30T16:12:00.000Z', |
| 109 | + }, { |
| 110 | + startDate: '2025-04-26T23:18:00.000Z', |
| 111 | + endDate: '2025-04-27T12:12:00.000Z', |
| 112 | + recurrenceRule: 'FREQ=DAILY;INTERVAL=2;COUNT=5', |
| 113 | + }], |
| 114 | + views: ['timelineWeek', 'week'], |
| 115 | + currentView, |
| 116 | + indicatorTime: today, |
| 117 | + currentDate: today, |
| 118 | + }); |
| 119 | + }); |
| 120 | +}); |
0 commit comments