[#522] added push for calendars updates (#541)

This commit is contained in:
Camille Moussu
2026-02-17 17:52:23 +01:00
committed by GitHub
parent c7843f8d69
commit 5d9eb8e19d
10 changed files with 50 additions and 72 deletions
@@ -336,45 +336,6 @@ describe("CalendarSlice", () => {
expect(result.payload.errors).toBeTruthy();
});
it("patchCalendarAsync.fulfilled updates calendar fields", () => {
const calId = "c1";
const prev = {
...initialState,
list: { c1: { id: calId, events: { e1: { uid: "e1" } } } as any },
};
const patch = { name: "N", desc: "D", color: { "apple:color": "#00f" } };
const state = reducer(
prev,
patchCalendarAsync.fulfilled(
{ calId, calLink: "link", patch },
"req1",
{
calId,
calLink: "link",
patch,
}
)
);
expect(state.list[calId].name).toBe("N");
expect(state.list[calId].description).toBe("D");
expect(state.list[calId].color?.["apple:color"]).toBe("#00f");
});
it("removeCalendarAsync.fulfilled deletes calendar", () => {
const prev = {
...initialState,
list: { c1: { id: "c1" } as any },
};
const state = reducer(
prev,
removeCalendarAsync.fulfilled({ calId: "c1" }, "req2", {
calId: "c1",
calLink: "l",
})
);
expect(state.list).toEqual({});
});
it("patchACLCalendarAsync.fulfilled sets visibility", () => {
const prev = {
...initialState,
@@ -41,10 +41,12 @@ const mockAccumulators: {
calendarsToRefresh: Map<string, any>;
calendarsToHide: Set<string>;
debouncedUpdateFn?: (dispatch: AppDispatch) => void;
shouldRefreshCalendarListRef: React.MutableRefObject<boolean>;
currentDebouncePeriod?: number;
} = {
calendarsToRefresh: new Map<string, any>(),
calendarsToHide: new Set(),
shouldRefreshCalendarListRef: { current: false },
currentDebouncePeriod: 0,
debouncedUpdateFn: undefined,
};
@@ -60,7 +62,9 @@ describe("websocket messages storm", () => {
window.WS_DEBOUNCE_PERIOD_MS = 500;
mockAccumulators.calendarsToRefresh = new Map<string, any>();
mockAccumulators.calendarsToHide = new Set();
mockAccumulators.shouldRefreshCalendarListRef.current = false;
mockAccumulators.currentDebouncePeriod = 0;
mockAccumulators.debouncedUpdateFn = undefined;
});
it("debounces calendar updates during message storm", () => {
@@ -33,10 +33,12 @@ describe("updateCalendars", () => {
calendarsToRefresh: Map<string, any>;
calendarsToHide: Set<string>;
debouncedUpdateFn?: (dispatch: AppDispatch) => void;
shouldRefreshCalendarListRef: React.MutableRefObject<boolean>;
currentDebouncePeriod?: number;
} = {
calendarsToRefresh: new Map<string, any>(),
calendarsToHide: new Set(),
shouldRefreshCalendarListRef: { current: false },
currentDebouncePeriod: 0,
debouncedUpdateFn: jest.fn(),
};
@@ -49,6 +51,7 @@ describe("updateCalendars", () => {
mockAccumulators.calendarsToRefresh = new Map<string, any>();
mockAccumulators.calendarsToHide = new Set();
mockAccumulators.currentDebouncePeriod = 0;
mockAccumulators.shouldRefreshCalendarListRef.current = false;
mockAccumulators.debouncedUpdateFn = jest.fn();
});