|
| 1 | +import { createScreenshotsComparer } from 'devextreme-screenshot-comparer'; |
1 | 2 | import Scheduler from 'devextreme-testcafe-models/scheduler'; |
2 | 3 | import { createWidget } from '../../../../helpers/createWidget'; |
3 | 4 | import url from '../../../../helpers/getPageUrl'; |
| 5 | +import { insertStylesheetRulesToPage, removeStylesheetRulesFromPage } from '../../../../helpers/domUtils'; |
4 | 6 |
|
5 | 7 | fixture.disablePageReloads`Scheduler header` |
6 | 8 | .page(url(__dirname, '../../../container.html')); |
@@ -42,3 +44,144 @@ test('dateNavigator buttons should have "contained" styling mode with generic th |
42 | 44 | views: ['day'], |
43 | 45 | height: 580, |
44 | 46 | })); |
| 47 | + |
| 48 | +const testData = [ |
| 49 | + { |
| 50 | + text: 'Website Re-Design Plan', |
| 51 | + startDate: new Date('2021-03-29T16:30:00.000Z'), |
| 52 | + endDate: new Date('2021-03-29T18:30:00.000Z'), |
| 53 | + }, { |
| 54 | + text: 'Book Flights to San Fran for Sales Trip', |
| 55 | + startDate: new Date('2021-03-29T19:00:00.000Z'), |
| 56 | + endDate: new Date('2021-03-29T20:00:00.000Z'), |
| 57 | + allDay: true, |
| 58 | + }, { |
| 59 | + text: 'Install New Router in Dev Room', |
| 60 | + startDate: new Date('2021-03-29T21:30:00.000Z'), |
| 61 | + endDate: new Date('2021-03-29T22:30:00.000Z'), |
| 62 | + }, { |
| 63 | + text: 'Approve Personal Computer Upgrade Plan', |
| 64 | + startDate: new Date('2021-03-30T17:00:00.000Z'), |
| 65 | + endDate: new Date('2021-03-30T18:00:00.000Z'), |
| 66 | + }, { |
| 67 | + text: 'Final Budget Review', |
| 68 | + startDate: new Date('2021-03-30T19:00:00.000Z'), |
| 69 | + endDate: new Date('2021-03-30T20:35:00.000Z'), |
| 70 | + }, { |
| 71 | + text: 'New Brochures', |
| 72 | + startDate: new Date('2021-03-30T21:30:00.000Z'), |
| 73 | + endDate: new Date('2021-03-30T22:45:00.000Z'), |
| 74 | + }, { |
| 75 | + text: 'Install New Database', |
| 76 | + startDate: new Date('2021-03-31T16:45:00.000Z'), |
| 77 | + endDate: new Date('2021-03-31T18:15:00.000Z'), |
| 78 | + }, { |
| 79 | + text: 'Approve New Online Marketing Strategy', |
| 80 | + startDate: new Date('2021-03-31T19:00:00.000Z'), |
| 81 | + endDate: new Date('2021-03-31T21:00:00.000Z'), |
| 82 | + }, { |
| 83 | + text: 'Upgrade Personal Computers', |
| 84 | + startDate: new Date('2021-03-31T22:15:00.000Z'), |
| 85 | + endDate: new Date('2021-03-31T23:30:00.000Z'), |
| 86 | + }, { |
| 87 | + text: 'Customer Workshop', |
| 88 | + startDate: new Date('2021-04-01T18:00:00.000Z'), |
| 89 | + endDate: new Date('2021-04-01T19:00:00.000Z'), |
| 90 | + allDay: true, |
| 91 | + }, { |
| 92 | + text: 'Prepare 2021 Marketing Plan', |
| 93 | + startDate: new Date('2021-04-01T18:00:00.000Z'), |
| 94 | + endDate: new Date('2021-04-01T20:30:00.000Z'), |
| 95 | + }, { |
| 96 | + text: 'Brochure Design Review', |
| 97 | + startDate: new Date('2021-04-01T21:00:00.000Z'), |
| 98 | + endDate: new Date('2021-04-01T22:30:00.000Z'), |
| 99 | + }, { |
| 100 | + text: 'Create Icons for Website', |
| 101 | + startDate: new Date('2021-04-02T17:00:00.000Z'), |
| 102 | + endDate: new Date('2021-04-02T18:30:00.000Z'), |
| 103 | + }, { |
| 104 | + text: 'Upgrade Server Hardware', |
| 105 | + startDate: new Date('2021-04-02T21:30:00.000Z'), |
| 106 | + endDate: new Date('2021-04-02T23:00:00.000Z'), |
| 107 | + }, { |
| 108 | + text: 'Submit New Website Design', |
| 109 | + startDate: new Date('2021-04-02T23:30:00.000Z'), |
| 110 | + endDate: new Date('2021-04-03T01:00:00.000Z'), |
| 111 | + }, { |
| 112 | + text: 'Launch New Website', |
| 113 | + startDate: new Date('2021-04-02T19:20:00.000Z'), |
| 114 | + endDate: new Date('2021-04-02T21:00:00.000Z'), |
| 115 | + }, |
| 116 | +]; |
| 117 | + |
| 118 | +const SCROLLBAR_STYLES = ` |
| 119 | + ::-webkit-scrollbar { |
| 120 | + -webkit-appearance: none; |
| 121 | + width: 7px; |
| 122 | + } |
| 123 | + ::-webkit-scrollbar-thumb { |
| 124 | + border-radius: 4px; |
| 125 | + background-color: rgba(0, 0, 0, .5); |
| 126 | + -webkit-box-shadow: 0 0 1px rgba(255, 255, 255, .5); |
| 127 | + } |
| 128 | + .dx-scheduler-date-table-scrollable .dx-scrollable-container { |
| 129 | + overflow: scroll !important; |
| 130 | + } |
| 131 | +`; |
| 132 | + |
| 133 | +test('Scheduler: maintain layout after horizontal scroll (T1306971)', async (t) => { |
| 134 | + const { |
| 135 | + takeScreenshot, |
| 136 | + compareResults, |
| 137 | + } = createScreenshotsComparer(t); |
| 138 | + const scheduler = new Scheduler('#container'); |
| 139 | + |
| 140 | + await insertStylesheetRulesToPage(SCROLLBAR_STYLES); |
| 141 | + |
| 142 | + await t.wait(100); |
| 143 | + |
| 144 | + await scheduler.repaint(); |
| 145 | + |
| 146 | + await t.wait(100); |
| 147 | + |
| 148 | + await t.expect( |
| 149 | + await takeScreenshot('T1306971__scheduler__horizontal-scrolling__before.png', scheduler.element), |
| 150 | + ).ok(); |
| 151 | + |
| 152 | + const container = scheduler.dateTableScrollableContainer; |
| 153 | + const scrollWidth = await container.scrollWidth; |
| 154 | + const clientWidth = await container.clientWidth; |
| 155 | + const maxScrollLeft = scrollWidth - clientWidth; |
| 156 | + |
| 157 | + await t.scroll(scheduler.workspaceScrollable, maxScrollLeft, 0); |
| 158 | + |
| 159 | + const finalScrollLeft = await container.scrollLeft; |
| 160 | + |
| 161 | + await t |
| 162 | + .expect(maxScrollLeft).gt(0, 'No horizontal scroll available') |
| 163 | + .expect(finalScrollLeft).gt(0, 'Scroll position should be greater than 0'); |
| 164 | + |
| 165 | + await t.wait(500); |
| 166 | + |
| 167 | + await t.expect( |
| 168 | + await takeScreenshot('T1306971__scheduler__horizontal-scrolling__after.png', scheduler.element), |
| 169 | + ).ok(); |
| 170 | + |
| 171 | + await t.expect(compareResults.isValid()) |
| 172 | + .ok(compareResults.errorMessages()); |
| 173 | +}).before(async () => { |
| 174 | + await createWidget('dxScheduler', { |
| 175 | + timeZone: 'America/Los_Angeles', |
| 176 | + dataSource: testData, |
| 177 | + views: ['week'], |
| 178 | + currentView: 'week', |
| 179 | + currentDate: new Date(2021, 2, 28), |
| 180 | + startDayHour: 9, |
| 181 | + height: 730, |
| 182 | + crossScrollingEnabled: true, |
| 183 | + width: 500, |
| 184 | + }); |
| 185 | +}).after(async () => { |
| 186 | + await removeStylesheetRulesFromPage(); |
| 187 | +}); |
0 commit comments