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