-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* reorder the e2e tests directory * fix linting/formatting * add data-testid to events table * add a basic upcoming events view test * update * fix pre-commit * Revert "fix pre-commit" This reverts commit 1997364.
- Loading branch information
1 parent
42c801d
commit 85b585f
Showing
8 changed files
with
168 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import { test as base } from "@playwright/test"; | ||
import { | ||
SecretsManagerClient, | ||
GetSecretValueCommand, | ||
} from "@aws-sdk/client-secrets-manager"; | ||
|
||
export const getSecretValue = async ( | ||
secretId: string, | ||
): Promise<Record<string, string | number | boolean> | null> => { | ||
const smClient = new SecretsManagerClient(); | ||
const data = await smClient.send( | ||
new GetSecretValueCommand({ SecretId: secretId }), | ||
); | ||
if (!data.SecretString) { | ||
return null; | ||
} | ||
try { | ||
return JSON.parse(data.SecretString) as Record< | ||
string, | ||
string | number | boolean | ||
>; | ||
} catch { | ||
return null; | ||
} | ||
}; | ||
|
||
async function getSecrets() { | ||
let response = { PLAYWRIGHT_USERNAME: "", PLAYWRIGHT_PASSWORD: "" }; | ||
let keyData; | ||
if (!process.env.PLAYWRIGHT_USERNAME || !process.env.PLAYWRIGHT_PASSWORD) { | ||
keyData = await getSecretValue("infra-core-api-config"); | ||
} | ||
response["PLAYWRIGHT_USERNAME"] = | ||
process.env.PLAYWRIGHT_USERNAME || | ||
(keyData ? keyData["playwright_username"] : ""); | ||
response["PLAYWRIGHT_PASSWORD"] = | ||
process.env.PLAYWRIGHT_PASSWORD || | ||
(keyData ? keyData["playwright_password"] : ""); | ||
return response; | ||
} | ||
|
||
const secrets = await getSecrets(); | ||
|
||
export function capitalizeFirstLetter(string: string) { | ||
return string.charAt(0).toUpperCase() + string.slice(1); | ||
} | ||
|
||
async function becomeUser(page) { | ||
await page.goto("https://manage.qa.acmuiuc.org/login"); | ||
await page | ||
.getByRole("button", { name: "Sign in with Illinois NetID" }) | ||
.click(); | ||
await page.getByPlaceholder("[email protected]").click(); | ||
await page | ||
.getByPlaceholder("[email protected]") | ||
.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.getByRole("button", { name: "Sign in" }).click(); | ||
await page.getByRole("button", { name: "No" }).click(); | ||
} | ||
|
||
export async function getUpcomingEvents() { | ||
const data = await fetch( | ||
"https://infra-core-api.aws.qa.acmuiuc.org/api/v1/events?upcomingOnly=true", | ||
); | ||
return (await data.json()) as Record<string, string>[]; | ||
} | ||
|
||
export async function getAllEvents() { | ||
const data = await fetch( | ||
"https://infra-core-api.aws.qa.acmuiuc.org/api/v1/events", | ||
); | ||
return (await data.json()) as Record<string, string>[]; | ||
} | ||
|
||
export const test = base.extend<{ becomeUser: (page) => Promise<void> }>({ | ||
becomeUser: async ({}, use) => { | ||
use(becomeUser); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { expect } from "@playwright/test"; | ||
import { capitalizeFirstLetter, getUpcomingEvents, test } from "./base"; | ||
import { describe } from "node:test"; | ||
|
||
describe("Events tests", () => { | ||
test("A user can login and view the upcoming events", async ({ | ||
page, | ||
becomeUser, | ||
}) => { | ||
await becomeUser(page); | ||
await page.locator("a").filter({ hasText: "Events" }).click(); | ||
await expect(page.getByRole("heading")).toContainText( | ||
"Core Management Service (NonProd)", | ||
); | ||
await expect( | ||
page.getByRole("button", { name: "New Calendar Event" }), | ||
).toBeVisible(); | ||
await expect( | ||
page.getByRole("button", { name: "Show Previous Events" }), | ||
).toBeVisible(); | ||
|
||
const table = page.getByTestId("events-table"); | ||
await expect(table).toBeVisible(); | ||
|
||
const rows = await table.locator("tbody tr").all(); | ||
const expectedTableData = await getUpcomingEvents(); | ||
|
||
for (let i = 0; i < rows.length; i++) { | ||
const row = rows[i]; | ||
const expectedData = expectedTableData[i]; | ||
const title = await row.locator("td:nth-child(1)").innerText(); | ||
const location = await row.locator("td:nth-child(4)").innerText(); | ||
const description = await row.locator("td:nth-child(5)").innerText(); | ||
const host = await row.locator("td:nth-child(6)").innerText(); | ||
const featured = await row.locator("td:nth-child(7)").innerText(); | ||
const repeats = await row.locator("td:nth-child(8)").innerText(); | ||
|
||
expect(title).toEqual(expectedData.title); | ||
expect(location).toEqual(expectedData.location); | ||
expect(description).toEqual(expectedData.description); | ||
expect(host).toEqual(expectedData.host); | ||
expect(featured).toEqual(expectedData.featured ? "Yes" : "No"); | ||
expect(repeats).toEqual(capitalizeFirstLetter(expectedData.repeats)); | ||
} | ||
|
||
expect(page.url()).toEqual("https://manage.qa.acmuiuc.org/events/manage"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { expect } from "@playwright/test"; | ||
import { test } from "./base"; | ||
import { describe } from "node:test"; | ||
|
||
describe("Login tests", () => { | ||
test("A user can login and view the home 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: "Events" })).toBeVisible(); | ||
await expect( | ||
page.locator("a").filter({ hasText: "Ticketing/Merch" }), | ||
).toBeVisible(); | ||
await expect(page.locator("a").filter({ hasText: "IAM" })).toBeVisible(); | ||
await expect( | ||
page.getByRole("link", { name: "ACM Logo Management Portal" }), | ||
).toBeVisible(); | ||
await expect( | ||
page.getByRole("link", { name: "P", exact: true }), | ||
).toBeVisible(); | ||
await page.getByRole("link", { name: "P", exact: true }).click(); | ||
await expect(page.getByLabel("PMy Account")).toContainText( | ||
"Name Playwright Core User", | ||
); | ||
await expect(page.getByLabel("PMy Account")).toContainText( | ||
"[email protected]", | ||
); | ||
expect(page.url()).toEqual("https://manage.qa.acmuiuc.org/home"); | ||
}); | ||
}); |