Co-authored-by: Camille Moussu <cmoussu@linagora.com>
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import { fireEvent, screen, waitFor } from "@testing-library/react";
|
||||
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 calendarThunks from "../../src/features/Calendars/CalendarSlice";
|
||||
import { act, useRef } from "react";
|
||||
import { useRef } from "react";
|
||||
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import CalendarLayout from "../../src/components/Calendar/CalendarLayout";
|
||||
@@ -41,7 +41,7 @@ describe("CalendarSelection", () => {
|
||||
calendars: {
|
||||
list: {
|
||||
"user1/cal1": {
|
||||
name: "Calendar personnal",
|
||||
name: "Calendar personal",
|
||||
id: "user1/cal1",
|
||||
color: { light: "#FF0000", dark: "#000" },
|
||||
ownerEmails: ["alice@example.com"],
|
||||
@@ -146,11 +146,11 @@ describe("CalendarSelection", () => {
|
||||
preloadedState
|
||||
);
|
||||
});
|
||||
expect(screen.getByText("Personnal Calendars")).toBeInTheDocument();
|
||||
expect(screen.getByText("Delegated Calendars")).toBeInTheDocument();
|
||||
expect(screen.getByText("Other Calendars")).toBeInTheDocument();
|
||||
expect(screen.getByText("calendar.personal")).toBeInTheDocument();
|
||||
expect(screen.getByText("calendar.delegated")).toBeInTheDocument();
|
||||
expect(screen.getByText("calendar.other")).toBeInTheDocument();
|
||||
|
||||
expect(screen.getByLabelText("Calendar personnal")).toBeInTheDocument();
|
||||
expect(screen.getByLabelText("Calendar personal")).toBeInTheDocument();
|
||||
expect(screen.getByLabelText("Calendar delegated")).toBeInTheDocument();
|
||||
expect(screen.getByLabelText("Calendar shared")).toBeInTheDocument();
|
||||
});
|
||||
@@ -162,16 +162,16 @@ describe("CalendarSelection", () => {
|
||||
preloadedState
|
||||
);
|
||||
});
|
||||
expect(screen.getByText("Personnal Calendars")).toBeInTheDocument();
|
||||
expect(screen.getByText("Delegated Calendars")).toBeInTheDocument();
|
||||
expect(screen.getByText("Other Calendars")).toBeInTheDocument();
|
||||
expect(screen.getByText("calendar.personal")).toBeInTheDocument();
|
||||
expect(screen.getByText("calendar.delegated")).toBeInTheDocument();
|
||||
expect(screen.getByText("calendar.other")).toBeInTheDocument();
|
||||
|
||||
expect(screen.getByLabelText("Calendar personnal")).toBeInTheDocument();
|
||||
expect(screen.getByLabelText("Calendar personal")).toBeInTheDocument();
|
||||
expect(screen.getByLabelText("Calendar delegated")).toBeInTheDocument();
|
||||
expect(screen.getByLabelText("Calendar shared")).toBeInTheDocument();
|
||||
|
||||
const sharedAccordionSummary = screen
|
||||
.getByText("Other Calendars")
|
||||
.getByText("calendar.other")
|
||||
.closest(".MuiAccordionSummary-root");
|
||||
|
||||
const addButton = screen.getAllByTestId("AddIcon")[2];
|
||||
@@ -185,12 +185,12 @@ describe("CalendarSelection", () => {
|
||||
});
|
||||
expect(sharedAccordionSummary).toHaveAttribute("aria-expanded", "true");
|
||||
});
|
||||
it("BUGFIX: remove dots in mini calendar when unselecting personnal calendar", async () => {
|
||||
it("BUGFIX: remove dots in mini calendar when unselecting personal calendar", async () => {
|
||||
await act(async () =>
|
||||
renderWithProviders(<CalendarLayout />, preloadedState)
|
||||
);
|
||||
|
||||
const checkbox = screen.getByLabelText("Calendar personnal");
|
||||
const checkbox = screen.getByLabelText("Calendar personal");
|
||||
// checkbox checked : events shown
|
||||
expect(
|
||||
screen.getByTestId(
|
||||
@@ -223,9 +223,9 @@ describe("CalendarSelection", () => {
|
||||
renderWithProviders(<CalendarLayout />, preloadedState)
|
||||
);
|
||||
|
||||
// hide personnal event first
|
||||
// hide personal event first
|
||||
await act(async () => {
|
||||
fireEvent.click(screen.getByLabelText("Calendar personnal"));
|
||||
fireEvent.click(screen.getByLabelText("Calendar personal"));
|
||||
});
|
||||
const checkbox = screen.getByLabelText("Calendar delegated");
|
||||
|
||||
@@ -250,9 +250,9 @@ describe("CalendarSelection", () => {
|
||||
renderWithProviders(<CalendarLayout />, preloadedState)
|
||||
);
|
||||
|
||||
// hide personnal event first
|
||||
// hide personal event first
|
||||
await act(async () => {
|
||||
fireEvent.click(screen.getByLabelText("Calendar personnal"));
|
||||
fireEvent.click(screen.getByLabelText("Calendar personal"));
|
||||
});
|
||||
const checkbox = screen.getByLabelText("Calendar shared");
|
||||
|
||||
@@ -286,7 +286,7 @@ describe("CalendarSelection", () => {
|
||||
);
|
||||
});
|
||||
|
||||
expect(screen.getByLabelText("Calendar personnal")).toBeChecked();
|
||||
expect(screen.getByLabelText("Calendar personal")).toBeChecked();
|
||||
expect(screen.getByLabelText("Calendar delegated")).toBeChecked();
|
||||
expect(screen.getByLabelText("Calendar shared")).toBeChecked();
|
||||
});
|
||||
@@ -299,12 +299,12 @@ describe("CalendarSelection", () => {
|
||||
);
|
||||
});
|
||||
|
||||
expect(screen.getByLabelText("Calendar personnal")).toBeChecked();
|
||||
expect(screen.getByLabelText("Calendar personal")).toBeChecked();
|
||||
expect(screen.getByLabelText("Calendar delegated")).not.toBeChecked();
|
||||
expect(screen.getByLabelText("Calendar shared")).not.toBeChecked();
|
||||
|
||||
await act(async () => {
|
||||
fireEvent.click(screen.getByLabelText("Calendar personnal"));
|
||||
fireEvent.click(screen.getByLabelText("Calendar personal"));
|
||||
fireEvent.click(screen.getByLabelText("Calendar shared"));
|
||||
});
|
||||
|
||||
@@ -333,7 +333,7 @@ describe("calendar Availability search", () => {
|
||||
calendars: {
|
||||
list: {
|
||||
"user1/cal1": {
|
||||
name: "Calendar personnal",
|
||||
name: "Calendar personal",
|
||||
id: "user1/cal1",
|
||||
color: { light: "#FF0000", dark: "#000" },
|
||||
ownerEmails: ["alice@example.com"],
|
||||
@@ -364,7 +364,7 @@ describe("calendar Availability search", () => {
|
||||
renderWithProviders(<CalendarTestWrapper />, preloadedState)
|
||||
);
|
||||
|
||||
const input = screen.getByPlaceholderText(/start typing a name or email/i);
|
||||
const input = screen.getByPlaceholderText("peopleSearch.placeholder");
|
||||
act(() => {
|
||||
userEvent.type(input, "New");
|
||||
});
|
||||
@@ -394,7 +394,7 @@ describe("calendar Availability search", () => {
|
||||
renderWithProviders(<CalendarTestWrapper />, preloadedState)
|
||||
);
|
||||
|
||||
const input = screen.getByPlaceholderText(/start typing a name or email/i);
|
||||
const input = screen.getByPlaceholderText("peopleSearch.placeholder");
|
||||
await act(async () => userEvent.type(input, "Alice"));
|
||||
|
||||
const option = await screen.findByText("Alice");
|
||||
@@ -423,7 +423,7 @@ describe("calendar Availability search", () => {
|
||||
renderWithProviders(<CalendarTestWrapper />, preloadedState)
|
||||
);
|
||||
|
||||
const input = screen.getByPlaceholderText(/start typing a name or email/i);
|
||||
const input = screen.getByPlaceholderText("peopleSearch.placeholder");
|
||||
await act(async () => userEvent.type(input, "New"));
|
||||
|
||||
const option = await screen.findByText("New User");
|
||||
@@ -433,10 +433,12 @@ describe("calendar Availability search", () => {
|
||||
});
|
||||
expect(spy).toHaveBeenCalled();
|
||||
await act(async () => {
|
||||
fireEvent.click(screen.getByRole("button", { name: /create event/i }));
|
||||
fireEvent.click(
|
||||
screen.getByRole("button", { name: "event.createEvent" })
|
||||
);
|
||||
});
|
||||
await waitFor(() => {
|
||||
expect(screen.getAllByText(/Create Event/i)).toHaveLength(2);
|
||||
expect(screen.getAllByText("event.createEvent")).toHaveLength(2);
|
||||
expect(screen.getAllByText(/New User/i)).toHaveLength(2);
|
||||
});
|
||||
});
|
||||
@@ -460,7 +462,7 @@ describe("calendar Availability search", () => {
|
||||
renderWithProviders(<CalendarTestWrapper />, preloadedState)
|
||||
);
|
||||
|
||||
const input = screen.getByPlaceholderText(/start typing a name or email/i);
|
||||
const input = screen.getByPlaceholderText("peopleSearch.placeholder");
|
||||
await act(async () => userEvent.type(input, "New"));
|
||||
|
||||
const option = await screen.findByText("New User");
|
||||
@@ -473,12 +475,12 @@ describe("calendar Availability search", () => {
|
||||
});
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getAllByText(/Create Event/i)).toHaveLength(2);
|
||||
expect(screen.getAllByText("event.createEvent")).toHaveLength(2);
|
||||
expect(screen.getAllByText(/New User/i)).toHaveLength(2);
|
||||
});
|
||||
});
|
||||
|
||||
it("BUGFIX: can untoggle all personnal calendars", async () => {
|
||||
it("BUGFIX: can untoggle all calendar.personal", async () => {
|
||||
await act(async () =>
|
||||
renderWithProviders(<CalendarTestWrapper />, {
|
||||
user: preloadedState.user,
|
||||
@@ -489,7 +491,7 @@ describe("calendar Availability search", () => {
|
||||
})
|
||||
);
|
||||
|
||||
const checkbox = screen.getByLabelText("Calendar personnal");
|
||||
const checkbox = screen.getByLabelText("Calendar personal");
|
||||
expect(checkbox).toBeChecked();
|
||||
|
||||
fireEvent.click(checkbox); // toggle off
|
||||
|
||||
Reference in New Issue
Block a user