[fix] removed added calendars old naming convention (#567)
Co-authored-by: Camille Moussu <cmoussu@linagora.com>
This commit is contained in:
@@ -76,7 +76,7 @@ describe("CalendarSelection", () => {
|
||||
delegated: true,
|
||||
id: "user2/cal1",
|
||||
color: { light: "#FF0000", dark: "#000" },
|
||||
owner: { emails: ["alice@example.com"] },
|
||||
owner: { emails: ["alice@example.com"], lastname: "alice" },
|
||||
events: {
|
||||
event1: {
|
||||
id: "event1",
|
||||
@@ -107,7 +107,7 @@ describe("CalendarSelection", () => {
|
||||
name: "Calendar shared",
|
||||
id: "user3/cal1",
|
||||
color: { light: "#FF0000", dark: "#000" },
|
||||
owner: { emails: ["alice@example.com"] },
|
||||
owner: { emails: ["alice@example.com"], lastname: "alice" },
|
||||
events: {
|
||||
event1: {
|
||||
id: "event1",
|
||||
@@ -709,10 +709,10 @@ describe("calendar Availability search", () => {
|
||||
);
|
||||
|
||||
const selectedCalls = spy.mock.calls.filter(
|
||||
(call: { calId: string }[]) => call[0].calId === "user1/cal1"
|
||||
(call) => call[0].calId === "user1/cal1"
|
||||
);
|
||||
const hiddenCalls = spy.mock.calls.filter(
|
||||
(call: { calId: string }[]) =>
|
||||
spy.mock.calls.filter(
|
||||
(call) =>
|
||||
call[0].calId === "user1/cal2" || call[0].calId === "user1/cal3"
|
||||
);
|
||||
|
||||
@@ -745,13 +745,12 @@ describe("calendar Availability search", () => {
|
||||
);
|
||||
|
||||
const callsForCal1 = spy.mock.calls.filter(
|
||||
(call: { calId: string }[]) => call[0].calId === "user1/cal1"
|
||||
(call) => call[0].calId === "user1/cal1"
|
||||
);
|
||||
|
||||
const uniqueRanges = new Set(
|
||||
callsForCal1.map(
|
||||
(call: { match: { end: string; start: string } }[]) =>
|
||||
`${call[0].match.start}_${call[0].match.end}`
|
||||
(call) => `${call[0].match.start}_${call[0].match.end}`
|
||||
)
|
||||
);
|
||||
|
||||
@@ -762,8 +761,8 @@ describe("calendar Availability search", () => {
|
||||
const stateWithUndefinedCalendars = {
|
||||
...preloadedState,
|
||||
calendars: {
|
||||
list: undefined as any,
|
||||
templist: undefined as any,
|
||||
list: undefined,
|
||||
templist: undefined,
|
||||
pending: false,
|
||||
},
|
||||
};
|
||||
@@ -783,7 +782,7 @@ describe("calendar Availability search", () => {
|
||||
...preloadedState,
|
||||
calendars: {
|
||||
...preloadedState.calendars,
|
||||
templist: undefined as any,
|
||||
templist: undefined,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ describe("CalendarSearch", () => {
|
||||
|
||||
await act(async () => {
|
||||
renderWithProviders(
|
||||
<CalendarSearch anchorEl={null} open={true} onClose={mockOnClose} />,
|
||||
<CalendarSearch open={true} onClose={mockOnClose} />,
|
||||
preloadedState
|
||||
);
|
||||
});
|
||||
@@ -96,7 +96,7 @@ describe("CalendarSearch", () => {
|
||||
});
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText("Test Calendar")).toBeInTheDocument();
|
||||
expect(screen.getByText(/Test Calendar/i)).toBeInTheDocument();
|
||||
expect(screen.getByText("user@example.com")).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
@@ -117,7 +117,7 @@ describe("CalendarSearch", () => {
|
||||
|
||||
await act(async () => {
|
||||
renderWithProviders(
|
||||
<CalendarSearch anchorEl={null} open={true} onClose={mockOnClose} />,
|
||||
<CalendarSearch open={true} onClose={mockOnClose} />,
|
||||
preloadedState
|
||||
);
|
||||
});
|
||||
@@ -133,7 +133,7 @@ describe("CalendarSearch", () => {
|
||||
});
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText("Test Calendar")).toBeInTheDocument();
|
||||
expect(screen.getByText(/Test Calendar/i)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
const addButton = screen.getByRole("button", { name: /add/i });
|
||||
@@ -170,7 +170,7 @@ describe("CalendarSearch", () => {
|
||||
|
||||
await act(async () => {
|
||||
renderWithProviders(
|
||||
<CalendarSearch anchorEl={null} open={true} onClose={mockOnClose} />,
|
||||
<CalendarSearch open={true} onClose={mockOnClose} />,
|
||||
preloadedState
|
||||
);
|
||||
});
|
||||
@@ -205,7 +205,7 @@ describe("CalendarSearch", () => {
|
||||
|
||||
await act(async () => {
|
||||
renderWithProviders(
|
||||
<CalendarSearch anchorEl={null} open={true} onClose={mockOnClose} />,
|
||||
<CalendarSearch open={true} onClose={mockOnClose} />,
|
||||
preloadedState
|
||||
);
|
||||
});
|
||||
@@ -237,7 +237,7 @@ describe("CalendarSearch", () => {
|
||||
|
||||
await act(async () => {
|
||||
renderWithProviders(
|
||||
<CalendarSearch anchorEl={null} open={true} onClose={mockOnClose} />,
|
||||
<CalendarSearch open={true} onClose={mockOnClose} />,
|
||||
preloadedState
|
||||
);
|
||||
});
|
||||
@@ -253,7 +253,7 @@ describe("CalendarSearch", () => {
|
||||
});
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText("Test Calendar")).toBeInTheDocument();
|
||||
expect(screen.getByText(/Test Calendar/i)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
// ColorPicker would need to be interacted with based on its implementation
|
||||
@@ -286,7 +286,7 @@ describe("CalendarSearch", () => {
|
||||
|
||||
await act(async () => {
|
||||
renderWithProviders(
|
||||
<CalendarSearch anchorEl={null} open={true} onClose={mockOnClose} />,
|
||||
<CalendarSearch open={true} onClose={mockOnClose} />,
|
||||
preloadedState
|
||||
);
|
||||
});
|
||||
@@ -302,8 +302,8 @@ describe("CalendarSearch", () => {
|
||||
});
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText("Test Calendar")).toBeInTheDocument();
|
||||
expect(screen.getByText("Second Calendar")).toBeInTheDocument();
|
||||
expect(screen.getByText(/Test Calendar/i)).toBeInTheDocument();
|
||||
expect(screen.getByText(/Second Calendar/i)).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -316,7 +316,7 @@ describe("CalendarSearch", () => {
|
||||
|
||||
await act(async () => {
|
||||
renderWithProviders(
|
||||
<CalendarSearch anchorEl={null} open={true} onClose={mockOnClose} />,
|
||||
<CalendarSearch open={true} onClose={mockOnClose} />,
|
||||
preloadedState
|
||||
);
|
||||
});
|
||||
@@ -351,7 +351,7 @@ describe("CalendarSearch", () => {
|
||||
|
||||
await act(async () => {
|
||||
renderWithProviders(
|
||||
<CalendarSearch anchorEl={null} open={true} onClose={mockOnClose} />,
|
||||
<CalendarSearch open={true} onClose={mockOnClose} />,
|
||||
preloadedState
|
||||
);
|
||||
});
|
||||
@@ -378,7 +378,7 @@ describe("CalendarSearch", () => {
|
||||
});
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText("Test Calendar")).toBeInTheDocument();
|
||||
expect(screen.getByText(/Test Calendar/i)).toBeInTheDocument();
|
||||
expect(screen.getByText("user@example.com")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
|
||||
@@ -24,20 +24,28 @@ describe("CalendarSelection", () => {
|
||||
name: "Calendar personal",
|
||||
id: "user1/cal1",
|
||||
color: "#FF0000",
|
||||
owner: { emails: ["alice@example.com"] },
|
||||
owner: { emails: ["alice@example.com"], lastname: "alice" },
|
||||
},
|
||||
"user2/cal1": {
|
||||
name: "Calendar delegated",
|
||||
delegated: true,
|
||||
id: "user2/cal1",
|
||||
color: "#00FF00",
|
||||
owner: { emails: ["bob@example.com"] },
|
||||
owner: {
|
||||
firstname: "Bob",
|
||||
lastname: "Builder",
|
||||
emails: ["bob@example.com"],
|
||||
},
|
||||
},
|
||||
"user3/cal1": {
|
||||
name: "Calendar shared",
|
||||
id: "user3/cal1",
|
||||
color: "#0000FF",
|
||||
owner: { emails: ["charlie@example.com"] },
|
||||
owner: {
|
||||
firstname: "Charlie",
|
||||
lastname: "Chaplin",
|
||||
emails: ["charlie@example.com"],
|
||||
},
|
||||
},
|
||||
};
|
||||
beforeAll(() => {
|
||||
@@ -273,4 +281,18 @@ describe("CalendarSelection", () => {
|
||||
fireEvent.click(delegatedAccordionSummary!);
|
||||
expect(delegatedAccordionSummary).toHaveAttribute("aria-expanded", "false");
|
||||
});
|
||||
|
||||
it("renders owner name caption for non-personal, non-default calendars", () => {
|
||||
renderWithProviders(
|
||||
<CalendarSelection
|
||||
selectedCalendars={[]}
|
||||
setSelectedCalendars={jest.fn()}
|
||||
/>,
|
||||
{ user: baseUser, calendars: { list: calendarsMock, pending: false } }
|
||||
);
|
||||
expect(screen.getByText("Bob Builder")).toBeInTheDocument();
|
||||
expect(screen.getByText("Charlie Chaplin")).toBeInTheDocument();
|
||||
// personal calendar should NOT show a caption
|
||||
expect(screen.queryByText("alice")).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -114,7 +114,7 @@ describe("Calendar API", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("get secret link ", async () => {
|
||||
it("get secret link without reset", async () => {
|
||||
const calLink = "/calendars/calId.json";
|
||||
(api.get as jest.Mock).mockReturnValue({
|
||||
json: jest.fn().mockResolvedValue("link"),
|
||||
@@ -131,7 +131,7 @@ describe("Calendar API", () => {
|
||||
}
|
||||
);
|
||||
});
|
||||
it("get secret link ", async () => {
|
||||
it("get secret link with reset", async () => {
|
||||
const calLink = "/calendars/calId.json";
|
||||
(api.get as jest.Mock).mockReturnValue({
|
||||
json: jest.fn().mockResolvedValue("link"),
|
||||
@@ -162,7 +162,7 @@ describe("Calendar API", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("When adding a sharedCal with #default as a name a new name is sent to the back", async () => {
|
||||
it("When adding a sharedCal with #default #default is preserved", async () => {
|
||||
const mockApiPost = jest.spyOn(api, "post");
|
||||
|
||||
const calData = {
|
||||
@@ -192,12 +192,11 @@ describe("Calendar API", () => {
|
||||
expect(mockApiPost).toHaveBeenCalledWith(
|
||||
"dav/calendars/currentUserId.json",
|
||||
expect.objectContaining({
|
||||
body: expect.stringContaining('"dav:name":"John Doe\'s calendar"'),
|
||||
body: expect.stringContaining('"dav:name":"#default"'),
|
||||
})
|
||||
);
|
||||
|
||||
const callBody = JSON.parse(String(mockApiPost.mock.calls[0][1]?.body));
|
||||
expect(callBody["dav:name"]).toBe("John Doe's calendar");
|
||||
expect(callBody["dav:name"]).not.toBe("#default");
|
||||
expect(callBody["dav:name"]).toBe("#default");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user