-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add recovery email related helpers and init test
- Loading branch information
1 parent
3b100bc
commit 59724d5
Showing
4 changed files
with
92 additions
and
9 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import fetch from "isomorphic-fetch"; | ||
import { TEST_SERVER_BASE_URL } from "../constants"; | ||
import { | ||
backendBeforeEach, | ||
setupBrowser, | ||
screenshotOnFailure, | ||
clearBrowserCookiesWithoutAffectingConsole, | ||
toggleSignInSignUp, | ||
setEnabledRecipes, | ||
waitForSTElement, | ||
submitForm, | ||
} from "../helpers"; | ||
import { tryWebauthnSignIn, openRecoveryAccountPage } from "./webauthn.helpers"; | ||
import assert from "assert"; | ||
|
||
describe("SuperTokens Webauthn Recovery Email", () => { | ||
let browser; | ||
let page; | ||
let consoleLogs = []; | ||
|
||
before(async function () { | ||
await backendBeforeEach(); | ||
|
||
await fetch(`${TEST_SERVER_BASE_URL}/startst`, { | ||
method: "POST", | ||
}).catch(console.error); | ||
|
||
browser = await setupBrowser(); | ||
page = await browser.newPage(); | ||
page.on("console", (consoleObj) => { | ||
const log = consoleObj.text(); | ||
if (log.startsWith("ST_LOGS")) { | ||
consoleLogs.push(log); | ||
} | ||
}); | ||
}); | ||
|
||
after(async function () { | ||
await browser.close(); | ||
await fetch(`${TEST_SERVER_BASE_URL}/after`, { | ||
method: "POST", | ||
}).catch(console.error); | ||
|
||
await fetch(`${TEST_SERVER_BASE_URL}/stopst`, { | ||
method: "POST", | ||
}).catch(console.error); | ||
}); | ||
|
||
afterEach(function () { | ||
return screenshotOnFailure(this, browser); | ||
}); | ||
|
||
beforeEach(async function () { | ||
consoleLogs = []; | ||
consoleLogs = await clearBrowserCookiesWithoutAffectingConsole(page, consoleLogs); | ||
await toggleSignInSignUp(page); | ||
}); | ||
|
||
describe("Recovery Email Test", () => { | ||
it("should show the recovery email page", async () => { | ||
await openRecoveryAccountPage(page); | ||
|
||
const headerTextContainer = await waitForSTElement( | ||
page, | ||
"[data-supertokens~='passkeyRecoverAccountFormHeader']" | ||
); | ||
const headerText = await headerTextContainer.evaluate((el) => el.textContent); | ||
assert.strictEqual(headerText, "Recover Account"); | ||
assert.deepStrictEqual(consoleLogs, [ | ||
"ST_LOGS SESSION OVERRIDE ADD_FETCH_INTERCEPTORS_AND_RETURN_MODIFIED_FETCH", | ||
"ST_LOGS SESSION OVERRIDE ADD_AXIOS_INTERCEPTORS", | ||
"ST_LOGS WEBAUTHN GET_REDIRECTION_URL SEND_RECOVERY_EMAIL", | ||
]); | ||
}); | ||
}); | ||
}); |