559 delegation create event in another user calendar (#561)
* [#559] added delegated calendars in user selector * [#559] selector for calendar display delegated and personal separatly Co-authored-by: Camille Moussu <cmoussu@linagora.com>
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import { buildDelegatedEventURL } from "@/features/Events/eventUtils";
|
||||
import { Calendar } from "@/features/Calendars/CalendarTypes";
|
||||
import { CalendarEvent } from "@/features/Events/EventsTypes";
|
||||
import { buildDelegatedEventURL } from "@/features/Events/eventUtils";
|
||||
|
||||
const makeCalendar = (link: string): Calendar =>
|
||||
({
|
||||
@@ -10,45 +9,42 @@ const makeCalendar = (link: string): Calendar =>
|
||||
owner: { emails: ["owner@example.com"] },
|
||||
}) as Calendar;
|
||||
|
||||
const makeEvent = (url: string): CalendarEvent =>
|
||||
({ URL: url, calId: "user2/cal1" }) as CalendarEvent;
|
||||
|
||||
describe("buildDelegatedEventURL", () => {
|
||||
it("rebases event filename onto calendar link base path", () => {
|
||||
const calendar = makeCalendar("/calendars/user2/cal1.json");
|
||||
const event = makeEvent("/calendars/someother/path/event-abc.ics");
|
||||
expect(buildDelegatedEventURL(calendar, event)).toBe(
|
||||
const eventURL = "/calendars/someother/path/event-abc.ics";
|
||||
expect(buildDelegatedEventURL(calendar, eventURL)).toBe(
|
||||
"/calendars/user2/cal1/event-abc.ics"
|
||||
);
|
||||
});
|
||||
|
||||
it("strips .json suffix from calendar link", () => {
|
||||
const calendar = makeCalendar("/calendars/user2/cal1.json");
|
||||
const event = makeEvent("/calendars/user2/cal1/event-abc.ics");
|
||||
const result = buildDelegatedEventURL(calendar, event);
|
||||
const eventURL = "/calendars/user2/cal1/event-abc.ics";
|
||||
const result = buildDelegatedEventURL(calendar, eventURL);
|
||||
expect(result).not.toContain(".json");
|
||||
});
|
||||
|
||||
it("preserves the exact filename from the event URL", () => {
|
||||
const calendar = makeCalendar("/calendars/user2/cal1.json");
|
||||
const event = makeEvent("/calendars/user2/cal1/some-uid-with-dashes.ics");
|
||||
expect(buildDelegatedEventURL(calendar, event)).toBe(
|
||||
const eventURL = "/calendars/user2/cal1/some-uid-with-dashes.ics";
|
||||
expect(buildDelegatedEventURL(calendar, eventURL)).toBe(
|
||||
"/calendars/user2/cal1/some-uid-with-dashes.ics"
|
||||
);
|
||||
});
|
||||
|
||||
it("throws when event URL has no filename", () => {
|
||||
const calendar = makeCalendar("/calendars/user2/cal1.json");
|
||||
const event = makeEvent("");
|
||||
expect(() => buildDelegatedEventURL(calendar, event)).toThrow(
|
||||
const eventURL = "";
|
||||
expect(() => buildDelegatedEventURL(calendar, eventURL)).toThrow(
|
||||
/Cannot extract filename from event URL/
|
||||
);
|
||||
});
|
||||
|
||||
it("works with nested calendar link paths", () => {
|
||||
const calendar = makeCalendar("/dav/calendars/users/user2/cal1.json");
|
||||
const event = makeEvent("/other/path/event-xyz.ics");
|
||||
expect(buildDelegatedEventURL(calendar, event)).toBe(
|
||||
const eventURL = "/other/path/event-xyz.ics";
|
||||
expect(buildDelegatedEventURL(calendar, eventURL)).toBe(
|
||||
"/dav/calendars/users/user2/cal1/event-xyz.ics"
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user