Skip to content

Commit 637b10a

Browse files
authored
Scheduler - Appointment popup may send redundant resource load requests on every opening (DevExpress#33667)
1 parent 8834ef2 commit 637b10a

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

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

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -976,6 +976,10 @@ describe('Appointment Form', () => {
976976
});
977977

978978
describe('Resources', () => {
979+
afterEach(() => {
980+
jest.useRealTimers();
981+
});
982+
979983
it('should have correct resource editor value', async () => {
980984
const { scheduler, POM } = await createScheduler({
981985
...getDefaultConfig(),
@@ -1197,6 +1201,41 @@ describe('Appointment Form', () => {
11971201
expect(byKeySpy).toHaveBeenCalledTimes(0);
11981202
});
11991203

1204+
it('should not trigger extra CustomStore load on second popup open', async () => {
1205+
const loadFn = jest.fn().mockImplementation(() => Promise.resolve([
1206+
{ text: 'Owner 1', id: 1 },
1207+
{ text: 'Owner 2', id: 2 },
1208+
]));
1209+
const resourceDataSource = new CustomStore({
1210+
load: loadFn as any,
1211+
byKey: () => {},
1212+
});
1213+
1214+
const { scheduler } = await createScheduler({
1215+
...getDefaultConfig(),
1216+
dataSource: [{
1217+
text: 'Resource test app',
1218+
startDate: new Date(2017, 4, 9, 9, 30),
1219+
endDate: new Date(2017, 4, 9, 11),
1220+
ownerId: 1,
1221+
}],
1222+
resources: [{
1223+
fieldExpr: 'ownerId',
1224+
dataSource: resourceDataSource,
1225+
}],
1226+
});
1227+
1228+
jest.useFakeTimers();
1229+
1230+
const appointment = (scheduler as any).getDataSource().items()[0];
1231+
scheduler.showAppointmentPopup(appointment);
1232+
scheduler.hideAppointmentPopup(false);
1233+
scheduler.showAppointmentPopup(appointment);
1234+
await jest.runAllTimersAsync();
1235+
1236+
expect(loadFn).toHaveBeenCalledTimes(1);
1237+
});
1238+
12001239
it('should recreate appointment form synchronously when resources option changes', async () => {
12011240
const { scheduler } = await createScheduler({
12021241
...getDefaultConfig(),

0 commit comments

Comments
 (0)