Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added join event button to EventDetails page #142

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/IsaacApiTypesCustom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ export interface IsaacEventPageDTO extends AutoGeneratedIsaacEventPageDTO {
// We don't want to use event thumbnail alt text for WCAG compliance (it's a decorative image, and conveys no meaning)
eventThumbnail?: Omit<ImageDTO, "altText">;
children?: ContentDTO[];
// TEMPORARY UNTIL API CHANGES MADE
meetingUrl?: string;
}

// temporary changes to the MisuseStatisticDTO and AssignmentStatusDTO until typescript generator plugin is correctly giving required properties
Expand Down
11 changes: 10 additions & 1 deletion src/app/components/pages/EventDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ const EventDetails = ({
src={event.eventThumbnail.src}
data-testid="event-details-image"
/>
<div className="border px-2 py-1 mt-3 bg-light" data-testid="event-details-title">
<div className="border px-2 py-1 mt-3 bg-light text-center" data-testid="event-details-title">
<strong>{event.title}</strong>
{event.isPrivateEvent && (
<Row className="mx-0 mt-2">
Expand All @@ -167,6 +167,15 @@ const EventDetails = ({
</Row>
)}
</div>

{event.userBookingStatus === "CONFIRMED" && event.meetingUrl && (
<a href={event.meetingUrl} className="w-100" target="_blank" rel="noopener noreferrer">
<Button color="primary" className="mt-2 w-100">
Join event now
</Button>
</a>
)}

{isDefined(event.location) &&
isDefined(event.location?.latitude) &&
isDefined(event.location?.longitude) && (
Expand Down
53 changes: 53 additions & 0 deletions src/test/pages/EventDetails.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const eventDate = () => screen.getByTestId("event-date");
const placesAvailable = () => screen.queryByTestId("event-availability");
const privateBadge = () => screen.queryByText("Private Event");
const bookingDeadline = () => screen.queryByTestId("event-booking-deadline");
const joinEventButton = () => screen.queryByRole("link", { name: "Join event now" });

describe("EventDetails", () => {
const setupTest = async ({ role, event }: { role: TestUserRole; event: IsaacEventPageDTO }) => {
Expand Down Expand Up @@ -253,4 +254,56 @@ describe("EventDetails", () => {
await setupTest({ role: "STUDENT", event });
expect(getButton("Leave waiting list")).toBeInTheDocument();
});

it("does not offer a 'join event now' button if user is not logged in", async () => {
const event = {
...mockEvent,
meetingUrl: "https://example-meeting-link.com",
};
await setupTest({ role: "ANONYMOUS", event });
expect(joinEventButton()).toBeNull();
});

it("does not offer a 'join event now' button if user is not booked on the event", async () => {
const event = {
...mockEvent,
meetingUrl: "https://example-meeting-link.com",
};
await setupTest({ role: "STUDENT", event });
expect(joinEventButton()).toBeNull();
});

it.each(["RESERVED", "CANCELLED", "WAITING_LIST", "ATTENDED", "ABSENT"] as BookingStatus[])(
"does not offer a 'join event now' button if user's booking status is %s",
async (bookingStatus) => {
const event = {
...mockEvent,
meetingUrl: "https://example-meeting-link.com",
userBookingStatus: bookingStatus,
};
await setupTest({ role: "STUDENT", event });
const joinEventButton = screen.queryByRole("link", { name: "Join event now" });
expect(joinEventButton).toBeNull();
},
);

it("does not offer a 'join event now' button if a meetingUrl is not provided", async () => {
const event = {
...mockEvent,
userBookingStatus: "CONFIRMED" as BookingStatus,
};
await setupTest({ role: "STUDENT", event });
expect(joinEventButton()).toBeNull();
});

it("offers a 'join event now' button if a meetingUrl is provided and user's booking status is CONFIRMED", async () => {
const event = {
...mockEvent,
meetingUrl: "https://example-meeting-link.com",
userBookingStatus: "CONFIRMED" as BookingStatus,
};
await setupTest({ role: "STUDENT", event });
expect(joinEventButton()).toBeInTheDocument();
expect(joinEventButton()).toHaveAttribute("href", event.meetingUrl);
});
});
Loading