Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,8 @@ export const setupSchedulerTestEnvironment = ({

return defaultRect;
});

Element.prototype.getClientRects = jest.fn(function (): DOMRectList {
return [Element.prototype.getBoundingClientRect.call(this)] as unknown as DOMRectList;
});
};
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
import type { dxElementWrapper } from '@js/core/renderer';
import $ from '@js/core/renderer';
import type dxTooltip from '@js/ui/tooltip';
import { within } from '@testing-library/dom';

const TOOLTIP_WRAPPER_SELECTOR = '.dx-overlay-wrapper.dx-scheduler-appointment-tooltip-wrapper';
const TOOLTIP_WRAPPER_SELECTOR = `
.dx-overlay-wrapper.dx-scheduler-overlay-panel,
.dx-overlay-wrapper.dx-scheduler-appointment-tooltip-wrapper
`;

export class TooltipModel {
private get element(): HTMLElement | null {
get element(): HTMLElement | null {
return document.querySelector<HTMLElement>(TOOLTIP_WRAPPER_SELECTOR);
}

get dxTooltip(): dxTooltip {
// @ts-expect-error
return $('.dx-tooltip.dx-widget').dxTooltip('instance') as dxTooltip;
}

get target(): Element | null {
const $target = this.dxTooltip.option('target') as unknown as dxElementWrapper;
return $target?.get(0) ?? null;
}

isVisible(): boolean {
return this.element !== null;
}
Expand All @@ -15,24 +31,35 @@ export class TooltipModel {
return this.element?.querySelector('.dx-scrollable .dx-scrollview-content') ?? null;
}

getDeleteButton(index = 0): HTMLElement {
const tooltip = this.element;
const buttons = tooltip
? within(tooltip).queryAllByRole('button').filter((btn) => btn.classList.contains('dx-tooltip-appointment-item-delete-button'))
getDeleteButtons(): HTMLElement[] {
return this.element
? within(this.element).queryAllByRole('button').filter(
(btn) => btn.classList.contains('dx-tooltip-appointment-item-delete-button'),
)
: [];
}

if (buttons.length === 0) {
getDeleteButton(index = 0): HTMLElement {
const buttons = this.getDeleteButtons();

if (buttons.length <= index) {
throw new Error('Tooltip delete button not found');
}

return buttons[index];
}

getAppointmentItems(): HTMLElement[] {
return this.element ? within(this.element).queryAllByRole('option') : [];
}

getAppointmentItem(index = 0): HTMLElement | null {
const tooltip = this.element;
if (!tooltip) {
return null;
const items = this.getAppointmentItems();

if (items.length <= index) {
throw new Error('Tooltip appointment item not found');
}
return within(tooltip).queryAllByRole('option')[index] ?? null;

return items[index];
Comment on lines 56 to +63
Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

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

getAppointmentItem is typed as returning HTMLElement | null, but it now throws when the item is missing and always returns an HTMLElement otherwise. This type no longer matches the actual behavior and can mislead test authors/TypeScript consumers.

Consider changing the return type to HTMLElement (or, if you want a nullable API, return null instead of throwing when the item isn’t found).

Copilot uses AI. Check for mistakes.
}
}
Loading
Loading