|
| 1 | +import Scheduler from 'devextreme-testcafe-models/scheduler'; |
| 2 | +import url from '../../../../helpers/getPageUrl'; |
| 3 | +import { getTimezoneTest, MACHINE_TIMEZONES } from '../../../../helpers/machineTimezones'; |
| 4 | +import createScheduler from './init/widget.setup'; |
| 5 | + |
| 6 | +fixture.disablePageReloads`Resize all day panel appointments` |
| 7 | + .page(url(__dirname, '../../../container.html')); |
| 8 | + |
| 9 | +[true, false].forEach((rtlEnabled) => { |
| 10 | + test(`Resize all day appointment rtlEnabled=${rtlEnabled}`, async (t) => { |
| 11 | + const scheduler = new Scheduler('#container'); |
| 12 | + const appointment = scheduler.getAppointment('Appointment'); |
| 13 | + const { left, right } = appointment.resizableHandle; |
| 14 | + const text = 'Appointment: February 9, 2015, All day'; |
| 15 | + const startDateExtendedText = 'Appointment: February 8, 2015 - February 9, 2015, All day'; |
| 16 | + const endDateExtendedText = 'Appointment: February 9, 2015 - February 10, 2015, All day'; |
| 17 | + |
| 18 | + await t |
| 19 | + .drag(right, 100, 0) |
| 20 | + .expect(appointment.getAriaLabel()) |
| 21 | + .eql(rtlEnabled ? startDateExtendedText : endDateExtendedText); |
| 22 | + await t |
| 23 | + .drag(right, -100, 0) |
| 24 | + .expect(appointment.getAriaLabel()) |
| 25 | + .eql(text); |
| 26 | + await t |
| 27 | + .drag(left, -100, 0) |
| 28 | + .expect(appointment.getAriaLabel()) |
| 29 | + .eql(rtlEnabled ? endDateExtendedText : startDateExtendedText); |
| 30 | + await t |
| 31 | + .drag(left, 100, 0) |
| 32 | + .expect(appointment.getAriaLabel()) |
| 33 | + .eql(text); |
| 34 | + }).before(async () => createScheduler({ |
| 35 | + currentDate: new Date(2015, 1, 9), |
| 36 | + currentView: 'week', |
| 37 | + firstDayOfWeek: 0, |
| 38 | + rtlEnabled, |
| 39 | + height: 400, |
| 40 | + dataSource: [{ |
| 41 | + text: 'Appointment', |
| 42 | + startDate: new Date(2015, 1, 9, 8), |
| 43 | + endDate: new Date(2015, 1, 9, 10), |
| 44 | + allDay: true, |
| 45 | + }], |
| 46 | + })); |
| 47 | + |
| 48 | + getTimezoneTest([MACHINE_TIMEZONES.EuropeBerlin])(`Shrink long appointment endDate rtlEnabled=${rtlEnabled}`, async (t) => { |
| 49 | + const scheduler = new Scheduler('#container'); |
| 50 | + const appointment = scheduler.getAppointment('Appointment'); |
| 51 | + const { left, right } = appointment.resizableHandle; |
| 52 | + |
| 53 | + // eslint-disable-next-line @typescript-eslint/no-unused-expressions |
| 54 | + rtlEnabled |
| 55 | + ? await t.drag(right, -100, 0) |
| 56 | + : await t.drag(left, 100, 0); |
| 57 | + await t.expect(appointment.getAriaLabel()) |
| 58 | + .eql('Appointment: February 10, 2015, 12:00 AM - 10:00 AM'); |
| 59 | + }).before(async () => createScheduler({ |
| 60 | + currentDate: new Date(2015, 1, 9), |
| 61 | + currentView: 'week', |
| 62 | + firstDayOfWeek: 0, |
| 63 | + rtlEnabled, |
| 64 | + height: 400, |
| 65 | + dataSource: [{ |
| 66 | + text: 'Appointment', |
| 67 | + startDate: new Date(2015, 1, 9, 8), |
| 68 | + endDate: new Date(2015, 1, 10, 10), |
| 69 | + }], |
| 70 | + })); |
| 71 | + |
| 72 | + getTimezoneTest([MACHINE_TIMEZONES.EuropeBerlin])(`Shrink long appointment startDate rtlEnabled=${rtlEnabled}`, async (t) => { |
| 73 | + const scheduler = new Scheduler('#container'); |
| 74 | + const appointment = scheduler.getAppointment('Appointment'); |
| 75 | + const { left, right } = appointment.resizableHandle; |
| 76 | + |
| 77 | + // eslint-disable-next-line @typescript-eslint/no-unused-expressions |
| 78 | + rtlEnabled |
| 79 | + ? await t.drag(left, 100, 0) |
| 80 | + : await t.drag(right, -100, 0); |
| 81 | + await t.expect(appointment.getAriaLabel()) |
| 82 | + .eql('Appointment: February 9, 2015, 8:00 AM - February 10, 2015, 12:00 AM'); |
| 83 | + }).before(async () => createScheduler({ |
| 84 | + currentDate: new Date(2015, 1, 9), |
| 85 | + currentView: 'week', |
| 86 | + firstDayOfWeek: 0, |
| 87 | + rtlEnabled, |
| 88 | + height: 400, |
| 89 | + dataSource: [{ |
| 90 | + text: 'Appointment', |
| 91 | + startDate: new Date(2015, 1, 9, 8), |
| 92 | + endDate: new Date(2015, 1, 10, 10), |
| 93 | + }], |
| 94 | + })); |
| 95 | + |
| 96 | + getTimezoneTest([MACHINE_TIMEZONES.EuropeBerlin])(`Resize long appointment endDate with offset rtlEnabled=${rtlEnabled}`, async (t) => { |
| 97 | + const scheduler = new Scheduler('#container'); |
| 98 | + const appointment = scheduler.getAppointment('Appointment'); |
| 99 | + const { left, right } = appointment.resizableHandle; |
| 100 | + const drag = async () => (rtlEnabled |
| 101 | + ? t.drag(left, 100, 0) |
| 102 | + : t.drag(right, -100, 0)); |
| 103 | + |
| 104 | + await drag(); |
| 105 | + await t |
| 106 | + .expect(appointment.getAriaLabel()) |
| 107 | + .eql('Appointment: March 30, 2021, 5:00 AM - March 31, 2021, 6:00 AM'); |
| 108 | + await drag(); |
| 109 | + await t |
| 110 | + .expect(appointment.getAriaLabel()) |
| 111 | + .eql('Appointment: March 30, 2021, 5:00 AM - 6:00 AM'); |
| 112 | + }).before(async () => createScheduler({ |
| 113 | + timeZone: 'Europe/Berlin', |
| 114 | + dataSource: [{ |
| 115 | + text: 'Appointment', |
| 116 | + startDate: new Date('2021-03-30T03:00:00.000Z'), |
| 117 | + endDate: new Date('2021-04-01T03:00:00.000Z'), |
| 118 | + }], |
| 119 | + currentView: 'week', |
| 120 | + currentDate: new Date(2021, 2, 28), |
| 121 | + height: 400, |
| 122 | + offset: 360, |
| 123 | + rtlEnabled, |
| 124 | + firstDayOfWeek: 0, |
| 125 | + })); |
| 126 | + |
| 127 | + getTimezoneTest([MACHINE_TIMEZONES.EuropeBerlin])(`Resize long appointment startDate with offset rtlEnabled=${rtlEnabled}`, async (t) => { |
| 128 | + const scheduler = new Scheduler('#container'); |
| 129 | + const appointment = scheduler.getAppointment('Appointment'); |
| 130 | + const { left, right } = appointment.resizableHandle; |
| 131 | + const drag = async () => (rtlEnabled |
| 132 | + ? t.drag(right, -100, 0) |
| 133 | + : t.drag(left, 100, 0)); |
| 134 | + |
| 135 | + await drag(); |
| 136 | + await t |
| 137 | + .expect(appointment.getAriaLabel()) |
| 138 | + .eql('Appointment: March 30, 2021, 6:00 AM - April 1, 2021, 5:00 AM'); |
| 139 | + await drag(); |
| 140 | + await t |
| 141 | + .expect(appointment.getAriaLabel()) |
| 142 | + .eql('Appointment: March 31, 2021, 6:00 AM - April 1, 2021, 5:00 AM'); |
| 143 | + }).before(async () => createScheduler({ |
| 144 | + dataSource: [{ |
| 145 | + text: 'Appointment', |
| 146 | + startDate: new Date('2021-03-30T03:00:00.000Z'), |
| 147 | + endDate: new Date('2021-04-01T03:00:00.000Z'), |
| 148 | + }], |
| 149 | + currentView: 'week', |
| 150 | + currentDate: new Date('2021-03-30T03:00:00.000Z'), |
| 151 | + height: 400, |
| 152 | + offset: 360, |
| 153 | + rtlEnabled, |
| 154 | + firstDayOfWeek: 0, |
| 155 | + })); |
| 156 | +}); |
| 157 | + |
| 158 | +getTimezoneTest([MACHINE_TIMEZONES.EuropeBerlin])('Resize long appointment rtlEnabled=true', async (t) => { |
| 159 | + const scheduler = new Scheduler('#container'); |
| 160 | + const appointment = scheduler.getAppointment('Appointment'); |
| 161 | + const { left, right } = appointment.resizableHandle; |
| 162 | + |
| 163 | + await t |
| 164 | + .drag(right, 100, 0) |
| 165 | + .expect(appointment.getAriaLabel()) |
| 166 | + .eql('Appointment: February 8, 2015, 12:00 AM - February 10, 2015, 10:00 AM'); |
| 167 | + await t |
| 168 | + .drag(right, -100, 0) |
| 169 | + .expect(appointment.getAriaLabel()) |
| 170 | + .eql('Appointment: February 9, 2015, 12:00 AM - February 10, 2015, 10:00 AM'); |
| 171 | + await t |
| 172 | + .drag(left, -100, 0) |
| 173 | + .expect(appointment.getAriaLabel()) |
| 174 | + .eql('Appointment: February 9, 2015, 12:00 AM - February 12, 2015, 12:00 AM'); |
| 175 | + await t |
| 176 | + .drag(left, 100, 0) |
| 177 | + .expect(appointment.getAriaLabel()) |
| 178 | + .eql('Appointment: February 9, 2015, 12:00 AM - February 11, 2015, 12:00 AM'); |
| 179 | +}).before(async () => createScheduler({ |
| 180 | + currentDate: new Date(2015, 1, 9), |
| 181 | + currentView: 'week', |
| 182 | + firstDayOfWeek: 0, |
| 183 | + rtlEnabled: true, |
| 184 | + height: 400, |
| 185 | + dataSource: [{ |
| 186 | + text: 'Appointment', |
| 187 | + startDate: new Date(2015, 1, 9, 8), |
| 188 | + endDate: new Date(2015, 1, 10, 10), |
| 189 | + }], |
| 190 | +})); |
| 191 | + |
| 192 | +getTimezoneTest([MACHINE_TIMEZONES.EuropeBerlin])('Resize long appointment rtlEnabled=false', async (t) => { |
| 193 | + const scheduler = new Scheduler('#container'); |
| 194 | + const appointment = scheduler.getAppointment('Appointment'); |
| 195 | + const { left, right } = appointment.resizableHandle; |
| 196 | + |
| 197 | + await t |
| 198 | + .drag(right, 100, 0) |
| 199 | + .expect(appointment.getAriaLabel()) |
| 200 | + .eql('Appointment: February 9, 2015, 8:00 AM - February 12, 2015, 12:00 AM'); |
| 201 | + await t |
| 202 | + .drag(right, -100, 0) |
| 203 | + .expect(appointment.getAriaLabel()) |
| 204 | + .eql('Appointment: February 9, 2015, 8:00 AM - February 11, 2015, 12:00 AM'); |
| 205 | + await t |
| 206 | + .drag(left, -100, 0) |
| 207 | + .expect(appointment.getAriaLabel()) |
| 208 | + .eql('Appointment: February 8, 2015, 12:00 AM - February 11, 2015, 12:00 AM'); |
| 209 | + await t |
| 210 | + .drag(left, 100, 0) |
| 211 | + .expect(appointment.getAriaLabel()) |
| 212 | + .eql('Appointment: February 9, 2015, 12:00 AM - February 11, 2015, 12:00 AM'); |
| 213 | +}).before(async () => createScheduler({ |
| 214 | + currentDate: new Date(2015, 1, 9), |
| 215 | + currentView: 'week', |
| 216 | + firstDayOfWeek: 0, |
| 217 | + rtlEnabled: false, |
| 218 | + height: 400, |
| 219 | + dataSource: [{ |
| 220 | + text: 'Appointment', |
| 221 | + startDate: new Date(2015, 1, 9, 8), |
| 222 | + endDate: new Date(2015, 1, 10, 10), |
| 223 | + }], |
| 224 | +})); |
0 commit comments