[#239] refresh is triggered only on save (#329)

Co-authored-by: Camille Moussu <cmoussu@linagora.com>
This commit is contained in:
Camille Moussu
2025-11-18 10:41:58 +01:00
committed by GitHub
parent 1b3faff0b5
commit cb69455a9b
4 changed files with 42 additions and 40 deletions
+10 -10
View File
@@ -213,7 +213,7 @@ describe("Repeat Event Integration Tests", () => {
fireEvent.click(dailyOption);
await expectRRule({ freq: "daily", interval: 1 });
expect(mockOnClose).toHaveBeenCalledWith({}, "backdropClick");
expect(mockOnClose).toHaveBeenCalledWith(true);
});
it("sends correct API payload for repeat daily with 2 day interval", async () => {
@@ -224,7 +224,7 @@ describe("Repeat Event Integration Tests", () => {
fireEvent.change(intervalInput, { target: { value: "2" } });
await expectRRule({ freq: "daily", interval: 2 });
expect(mockOnClose).toHaveBeenCalledWith({}, "backdropClick");
expect(mockOnClose).toHaveBeenCalledWith(true);
});
it("sends correct API payload for repeat daily for 5 repetitions", async () => {
@@ -239,7 +239,7 @@ describe("Repeat Event Integration Tests", () => {
fireEvent.change(occurrencesInput, { target: { value: "5" } });
await expectRRule({ freq: "daily", interval: 1, occurrences: 5 });
expect(mockOnClose).toHaveBeenCalledWith({}, "backdropClick");
expect(mockOnClose).toHaveBeenCalledWith(true);
});
it("sends correct API payload for repeat daily until specific date", async () => {
@@ -256,7 +256,7 @@ describe("Repeat Event Integration Tests", () => {
fireEvent.change(endDateInput, { target: { value: "2025-12-31" } });
await expectRRule({ freq: "daily", interval: 1, endDate: "2025-12-31" });
expect(mockOnClose).toHaveBeenCalledWith({}, "backdropClick");
expect(mockOnClose).toHaveBeenCalledWith(true);
});
it("sends correct API payload for repeat weekly on specific days", async () => {
@@ -281,7 +281,7 @@ describe("Repeat Event Integration Tests", () => {
interval: 1,
byday: ["FR", "TH"],
});
expect(mockOnClose).toHaveBeenCalledWith({}, "backdropClick");
expect(mockOnClose).toHaveBeenCalledWith(true);
});
it("sends correct API payload for repeat weekly with 3 week interval", async () => {
@@ -300,7 +300,7 @@ describe("Repeat Event Integration Tests", () => {
fireEvent.change(intervalInput, { target: { value: "3" } });
await expectRRule({ freq: "weekly", interval: 3 });
expect(mockOnClose).toHaveBeenCalledWith({}, "backdropClick");
expect(mockOnClose).toHaveBeenCalledWith(true);
});
it("sends correct API payload for repeat monthly", async () => {
@@ -315,7 +315,7 @@ describe("Repeat Event Integration Tests", () => {
fireEvent.click(monthlyOption);
await expectRRule({ freq: "monthly", interval: 1 });
expect(mockOnClose).toHaveBeenCalledWith({}, "backdropClick");
expect(mockOnClose).toHaveBeenCalledWith(true);
});
it("sends correct API payload for repeat monthly and end after 5 occurrences", async () => {
@@ -338,7 +338,7 @@ describe("Repeat Event Integration Tests", () => {
fireEvent.change(occurrencesInput, { target: { value: "5" } });
await expectRRule({ freq: "monthly", interval: 1, occurrences: 5 });
expect(mockOnClose).toHaveBeenCalledWith({}, "backdropClick");
expect(mockOnClose).toHaveBeenCalledWith(true);
});
it("sends correct API payload for repeat yearly", async () => {
@@ -353,7 +353,7 @@ describe("Repeat Event Integration Tests", () => {
fireEvent.click(yearlyOption);
await expectRRule({ freq: "yearly", interval: 1 });
expect(mockOnClose).toHaveBeenCalledWith({}, "backdropClick");
expect(mockOnClose).toHaveBeenCalledWith(true);
});
it("sends correct API payload for repeat yearly with end option changes", async () => {
@@ -383,6 +383,6 @@ describe("Repeat Event Integration Tests", () => {
occurrences: 0,
endDate: "",
});
expect(mockOnClose).toHaveBeenCalledWith({}, "backdropClick");
expect(mockOnClose).toHaveBeenCalledWith(true);
});
});
+3 -3
View File
@@ -314,10 +314,10 @@ describe("EventPopover", () => {
);
// onClose should be called
expect(mockOnClose).toHaveBeenCalledWith({}, "backdropClick");
expect(mockOnClose).toHaveBeenCalledWith(true);
});
it("calls onClose when Cancel clicked", () => {
it("calls onClose with refresh = false when Cancel clicked", () => {
renderPopover();
// Cancel button only appears in expanded mode
@@ -325,7 +325,7 @@ describe("EventPopover", () => {
fireEvent.click(screen.getByRole("button", { name: /Cancel/i }));
expect(mockOnClose).toHaveBeenCalledWith({}, "backdropClick");
expect(mockOnClose).toHaveBeenCalledWith(false);
});
it("BUGFIX: Prefill Calendar field", async () => {
@@ -86,33 +86,35 @@ export const createEventHandlers = (props: EventHandlersProps) => {
setAnchorEl(document.body);
};
const handleClosePopover = () => {
const handleClosePopover = (refresh?: boolean) => {
calendarRef.current?.unselect();
setAnchorEl(null);
setSelectedRange(null);
selectedCalendars.forEach((calId) =>
dispatch(
getCalendarDetailAsync({
calId,
match: {
start: formatDateToYYYYMMDDTHHMMSS(calendarRange.start),
end: formatDateToYYYYMMDDTHHMMSS(calendarRange.end),
},
})
)
);
Object.keys(tempcalendars).forEach((calId) =>
dispatch(
getCalendarDetailAsync({
calId,
match: {
start: formatDateToYYYYMMDDTHHMMSS(calendarRange.start),
end: formatDateToYYYYMMDDTHHMMSS(calendarRange.end),
},
calType: "temp",
})
)
);
if (refresh) {
selectedCalendars.forEach((calId) =>
dispatch(
getCalendarDetailAsync({
calId,
match: {
start: formatDateToYYYYMMDDTHHMMSS(calendarRange.start),
end: formatDateToYYYYMMDDTHHMMSS(calendarRange.end),
},
})
)
);
Object.keys(tempcalendars).forEach((calId) =>
dispatch(
getCalendarDetailAsync({
calId,
match: {
start: formatDateToYYYYMMDDTHHMMSS(calendarRange.start),
end: formatDateToYYYYMMDDTHHMMSS(calendarRange.end),
},
calType: "temp",
})
)
);
}
};
const handleCloseEventDisplay = () => {
+3 -3
View File
@@ -42,7 +42,7 @@ function EventPopover({
}: {
anchorEl: HTMLElement | null;
open: boolean;
onClose: (event: {}, reason: "backdropClick" | "escapeKeyDown") => void;
onClose: (refresh?: boolean) => void;
selectedRange: DateSelectArg | null;
setSelectedRange: Function;
calendarRef: React.RefObject<CalendarApi | null>;
@@ -564,7 +564,7 @@ function EventPopover({
);
const handleClose = () => {
onClose({}, "backdropClick");
onClose(false);
setShowValidationErrors(false);
resetAllStateToDefault();
setStart("");
@@ -656,7 +656,7 @@ function EventPopover({
setShowValidationErrors(false);
// Close popup immediately
onClose({}, "backdropClick");
onClose(true);
// Reset all state to default values
resetAllStateToDefault();