Skip to content

Commit c92bbab

Browse files
author
Maksim Zakharov
committed
test(scheduler): await save before asserting in popup tests
1 parent 17bdcd8 commit c92bbab

6 files changed

Lines changed: 33 additions & 0 deletions

File tree

packages/devextreme/js/__internal/scheduler/__tests__/__mock__/create_appointment_popup.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ export const createAppointmentPopup = async (
130130
getTimeZoneCalculator: (): typeof timeZoneCalculator => timeZoneCalculator,
131131
};
132132

133+
// @ts-expect-error // TODO: redo changed Scheduler popup api
133134
const form = new AppointmentForm(formSchedulerProxy);
134135

135136
const noop = (): void => { };

packages/devextreme/js/__internal/scheduler/__tests__/scheduler.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ describe('Scheduler scrollTo', () => {
109109
const item = (scheduler as any).getDataSource().items()[0];
110110
scheduler.showAppointmentPopup(item);
111111
POM.popup.saveButton.click();
112+
await Promise.resolve();
112113

113114
expect(scrollLeftBeforeSave).toBe(0);
114115
expect(scrollableContainer.scrollLeft).toBeGreaterThan(0);

packages/devextreme/js/__internal/scheduler/appointment_popup/appointment_popup.integration.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ describe('Appointment Form', () => {
8585
scheduler.showAppointmentPopup(item);
8686
POM.popup.setInputValue('subjectEditor', 'New Subject');
8787
POM.popup.saveButton.click();
88+
await Promise.resolve();
8889

8990
expect(dataSource.items()[0]).toMatchObject({
9091
...commonAppointment,
@@ -121,6 +122,7 @@ describe('Appointment Form', () => {
121122
POM.popup.setInputValue('subjectEditor', 'New Subject');
122123
POM.popup.recurrenceSettingsButton.click();
123124
POM.popup.saveButton.click();
125+
await Promise.resolve();
124126

125127
expect(dataSource.items()[0]).toMatchObject({
126128
...recurringAppointment,
@@ -156,6 +158,7 @@ describe('Appointment Form', () => {
156158
scheduler.showAppointmentPopup(item);
157159
POM.popup.selectRepeatValue('daily');
158160
POM.popup.saveButton.click();
161+
await Promise.resolve();
159162

160163
expect(dataSource.items()[0]).toMatchObject({
161164
...commonAppointment,
@@ -190,6 +193,7 @@ describe('Appointment Form', () => {
190193
scheduler.showAppointmentPopup(item);
191194
POM.popup.editSeriesButton.click();
192195
POM.popup.saveButton.click();
196+
await Promise.resolve();
193197

194198
expect(dataSource.items()[0]).toMatchObject(recurringAppointment);
195199
});
@@ -207,6 +211,7 @@ describe('Appointment Form', () => {
207211
POM.popup.editSeriesButton.click();
208212
POM.popup.selectRepeatValue('never');
209213
POM.popup.saveButton.click();
214+
await Promise.resolve();
210215

211216
expect(dataSource.items()[0]).toMatchObject({
212217
...recurringAppointment,
@@ -297,6 +302,7 @@ describe('Appointment Form', () => {
297302
scheduler.showAppointmentPopup(item);
298303
POM.popup.setInputValue('roomId', 2);
299304
POM.popup.saveButton.click();
305+
await Promise.resolve();
300306

301307
expect(dataSource.items()[0].roomId).toBe(2);
302308
});
@@ -344,6 +350,7 @@ describe('Appointment Form', () => {
344350

345351
POM.popup.setInputValue(editorName, null);
346352
POM.popup.saveButton.click();
353+
await Promise.resolve();
347354

348355
expect(POM.isPopupVisible()).toBe(true);
349356
});
@@ -358,6 +365,7 @@ describe('Appointment Form', () => {
358365
POM.popup.setInputValue(editorName, null);
359366
POM.popup.selectRepeatValue('daily');
360367
POM.popup.saveButton.click();
368+
await Promise.resolve();
361369

362370
expect(POM.isPopupVisible()).toBe(true);
363371
});
@@ -373,6 +381,7 @@ describe('Appointment Form', () => {
373381
expect(POM.popup.getInputValue('recurrenceStartDateEditor')).toBe('5/9/2017');
374382

375383
POM.popup.saveButton.click();
384+
await Promise.resolve();
376385

377386
expect(POM.isPopupVisible()).toBe(false);
378387
});
@@ -1888,6 +1897,7 @@ describe('Appointment Form', () => {
18881897

18891898
scheduler.showAppointmentPopup({ ...commonAppointment }, true);
18901899
POM.popup.saveButton.click();
1900+
await Promise.resolve();
18911901

18921902
expect(addAppointmentSpy).toHaveBeenCalledTimes(1);
18931903
expect(addAppointmentSpy).toHaveBeenCalledWith(
@@ -1903,6 +1913,7 @@ describe('Appointment Form', () => {
19031913

19041914
scheduler.showAppointmentPopup({ ...commonAppointment }, true);
19051915
POM.popup.saveButton.click();
1916+
await Promise.resolve();
19061917

19071918
const dataSource = (scheduler as any).getDataSource();
19081919
expect(dataSource.items().length).toBe(0);
@@ -1916,6 +1927,7 @@ describe('Appointment Form', () => {
19161927

19171928
scheduler.showAppointmentPopup({ ...commonAppointment }, true);
19181929
POM.popup.saveButton.click();
1930+
await Promise.resolve();
19191931

19201932
const dataSource = (scheduler as any).getDataSource();
19211933
expect(dataSource.items().length).toBe(1);
@@ -1936,6 +1948,7 @@ describe('Appointment Form', () => {
19361948
scheduler.showAppointmentPopup(updatedItem);
19371949
POM.popup.setInputValue('subjectEditor', 'Updated Subject');
19381950
POM.popup.saveButton.click();
1951+
await Promise.resolve();
19391952

19401953
expect(updateAppointmentSpy).toHaveBeenCalledTimes(1);
19411954
expect(updateAppointmentSpy).toHaveBeenCalledWith(updatedItem, updatedItem);
@@ -1953,6 +1966,7 @@ describe('Appointment Form', () => {
19531966
scheduler.showAppointmentPopup(updatedItem);
19541967
POM.popup.setInputValue('subjectEditor', 'Updated Subject');
19551968
POM.popup.saveButton.click();
1969+
await Promise.resolve();
19561970

19571971
expect(dataSource.items()[0]).toEqual(commonAppointment);
19581972
});
@@ -1969,6 +1983,7 @@ describe('Appointment Form', () => {
19691983
scheduler.showAppointmentPopup(updatedItem);
19701984
POM.popup.setInputValue('subjectEditor', 'New Subject');
19711985
POM.popup.saveButton.click();
1986+
await Promise.resolve();
19721987

19731988
expect(dataSource.items()[0]).toEqual({
19741989
allDay: false,

packages/devextreme/js/__internal/scheduler/appointment_popup/appointment_popup.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ describe('Isolated AppointmentPopup environment', () => {
5454
});
5555

5656
POM.saveButton.click();
57+
await new Promise(process.nextTick);
5758

5859
expect(callbacks.onSave).toHaveBeenCalledTimes(1);
5960
expect(callbacks.onSave).toHaveBeenCalledWith(
@@ -75,6 +76,7 @@ describe('Isolated AppointmentPopup environment', () => {
7576
});
7677

7778
POM.saveButton.click();
79+
await new Promise(process.nextTick);
7880

7981
expect(callbacks.addAppointment).not.toHaveBeenCalled();
8082
expect(callbacks.updateAppointment).not.toHaveBeenCalled();
@@ -139,6 +141,7 @@ describe('Isolated AppointmentPopup environment', () => {
139141
});
140142

141143
POM.saveButton.click();
144+
await new Promise(process.nextTick);
142145

143146
expect(onSave).toHaveBeenCalledTimes(1);
144147
expect(updateAppointment).toHaveBeenCalledWith(sourceAppointment, updatedAppointment);

packages/devextreme/testing/tests/DevExpress.ui.widgets.scheduler/appointment.scroll.tests.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ module('Integration: Appointment scroll', {
8080
try {
8181
scheduler.instance.showAppointmentPopup(appointment);
8282
$('.dx-scheduler-appointment-popup .dx-popup-done').trigger('dxclick');
83+
await Promise.resolve();
8384

8485
assert.ok(scrollToSpy.calledOnce, 'scrollTo was called');
8586
} finally {
@@ -105,6 +106,7 @@ module('Integration: Appointment scroll', {
105106
try {
106107
scheduler.instance.showAppointmentPopup(appointment);
107108
$('.dx-scheduler-appointment-popup .dx-popup-done').trigger('dxclick');
109+
await Promise.resolve();
108110

109111
assert.ok(scrollToSpy.calledOnce, 'scrollTo was called');
110112
} finally {
@@ -131,6 +133,7 @@ module('Integration: Appointment scroll', {
131133
try {
132134
scheduler.instance.showAppointmentPopup(appointment);
133135
$('.dx-scheduler-appointment-popup .dx-popup-done').trigger('dxclick');
136+
await Promise.resolve();
134137

135138
assert.notOk(scrollTo.calledOnce, 'scrollTo was not called');
136139
} finally {
@@ -156,6 +159,7 @@ module('Integration: Appointment scroll', {
156159
try {
157160
scheduler.instance.showAppointmentPopup(appointment);
158161
$('.dx-scheduler-appointment-popup .dx-popup-done').trigger('dxclick');
162+
await Promise.resolve();
159163

160164
assert.ok(scrollToSpy.calledOnce, 'scrollTo was called');
161165
} finally {
@@ -182,6 +186,7 @@ module('Integration: Appointment scroll', {
182186
try {
183187
scheduler.instance.showAppointmentPopup(appointment);
184188
$('.dx-scheduler-appointment-popup .dx-popup-done').trigger('dxclick');
189+
await Promise.resolve();
185190

186191
assert.ok(scrollToSpy.calledOnce, 'scrollTo was called');
187192
} finally {
@@ -211,6 +216,7 @@ module('Integration: Appointment scroll', {
211216
try {
212217
scheduler.instance.showAppointmentPopup(appointment);
213218
$('.dx-scheduler-appointment-popup .dx-popup-done').trigger('dxclick');
219+
await Promise.resolve();
214220

215221
assert.ok(scrollToSpy.calledOnce, 'scrollTo was called');
216222
} finally {
@@ -239,6 +245,7 @@ module('Integration: Appointment scroll', {
239245
try {
240246
scheduler.instance.showAppointmentPopup(appointment);
241247
$('.dx-scheduler-appointment-popup .dx-popup-done').trigger('dxclick');
248+
await Promise.resolve();
242249

243250
assert.ok(scrollToSpy.calledOnce, 'scrollTo was called');
244251
} finally {

packages/devextreme/testing/tests/DevExpress.ui.widgets.scheduler/timezones.tests.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ module('API', moduleConfig, () => {
265265

266266
scheduler.instance.showAppointmentPopup(appointment, true);
267267
$('.dx-scheduler-appointment-popup .dx-popup-done').trigger('dxclick');
268+
await Promise.resolve();
268269

269270
const $appointment = scheduler.instance.$element().find(CLASSES.appointment);
270271
const startDate = $appointment.dxSchedulerAppointment('instance').option('startDate');
@@ -294,6 +295,7 @@ module('API', moduleConfig, () => {
294295
scheduler.instance.showAppointmentPopup(updatedItem);
295296

296297
$('.dx-scheduler-appointment-popup .dx-popup-done').trigger('dxclick');
298+
await Promise.resolve();
297299

298300
hide();
299301

@@ -1431,6 +1433,7 @@ module('Scheduler grid', moduleConfigWithClock, () => {
14311433

14321434
scheduler.instance.showAppointmentPopup(appointment);
14331435
$('.dx-scheduler-appointment-popup .dx-popup-done').trigger('dxclick');
1436+
await Promise.resolve();
14341437

14351438
assert.notOk(scrollToSpy.calledOnce, 'scrollTo was not called');
14361439
} finally {
@@ -1460,6 +1463,7 @@ module('Scheduler grid', moduleConfigWithClock, () => {
14601463
try {
14611464
scheduler.instance.showAppointmentPopup(appointment);
14621465
$('.dx-scheduler-appointment-popup .dx-popup-done').trigger('dxclick');
1466+
await Promise.resolve();
14631467

14641468
assert.ok(scrollToSpy.calledOnce, 'scrollTo was called');
14651469
} finally {
@@ -1723,6 +1727,7 @@ module('Appointment popup', moduleConfig, () => {
17231727
scheduler.instance.showAppointmentPopup(updatedItem);
17241728

17251729
$('.dx-scheduler-appointment-popup .dx-popup-done').trigger('dxclick');
1730+
await Promise.resolve();
17261731

17271732
assert.ok(updateAppointment.calledOnce, 'Update method is called');
17281733
assert.deepEqual(updateAppointment.getCall(0).args[0], updatedItem, 'Target item is correct');
@@ -1984,6 +1989,7 @@ module('Fixed client time zone offset', () => {
19841989
const initialPosition = $appointment.position();
19851990

19861991
$('.dx-scheduler-appointment-popup .dx-popup-done').trigger('dxclick');
1992+
await Promise.resolve();
19871993
const updatedPosition = $(scheduler.getElement()).find(CLASSES.appointment).not('.dx-scheduler-appointment-recurrence').position();
19881994

19891995
assert.equal(updatedPosition.top, initialPosition.top, 'Top is updated correctly');

0 commit comments

Comments
 (0)