summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/views/calendar_tests.js
diff options
context:
space:
mode:
authorRomeo Fragomeli <rfr@odoo.com>2020-03-18 09:19:05 +0000
committerPierre Paridans <app@odoo.com>2020-03-31 15:09:18 +0000
commit7b815c3bf28db3625c4d377eab6aec90867825be (patch)
treee7a99087f2f11218504e5ccac82f47d9a3c9d64c /addons/web/static/tests/views/calendar_tests.js
parentd57470387aa1a155e004aaebec7b8b66de581dcd (diff)
[FIX] web: calendar's drag-and-dropped event has wrong end-date
Due to previous commit, in month view, the flag marking events as "all day" is no more present and so some logic is not applied anymore. This results into the wrong end-date. With this commit we avoid to change the end date of an event in FullCalendar. Note that it changes the behavior on drag-and-dropped event in month view: * Before both the last and this commit, an event if 1H will become an "all day" event when it's dropped into another cell. * After them, the time will be the same as the original event and only the date will change. Also, one test was already added in commit odoo/odoo@7af13089dffcd3c9d98716af4aa76b923825fdfc to check that, in month view, when we move a non-"all day" event to another day, it can't change into a all day event. This commit adds a second test to cover the case when the "all day" mapping is present. Task ID: 2183249
Diffstat (limited to 'addons/web/static/tests/views/calendar_tests.js')
-rw-r--r--addons/web/static/tests/views/calendar_tests.js61
1 files changed, 61 insertions, 0 deletions
diff --git a/addons/web/static/tests/views/calendar_tests.js b/addons/web/static/tests/views/calendar_tests.js
index b6debe56f58..0de9c8e09dc 100644
--- a/addons/web/static/tests/views/calendar_tests.js
+++ b/addons/web/static/tests/views/calendar_tests.js
@@ -2857,6 +2857,67 @@ QUnit.module('Views', {
calendar.destroy();
});
+ QUnit.test("drag and drop on month mode with all_day mapping", async function (assert) {
+ // Same test as before but in calendarEventToRecord (calendar_model.js) there is
+ // different condition branching with all_day mapping or not
+ assert.expect(2);
+
+ const calendar = await createCalendarView({
+ arch:
+ `<calendar date_start="start" date_stop="stop" mode="month" event_open_popup="true" quick_add="False" all_day="allday">
+ <field name="name"/>
+ <field name="partner_id"/>
+ </calendar>`,
+ archs: archs,
+ data: this.data,
+ model: 'event',
+ View: CalendarView,
+ viewOptions: { initialDate: initialDate },
+ });
+
+ // Create event (on 20 december)
+ var $cell = calendar.$('.fc-day-grid .fc-row:eq(3) .fc-day:eq(2)');
+ testUtils.triggerMouseEvent($cell, "mousedown");
+ testUtils.triggerMouseEvent($cell, "mouseup");
+ await testUtils.nextTick();
+ var $input = $('.modal-body input:first');
+ await testUtils.fields.editInput($input, "An event");
+ await testUtils.dom.click($('.o_field_widget[name="allday"] input'));
+ await testUtils.nextTick();
+
+ // use datepicker to enter a date: 12/20/2016 07:00:00
+ testUtils.dom.openDatepicker($('.o_field_widget[name="start"].o_datepicker'));
+ await testUtils.dom.click($('.bootstrap-datetimepicker-widget .picker-switch a[data-action="togglePicker"]'));
+ await testUtils.dom.click($('.bootstrap-datetimepicker-widget .timepicker .timepicker-hour'));
+ await testUtils.dom.click($('.bootstrap-datetimepicker-widget .timepicker-hours td.hour:contains(07)'));
+ await testUtils.dom.click($('.bootstrap-datetimepicker-widget .picker-switch a[data-action="close"]'));
+
+ // use datepicker to enter a date: 12/20/2016 19:00:00
+ testUtils.dom.openDatepicker($('.o_field_widget[name="stop"].o_datepicker'));
+ await testUtils.dom.click($('.bootstrap-datetimepicker-widget .picker-switch a[data-action="togglePicker"]'));
+ await testUtils.dom.click($('.bootstrap-datetimepicker-widget .timepicker .timepicker-hour'));
+ await testUtils.dom.click($('.bootstrap-datetimepicker-widget .timepicker-hours td.hour:contains(19)'));
+ await testUtils.dom.click($('.bootstrap-datetimepicker-widget .picker-switch a[data-action="close"]'));
+
+ await testUtils.dom.click($('.modal button.btn-primary'));
+ await testUtils.nextTick();
+
+ // Move event to another day (on 19 december)
+ await testUtils.dragAndDrop(
+ calendar.$('.fc-event:contains("An event")'),
+ calendar.$('.fc-day-grid .fc-row:eq(3) .fc-day-top:eq(1)')
+ );
+ await testUtils.nextTick();
+ await testUtils.dom.click(calendar.$('.fc-event:contains("An event")'));
+
+ assert.containsOnce(calendar, '.popover:contains("07:00")',
+ "start hour shouldn't have been changed");
+ assert.containsOnce(calendar, '.popover:contains("19:00")',
+ "end hour shouldn't have been changed");
+
+ calendar.destroy();
+ });
+
QUnit.test('drag and drop on month mode with date_start and date_delay', async function (assert) {
assert.expect(1);