Skip to content

Commit 0439dad

Browse files
committed
fix & test
1 parent 9682398 commit 0439dad

3 files changed

Lines changed: 89 additions & 6 deletions

File tree

  • e2e/testcafe-devextreme/tests/scheduler/common/appointmentForm
  • packages
    • devextreme/js/__internal/scheduler/appointment_popup
    • testcafe-models/scheduler

e2e/testcafe-devextreme/tests/scheduler/common/appointmentForm/form.functional.ts

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ fixture.disablePageReloads`Appointment Form: Functional`
77

88
const SCHEDULER_SELECTOR = '#container';
99

10+
const roughEqualClientBoundingRect = (a: TextRectangle, b: TextRectangle): boolean => (
11+
Math.abs(a.width - b.width) < 1
12+
&& Math.abs(a.height - b.height) < 1
13+
&& Math.abs(a.top - b.top) < 1
14+
&& Math.abs(a.left - b.left) < 1
15+
);
16+
1017
test('Subject text editor should have focus after returning from recurrence form', async (t) => {
1118
const appointment = {
1219
text: 'Appointment',
@@ -60,3 +67,73 @@ test('Recurrence start date editor should have focus after opening recurrence se
6067
currentDate: new Date(2021, 2, 25),
6168
});
6269
});
70+
71+
test('Popup should not change dimensions when switching groups and recurrence group height is larger', async (t) => {
72+
const scheduler = new Scheduler(SCHEDULER_SELECTOR);
73+
74+
await scheduler.openAppointmentPopup(t);
75+
const boundingClientRect1 = await scheduler.appointmentPopup.contentElement.boundingClientRect;
76+
77+
await scheduler.appointmentPopup.selectRepeatValue(t, 'Weekly');
78+
const boundingClientRect2 = await scheduler.appointmentPopup.contentElement.boundingClientRect;
79+
80+
await t.click(scheduler.appointmentPopup.recurrence.backButton);
81+
const boundingClientRect3 = await scheduler.appointmentPopup.contentElement.boundingClientRect;
82+
83+
await t
84+
.expect(roughEqualClientBoundingRect(boundingClientRect1, boundingClientRect2)).ok()
85+
.expect(roughEqualClientBoundingRect(boundingClientRect1, boundingClientRect3)).ok();
86+
}).before(async () => {
87+
await createWidget('dxScheduler', {
88+
dataSource: [],
89+
views: ['week'],
90+
currentView: 'week',
91+
currentDate: new Date(2021, 2, 25),
92+
editing: {
93+
form: {
94+
items: [
95+
{
96+
name: 'mainGroup',
97+
items: ['repeatGroup'],
98+
},
99+
'recurrenceGroup',
100+
],
101+
},
102+
},
103+
});
104+
});
105+
106+
test('Popup should not change dimensions when switching groups and main group height is larger', async (t) => {
107+
const scheduler = new Scheduler(SCHEDULER_SELECTOR);
108+
109+
await scheduler.openAppointmentPopup(t);
110+
const boundingClientRect1 = await scheduler.appointmentPopup.contentElement.boundingClientRect;
111+
112+
await scheduler.appointmentPopup.selectRepeatValue(t, 'Weekly');
113+
const boundingClientRect2 = await scheduler.appointmentPopup.contentElement.boundingClientRect;
114+
115+
await t.click(scheduler.appointmentPopup.recurrence.backButton);
116+
const boundingClientRect3 = await scheduler.appointmentPopup.contentElement.boundingClientRect;
117+
118+
await t
119+
.expect(roughEqualClientBoundingRect(boundingClientRect1, boundingClientRect2)).ok()
120+
.expect(roughEqualClientBoundingRect(boundingClientRect1, boundingClientRect3)).ok();
121+
}).before(async () => {
122+
await createWidget('dxScheduler', {
123+
dataSource: [],
124+
views: ['week'],
125+
currentView: 'week',
126+
currentDate: new Date(2021, 2, 25),
127+
editing: {
128+
form: {
129+
items: [
130+
'mainGroup',
131+
{
132+
name: 'recurrenceGroup',
133+
items: ['recurrenceStartDateGroup'],
134+
},
135+
],
136+
},
137+
},
138+
});
139+
});

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -896,8 +896,6 @@ export class AppointmentForm {
896896
}
897897

898898
showMainGroup(): void {
899-
this._popup.updateToolbarForMainGroup();
900-
901899
const currentHeight = this.dxPopup.option('height') as string | number | undefined;
902900
const editingConfig = this.scheduler.getEditingConfig();
903901
const configuredHeight = editingConfig?.popup?.height ?? 'auto';
@@ -917,11 +915,14 @@ export class AppointmentForm {
917915
this._$recurrenceGroup.addClass(CLASSES.recurrenceHidden);
918916
this._$recurrenceGroup.attr('inert', true);
919917
}
918+
919+
// Note: Updating toolbar causes popup position recalculation,
920+
// so it should be called after changing groups visibility.
921+
// Alternatively, dxPopup.repaint() can be called.
922+
this._popup.updateToolbarForMainGroup();
920923
}
921924

922925
showRecurrenceGroup(): void {
923-
this._popup.updateToolbarForRecurrenceGroup();
924-
925926
const currentHeight = this.dxPopup.option('height') as string | number | undefined;
926927

927928
if (currentHeight === 'auto' || currentHeight === undefined) {
@@ -940,6 +941,11 @@ export class AppointmentForm {
940941

941942
this.focusFirstFocusableInGroup(this._$recurrenceGroup);
942943
}
944+
945+
// Note: Updating toolbar causes popup position recalculation,
946+
// so it should be called after changing groups visibility.
947+
// Alternatively, dxPopup.repaint() can be called.
948+
this._popup.updateToolbarForRecurrenceGroup();
943949
}
944950

945951
saveRecurrenceValue(): void {

packages/testcafe-models/scheduler/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,8 @@ export default class Scheduler extends Widget {
250250

251251
async openAppointmentPopup(
252252
t: TestController,
253-
appointment: any,
254-
isRecurringAppointment: boolean,
253+
appointment?: any,
254+
isRecurringAppointment?: boolean,
255255
): Promise<AppointmentPopup> {
256256
const { getInstance } = this;
257257

0 commit comments

Comments
 (0)