Skip to content

Fix room requests and add e2e tests #198

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

Merged
merged 1 commit into from
Jul 6, 2025
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
11 changes: 5 additions & 6 deletions src/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,18 @@ export const generateProjectionParams = ({ userFields }: GenerateProjectionParam


export const nonEmptyCommaSeparatedStringSchema = z.
string().
min(1, { message: "Filter expression must be at least 1 character long." }).
transform((val) => val.split(',').map((item) => item.trim())).
pipe(z.array(z.string()).nonempty());
array(z.string().min(1)).
min(1, { message: "Filter expression must select at least one item." }).
transform((val) => val.map((item) => item.trim()))

type GetDefaultFilteringQuerystringInput = {
defaultSelect: string[];
};
export const getDefaultFilteringQuerystring = ({ defaultSelect }: GetDefaultFilteringQuerystringInput) => {
return {
select: z.optional(nonEmptyCommaSeparatedStringSchema).default(defaultSelect).meta({
description: "Comma-seperated list of attributes to return",
...(defaultSelect.length === 0 ? { default: "<ALL ATTRIBUTES>" } : {})
description: "A list of attributes to return.",
...(defaultSelect.length === 0 ? { default: ["<ALL ATTRIBUTES>"] } : { example: defaultSelect })
})
};
};
4 changes: 3 additions & 1 deletion src/ui/pages/roomRequest/RoomRequestLanding.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ export const ManageRoomRequestsPage: React.FC = () => {
host: string;
status: RoomRequestStatus;
}[]
>(`/api/v1/roomRequests/${semester}?select=requestId,title,host,status`);
>(
`/api/v1/roomRequests/${semester}?select=requestId&select=title&select=host&select=status`,
);
return response.data.map((x) => ({ ...x, semester }));
};

Expand Down
8 changes: 6 additions & 2 deletions tests/e2e/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ export function capitalizeFirstLetter(string: string) {
}

async function becomeUser(page: Page) {
await page.goto("https://core.aws.qa.acmuiuc.org/login");
await page.goto(
process.env.E2E_TEST_HOST || "https://core.aws.qa.acmuiuc.org/login",
);
await page
.getByRole("button", { name: "Sign in with Illinois NetID" })
.click();
Expand All @@ -58,7 +60,9 @@ async function becomeUser(page: Page) {
.fill(secrets["PLAYWRIGHT_USERNAME"]);
await page.getByPlaceholder("[email protected]").press("Enter");
await page.getByPlaceholder("Password").click();
await page.getByPlaceholder("Password").fill(secrets["PLAYWRIGHT_PASSWORD"]);
await page.getByPlaceholder("Password").evaluate((input, password) => {
(input as any).value = password;
}, secrets["PLAYWRIGHT_PASSWORD"]);
await page.getByRole("button", { name: "Sign in" }).click();
await page.getByRole("button", { name: "No" }).click();
}
Expand Down
30 changes: 30 additions & 0 deletions tests/e2e/roomRequests.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { expect } from "@playwright/test";
import { test } from "./base.js";
import { describe } from "node:test";

describe("Room Requests Tests", () => {
test("A user can see the room requests screen", async ({
page,
becomeUser,
}) => {
await becomeUser(page);
await expect(
page.locator("a").filter({ hasText: "Management Portal DEV ENV" }),
).toBeVisible();
await expect(
page.locator("a").filter({ hasText: "Room Requests" }),
).toBeVisible();
await page.locator("a").filter({ hasText: "Room Requests" }).click();
await expect(page.getByRole("heading")).toContainText("Room Requests");
await page.locator("button").filter({ hasText: "New Request" }).click();
await expect(page.getByText("Basic Information")).toBeVisible();
await expect(page.getByText("Compliance Information")).toBeVisible();
await expect(page.getByText("Room Requirements")).toBeVisible();
await expect(page.getByText("Miscellaneous Information")).toBeVisible();
await page
.locator("button")
.filter({ hasText: "Existing Requests" })
.click();
await expect(page.locator(".mantine-Loader-root")).toHaveCount(0);
});
});
Loading