Co-authored-by: Camille Moussu <cmoussu@linagora.com>
This commit is contained in:
@@ -250,4 +250,21 @@ describe("calendar Availability search", () => {
|
||||
|
||||
expect(spy).not.toHaveBeenCalledWith();
|
||||
});
|
||||
|
||||
it("BUGFIX: can untoggle all personnal calendars", () => {
|
||||
renderWithProviders(<CalendarTestWrapper />, {
|
||||
user: preloadedState.user,
|
||||
calendars: {
|
||||
list: { "user1/cal1": preloadedState.calendars.list["user1/cal1"] },
|
||||
pending: false,
|
||||
},
|
||||
});
|
||||
|
||||
const checkbox = screen.getByLabelText("Calendar personnal");
|
||||
expect(checkbox).toBeChecked();
|
||||
|
||||
fireEvent.click(checkbox); // toggle off
|
||||
|
||||
expect(checkbox).not.toBeChecked();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -100,18 +100,17 @@ export default function CalendarApp({
|
||||
const fetchedRangesRef = useRef<Record<string, string>>({});
|
||||
|
||||
// Auto-select personal calendars when first loaded
|
||||
const initialLoadRef = useRef(true);
|
||||
|
||||
useEffect(() => {
|
||||
if (
|
||||
Object.keys(calendars).length > 0 &&
|
||||
userId &&
|
||||
selectedCalendars.length === 0
|
||||
) {
|
||||
if (initialLoadRef.current && Object.keys(calendars).length > 0 && userId) {
|
||||
const personalCalendarIds = Object.keys(calendars).filter(
|
||||
(id) => id.split("/")[0] === userId
|
||||
);
|
||||
setSelectedCalendars(personalCalendarIds);
|
||||
initialLoadRef.current = false;
|
||||
}
|
||||
}, [calendars, userId, selectedCalendars.length]);
|
||||
}, [calendars, userId]);
|
||||
|
||||
const calendarRange = getCalendarRange(selectedDate);
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ export const updateCalsDetails = (
|
||||
});
|
||||
|
||||
if (rangeKey !== previousRangeKey) {
|
||||
selectedCalendars.forEach((id) => {
|
||||
selectedCalendars?.forEach((id) => {
|
||||
dispatch(
|
||||
getCalendarDetailAsync({
|
||||
calId: id,
|
||||
|
||||
Reference in New Issue
Block a user