-
Notifications
You must be signed in to change notification settings - Fork 666
Scheduler - Appointments Refactoring - Rendering #33014
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
Merged
Merged
Changes from 5 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
dadf6d1
implement rendering
Tucchhaa 9e03e0c
fix tests
Tucchhaa f291e0a
fix tests
Tucchhaa 7bf2f88
update etalons
Tucchhaa 1e5443a
implement tests
Tucchhaa dde3168
move to __mock__
Tucchhaa 25f9e8c
remove my comments
Tucchhaa 69ef155
apply copilot review
Tucchhaa 12972e4
simplify appointment components properties
Tucchhaa 92ce255
simplify appointmentRendered callback
Tucchhaa 12ab206
set agenda's geometry
Tucchhaa e050533
rename components
Tucchhaa 775600e
apply copilot's review
Tucchhaa 53510ca
lint
Tucchhaa 9a9defe
lint
Tucchhaa b8c5c6c
apply review
Tucchhaa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file modified
BIN
-1 Byte
(100%)
...ve/etalons/view=day-crossScrolling=false-horizontal-rtl (fluent.blue.light).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-2 Bytes
(100%)
...yout/adaptive/etalons/view=day-crossScrolling=false-rtl (fluent.blue.light).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+0 Bytes
(100%)
...tive/etalons/view=day-crossScrolling=false-vertical-rtl (fluent.blue.light).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+0 Bytes
(100%)
...ive/etalons/view=day-crossScrolling=true-horizontal-rtl (fluent.blue.light).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-2 Bytes
(100%)
...ayout/adaptive/etalons/view=day-crossScrolling=true-rtl (fluent.blue.light).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+1 Byte
(100%)
...ptive/etalons/view=day-crossScrolling=true-vertical-rtl (fluent.blue.light).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
228 changes: 228 additions & 0 deletions
228
...evextreme/js/__internal/scheduler/appointments_new/appointment/agenda_appointment.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,228 @@ | ||
| import { | ||
| afterEach, beforeEach, describe, expect, it, jest, | ||
| } from '@jest/globals'; | ||
| import $ from '@js/core/renderer'; | ||
| import type { SafeAppointment } from '@ts/scheduler/types'; | ||
| import type { ResourceConfig } from '@ts/scheduler/utils/loader/types'; | ||
| import type { AppointmentAgendaViewModel } from '@ts/scheduler/view_model/types'; | ||
|
|
||
| import fx from '../../../common/core/animation/fx'; | ||
| import { AGENDA_APPOINTMENT_CLASSES, APPOINTMENT_CLASSES } from '../const'; | ||
| import type { AgendaAppointmentProperties } from './agenda_appointment'; | ||
| import { AgendaAppointment } from './agenda_appointment'; | ||
| import { getBaseMockedAppointmentProperties, mockAgendaViewModel } from './utils.test'; | ||
|
|
||
| const getAgendaAppointmentProperties = (options: { | ||
| appointmentData: SafeAppointment; | ||
| partialViewModel?: Partial<AppointmentAgendaViewModel>; | ||
| resources?: ResourceConfig[] | ||
| }): AgendaAppointmentProperties => { | ||
| const viewModel = mockAgendaViewModel(options.appointmentData, options.partialViewModel); | ||
| const result = getBaseMockedAppointmentProperties({ ...options, viewModel }); | ||
|
|
||
| return { | ||
| ...result, | ||
| viewModel: result.viewModel as AppointmentAgendaViewModel, | ||
| }; | ||
| }; | ||
|
|
||
| const createAgendaAppointment = async ( | ||
| properties: AgendaAppointmentProperties, | ||
| ): Promise<AgendaAppointment> => { | ||
| const $element = $('.root'); | ||
|
|
||
| // @ts-expect-error | ||
| const instance = new AgendaAppointment($element, properties); | ||
|
|
||
| // Await for resources | ||
| await new Promise(process.nextTick); | ||
|
|
||
| return instance; | ||
| }; | ||
|
|
||
| const defaultAppointmentData = { | ||
| text: 'Test appointment', | ||
| startDate: new Date(2024, 0, 1, 9, 0), | ||
| endDate: new Date(2024, 0, 1, 10, 0), | ||
| }; | ||
|
|
||
| describe('AgendaAppointment', () => { | ||
| beforeEach(() => { | ||
| fx.off = true; | ||
|
|
||
| const $container = $('<div>') | ||
| .addClass('container') | ||
| .appendTo(document.body); | ||
|
|
||
| $('<div>') | ||
| .addClass('root') | ||
| .appendTo($container); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| $('.container').remove(); | ||
| fx.off = false; | ||
| jest.useRealTimers(); | ||
| }); | ||
|
|
||
| describe('Classes', () => { | ||
| it.each([ | ||
| true, false, | ||
| ])('should have correct class for viewModel.lastInGroup = %o', async (isLastInGroup) => { | ||
| const instance = await createAgendaAppointment( | ||
| getAgendaAppointmentProperties({ | ||
| appointmentData: defaultAppointmentData, | ||
| partialViewModel: { isLastInGroup }, | ||
| }), | ||
| ); | ||
|
|
||
| expect( | ||
| instance.$element().hasClass(AGENDA_APPOINTMENT_CLASSES.LAST_IN_DATE), | ||
| ).toBe(isLastInGroup); | ||
| }); | ||
| }); | ||
|
|
||
| describe('Title', () => { | ||
| it('should have correct title text', async () => { | ||
| const instance = await createAgendaAppointment( | ||
| getAgendaAppointmentProperties({ | ||
| appointmentData: { ...defaultAppointmentData, text: 'Test title' }, | ||
| }), | ||
| ); | ||
|
|
||
| const $title = instance.$element().find(`.${APPOINTMENT_CLASSES.TITLE}`); | ||
|
|
||
| expect($title.text()).toBe('Test title'); | ||
| }); | ||
|
|
||
| it('should have emptry title text if appointment has no text', async () => { | ||
| const instance = await createAgendaAppointment( | ||
| getAgendaAppointmentProperties({ | ||
| appointmentData: { ...defaultAppointmentData, text: undefined }, | ||
| }), | ||
| ); | ||
|
|
||
| const $title = instance.$element().find(`.${APPOINTMENT_CLASSES.TITLE}`); | ||
| expect($title.text()).toBe('(No subject)'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('Date text', () => { | ||
| it('should have correct date text', async () => { | ||
| const instance = await createAgendaAppointment( | ||
| getAgendaAppointmentProperties({ | ||
| appointmentData: { | ||
| ...defaultAppointmentData, | ||
| startDate: new Date(2024, 0, 1, 9, 0), | ||
| endDate: new Date(2024, 0, 1, 10, 0), | ||
| }, | ||
| }), | ||
| ); | ||
|
|
||
| const $date = instance.$element().find(`.${APPOINTMENT_CLASSES.DATE}`); | ||
|
|
||
| expect($date.text()).toBe('9:00 AM - 10:00 AM'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('Recurrence', () => { | ||
| it.each([ | ||
| true, false, | ||
| ])('should have correct recurrence icon visibility for isRecurring = %o', async (isRecurring) => { | ||
| const appointmentData = isRecurring | ||
| ? { ...defaultAppointmentData, recurrenceRule: 'FREQ=DAILY' } | ||
| : defaultAppointmentData; | ||
|
|
||
| const instance = await createAgendaAppointment( | ||
| getAgendaAppointmentProperties({ | ||
| appointmentData, | ||
| }), | ||
| ); | ||
|
|
||
| const $icon = instance.$element().find(`.${APPOINTMENT_CLASSES.RECURRENCE_ICON}`); | ||
|
|
||
| expect($icon.length).toBe(isRecurring ? 1 : 0); | ||
| }); | ||
| }); | ||
|
|
||
| describe('All Day', () => { | ||
| it.each([ | ||
| true, false, | ||
| ])('should have correct all day text visibility for allDay = %o', async (isAllDay) => { | ||
| const appointmentData = { ...defaultAppointmentData, allDay: isAllDay }; | ||
|
|
||
| const instance = await createAgendaAppointment( | ||
| getAgendaAppointmentProperties({ | ||
| appointmentData, | ||
| }), | ||
| ); | ||
|
|
||
| const $allDayText = instance.$element().find(`.${APPOINTMENT_CLASSES.ALL_DAY_TEXT}`); | ||
|
|
||
| expect($allDayText.length).toBe(isAllDay ? 1 : 0); | ||
| }); | ||
| }); | ||
|
|
||
| describe('Resources', () => { | ||
| it('should have marker with color from resource', async () => { | ||
| const resourceColor = 'rgb(255, 0, 0)'; | ||
| const resources = [ | ||
| { | ||
| field: 'roomId', | ||
| dataSource: [{ id: 1, text: 'Room 1', color: resourceColor }], | ||
| }, | ||
| ]; | ||
|
|
||
| const instance = await createAgendaAppointment( | ||
| getAgendaAppointmentProperties({ | ||
| appointmentData: { ...defaultAppointmentData, roomId: 1 }, | ||
| resources, | ||
| }), | ||
| ); | ||
|
|
||
| const $marker = instance.$element().find(`.${AGENDA_APPOINTMENT_CLASSES.MARKER}`); | ||
|
|
||
| expect($marker.css('backgroundColor')).toBe(resourceColor); | ||
| }); | ||
|
|
||
| it('should render resource list', async () => { | ||
| const resources = [ | ||
| { | ||
| label: 'roomId', | ||
| fieldExpr: 'roomId', | ||
| dataSource: [{ id: 1, text: 'Room 1' }], | ||
| }, | ||
| { | ||
| label: 'ownerId', | ||
| fieldExpr: 'ownerId', | ||
| dataSource: [{ id: 2, text: 'Owner 1' }], | ||
| }, | ||
| ]; | ||
|
|
||
| const instance = await createAgendaAppointment( | ||
| getAgendaAppointmentProperties({ | ||
| appointmentData: { ...defaultAppointmentData, roomId: 1, ownerId: 2 }, | ||
| resources, | ||
| }), | ||
| ); | ||
|
|
||
| const $resourceItems = instance.$element().find(`.${AGENDA_APPOINTMENT_CLASSES.RESOURCE_ITEM}`); | ||
|
|
||
| expect($resourceItems.length).toBe(2); | ||
| expect($resourceItems.eq(0).text()).toBe('roomId:Room 1'); | ||
| expect($resourceItems.eq(1).text()).toBe('ownerId:Owner 1'); | ||
| }); | ||
|
|
||
| it('should not render resource list if there are no resources', async () => { | ||
| const instance = await createAgendaAppointment( | ||
| getAgendaAppointmentProperties({ | ||
| appointmentData: defaultAppointmentData, | ||
| }), | ||
| ); | ||
|
|
||
| const $resourceItems = instance.$element().find(`.${AGENDA_APPOINTMENT_CLASSES.RESOURCE_ITEM}`); | ||
|
|
||
| expect($resourceItems.length).toBe(0); | ||
| }); | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.