-
Notifications
You must be signed in to change notification settings - Fork 665
Scheduler: delete Appointment enhancements #32633
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 26_1
Are you sure you want to change the base?
Changes from all commits
aa4c78f
64271bf
e34db03
c960d85
6a133ad
421678b
0f53edd
2b1a00a
b4f1e8c
ff9174d
f0b3332
afb88c8
1678acd
cfe1143
4afd4e9
59b2061
01cbee5
e3f213e
393fdeb
65b7a24
fd57ba8
5055c5d
7f2de0e
68a4882
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| import { within } from '@testing-library/dom'; | ||
|
|
||
| const TOOLTIP_WRAPPER_SELECTOR = '.dx-overlay-wrapper.dx-scheduler-appointment-tooltip-wrapper'; | ||
|
|
||
| export class TooltipModel { | ||
| private get element(): HTMLElement | null { | ||
| return document.querySelector<HTMLElement>(TOOLTIP_WRAPPER_SELECTOR); | ||
| } | ||
|
|
||
| isVisible(): boolean { | ||
| return this.element !== null; | ||
| } | ||
|
|
||
| getScrollableContent(): Element | null { | ||
| 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')) | ||
| : []; | ||
|
|
||
| if (buttons.length === 0) { | ||
| throw new Error('Tooltip delete button not found'); | ||
| } | ||
|
|
||
| return buttons[index]; | ||
| } | ||
|
|
||
| getAppointmentItem(index = 0): HTMLElement | null { | ||
| const tooltip = this.element; | ||
| if (!tooltip) { | ||
| return null; | ||
| } | ||
| return within(tooltip).queryAllByRole('option')[index] ?? null; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,162 @@ | ||
| import { | ||
| afterEach, beforeEach, describe, expect, it, jest, | ||
| } from '@jest/globals'; | ||
| import fx from '@js/common/core/animation/fx'; | ||
|
|
||
| import { createScheduler } from './__mock__/create_scheduler'; | ||
| import { setupSchedulerTestEnvironment } from './__mock__/m_mock_scheduler'; | ||
|
|
||
| describe('Appointment tooltip behavior', () => { | ||
| beforeEach(() => { | ||
| fx.off = true; | ||
| setupSchedulerTestEnvironment(); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| fx.off = false; | ||
| jest.useRealTimers(); | ||
| document.body.innerHTML = ''; | ||
| }); | ||
|
|
||
| it('should delete appointment by Delete key when focused in tooltip from collector', async () => { | ||
| const { POM } = await createScheduler({ | ||
| dataSource: [ | ||
| { | ||
| text: 'Apt1', | ||
| startDate: new Date(2017, 4, 22, 9, 30), | ||
| endDate: new Date(2017, 4, 22, 10, 30), | ||
| }, | ||
| { | ||
| text: 'Apt2', | ||
| startDate: new Date(2017, 4, 22, 9, 30), | ||
| endDate: new Date(2017, 4, 22, 10, 30), | ||
| }, | ||
| ], | ||
| views: [{ type: 'month', maxAppointmentsPerCell: 1 }], | ||
| currentView: 'month', | ||
| currentDate: new Date(2017, 4, 22), | ||
| height: 600, | ||
| }); | ||
|
|
||
| POM.getCollectorButton().click(); | ||
|
|
||
| const tooltipScrollableContent = POM.tooltip.getScrollableContent(); | ||
| tooltipScrollableContent?.dispatchEvent(new FocusEvent('focusin', { bubbles: true })); | ||
| tooltipScrollableContent?.dispatchEvent(new KeyboardEvent('keydown', { key: 'Delete', bubbles: true })); | ||
|
|
||
| expect(POM.tooltip.isVisible()).toBe(false); | ||
| }); | ||
|
|
||
| it('should delete appointment on delete button click in tooltip', async () => { | ||
| const { POM } = await createScheduler({ | ||
| dataSource: [ | ||
| { | ||
| text: 'Apt1', | ||
| startDate: new Date(2017, 4, 22, 9, 30), | ||
| endDate: new Date(2017, 4, 22, 10, 30), | ||
| }, | ||
| { | ||
| text: 'Apt2', | ||
| startDate: new Date(2017, 4, 22, 9, 30), | ||
| endDate: new Date(2017, 4, 22, 10, 30), | ||
| }, | ||
| ], | ||
| views: [{ type: 'month', maxAppointmentsPerCell: 1 }], | ||
| currentView: 'month', | ||
| currentDate: new Date(2017, 4, 22), | ||
| height: 600, | ||
| }); | ||
|
|
||
| POM.getCollectorButton().click(); | ||
| POM.tooltip.getDeleteButton().click(); | ||
|
|
||
| expect(POM.tooltip.isVisible()).toBe(false); | ||
| }); | ||
|
|
||
| it('delete button in tooltip should not be focusable using tab', async () => { | ||
| const { POM } = await createScheduler({ | ||
| dataSource: [ | ||
| { | ||
| text: 'Apt1', | ||
| startDate: new Date(2017, 4, 22, 9, 30), | ||
| endDate: new Date(2017, 4, 22, 10, 30), | ||
| }, | ||
| { | ||
| text: 'Apt2', | ||
| startDate: new Date(2017, 4, 22, 9, 30), | ||
| endDate: new Date(2017, 4, 22, 10, 30), | ||
| }, | ||
| ], | ||
| views: [{ type: 'month', maxAppointmentsPerCell: 1 }], | ||
| currentView: 'month', | ||
| currentDate: new Date(2017, 4, 22), | ||
| height: 600, | ||
| }); | ||
|
|
||
| POM.getCollectorButton().click(); | ||
|
|
||
| expect(POM.tooltip.getDeleteButton().getAttribute('tabindex')).toBe('-1'); | ||
| }); | ||
|
|
||
| it('should not delete appointment by Delete key when editing.allowDeleting=false', async () => { | ||
| const { POM } = await createScheduler({ | ||
| dataSource: [ | ||
| { | ||
| text: 'Apt1', | ||
| startDate: new Date(2017, 4, 22, 9, 30), | ||
| endDate: new Date(2017, 4, 22, 10, 30), | ||
| }, | ||
| { | ||
| text: 'Apt2', | ||
| startDate: new Date(2017, 4, 22, 9, 30), | ||
| endDate: new Date(2017, 4, 22, 10, 30), | ||
| }, | ||
| ], | ||
| views: [{ type: 'month', maxAppointmentsPerCell: 1 }], | ||
| currentView: 'month', | ||
| currentDate: new Date(2017, 4, 22), | ||
| height: 600, | ||
| editing: { | ||
| allowDeleting: false, | ||
| }, | ||
| }); | ||
|
|
||
| POM.getCollectorButton().click(); | ||
|
|
||
| const tooltipScrollableContent = POM.tooltip.getScrollableContent(); | ||
| tooltipScrollableContent?.dispatchEvent(new FocusEvent('focusin', { bubbles: true })); | ||
| tooltipScrollableContent?.dispatchEvent(new KeyboardEvent('keydown', { key: 'Delete', bubbles: true })); | ||
|
|
||
| expect(POM.tooltip.isVisible()).toBe(true); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we check that appointment is not deleted from dataSource instead of checking that tooltip is visible? I thought we have a task, to try not hide tooltip on appt delete. So, it would be less problems for us in the future if we remove this visibility check
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moreover the test doesn't actually check that appointment wasn't deleted... |
||
| }); | ||
|
|
||
| it('should not delete disabled appointment by Delete key when focused in tooltip from collector', async () => { | ||
| const { POM } = await createScheduler({ | ||
| dataSource: [ | ||
| { | ||
| text: 'Apt1', | ||
| startDate: new Date(2017, 4, 22, 9, 30), | ||
| endDate: new Date(2017, 4, 22, 10, 30), | ||
| }, | ||
| { | ||
| text: 'Apt2', | ||
| startDate: new Date(2017, 4, 22, 9, 30), | ||
| endDate: new Date(2017, 4, 22, 10, 30), | ||
| disabled: true, | ||
| }, | ||
| ], | ||
| views: [{ type: 'month', maxAppointmentsPerCell: 1 }], | ||
| currentView: 'month', | ||
| currentDate: new Date(2017, 4, 22), | ||
| height: 600, | ||
| }); | ||
|
|
||
| POM.getCollectorButton().click(); | ||
|
|
||
| const tooltipScrollableContent = POM.tooltip.getScrollableContent(); | ||
| tooltipScrollableContent?.dispatchEvent(new FocusEvent('focusin', { bubbles: true })); | ||
| tooltipScrollableContent?.dispatchEvent(new KeyboardEvent('keydown', { key: 'Delete', bubbles: true })); | ||
|
|
||
| expect(POM.tooltip.isVisible()).toBe(true); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we check datasource data instead of tooltip visibility here too? |
||
| }); | ||
Tucchhaa marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }); | ||
Uh oh!
There was an error while loading. Please reload this page.