BUGFIX : Minicalendar event toggle (#202)
Co-authored-by: Camille Moussu <cmoussu@linagora.com>
This commit is contained in:
@@ -174,6 +174,77 @@ describe("CalendarSelection", () => {
|
|||||||
fireEvent.click(addButton);
|
fireEvent.click(addButton);
|
||||||
expect(sharedAccordionSummary).toHaveAttribute("aria-expanded", "true");
|
expect(sharedAccordionSummary).toHaveAttribute("aria-expanded", "true");
|
||||||
});
|
});
|
||||||
|
it("BUGFIX: remove dots in mini calendar when unselecting personnal calendar", () => {
|
||||||
|
renderWithProviders(<CalendarLayout />, preloadedState);
|
||||||
|
|
||||||
|
const checkbox = screen.getByLabelText("Calendar personnal");
|
||||||
|
// checkbox checked : events shown
|
||||||
|
expect(
|
||||||
|
screen.getByTestId(
|
||||||
|
`date-${start.getFullYear()}-${start.getMonth()}-${start.getDate()}`
|
||||||
|
)
|
||||||
|
).toHaveClass("event-dot");
|
||||||
|
|
||||||
|
// checkbox unchecked : events hidden
|
||||||
|
fireEvent.click(checkbox);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
screen.getByTestId(
|
||||||
|
`date-${start.getFullYear()}-${start.getMonth()}-${start.getDate()}`
|
||||||
|
)
|
||||||
|
).not.toHaveClass("event-dot");
|
||||||
|
|
||||||
|
// checkbox rechecked : events shown
|
||||||
|
fireEvent.click(checkbox);
|
||||||
|
expect(
|
||||||
|
screen.getByTestId(
|
||||||
|
`date-${start.getFullYear()}-${start.getMonth()}-${start.getDate()}`
|
||||||
|
)
|
||||||
|
).toHaveClass("event-dot");
|
||||||
|
});
|
||||||
|
it("BUGFIX: remove dots in mini calendar when unselecting delegated calendar", () => {
|
||||||
|
renderWithProviders(<CalendarLayout />, preloadedState);
|
||||||
|
|
||||||
|
// hide personnal event first
|
||||||
|
fireEvent.click(screen.getByLabelText("Calendar personnal"));
|
||||||
|
const checkbox = screen.getByLabelText("Calendar delegated");
|
||||||
|
|
||||||
|
expect(
|
||||||
|
screen.getByTestId(
|
||||||
|
`date-${start.getFullYear()}-${start.getMonth()}-${start.getDate()}`
|
||||||
|
)
|
||||||
|
).not.toHaveClass("event-dot");
|
||||||
|
|
||||||
|
// checkbox checked : events shown
|
||||||
|
fireEvent.click(checkbox);
|
||||||
|
expect(
|
||||||
|
screen.getByTestId(
|
||||||
|
`date-${start.getFullYear()}-${start.getMonth()}-${start.getDate()}`
|
||||||
|
)
|
||||||
|
).toHaveClass("event-dot");
|
||||||
|
});
|
||||||
|
it("BUGFIX: remove dots in mini calendar when unselecting shared calendar", () => {
|
||||||
|
renderWithProviders(<CalendarLayout />, preloadedState);
|
||||||
|
|
||||||
|
// hide personnal event first
|
||||||
|
fireEvent.click(screen.getByLabelText("Calendar personnal"));
|
||||||
|
const checkbox = screen.getByLabelText("Calendar shared");
|
||||||
|
|
||||||
|
// checkbox unchecked : events hidden
|
||||||
|
expect(
|
||||||
|
screen.getByTestId(
|
||||||
|
`date-${start.getFullYear()}-${start.getMonth()}-${start.getDate()}`
|
||||||
|
)
|
||||||
|
).not.toHaveClass("event-dot");
|
||||||
|
|
||||||
|
// checkbox checked : events shown
|
||||||
|
fireEvent.click(checkbox);
|
||||||
|
expect(
|
||||||
|
screen.getByTestId(
|
||||||
|
`date-${start.getFullYear()}-${start.getMonth()}-${start.getDate()}`
|
||||||
|
)
|
||||||
|
).toHaveClass("event-dot");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("calendar Availability search", () => {
|
describe("calendar Availability search", () => {
|
||||||
|
|||||||
@@ -63,30 +63,11 @@ export default function CalendarApp({
|
|||||||
const tempcalendars =
|
const tempcalendars =
|
||||||
useAppSelector((state) => state.calendars.templist) ?? {};
|
useAppSelector((state) => state.calendars.templist) ?? {};
|
||||||
const pending = useAppSelector((state) => state.calendars.pending);
|
const pending = useAppSelector((state) => state.calendars.pending);
|
||||||
const selectPersonnalCalendars = createSelector(
|
|
||||||
(state) => state.calendars,
|
|
||||||
(calendars) =>
|
|
||||||
Object.keys(calendars.list).map((id) => {
|
|
||||||
if (id.split("/")[0] === userId) {
|
|
||||||
return calendars.list[id];
|
|
||||||
}
|
|
||||||
return {} as Calendars;
|
|
||||||
})
|
|
||||||
);
|
|
||||||
const userPersonnalCalendars: Calendars[] = useAppSelector(
|
|
||||||
selectPersonnalCalendars
|
|
||||||
);
|
|
||||||
let personnalEvents: CalendarEvent[] = [];
|
|
||||||
Object.keys(userPersonnalCalendars).forEach((value, id) => {
|
|
||||||
if (userPersonnalCalendars[id].events) {
|
|
||||||
personnalEvents = personnalEvents.concat(
|
|
||||||
Object.keys(userPersonnalCalendars[id].events).map(
|
|
||||||
(eventid) => userPersonnalCalendars[id].events[eventid]
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
const [selectedCalendars, setSelectedCalendars] = useState<string[]>([]);
|
const [selectedCalendars, setSelectedCalendars] = useState<string[]>([]);
|
||||||
|
|
||||||
|
const dottedEvents: CalendarEvent[] = selectedCalendars.flatMap((calId) =>
|
||||||
|
Object.values(calendars[calId].events)
|
||||||
|
);
|
||||||
const fetchedRangesRef = useRef<Record<string, string>>({});
|
const fetchedRangesRef = useRef<Record<string, string>>({});
|
||||||
|
|
||||||
// Auto-select personal calendars when first loaded
|
// Auto-select personal calendars when first loaded
|
||||||
@@ -296,7 +277,7 @@ export default function CalendarApp({
|
|||||||
}}
|
}}
|
||||||
tileContent={({ date }) => {
|
tileContent={({ date }) => {
|
||||||
const classNames: string[] = [];
|
const classNames: string[] = [];
|
||||||
const hasEvents = personnalEvents.some((event) => {
|
const hasEvents = dottedEvents.some((event) => {
|
||||||
const eventDate = new Date(event.start);
|
const eventDate = new Date(event.start);
|
||||||
return (
|
return (
|
||||||
eventDate.getFullYear() === date.getFullYear() &&
|
eventDate.getFullYear() === date.getFullYear() &&
|
||||||
|
|||||||
Reference in New Issue
Block a user