Co-authored-by: lethemanh <lethemanh@lethemanhs-MacBook-Pro.local>
This commit is contained in:
@@ -25,6 +25,7 @@ const preloadedState = {
|
||||
id: "667037022b752d0026472254/cal1",
|
||||
name: "Calendar",
|
||||
color: "#FF0000",
|
||||
owner: { emails: ["test@test.com"] },
|
||||
events: {
|
||||
event1: {
|
||||
uid: "event1",
|
||||
|
||||
@@ -51,7 +51,12 @@ describe("helpers", () => {
|
||||
expect(mockedGetUserDetails).toHaveBeenNthCalledWith(1, "resource-123");
|
||||
expect(mockedGetResourceDetails).toHaveBeenCalledWith("resource-123");
|
||||
expect(mockedGetUserDetails).toHaveBeenNthCalledWith(2, "creator-456");
|
||||
expect(result).toEqual({ ...mockCreator, resource: true });
|
||||
expect(result).toEqual({
|
||||
...mockCreator,
|
||||
resource: true,
|
||||
administrators: undefined,
|
||||
resourceIcon: undefined,
|
||||
});
|
||||
});
|
||||
|
||||
it("should throw error when getUserDetails fails with non-404 error", async () => {
|
||||
|
||||
@@ -129,4 +129,55 @@ describe("AttendanceValidation - delegation", () => {
|
||||
expect(container.firstChild).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("resource calendar", () => {
|
||||
const resourceContext = makeContext({
|
||||
isOwn: false,
|
||||
calendar: {
|
||||
id: "res1/cal1",
|
||||
name: "Resource Cal",
|
||||
delegated: false,
|
||||
owner: {
|
||||
emails: ["resource@example.com"],
|
||||
resource: true,
|
||||
administrators: [{ id: "admin1" }],
|
||||
},
|
||||
events: {},
|
||||
} as Calendar,
|
||||
});
|
||||
|
||||
it("renders when user is an administrator of the resource", () => {
|
||||
const { getByText } = render(
|
||||
<AttendanceValidation
|
||||
contextualizedEvent={resourceContext}
|
||||
user={
|
||||
{
|
||||
...makeUser("admin@example.com"),
|
||||
openpaasId: "admin1",
|
||||
} as userData
|
||||
}
|
||||
setAfterChoiceFunc={noopSetFunc}
|
||||
setOpenEditModePopup={noopSetFunc}
|
||||
/>
|
||||
);
|
||||
expect(getByText("eventPreview.authorizeQuestion")).toBeTruthy();
|
||||
});
|
||||
|
||||
it("returns null when user is not an administrator of the resource", () => {
|
||||
const { container } = render(
|
||||
<AttendanceValidation
|
||||
contextualizedEvent={resourceContext}
|
||||
user={
|
||||
{
|
||||
...makeUser("other@example.com"),
|
||||
openpaasId: "other1",
|
||||
} as userData
|
||||
}
|
||||
setAfterChoiceFunc={noopSetFunc}
|
||||
setOpenEditModePopup={noopSetFunc}
|
||||
/>
|
||||
);
|
||||
expect(container.firstChild).toBeNull();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -103,6 +103,7 @@ describe("Event Preview Display", () => {
|
||||
id: "otherCal/cal",
|
||||
name: "Calendar 1",
|
||||
color: "#FF0000",
|
||||
owner: { emails: ["other@test.com"] },
|
||||
events: {
|
||||
event1: {
|
||||
uid: "event1",
|
||||
@@ -901,7 +902,7 @@ describe("Event Preview Display", () => {
|
||||
name: "Calendar 1",
|
||||
id: "667037022b752d0026472254/cal1",
|
||||
color: "#FF0000",
|
||||
// ownerEmails missing
|
||||
owner: {},
|
||||
events: {
|
||||
event1: {
|
||||
calId: "667037022b752d0026472254/cal1",
|
||||
|
||||
@@ -61,7 +61,8 @@ describe("EventUpdateModal Timezone Handling", () => {
|
||||
allday: false,
|
||||
organizer: { cn: "test", cal_address: "test@test.com" },
|
||||
attendee: [{ cn: "test", cal_address: "test@test.com" }],
|
||||
};
|
||||
URL: "/calendars/667037022b752d0026472254/cal1/test-event-1.ics",
|
||||
} as CalendarEvent;
|
||||
|
||||
const stateWithEvent = {
|
||||
...preloadedState,
|
||||
@@ -122,7 +123,8 @@ describe("EventUpdateModal Timezone Handling", () => {
|
||||
allday: false,
|
||||
organizer: { cn: "test", cal_address: "test@test.com" },
|
||||
attendee: [{ cn: "test", cal_address: "test@test.com" }],
|
||||
};
|
||||
URL: "/calendars/667037022b752d0026472254/cal1/test-event-2.ics",
|
||||
} as CalendarEvent;
|
||||
|
||||
const stateWithEvent = {
|
||||
...preloadedState,
|
||||
@@ -181,7 +183,8 @@ describe("EventUpdateModal Timezone Handling", () => {
|
||||
cutype: "RESOURCE",
|
||||
},
|
||||
],
|
||||
};
|
||||
URL: "/calendars/667037022b752d0026472254/cal1/test-event-resource.ics",
|
||||
} as CalendarEvent;
|
||||
|
||||
const stateWithEvent = {
|
||||
...preloadedState,
|
||||
@@ -239,6 +242,10 @@ describe("EventUpdateModal Timezone Handling", () => {
|
||||
expect(resource).toBeDefined();
|
||||
expect(resource!.cn).toBe("Conference Room");
|
||||
expect(resource!.cal_address).toBe("room@test.com");
|
||||
expect(resource!.partstat).toBe("ACCEPTED");
|
||||
expect(resource!.rsvp).toBe("TRUE");
|
||||
expect(resource!.role).toBe("REQ-PARTICIPANT");
|
||||
expect(resource!.cutype).toBe("RESOURCE");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -294,7 +301,8 @@ describe("EventUpdateModal Recurring to Non-Recurring Conversion", () => {
|
||||
organizer: { cn: "test", cal_address: "test@test.com" },
|
||||
attendee: [{ cn: "test", cal_address: "test@test.com" }],
|
||||
URL: `/calendars/${calId}/${baseUID}.ics`,
|
||||
};
|
||||
timezone: "UTC",
|
||||
} as CalendarEvent;
|
||||
|
||||
const instance1 = {
|
||||
...masterEvent,
|
||||
@@ -445,6 +453,7 @@ describe("EventUpdateModal Recurring to Non-Recurring Conversion", () => {
|
||||
organizer: { cn: "test", cal_address: "test@test.com" },
|
||||
attendee: [{ cn: "test", cal_address: "test@test.com" }],
|
||||
URL: `/calendars/${calId}/${baseUID}.ics`,
|
||||
timezone: "UTC",
|
||||
} as CalendarEvent;
|
||||
|
||||
const instance1 = {
|
||||
@@ -582,7 +591,8 @@ describe("EventUpdateModal Recurring to Non-Recurring Conversion", () => {
|
||||
organizer: { cn: "test", cal_address: "test@test.com" },
|
||||
attendee: [{ cn: "test", cal_address: "test@test.com" }],
|
||||
URL: `/calendars/${calId}/${baseUID}.ics`,
|
||||
};
|
||||
timezone: "UTC",
|
||||
} as CalendarEvent;
|
||||
|
||||
const instance1 = {
|
||||
...masterEvent,
|
||||
|
||||
Reference in New Issue
Block a user