Skip to content

Commit c11c3e4

Browse files
authored
Fix room requests and add e2e tests (#198)
1 parent 16dc3d0 commit c11c3e4

File tree

4 files changed

+44
-9
lines changed

4 files changed

+44
-9
lines changed

src/common/utils.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,18 @@ export const generateProjectionParams = ({ userFields }: GenerateProjectionParam
3838

3939

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

4645
type GetDefaultFilteringQuerystringInput = {
4746
defaultSelect: string[];
4847
};
4948
export const getDefaultFilteringQuerystring = ({ defaultSelect }: GetDefaultFilteringQuerystringInput) => {
5049
return {
5150
select: z.optional(nonEmptyCommaSeparatedStringSchema).default(defaultSelect).meta({
52-
description: "Comma-seperated list of attributes to return",
53-
...(defaultSelect.length === 0 ? { default: "<ALL ATTRIBUTES>" } : {})
51+
description: "A list of attributes to return.",
52+
...(defaultSelect.length === 0 ? { default: ["<ALL ATTRIBUTES>"] } : { example: defaultSelect })
5453
})
5554
};
5655
};

src/ui/pages/roomRequest/RoomRequestLanding.page.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ export const ManageRoomRequestsPage: React.FC = () => {
3737
host: string;
3838
status: RoomRequestStatus;
3939
}[]
40-
>(`/api/v1/roomRequests/${semester}?select=requestId,title,host,status`);
40+
>(
41+
`/api/v1/roomRequests/${semester}?select=requestId&select=title&select=host&select=status`,
42+
);
4143
return response.data.map((x) => ({ ...x, semester }));
4244
};
4345

tests/e2e/base.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ export function capitalizeFirstLetter(string: string) {
4848
}
4949

5050
async function becomeUser(page: Page) {
51-
await page.goto("https://core.aws.qa.acmuiuc.org/login");
51+
await page.goto(
52+
process.env.E2E_TEST_HOST || "https://core.aws.qa.acmuiuc.org/login",
53+
);
5254
await page
5355
.getByRole("button", { name: "Sign in with Illinois NetID" })
5456
.click();
@@ -58,7 +60,9 @@ async function becomeUser(page: Page) {
5860
.fill(secrets["PLAYWRIGHT_USERNAME"]);
5961
await page.getByPlaceholder("NetID@illinois.edu").press("Enter");
6062
await page.getByPlaceholder("Password").click();
61-
await page.getByPlaceholder("Password").fill(secrets["PLAYWRIGHT_PASSWORD"]);
63+
await page.getByPlaceholder("Password").evaluate((input, password) => {
64+
(input as any).value = password;
65+
}, secrets["PLAYWRIGHT_PASSWORD"]);
6266
await page.getByRole("button", { name: "Sign in" }).click();
6367
await page.getByRole("button", { name: "No" }).click();
6468
}

tests/e2e/roomRequests.spec.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { expect } from "@playwright/test";
2+
import { test } from "./base.js";
3+
import { describe } from "node:test";
4+
5+
describe("Room Requests Tests", () => {
6+
test("A user can see the room requests screen", async ({
7+
page,
8+
becomeUser,
9+
}) => {
10+
await becomeUser(page);
11+
await expect(
12+
page.locator("a").filter({ hasText: "Management Portal DEV ENV" }),
13+
).toBeVisible();
14+
await expect(
15+
page.locator("a").filter({ hasText: "Room Requests" }),
16+
).toBeVisible();
17+
await page.locator("a").filter({ hasText: "Room Requests" }).click();
18+
await expect(page.getByRole("heading")).toContainText("Room Requests");
19+
await page.locator("button").filter({ hasText: "New Request" }).click();
20+
await expect(page.getByText("Basic Information")).toBeVisible();
21+
await expect(page.getByText("Compliance Information")).toBeVisible();
22+
await expect(page.getByText("Room Requirements")).toBeVisible();
23+
await expect(page.getByText("Miscellaneous Information")).toBeVisible();
24+
await page
25+
.locator("button")
26+
.filter({ hasText: "Existing Requests" })
27+
.click();
28+
await expect(page.locator(".mantine-Loader-root")).toHaveCount(0);
29+
});
30+
});

0 commit comments

Comments
 (0)