[#421] added eslint check to CI (#534)

Co-authored-by: Camille Moussu <cmoussu@linagora.com>
This commit is contained in:
Camille Moussu
2026-02-10 10:41:37 +01:00
committed by GitHub
parent 8a6ec8fc39
commit d6e464afad
116 changed files with 1232 additions and 801 deletions
@@ -309,7 +309,7 @@ describe("CalendarPopover - Tabs Scenarios", () => {
});
it("copies CalDAV link from Access tab", async () => {
(window as any).CALENDAR_BASE_URL = "https://cal.example.org";
window.CALENDAR_BASE_URL = "https://cal.example.org";
Object.assign(navigator, {
clipboard: { writeText: jest.fn() },
});
@@ -443,7 +443,7 @@ describe("CalendarPopover - Tabs Scenarios", () => {
});
it("fetches and resets the secret link", async () => {
(window as any).CALENDAR_BASE_URL = "https://cal.example.org";
window.CALENDAR_BASE_URL = "https://cal.example.org";
(getSecretLink as jest.Mock)
.mockResolvedValueOnce({
@@ -10,15 +10,12 @@ import { Calendar } from "@/features/Calendars/CalendarTypes";
import {
addSharedCalendarAsync,
createCalendarAsync,
deleteEventAsync,
getCalendarDetailAsync,
getCalendarsListAsync,
getEventAsync,
getTempCalendarsListAsync,
moveEventAsync,
patchACLCalendarAsync,
patchCalendarAsync,
putEventAsync,
removeCalendarAsync,
} from "@/features/Calendars/services";
import { CalendarEvent } from "@/features/Events/EventsTypes";
+3 -3
View File
@@ -68,18 +68,18 @@ describe("eventApi", () => {
});
it("putEvent logs when status is 201", async () => {
const consoleLogSpy = jest.spyOn(console, "log").mockImplementation();
const consoleInfoSpy = jest.spyOn(console, "info").mockImplementation();
const mockResponse = { status: 201, url: "/dav/cals/test.ics" };
(api as unknown as jest.Mock).mockReturnValue(mockResponse);
await putEvent(mockEvent);
expect(consoleLogSpy).toHaveBeenCalledWith(
expect(consoleInfoSpy).toHaveBeenCalledWith(
"Event created successfully:",
"/dav/cals/test.ics"
);
consoleLogSpy.mockRestore();
consoleInfoSpy.mockRestore();
});
test("moveEvent sends MOVE request with destination header", async () => {
@@ -27,7 +27,7 @@ describe("Event Preview Display", () => {
beforeEach(() => {
jest.clearAllMocks();
sessionStorage.clear();
(window as any).MAIL_SPA_URL = null;
window.MAIL_SPA_URL = null;
});
const preloadedState = {
@@ -598,7 +598,7 @@ describe("Event Preview Display", () => {
});
});
it("properly render message button when MAIL_SPA_URL is not null and event has attendees", () => {
(window as any).MAIL_SPA_URL = "test";
window.MAIL_SPA_URL = "test";
renderWithProviders(
<EventPreviewModal
open={true}
@@ -612,7 +612,7 @@ describe("Event Preview Display", () => {
expect(screen.getByText("eventPreview.emailAttendees")).toBeInTheDocument();
});
it("doesnt render message button when MAIL_SPA_URL is not null and event has no attendees", () => {
(window as any).MAIL_SPA_URL = "test";
window.MAIL_SPA_URL = "test";
renderWithProviders(
<EventPreviewModal
open={true}
@@ -637,7 +637,7 @@ describe("Event Preview Display", () => {
expect(screen.queryByTestId("EmailIcon")).not.toBeInTheDocument();
});
it("message button opens url with attendees as uri and title as subject", () => {
(window as any).MAIL_SPA_URL = "test";
window.MAIL_SPA_URL = "test";
const mockOpen = jest.fn();
window.open = mockOpen;
@@ -669,7 +669,7 @@ describe("Event Preview Display", () => {
});
it("message button encodes special characters in event title correctly", () => {
(window as any).MAIL_SPA_URL = "test";
window.MAIL_SPA_URL = "test";
const mockOpen = jest.fn();
window.open = mockOpen;
@@ -952,7 +952,7 @@ describe("Event Preview Display", () => {
beforeEach(() => {
jest.clearAllMocks();
(window as any).MAIL_SPA_URL = null;
window.MAIL_SPA_URL = null;
});
const createStateWithAttendees = (attendees: any[]) => ({
@@ -322,7 +322,7 @@ describe("WebSocketGate", () => {
it("should reset reconnection attempts counter on successful connection", async () => {
jest.useFakeTimers();
const consoleLog = jest.spyOn(console, "log").mockImplementation();
const consoleLog = jest.spyOn(console, "info").mockImplementation();
let onCloseCallback: Function | undefined;
(createWebSocketConnection as jest.Mock).mockImplementation(
@@ -576,7 +576,7 @@ describe("WebSocketGate", () => {
it("should reset attempt counter when online event fires", async () => {
jest.useFakeTimers();
const consoleLog = jest.spyOn(console, "log").mockImplementation();
const consoleLog = jest.spyOn(console, "info").mockImplementation();
let onCloseCallback: Function | undefined;
(createWebSocketConnection as jest.Mock).mockImplementation(
@@ -49,22 +49,22 @@ describe("createWebSocketConnection", () => {
beforeEach(() => {
({ webSocketInstances, mockWebSocket, cleanup } = setupWebsocket());
(window as any).WEBSOCKET_URL = "wss://calendar.example.com";
window.WEBSOCKET_URL = "wss://calendar.example.com";
(fetchWebSocketTicket as jest.Mock).mockResolvedValue(mockTicket);
});
afterEach(() => {
jest.clearAllMocks();
delete (window as any).WEBSOCKET_URL;
delete (window as any).CALENDAR_BASE_URL;
delete window.WEBSOCKET_URL;
delete window.CALENDAR_BASE_URL;
cleanup();
});
/** ---------- Tests ---------- */
it("throws when WEBSOCKET_URL is not defined", async () => {
delete (window as any).WEBSOCKET_URL;
delete window.WEBSOCKET_URL;
const mockCallbacks = {
onMessage: jest.fn(),
};
@@ -88,8 +88,8 @@ describe("createWebSocketConnection", () => {
});
it("creates WebSocket with correct URL and ticket without the WEBSOCKET_URL", async () => {
delete (window as any).WEBSOCKET_URL;
(window as any).CALENDAR_BASE_URL = "https://calendar.example.com";
delete window.WEBSOCKET_URL;
window.CALENDAR_BASE_URL = "https://calendar.example.com";
await createAndOpenConnection();
expect(mockWebSocket).toHaveBeenCalledWith(
@@ -57,7 +57,7 @@ describe("websocket messages storm", () => {
jest.resetModules();
(getDisplayedCalendarRange as jest.Mock).mockReturnValue(mockRange);
(store.getState as jest.Mock).mockReturnValue(mockState);
(window as any).WS_DEBOUNCE_PERIOD_MS = 500;
window.WS_DEBOUNCE_PERIOD_MS = 500;
mockAccumulators.calendarsToRefresh = new Map<string, any>();
mockAccumulators.calendarsToHide = new Set();
mockAccumulators.currentDebouncePeriod = 0;
@@ -118,7 +118,7 @@ describe("websocket messages storm", () => {
});
it("executes immediately when debounce is disabled", () => {
(window as any).WS_DEBOUNCE_PERIOD_MS = 0;
window.WS_DEBOUNCE_PERIOD_MS = 0;
updateCalendars(
{ "/calendars/cal1/entry1": { syncToken: "abc" } },
@@ -42,16 +42,16 @@ describe("registerToCalendars", () => {
});
it("should log registration", () => {
const consoleLogSpy = jest.spyOn(console, "log").mockImplementation();
const consoleInfoSpy = jest.spyOn(console, "info").mockImplementation();
const calendarURIs = ["/calendars/cal1", "/calendars/cal2"];
registerToCalendars(mockSocket, calendarURIs);
expect(consoleLogSpy).toHaveBeenCalledWith(
expect(consoleInfoSpy).toHaveBeenCalledWith(
"Registered to calendars",
calendarURIs
);
consoleLogSpy.mockRestore();
consoleInfoSpy.mockRestore();
});
});
@@ -43,16 +43,16 @@ describe("unregisterToCalendars", () => {
});
it("should log unregistration", () => {
const consoleLogSpy = jest.spyOn(console, "log").mockImplementation();
const consoleInfoSpy = jest.spyOn(console, "info").mockImplementation();
const calendarURIs = ["/calendars/cal1", "/calendars/cal2"];
unregisterToCalendars(mockSocket, calendarURIs);
expect(consoleLogSpy).toHaveBeenCalledWith(
expect(consoleInfoSpy).toHaveBeenCalledWith(
"Unregistered to calendars",
calendarURIs
);
consoleLogSpy.mockRestore();
consoleInfoSpy.mockRestore();
});
});