From f42f2f648a14487fe4f0980aeda97bade33eb9ee Mon Sep 17 00:00:00 2001 From: Yana Yarovaya Date: Thu, 23 Jan 2020 11:36:35 +0300 Subject: [PATCH 1/4] Add test --- js/ui/scheduler/ui.scheduler.subscribes.js | 2 +- .../integration.appointments.tests.js | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/js/ui/scheduler/ui.scheduler.subscribes.js b/js/ui/scheduler/ui.scheduler.subscribes.js index 36d30630ec19..703e71f65738 100644 --- a/js/ui/scheduler/ui.scheduler.subscribes.js +++ b/js/ui/scheduler/ui.scheduler.subscribes.js @@ -778,7 +778,7 @@ const subscribes = { extend(true, result, appointmentData, recurringData); - if(this._isAppointmentRecurrence(appointmentData) && !skipTimezoneConvert) { + if(this._isAppointmentRecurrence(appointmentData)) { this._convertDatesByTimezoneBack(false, result); // TODO: temporary solution fox fix T848058, more information in the ticket } diff --git a/testing/tests/DevExpress.ui.widgets.scheduler/integration.appointments.tests.js b/testing/tests/DevExpress.ui.widgets.scheduler/integration.appointments.tests.js index ffce3bb4d4c4..1e3977f76c22 100644 --- a/testing/tests/DevExpress.ui.widgets.scheduler/integration.appointments.tests.js +++ b/testing/tests/DevExpress.ui.widgets.scheduler/integration.appointments.tests.js @@ -4032,6 +4032,24 @@ QUnit.module('Appointments', () => { assert.ok(eventCallCount === 5, 'appointmentTooltipTemplate should be raised'); }); + + QUnit.test('model.targetedAppointmentData argument should have current appointment data in case hourly recurrence in collector, custom timezone is set', function(assert) { + const scheduler = createScheduler(hourlyRecurrenceData, { + textExpr: 'textCustom', + startDateExpr: 'startDateCustom', + endDateExpr: 'endDateCustom', + currentView: 'week', + timeZone: 'Asia/Yekaterinburg' + }); + + scheduler.option({ appointmentTooltipTemplate: createTestForHourlyRecurrenceData(assert, scheduler) }); + + for(let i = 0; i < 5; i++) { + scheduler.appointments.compact.click(i); + } + + assert.ok(eventCallCount === 5, 'appointmentTooltipTemplate should be raised'); + }); }); QUnit.test('Remote filter should apply after change view type', function(assert) { From 4fcc40773973fb850e744cc5c288cd98d0678918 Mon Sep 17 00:00:00 2001 From: Yana Yarovaya Date: Thu, 23 Jan 2020 11:39:37 +0300 Subject: [PATCH 2/4] Refactoring --- js/ui/scheduler/ui.scheduler.appointments.js | 2 +- js/ui/scheduler/ui.scheduler.subscribes.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/js/ui/scheduler/ui.scheduler.appointments.js b/js/ui/scheduler/ui.scheduler.appointments.js index 51173a2ab6ea..a5927a9da9d5 100644 --- a/js/ui/scheduler/ui.scheduler.appointments.js +++ b/js/ui/scheduler/ui.scheduler.appointments.js @@ -719,7 +719,7 @@ const SchedulerAppointments = CollectionWidget.inherit({ }; } - appointmentSetting.targetedAppointmentData = this.invoke('getTargetedAppointmentData', appointmentData, $appointment, true); + appointmentSetting.targetedAppointmentData = this.invoke('getTargetedAppointmentData', appointmentData, $appointment); this._virtualAppointments[virtualGroupIndex].items.settings.push(appointmentSetting); this._virtualAppointments[virtualGroupIndex].items.data.push(appointmentData); diff --git a/js/ui/scheduler/ui.scheduler.subscribes.js b/js/ui/scheduler/ui.scheduler.subscribes.js index 703e71f65738..bded96c8d134 100644 --- a/js/ui/scheduler/ui.scheduler.subscribes.js +++ b/js/ui/scheduler/ui.scheduler.subscribes.js @@ -765,7 +765,7 @@ const subscribes = { return SchedulerTimezones.getTimezonesIdsByDisplayName(displayName); }, - getTargetedAppointmentData: function(appointmentData, appointmentElement, skipTimezoneConvert) { + getTargetedAppointmentData: function(appointmentData, appointmentElement) { const $appointmentElement = $(appointmentElement); const appointmentIndex = $appointmentElement.data(this._appointments._itemIndexKey()); From 41d12ab6a1080c87904654842e9a0e6faad1d719 Mon Sep 17 00:00:00 2001 From: Yana Yarovaya Date: Fri, 24 Jan 2020 11:39:53 +0300 Subject: [PATCH 3/4] Make matrix tests --- .../integration.appointments.tests.js | 119 +++++++++--------- 1 file changed, 57 insertions(+), 62 deletions(-) diff --git a/testing/tests/DevExpress.ui.widgets.scheduler/integration.appointments.tests.js b/testing/tests/DevExpress.ui.widgets.scheduler/integration.appointments.tests.js index 1e3977f76c22..00f853f2cd5a 100644 --- a/testing/tests/DevExpress.ui.widgets.scheduler/integration.appointments.tests.js +++ b/testing/tests/DevExpress.ui.widgets.scheduler/integration.appointments.tests.js @@ -3841,7 +3841,6 @@ QUnit.module('Appointments', () => { return (model, index, container) => { const { appointmentData, targetedAppointmentData } = model; - const startDateExpr = scheduler.option('startDateExpr'); const endDateExpr = scheduler.option('endDateExpr'); const textExpr = scheduler.option('textExpr'); @@ -3983,72 +3982,68 @@ QUnit.module('Appointments', () => { }); QUnit.module('appointmentTooltipTemplate', () => { - QUnit.test('model.targetedAppointmentData argument should have current appointment data', function(assert) { - const scheduler = createScheduler(commonData); - scheduler.option({ appointmentTooltipTemplate: createTestForCommonData(assert, true) }); - - for(let i = 0; i < 5; i++) { - scheduler.appointments.click(i); - } - - assert.ok(eventCallCount === 5, 'appointmentTemplate should be raised'); - }); - - QUnit.test('model.targetedAppointmentData argument should have current appointment data in case recurrence', function(assert) { - const scheduler = createScheduler(recurrenceData); - scheduler.option({ appointmentTooltipTemplate: createTestForRecurrenceData(assert, scheduler) }); - - for(let i = 0; i < 5; i++) { - scheduler.appointments.click(i); - } - - assert.ok(eventCallCount === 5, 'appointmentTooltipTemplate should be raised'); - }); - - QUnit.test('model.targetedAppointmentData argument should have current appointment data in case recurrence in collector', function(assert) { - const scheduler = createScheduler(recurrenceAndCompactData); - scheduler.option({ appointmentTooltipTemplate: createTestForRecurrenceData(assert, scheduler) }); - - for(let i = 0; i < 5; i++) { - scheduler.appointments.compact.click(i); + const cases = [ + { + data: commonData, + setAppointmentTooltip: (assert, scheduler) => { + scheduler.option('appointmentTooltipTemplate', createTestForCommonData(assert, true)); + }, + name: 'common' + }, + { + data: recurrenceData, + setAppointmentTooltip: (assert, scheduler) => { + scheduler.option('appointmentTooltipTemplate', createTestForRecurrenceData(assert, scheduler)); + }, + name: 'recurrence' + }, + { + data: recurrenceAndCompactData, + setAppointmentTooltip: (assert, scheduler) => { + scheduler.option('appointmentTooltipTemplate', createTestForRecurrenceData(assert, scheduler)); + }, + name: 'recurrence in collector' + }, + { + data: hourlyRecurrenceData, + options: { + textExpr: 'textCustom', + startDateExpr: 'startDateCustom', + endDateExpr: 'endDateCustom', + currentView: 'week' + }, + setAppointmentTooltip: (assert, scheduler) => { + scheduler.option('appointmentTooltipTemplate', createTestForHourlyRecurrenceData(assert, scheduler)); + }, + name: 'hourly recurrence in collector' + }, + { + data: hourlyRecurrenceData, + options: { + textExpr: 'textCustom', + startDateExpr: 'startDateCustom', + endDateExpr: 'endDateCustom', + currentView: 'week', + timeZone: 'Asia/Yekaterinburg' + }, + setAppointmentTooltip: (assert, scheduler) => { + scheduler.option('appointmentTooltipTemplate', createTestForHourlyRecurrenceData(assert, scheduler)); + }, + name: 'hourly recurrence in collector, custom timezone is set' } + ]; - assert.ok(eventCallCount === 5, 'appointmentTooltipTemplate should be raised'); - }); - - QUnit.test('model.targetedAppointmentData argument should have current appointment data in case hourly recurrence in collector', function(assert) { - const scheduler = createScheduler(hourlyRecurrenceData, { - textExpr: 'textCustom', - startDateExpr: 'startDateCustom', - endDateExpr: 'endDateCustom', - currentView: 'week' - }); - - scheduler.option({ appointmentTooltipTemplate: createTestForHourlyRecurrenceData(assert, scheduler) }); - - for(let i = 0; i < 5; i++) { - scheduler.appointments.compact.click(i); - } + cases.forEach(testCase => { + QUnit.test(`model.targetedAppointmentData argument should have current appointment data, ${testCase.name} case`, function(assert) { + const scheduler = createScheduler(testCase.data, testCase.options); + testCase.setAppointmentTooltip(assert, scheduler); - assert.ok(eventCallCount === 5, 'appointmentTooltipTemplate should be raised'); - }); + for(let i = 0; i < 5; i++) { + scheduler.appointments.click(i); + } - QUnit.test('model.targetedAppointmentData argument should have current appointment data in case hourly recurrence in collector, custom timezone is set', function(assert) { - const scheduler = createScheduler(hourlyRecurrenceData, { - textExpr: 'textCustom', - startDateExpr: 'startDateCustom', - endDateExpr: 'endDateCustom', - currentView: 'week', - timeZone: 'Asia/Yekaterinburg' + assert.ok(eventCallCount === 5, 'appointmentTemplate should be raised'); }); - - scheduler.option({ appointmentTooltipTemplate: createTestForHourlyRecurrenceData(assert, scheduler) }); - - for(let i = 0; i < 5; i++) { - scheduler.appointments.compact.click(i); - } - - assert.ok(eventCallCount === 5, 'appointmentTooltipTemplate should be raised'); }); }); From 5709f7c12d96a726532bb458c17d8df543ce452d Mon Sep 17 00:00:00 2001 From: Yana Yarovaya Date: Sat, 25 Jan 2020 21:25:23 +0300 Subject: [PATCH 4/4] Small fix --- .../integration.appointments.tests.js | 24 ++++++------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/testing/tests/DevExpress.ui.widgets.scheduler/integration.appointments.tests.js b/testing/tests/DevExpress.ui.widgets.scheduler/integration.appointments.tests.js index 00f853f2cd5a..d4e5a9870e90 100644 --- a/testing/tests/DevExpress.ui.widgets.scheduler/integration.appointments.tests.js +++ b/testing/tests/DevExpress.ui.widgets.scheduler/integration.appointments.tests.js @@ -3821,7 +3821,7 @@ QUnit.module('Appointments', () => { return createWrapper($.extend(config, options)); }; - const createTestForCommonData = (assert, skipCallCount = false) => { + const createTestForCommonData = (assert, scheduler, skipCallCount = false) => { eventCallCount = 0; return (model, index, container) => { @@ -3985,23 +3985,17 @@ QUnit.module('Appointments', () => { const cases = [ { data: commonData, - setAppointmentTooltip: (assert, scheduler) => { - scheduler.option('appointmentTooltipTemplate', createTestForCommonData(assert, true)); - }, + appointmentTooltip: createTestForCommonData, name: 'common' }, { data: recurrenceData, - setAppointmentTooltip: (assert, scheduler) => { - scheduler.option('appointmentTooltipTemplate', createTestForRecurrenceData(assert, scheduler)); - }, + appointmentTooltip: createTestForRecurrenceData, name: 'recurrence' }, { data: recurrenceAndCompactData, - setAppointmentTooltip: (assert, scheduler) => { - scheduler.option('appointmentTooltipTemplate', createTestForRecurrenceData(assert, scheduler)); - }, + appointmentTooltip: createTestForRecurrenceData, name: 'recurrence in collector' }, { @@ -4012,9 +4006,7 @@ QUnit.module('Appointments', () => { endDateExpr: 'endDateCustom', currentView: 'week' }, - setAppointmentTooltip: (assert, scheduler) => { - scheduler.option('appointmentTooltipTemplate', createTestForHourlyRecurrenceData(assert, scheduler)); - }, + appointmentTooltip: createTestForHourlyRecurrenceData, name: 'hourly recurrence in collector' }, { @@ -4026,9 +4018,7 @@ QUnit.module('Appointments', () => { currentView: 'week', timeZone: 'Asia/Yekaterinburg' }, - setAppointmentTooltip: (assert, scheduler) => { - scheduler.option('appointmentTooltipTemplate', createTestForHourlyRecurrenceData(assert, scheduler)); - }, + appointmentTooltip: createTestForHourlyRecurrenceData, name: 'hourly recurrence in collector, custom timezone is set' } ]; @@ -4036,7 +4026,7 @@ QUnit.module('Appointments', () => { cases.forEach(testCase => { QUnit.test(`model.targetedAppointmentData argument should have current appointment data, ${testCase.name} case`, function(assert) { const scheduler = createScheduler(testCase.data, testCase.options); - testCase.setAppointmentTooltip(assert, scheduler); + scheduler.option('appointmentTooltipTemplate', testCase.appointmentTooltip(assert, scheduler, true)); for(let i = 0; i < 5; i++) { scheduler.appointments.click(i);