diff --git a/src/common/utils.ts b/src/common/utils.ts index 73f16cc7..e2328fb7 100644 --- a/src/common/utils.ts +++ b/src/common/utils.ts @@ -38,10 +38,9 @@ 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[]; @@ -49,8 +48,8 @@ type GetDefaultFilteringQuerystringInput = { 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: "" } : {}) + description: "A list of attributes to return.", + ...(defaultSelect.length === 0 ? { default: [""] } : { example: defaultSelect }) }) }; }; diff --git a/src/ui/pages/roomRequest/RoomRequestLanding.page.tsx b/src/ui/pages/roomRequest/RoomRequestLanding.page.tsx index d033b6cd..13756e98 100644 --- a/src/ui/pages/roomRequest/RoomRequestLanding.page.tsx +++ b/src/ui/pages/roomRequest/RoomRequestLanding.page.tsx @@ -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 })); }; diff --git a/tests/e2e/base.ts b/tests/e2e/base.ts index 58153b49..57967446 100644 --- a/tests/e2e/base.ts +++ b/tests/e2e/base.ts @@ -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(); @@ -58,7 +60,9 @@ async function becomeUser(page: Page) { .fill(secrets["PLAYWRIGHT_USERNAME"]); await page.getByPlaceholder("NetID@illinois.edu").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(); } diff --git a/tests/e2e/roomRequests.spec.ts b/tests/e2e/roomRequests.spec.ts new file mode 100644 index 00000000..7e857506 --- /dev/null +++ b/tests/e2e/roomRequests.spec.ts @@ -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); + }); +});