From 1edeff8408ad1b5940cdf0d4e4ea983c0c166118 Mon Sep 17 00:00:00 2001 From: Maksim Zakharov <251575087+bit-byte0@users.noreply.github.com> Date: Thu, 21 May 2026 21:48:19 +0400 Subject: [PATCH] test(scheduler): add regression test for redundant CustomStore load on popup reopen --- .../appointment_popup.integration.test.ts | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/packages/devextreme/js/__internal/scheduler/appointment_popup/appointment_popup.integration.test.ts b/packages/devextreme/js/__internal/scheduler/appointment_popup/appointment_popup.integration.test.ts index 8278e2c5afd0..1493130f0fab 100644 --- a/packages/devextreme/js/__internal/scheduler/appointment_popup/appointment_popup.integration.test.ts +++ b/packages/devextreme/js/__internal/scheduler/appointment_popup/appointment_popup.integration.test.ts @@ -976,6 +976,10 @@ describe('Appointment Form', () => { }); describe('Resources', () => { + afterEach(() => { + jest.useRealTimers(); + }); + it('should have correct resource editor value', async () => { const { scheduler, POM } = await createScheduler({ ...getDefaultConfig(), @@ -1197,6 +1201,41 @@ describe('Appointment Form', () => { expect(byKeySpy).toHaveBeenCalledTimes(0); }); + it('should not trigger extra CustomStore load on second popup open', async () => { + const loadFn = jest.fn().mockImplementation(() => Promise.resolve([ + { text: 'Owner 1', id: 1 }, + { text: 'Owner 2', id: 2 }, + ])); + const resourceDataSource = new CustomStore({ + load: loadFn as any, + byKey: () => {}, + }); + + const { scheduler } = await createScheduler({ + ...getDefaultConfig(), + dataSource: [{ + text: 'Resource test app', + startDate: new Date(2017, 4, 9, 9, 30), + endDate: new Date(2017, 4, 9, 11), + ownerId: 1, + }], + resources: [{ + fieldExpr: 'ownerId', + dataSource: resourceDataSource, + }], + }); + + jest.useFakeTimers(); + + const appointment = (scheduler as any).getDataSource().items()[0]; + scheduler.showAppointmentPopup(appointment); + scheduler.hideAppointmentPopup(false); + scheduler.showAppointmentPopup(appointment); + await jest.runAllTimersAsync(); + + expect(loadFn).toHaveBeenCalledTimes(1); + }); + it('should recreate appointment form synchronously when resources option changes', async () => { const { scheduler } = await createScheduler({ ...getDefaultConfig(),