Skip to content

Commit

Permalink
test: work around if token is invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
Harry authored and Harry committed Aug 20, 2024
1 parent 3eed4c1 commit 777aaa6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions authservice/login-with-passwordless/AuthServicePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,23 @@ export class AuthServicePage {
});

await this.page.locator(`xpath=.//input[@data-test='single-input']`).first().type(token);

await delay(2000);
if (await this.page.locator('text="Invalid OTP, please try again"').isVisible()) {
await this.page.locator(`xpath=.//input[@data-test='single-input']`).last().click();

for (let index = 0; index < 6; index++) {
await this.page.keyboard.press("Delete");
}

const newToken = speakeasy.totp({
secret,
encoding: "base32",
step: 30,
});

await this.page.locator(`xpath=.//input[@data-test='single-input']`).first().type(newToken);
}
}

async setupAuthenticator() {
Expand Down
2 changes: 1 addition & 1 deletion authservice/login-with-passwordless/auth-case-3.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { LoginPage } from "./LoginPage";
const passwordTestingFactor = "Testing@123";

test.describe.serial("Passwordless Login scenarios", () => {
test.setTimeout(90000);
test.setTimeout(120000);

test("Login email passwordless case 3, mandatory MFA then setup 2FA @mandatorymfa", async ({ page, browser }) => {
const testEmail = generateEmailWithTag();
Expand Down

0 comments on commit 777aaa6

Please sign in to comment.