Skip to content

Scheduler - Create isolated AppointmentPopup test environment#33002

Merged
aleksei-semikozov merged 4 commits intoDevExpress:26_1from
aleksei-semikozov:worktree-scheduler-popup-env-3718
Mar 25, 2026
Merged

Scheduler - Create isolated AppointmentPopup test environment#33002
aleksei-semikozov merged 4 commits intoDevExpress:26_1from
aleksei-semikozov:worktree-scheduler-popup-env-3718

Conversation

@aleksei-semikozov
Copy link
Contributor

@aleksei-semikozov aleksei-semikozov commented Mar 20, 2026

No description provided.

@aleksei-semikozov aleksei-semikozov self-assigned this Mar 20, 2026
@aleksei-semikozov aleksei-semikozov force-pushed the worktree-scheduler-popup-env-3718 branch from d9420d7 to 1385ce5 Compare March 20, 2026 20:23
@aleksei-semikozov aleksei-semikozov marked this pull request as ready for review March 23, 2026 15:21
@aleksei-semikozov aleksei-semikozov requested a review from a team as a code owner March 23, 2026 15:21
Copilot AI review requested due to automatic review settings March 23, 2026 15:21
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an isolated Jest (JSDOM) test harness for the Scheduler AppointmentPopup, allowing the popup + form to be instantiated and asserted without creating a full Scheduler instance.

Changes:

  • Added a new appointment_popup.test.ts suite that validates basic popup rendering, form binding, and Save/Cancel behavior.
  • Introduced a dedicated createAppointmentPopup test helper and centralized cleanup via disposeAppointmentPopups.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
packages/devextreme/js/__internal/scheduler/tests/appointment_popup.test.ts New isolated AppointmentPopup tests covering rendering, data binding, and Save/Cancel actions.
packages/devextreme/js/__internal/scheduler/tests/mock/create_appointment_popup.ts New helper to construct an AppointmentPopup + AppointmentForm with minimal scheduler proxies and deterministic cleanup.


describe('Isolated AppointmentPopup environment', () => {
beforeEach(() => {
fx.off = true;
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider calling setupSchedulerTestEnvironment() (or at least stubbing DOMComponent.prototype._isVisible) in beforeEach. Most other Scheduler jsdom tests do this to avoid :visible returning false in JSDOM, which can make overlay/popup rendering and visibility-dependent logic flaky.

Suggested change
fx.off = true;
fx.off = true;
setupSchedulerTestEnvironment();

Copilot uses AI. Check for mistakes.
Comment on lines +60 to +69
interface CreateAppointmentPopupOptions {
appointmentData?: Record<string, unknown>;
action?: number;
editing?: Record<string, unknown>;
firstDayOfWeek?: number;
startDayHour?: number;
onAppointmentFormOpening?: (...args: unknown[]) => void;
addAppointment?: jest.Mock;
updateAppointment?: jest.Mock;
}
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The option types here are very generic (Record<string, unknown>, number), which reduces the value of these helpers and can hide breaking changes in the popup contract. Consider typing appointmentData as Partial<SafeAppointment> (or similar) and action as a union of ACTION_TO_APPOINTMENT values, and tightening editing to the scheduler editing config shape used by AppointmentPopup/AppointmentForm.

Copilot uses AI. Check for mistakes.
Copilot AI review requested due to automatic review settings March 24, 2026 11:28
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 4 changed files in this pull request and generated 1 comment.

Comment on lines +2951 to +2976
it('should call custom onContentReady and onInitialized and preserving default', async () => {
const onContentReady = jest.fn();
const onInitialized = jest.fn();
const { scheduler, POM } = await createScheduler({
...getDefaultConfig(),
...{
editing: {
form: {
onContentReady,
onInitialized,
},
},
},
});

scheduler.showAppointmentPopup();

POM.popup.selectRepeatValue('weekly');

expect(POM.popup.isMainGroupVisible()).toBe(false);
expect(POM.popup.isRecurrenceGroupVisible()).toBe(true);

expect(onContentReady).toHaveBeenCalled();
expect(onInitialized).toHaveBeenCalled();
});

Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test appears duplicated: the same "should call custom onContentReady and onInitialized and preserving default" case exists both inside the "Basic form customization" describe and again immediately after it. Keeping both adds runtime and makes failures harder to interpret; consider removing the duplicate or changing it to cover a distinct scenario.

Suggested change
it('should call custom onContentReady and onInitialized and preserving default', async () => {
const onContentReady = jest.fn();
const onInitialized = jest.fn();
const { scheduler, POM } = await createScheduler({
...getDefaultConfig(),
...{
editing: {
form: {
onContentReady,
onInitialized,
},
},
},
});
scheduler.showAppointmentPopup();
POM.popup.selectRepeatValue('weekly');
expect(POM.popup.isMainGroupVisible()).toBe(false);
expect(POM.popup.isRecurrenceGroupVisible()).toBe(true);
expect(onContentReady).toHaveBeenCalled();
expect(onInitialized).toHaveBeenCalled();
});

Copilot uses AI. Check for mistakes.
Tucchhaa
Tucchhaa previously approved these changes Mar 24, 2026
Copilot AI review requested due to automatic review settings March 24, 2026 21:03
@aleksei-semikozov aleksei-semikozov force-pushed the worktree-scheduler-popup-env-3718 branch from d58be59 to 749fea5 Compare March 24, 2026 21:03
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 3 changed files in this pull request and generated 2 comments.

Comment on lines +169 to +177
const selector = `.dx-overlay-wrapper.${APPOINTMENT_POPUP_CLASS}`;
const overlayWrapper = document.querySelector(
selector,
) as HTMLDivElement;

if (!overlayWrapper) {
throw new Error(
'AppointmentPopup overlay wrapper not found in DOM',
);
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

createAppointmentPopup locates the overlay wrapper via document.querySelector(...), which will return the first matching wrapper. If multiple AppointmentPopups are created in the same test without calling disposeAppointmentPopups() in between, this can bind the POM to the wrong popup instance. Consider selecting the most recently created wrapper (e.g., querySelectorAll + last) or deriving the wrapper from popup.popup.$element() to make the helper robust for multiple instances.

Copilot uses AI. Check for mistakes.
Comment on lines +2818 to +2833
it('should call custom onContentReady and onInitialized and preserving default', async () => {
const onContentReady = jest.fn();
const onInitialized = jest.fn();
const { scheduler, POM } = await createScheduler({
...getDefaultConfig(),
...{
editing: {
form: {
onContentReady,
onInitialized,
},
},
},
});

scheduler.showAppointmentPopup();
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file contains the same test case (should call custom onContentReady and onInitialized and preserving default) twice, which adds redundant coverage and extra runtime. Please remove one of the duplicates or differentiate them if they are meant to validate different behavior.

Copilot uses AI. Check for mistakes.
@aleksei-semikozov aleksei-semikozov merged commit 3c22167 into DevExpress:26_1 Mar 25, 2026
106 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants