-
Notifications
You must be signed in to change notification settings - Fork 607
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Scheduler - The 'Cannot read properties of undefined (reading 'getTim…
…e')' error is thrown on an attempt to drag an outside element if the previous drag operation was canceled (T1263508) (#28582)
- Loading branch information
1 parent
7f51ac1
commit 8ae9799
Showing
3 changed files
with
115 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
packages/devextreme/testing/testcafe/tests/scheduler/dragAndDrop/T1263508.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
import { ClientFunction, Selector } from 'testcafe'; | ||
import Scheduler from '../../../model/scheduler'; | ||
import { MouseAction, MouseUpEvents } from '../../../helpers/mouseUpEvents'; | ||
import { createWidget } from '../../../helpers/createWidget'; | ||
import url from '../../../helpers/getPageUrl'; | ||
|
||
fixture.disablePageReloads`Scheduler Drag-and-Drop Fix` | ||
.page(url(__dirname, '../../container.html')); | ||
|
||
const DRAGGABLE_ITEM_CLASS = 'dx-card'; | ||
const draggingGroupName = 'appointmentsGroup'; | ||
|
||
const initList = ClientFunction(() => { | ||
$('<div>', { id: 'list' }).appendTo('#parentContainer'); | ||
}); | ||
|
||
const removeList = ClientFunction(() => { | ||
$('#list').remove(); | ||
}); | ||
|
||
const addTasksToList = ClientFunction((tasks) => { | ||
tasks.forEach((task) => { | ||
$('<div>', { | ||
class: 'dx-card', | ||
text: task.text, | ||
}).appendTo('#list'); | ||
}); | ||
}); | ||
|
||
const createItemElement = async (task) => { | ||
await createWidget('dxDraggable', { | ||
group: draggingGroupName, | ||
data: task, | ||
clone: true, | ||
onDragStart(e) { | ||
e.itemData = e.fromData; | ||
}, | ||
}, `.${DRAGGABLE_ITEM_CLASS}:contains(${task.text})`); | ||
}; | ||
|
||
test('Scheduler - The \'Cannot read properties of undefined (reading \'getTime\')\' error is thrown on an attempt to drag an outside element if the previous drag operation was canceled', async (t) => { | ||
const scheduler = new Scheduler('#container'); | ||
const draggableAppointment = scheduler.getAppointment('Book').element; | ||
const targetCell = scheduler.getDateTableCell(5, 0); | ||
const draggableItem = Selector(`.${DRAGGABLE_ITEM_CLASS}`).withText('Brochures'); | ||
|
||
await t.expect(scheduler.element.exists).ok(); | ||
|
||
await MouseUpEvents.disable(MouseAction.dragToElement); | ||
|
||
await t | ||
.dragToElement(draggableAppointment, targetCell) | ||
.pressKey('esc'); | ||
|
||
await MouseUpEvents.enable(MouseAction.dragToElement); | ||
|
||
await t | ||
.expect(draggableItem.exists) | ||
.ok() | ||
.dragToElement(draggableItem, targetCell); | ||
|
||
const newAppointment = scheduler.getAppointment('Brochures'); | ||
|
||
await t | ||
.expect(newAppointment.element.exists) | ||
.ok(); | ||
}).before(async () => { | ||
const tasks = [ | ||
{ text: 'Brochures' }, | ||
]; | ||
|
||
await initList(); | ||
await addTasksToList(tasks); | ||
await Promise.all(tasks.map((task) => createItemElement(task))); | ||
await createWidget('dxScheduler', { | ||
timeZone: 'America/Los_Angeles', | ||
dataSource: [ | ||
{ | ||
text: 'Book', | ||
startDate: new Date('2021-04-26T19:00:00.000Z'), | ||
endDate: new Date('2021-04-26T20:00:00.000Z'), | ||
}, | ||
], | ||
currentDate: new Date(2021, 3, 26), | ||
startDayHour: 9, | ||
height: 600, | ||
editing: true, | ||
appointmentDragging: { | ||
group: draggingGroupName, | ||
onDragEnd(e) { | ||
e.cancel = e.event.ctrlKey; | ||
}, | ||
onRemove(e) { | ||
e.component.deleteAppointment(e.itemData); | ||
}, | ||
onAdd(e) { | ||
e.component.addAppointment(e.itemData); | ||
}, | ||
}, | ||
}); | ||
}).after(async () => { | ||
await removeList(); | ||
}); |