Skip to content

Commit 520a54c

Browse files
committed
Feedback
1 parent 2fe13dd commit 520a54c

3 files changed

Lines changed: 38 additions & 12 deletions

File tree

load_testing/auth.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export function getAccessToken(): string | null {
1010
}
1111

1212
export function hasAccessToken(): boolean {
13-
return !getAccessToken()
13+
return !!getAccessToken()
1414
}
1515

1616
function _validate_credentials(credentials) {

load_testing/backend/test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ export function testBackend() {
1919
group("video shorts", () => {
2020
const res = client.videoShortsList({ limit: 50 })
2121

22-
group
2322
check(res, {
2423
"is status 200": (r) => r.response.status === 200,
2524
"has results": (r) => r.response.json("results").length > 0,

load_testing/frontend/test.ts

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,25 @@ async function home(page: Page, context: Context) {
2121
await page.goto(FRONTEND_BASE_URL)
2222

2323
const carousel = await page.getByTestId("resource-carousel")
24-
const articlesCount = await carousel.locator("article").count()
24+
const articles = carousel.locator("article")
25+
26+
try {
27+
await articles.first().waitFor({ timeout: 10_000 })
28+
} catch {
29+
// carousel never populated; let the assertion below report it
30+
}
31+
32+
const articlesCount = await articles.count()
33+
2534
await check(carousel, {
2635
"home page carousel has 12 items": () => articlesCount === 12,
2736
})
2837

29-
await carousel
30-
.locator("article")
31-
.nth(randomIntBetween(0, articlesCount - 1))
32-
.click()
38+
if (articlesCount === 0) {
39+
return
40+
}
41+
42+
await articles.nth(randomIntBetween(0, articlesCount - 1)).click()
3343
}
3444

3545
async function search(page: Page, context: Context) {
@@ -53,12 +63,18 @@ async function units(page: Page, context: Context) {
5363
}
5464

5565
async function login(page: Page, context: Context) {
56-
const credential: AuthCredential = randomItem(credentials)
66+
const credential: AuthCredential | undefined = randomItem(credentials)
5767

5868
if (credential == null) {
5969
console.log("Login > skipping because no credentials provided")
70+
return
71+
}
72+
73+
if (!SSO_BASE_URL) {
74+
throw Error("SSO_BASE_URL must be set to run the login flow")
6075
}
61-
if (page.url() == "about:blank") {
76+
77+
if (page.url() === "about:blank") {
6278
await page.goto(FRONTEND_BASE_URL)
6379
}
6480

@@ -67,11 +83,22 @@ async function login(page: Page, context: Context) {
6783
const loginButton = page.getByTestId("login-button-desktop")
6884
await loginButton.first().click()
6985

70-
await loginKeycloak(page, credential, context)
86+
let loggedIn = false
7187

72-
await page.waitForURL(/.*\/dashboard.*/)
88+
try {
89+
await loginKeycloak(page, credential, context)
90+
await page.locator('[aria-label="User Menu"]').waitFor({ timeout: 10_000 })
91+
loggedIn = true
92+
console.log("Login > authenticated; user menu visible")
93+
} catch (err) {
94+
console.log(
95+
`Login > failed for '${credential.email}' at URL '${page.url()}': ${err}`,
96+
)
97+
}
7398

74-
console.log("Login > reached dashboard")
99+
check(null, {
100+
"login succeeded": () => loggedIn,
101+
})
75102
}
76103

77104
const ESCAPED_SSO_URL = escapeRegex(SSO_BASE_URL)

0 commit comments

Comments
 (0)