Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions e2e/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,26 @@ export const login = async (browser: Browser, nhsLoginUsername: string): Promise
}, user.nhsLoginPassword);
await page.getByRole("button", { name: "Continue" }).click();

await page.waitForURL(/\/(enter-mobile-code|choose-authentication-method)$/, { timeout: 30000 });
await page.waitForURL(/\/(enter-mobile-code|choose-authentication-method)/, { timeout: 30000 });
if (new URL(page.url()).pathname === "/choose-authentication-method") {
await page.getByLabel("Use my mobile phone to recieve a security code by text message").click();
await page.getByRole("button", { name: "Continue" }).click();
}

await page.waitForURL("**/enter-mobile-code", { waitUntil: "networkidle", timeout: 30000 });
await page.waitForURL(/\/enter-mobile-code/, { waitUntil: "networkidle", timeout: 30000 });
await page.getByRole("textbox", { name: "Security code" }).evaluate((input: HTMLInputElement, fillText) => {
input.value = fillText;
input.dispatchEvent(new Event("input"));
}, user.nhsLoginOTP);
await page.getByRole("button", { name: "Continue" }).click();

await page.waitForURL(/\/trust-device/, {
timeout: 30000,
});

await page.locator("#choose-not-now").click();
await page.getByRole("button", { name: "Continue" }).click();

if (useFakeAuth) {
await page.waitForURL(user.vaccinationsHubUrl, { timeout: 60000, waitUntil: "domcontentloaded" });
return page;
Expand Down