Refactor imports (#470)

This commit is contained in:
Camille Moussu
2026-01-20 17:33:30 +01:00
committed by GitHub
parent aeb8670895
commit 23d50f250d
149 changed files with 1439 additions and 1374 deletions
+18 -18
View File
@@ -1,15 +1,14 @@
import CalendarApp from "@/components/Calendar/Calendar";
import CalendarLayout from "@/components/Calendar/CalendarLayout";
import * as calendarDetailThunks from "@/features/Calendars/services";
import * as servicesModule from "@/features/Calendars/services";
import { searchUsers } from "@/features/User/userAPI";
import { act, fireEvent, screen, waitFor } from "@testing-library/react";
import CalendarApp from "../../src/components/Calendar/Calendar";
import * as eventThunks from "../../src/features/Calendars/CalendarSlice";
import { renderWithProviders } from "../utils/Renderwithproviders";
import { searchUsers } from "../../src/features/User/userAPI";
import * as calendarDetailThunks from "../../src/features/Calendars/services/getCalendarDetailAsync";
import { useRef } from "react";
import userEvent from "@testing-library/user-event";
import CalendarLayout from "../../src/components/Calendar/CalendarLayout";
jest.mock("../../src/features/User/userAPI");
import { useRef } from "react";
import { renderWithProviders } from "../utils/Renderwithproviders";
jest.mock("@/features/User/userAPI");
const mockedSearchUsers = searchUsers as jest.MockedFunction<
typeof searchUsers
>;
@@ -348,7 +347,7 @@ describe("calendar Availability search", () => {
it("imports temporary calendars when selecting new users", async () => {
const spy = jest
.spyOn(eventThunks, "getTempCalendarsListAsync")
.spyOn(servicesModule, "getTempCalendarsListAsync")
.mockImplementation((payload) => {
return () => Promise.resolve(payload) as any;
});
@@ -389,7 +388,7 @@ describe("calendar Availability search", () => {
},
]);
const spy = jest
.spyOn(eventThunks, "getTempCalendarsListAsync")
.spyOn(servicesModule, "getTempCalendarsListAsync")
.mockImplementation((payload) => {
return () => Promise.resolve(payload) as any;
});
@@ -411,7 +410,7 @@ describe("calendar Availability search", () => {
it("open window with attendees filled after temp search on create event button click", async () => {
const spy = jest
.spyOn(eventThunks, "getTempCalendarsListAsync")
.spyOn(servicesModule, "getTempCalendarsListAsync")
.mockImplementation((payload) => {
return () => Promise.resolve(payload) as any;
});
@@ -455,7 +454,7 @@ describe("calendar Availability search", () => {
it("open window with attendees filled after temp search on enter in temp input", async () => {
const spy = jest
.spyOn(eventThunks, "getTempCalendarsListAsync")
.spyOn(servicesModule, "getTempCalendarsListAsync")
.mockImplementation((payload) => {
return () => Promise.resolve(payload) as any;
});
@@ -696,10 +695,10 @@ describe("calendar Availability search", () => {
);
const selectedCalls = spy.mock.calls.filter(
(call) => call[0].calId === "user1/cal1"
(call: { calId: string }[]) => call[0].calId === "user1/cal1"
);
const hiddenCalls = spy.mock.calls.filter(
(call) =>
(call: { calId: string }[]) =>
call[0].calId === "user1/cal2" || call[0].calId === "user1/cal3"
);
@@ -729,12 +728,13 @@ describe("calendar Availability search", () => {
);
const callsForCal1 = spy.mock.calls.filter(
(call) => call[0].calId === "user1/cal1"
(call: { calId: string }[]) => call[0].calId === "user1/cal1"
);
const uniqueRanges = new Set(
callsForCal1.map(
(call) => `${call[0].match.start}_${call[0].match.end}`
(call: { match: { end: string; start: string } }[]) =>
`${call[0].match.start}_${call[0].match.end}`
)
);
+7 -7
View File
@@ -1,13 +1,13 @@
import { fireEvent, screen, waitFor, act } from "@testing-library/react";
import CalendarSearch from "@/components/Calendar/CalendarSearch";
import * as CalendarApi from "@/features/Calendars/CalendarApi";
import * as CalendarSlice from "@/features/Calendars/services";
import { searchUsers } from "@/features/User/userAPI";
import { act, fireEvent, screen, waitFor } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import CalendarSearch from "../../src/components/Calendar/CalendarSearch";
import * as CalendarApi from "../../src/features/Calendars/CalendarApi";
import * as CalendarSlice from "../../src/features/Calendars/CalendarSlice";
import { searchUsers } from "../../src/features/User/userAPI";
import { renderWithProviders } from "../utils/Renderwithproviders";
jest.mock("../../src/features/User/userAPI");
jest.mock("../../src/features/Calendars/CalendarApi");
jest.mock("@/features/User/userAPI");
jest.mock("@/features/Calendars/CalendarApi");
const mockedSearchUsers = searchUsers as jest.MockedFunction<
typeof searchUsers
@@ -1,9 +1,9 @@
import { screen, fireEvent, waitFor, cleanup } from "@testing-library/react";
import CalendarSelection from "@/components/Calendar/CalendarSelection";
import * as calendarThunks from "@/features/Calendars/services";
import "@testing-library/jest-dom";
import CalendarSelection from "../../src/components/Calendar/CalendarSelection";
import { renderWithProviders } from "../utils/Renderwithproviders";
import * as calendarThunks from "../../src/features/Calendars/CalendarSlice";
import { cleanup, fireEvent, screen, waitFor } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { renderWithProviders } from "../utils/Renderwithproviders";
describe("CalendarSelection", () => {
beforeEach(() => {
+7 -7
View File
@@ -1,15 +1,15 @@
import {
screen,
fireEvent,
waitFor,
DateTimeFields,
DateTimeFieldsProps,
} from "@/components/Event/components/DateTimeFields";
import {
act,
fireEvent,
render,
screen,
waitFor,
} from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import {
DateTimeFieldsProps,
DateTimeFields,
} from "../../src/components/Event/components/DateTimeFields";
jest.mock("twake-i18n", () => ({
useI18n: () => ({
+6 -5
View File
@@ -1,8 +1,9 @@
import { RootState } from "@/app/store";
import EventDuplication from "@/components/Event/EventDuplicate";
import EventPreviewModal from "@/features/Events/EventDisplayPreview";
import EventPopover from "@/features/Events/EventModal";
import { fireEvent, screen, waitFor } from "@testing-library/react";
import EventDuplication from "../../src/components/Event/EventDuplicate";
import EventPopover from "../../src/features/Events/EventModal";
import { renderWithProviders } from "../utils/Renderwithproviders";
import EventPreviewModal from "../../src/features/Events/EventDisplayPreview";
const day = new Date();
const preloadedState = {
@@ -58,7 +59,7 @@ const preloadedState = {
},
pending: false,
},
};
} as unknown as RootState;
describe("EventDuplication", () => {
it("calls onOpenDuplicate when button clicked", () => {
@@ -155,7 +156,7 @@ describe("EventDisplayModal", () => {
expect(
screen.getByDisplayValue(
preloadedState.calendars.list["667037022b752d0026472254/cal1"].events
.event1.title
.event1.title as string
)
).toBeInTheDocument();
});
@@ -4,7 +4,7 @@ import {
DATETIME_WITH_SECONDS_LENGTH,
DATETIME_FORMAT_WITH_SECONDS,
DATETIME_FORMAT_WITHOUT_SECONDS,
} from "../../../../src/components/Event/utils/dateTimeHelpers";
} from "@/components/Event/utils/dateTimeHelpers";
describe("dateTimeHelpers", () => {
describe("Constants", () => {
@@ -1,6 +1,6 @@
import CalendarLayout from "@/components/Calendar/CalendarLayout";
import { act, fireEvent, screen, waitFor } from "@testing-library/react";
import { renderWithProviders } from "../utils/Renderwithproviders";
import CalendarLayout from "../../src/components/Calendar/CalendarLayout";
describe("Event Error Handling", () => {
beforeEach(() => {
+10 -10
View File
@@ -1,6 +1,14 @@
import * as appHooks from "@/app/hooks";
import { AppDispatch } from "@/app/store";
import CalendarApp from "@/components/Calendar/Calendar";
import {
createEventHandlers,
EventHandlersProps,
} from "@/components/Calendar/handlers/eventHandlers";
import * as eventThunks from "@/features/Calendars/services";
import EventUpdateModal from "@/features/Events/EventUpdateModal";
import { CalendarApi } from "@fullcalendar/core";
import { jest } from "@jest/globals";
import { ThunkDispatch } from "@reduxjs/toolkit";
import "@testing-library/jest-dom";
import {
act,
@@ -9,15 +17,7 @@ import {
waitFor,
within,
} from "@testing-library/react";
import * as appHooks from "../../src/app/hooks";
import * as eventThunks from "../../src/features/Calendars/CalendarSlice";
import CalendarApp from "../../src/components/Calendar/Calendar";
import EventUpdateModal from "../../src/features/Events/EventUpdateModal";
import { renderWithProviders } from "../utils/Renderwithproviders";
import {
createEventHandlers,
EventHandlersProps,
} from "../../src/components/Calendar/handlers/eventHandlers";
describe("CalendarApp integration", () => {
const today = new Date();
@@ -28,7 +28,7 @@ describe("CalendarApp integration", () => {
beforeEach(() => {
jest.clearAllMocks();
const dispatch = jest.fn() as ThunkDispatch<any, any, any>;
const dispatch = jest.fn() as AppDispatch;
jest.spyOn(appHooks, "useAppDispatch").mockReturnValue(dispatch);
});
+3 -3
View File
@@ -1,8 +1,8 @@
import { act, fireEvent, screen, waitFor } from "@testing-library/react";
import { Menubar } from "@/components/Menubar/Menubar";
import * as oidcAuth from "@/features/User/oidcAuth";
import "@testing-library/jest-dom";
import { Menubar } from "../../src/components/Menubar/Menubar";
import { act, fireEvent, screen, waitFor } from "@testing-library/react";
import { renderWithProviders } from "../utils/Renderwithproviders";
import * as oidcAuth from "../../src/features/User/oidcAuth";
describe("Calendar App Component Display Tests", () => {
const preloadedState = {
@@ -1,15 +1,15 @@
import { renderWithProviders } from "../utils/Renderwithproviders";
import { screen } from "@testing-library/react";
import * as appHooks from "@/app/hooks";
import { AppDispatch } from "@/app/store";
import CalendarApp from "@/components/Calendar/Calendar";
import { jest } from "@jest/globals";
import CalendarApp from "../../src/components/Calendar/Calendar";
import * as appHooks from "../../src/app/hooks";
import { ThunkDispatch } from "@reduxjs/toolkit";
import { screen } from "@testing-library/react";
import { renderWithProviders } from "../utils/Renderwithproviders";
describe("MiniCalendar", () => {
const day = new Date();
beforeEach(() => {
jest.clearAllMocks();
const dispatch = jest.fn() as ThunkDispatch<any, any, any>;
const dispatch = jest.fn() as AppDispatch;
jest.spyOn(appHooks, "useAppDispatch").mockReturnValue(dispatch);
jest.useFakeTimers().clearAllTimers();
});
+4 -7
View File
@@ -1,13 +1,10 @@
import { screen, fireEvent, waitFor, act } from "@testing-library/react";
import { PeopleSearch, User } from "@/components/Attendees/PeopleSearch";
import { searchUsers } from "@/features/User/userAPI";
import { act, fireEvent, screen, waitFor } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import {
User,
PeopleSearch,
} from "../../src/components/Attendees/PeopleSearch";
import { renderWithProviders } from "../utils/Renderwithproviders";
import { searchUsers } from "../../src/features/User/userAPI";
jest.mock("../../src/features/User/userAPI");
jest.mock("@/features/User/userAPI");
const mockedSearchUsers = searchUsers as jest.MockedFunction<
typeof searchUsers
>;
+6 -9
View File
@@ -1,13 +1,10 @@
import { screen, fireEvent, waitFor, act } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { renderWithProviders } from "../utils/Renderwithproviders";
import RepeatEvent from "../../src/components/Event/EventRepeat";
import EventPopover from "../../src/features/Events/EventModal";
import { RepetitionObject } from "../../src/features/Events/EventsTypes";
import RepeatEvent from "@/components/Event/EventRepeat";
import * as eventThunks from "@/features/Calendars/services";
import EventPopover from "@/features/Events/EventModal";
import { RepetitionObject } from "@/features/Events/EventsTypes";
import { DateSelectArg } from "@fullcalendar/core";
import { formatDateToYYYYMMDDTHHMMSS } from "../../src/utils/dateUtils";
import * as eventThunks from "../../src/features/Calendars/CalendarSlice";
import * as apiUtils from "../../src/utils/apiUtils";
import { act, fireEvent, screen, waitFor } from "@testing-library/react";
import { renderWithProviders } from "../utils/Renderwithproviders";
const baseRepetition: RepetitionObject = {
freq: "",
@@ -1,8 +1,7 @@
import { ResponsiveDialog } from "@/components/Dialog";
import { Button, TextField, TwakeMuiThemeProvider } from "@linagora/twake-mui";
import { fireEvent, render, screen } from "@testing-library/react";
import React from "react";
import { ResponsiveDialog } from "../../src/components/Dialog";
import { Button, TextField } from "@linagora/twake-mui";
import { TwakeMuiThemeProvider } from "@linagora/twake-mui";
describe("ResponsiveDialog", () => {
const mockOnClose = jest.fn();