Skip to content

Commit 874a882

Browse files
authored
Reorganize Live and E2E tests (#161)
* FIx Playwright base typing issues * Create linkry exists and not-exists tests. * Use `getBaseEndpoint()` function to allow us to run live tests on different endpoints.
1 parent 2eb8e1d commit 874a882

17 files changed

+207
-25
lines changed

tests/e2e/base.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { test as base } from "@playwright/test";
1+
import { test as base, Page } from "@playwright/test";
22
import {
33
SecretsManagerClient,
44
GetSecretValueCommand,
@@ -7,7 +7,9 @@ import {
77
export const getSecretValue = async (
88
secretId: string,
99
): Promise<Record<string, string | number | boolean> | null> => {
10-
const smClient = new SecretsManagerClient();
10+
const smClient = new SecretsManagerClient({
11+
region: process.env.AWS_REGION ?? "us-east-1",
12+
});
1113
const data = await smClient.send(
1214
new GetSecretValueCommand({ SecretId: secretId }),
1315
);
@@ -32,10 +34,10 @@ async function getSecrets() {
3234
}
3335
response["PLAYWRIGHT_USERNAME"] =
3436
process.env.PLAYWRIGHT_USERNAME ||
35-
(keyData ? keyData["playwright_username"] : "");
37+
((keyData ? keyData["playwright_username"] : "") as string);
3638
response["PLAYWRIGHT_PASSWORD"] =
3739
process.env.PLAYWRIGHT_PASSWORD ||
38-
(keyData ? keyData["playwright_password"] : "");
40+
((keyData ? keyData["playwright_password"] : "") as string);
3941
return response;
4042
}
4143

@@ -45,7 +47,7 @@ export function capitalizeFirstLetter(string: string) {
4547
return string.charAt(0).toUpperCase() + string.slice(1);
4648
}
4749

48-
async function becomeUser(page) {
50+
async function becomeUser(page: Page) {
4951
await page.goto("https://core.aws.qa.acmuiuc.org/login");
5052
await page
5153
.getByRole("button", { name: "Sign in with Illinois NetID" })
@@ -73,7 +75,7 @@ export async function getAllEvents() {
7375
return (await data.json()) as Record<string, string>[];
7476
}
7577

76-
export const test = base.extend<{ becomeUser: (page) => Promise<void> }>({
78+
export const test = base.extend<{ becomeUser: (page: Page) => Promise<void> }>({
7779
becomeUser: async ({}, use) => {
7880
use(becomeUser);
7981
},

tests/live/apiKey.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { expect, test, describe } from "vitest";
2+
import { getBaseEndpoint } from "./utils.js";
23

3-
const baseEndpoint = `https://core.aws.qa.acmuiuc.org`;
4+
const baseEndpoint = getBaseEndpoint();
45

56
describe("API Key tests", async () => {
67
test("Test that auth is present on routes", { timeout: 10000 }, async () => {

tests/live/documentation.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { expect, test } from "vitest";
2+
import { getBaseEndpoint } from "./utils.js";
23

3-
const baseEndpoint = `https://core.aws.qa.acmuiuc.org`;
4+
const baseEndpoint = getBaseEndpoint();
45

56
test("Get OpenAPI JSON", async () => {
67
const response = await fetch(`${baseEndpoint}/api/documentation/json`);

tests/live/events.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ import { expect, test } from "vitest";
22
import { EventsGetResponse } from "../../src/api/routes/events.js";
33
import { createJwt } from "./utils.js";
44
import { describe } from "node:test";
5+
import { getBaseEndpoint } from "./utils.js";
6+
7+
const baseEndpoint = getBaseEndpoint();
58

6-
const baseEndpoint = `https://core.aws.qa.acmuiuc.org`;
79
test("getting events", async () => {
810
const response = await fetch(`${baseEndpoint}/api/v1/events`);
911
expect(response.status).toBe(200);

tests/live/healthz.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { expect, test } from "vitest";
2-
import { InternalServerError } from "../../src/common/errors/index.js";
2+
import { getBaseEndpoint } from "./utils.js";
33

4-
const baseEndpoint = `https://core.aws.qa.acmuiuc.org`;
4+
const baseEndpoint = getBaseEndpoint();
55

66
test("healthz", async () => {
77
const response = await fetch(`${baseEndpoint}/api/v1/healthz`);

tests/live/iam.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ import {
55
GroupMemberGetResponse,
66
} from "../../src/common/types/iam.js";
77
import { allAppRoles, AppRoles } from "../../src/common/roles.js";
8+
import { getBaseEndpoint } from "./utils.js";
89

9-
const baseEndpoint = `https://core.aws.qa.acmuiuc.org`;
10+
const baseEndpoint = getBaseEndpoint();
1011
test("getting members of a group", async () => {
1112
const token = await createJwt();
1213
const response = await fetch(

tests/live/ical.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { describe, expect, test } from "vitest";
22
import { CoreOrganizationList } from "@acm-uiuc/js-shared";
33
import ical from "node-ical";
4-
const baseEndpoint = `https://core.aws.qa.acmuiuc.org`;
4+
import { getBaseEndpoint } from "./utils.js";
5+
const baseEndpoint = getBaseEndpoint();
56

67
const delay = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
78

tests/live/linrky.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { describe, expect, test } from "vitest";
2+
import { getBaseEndpoint, makeRandomString } from "./utils.js";
3+
4+
const baseEndpoint = getBaseEndpoint("go");
5+
6+
describe("Linkry live tests", async () => {
7+
test("Linkry health check", async () => {
8+
const response = await fetch(`${baseEndpoint}/healthz`);
9+
expect(response.status).toBe(200);
10+
expect(response.redirected).toBe(true);
11+
expect(response.url).toBe("https://www.google.com/");
12+
});
13+
test("Linkry 404 redirect", async () => {
14+
const response = await fetch(`${baseEndpoint}/${makeRandomString(16)}`);
15+
expect(response.status).toBe(200);
16+
expect(response.redirected).toBe(true);
17+
expect(response.url).toBe("https://www.acm.illinois.edu/404");
18+
});
19+
});

tests/live/membership.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { expect, test, describe } from "vitest";
2+
import { getBaseEndpoint } from "./utils.js";
23

3-
const baseEndpoint = `https://core.aws.qa.acmuiuc.org`;
4+
const baseEndpoint = getBaseEndpoint();
45

56
describe("Membership API basic checks", async () => {
67
test("Test that getting member succeeds", { timeout: 3000 }, async () => {

tests/live/mobileWallet.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { expect, test, describe } from "vitest";
2+
import { getBaseEndpoint } from "./utils.js";
23

3-
const baseEndpoint = `https://core.aws.qa.acmuiuc.org`;
4+
const baseEndpoint = getBaseEndpoint();
45

56
describe("Mobile pass issuance", async () => {
67
test(

0 commit comments

Comments
 (0)