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();
|
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>>({});
|
const fetchedRangesRef = useRef<Record<string, string>>({});
|
||||||
|
|
||||||
// Auto-select personal calendars when first loaded
|
// Auto-select personal calendars when first loaded
|
||||||
|
const initialLoadRef = useRef(true);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (
|
if (initialLoadRef.current && Object.keys(calendars).length > 0 && userId) {
|
||||||
Object.keys(calendars).length > 0 &&
|
|
||||||
userId &&
|
|
||||||
selectedCalendars.length === 0
|
|
||||||
) {
|
|
||||||
const personalCalendarIds = Object.keys(calendars).filter(
|
const personalCalendarIds = Object.keys(calendars).filter(
|
||||||
(id) => id.split("/")[0] === userId
|
(id) => id.split("/")[0] === userId
|
||||||
);
|
);
|
||||||
setSelectedCalendars(personalCalendarIds);
|
setSelectedCalendars(personalCalendarIds);
|
||||||
|
initialLoadRef.current = false;
|
||||||
}
|
}
|
||||||
}, [calendars, userId, selectedCalendars.length]);
|
}, [calendars, userId]);
|
||||||
|
|
||||||
const calendarRange = getCalendarRange(selectedDate);
|
const calendarRange = getCalendarRange(selectedDate);
|
||||||
|
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ export const updateCalsDetails = (
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (rangeKey !== previousRangeKey) {
|
if (rangeKey !== previousRangeKey) {
|
||||||
selectedCalendars.forEach((id) => {
|
selectedCalendars?.forEach((id) => {
|
||||||
dispatch(
|
dispatch(
|
||||||
getCalendarDetailAsync({
|
getCalendarDetailAsync({
|
||||||
calId: id,
|
calId: id,
|
||||||
|
|||||||
Reference in New Issue
Block a user