Skip to content

Commit

Permalink
Add tests for resetPassword email field
Browse files Browse the repository at this point in the history
  • Loading branch information
amitbadala committed Nov 6, 2023
1 parent be4c00a commit 363b575
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
15 changes: 12 additions & 3 deletions examples/for-tests/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,17 @@ function getSignInFormFields() {
return {};
}

function emailFormForResetPassword() {
let showDefaultFields = localStorage.getItem("SHOW_DEFAULT_EMAIL_FOR_RESET_PASSWORD");
if (showDefaultFields === "YES") {
return {
getDefaultValue: () => "[email protected]",
style: theme,
};
}
return { style: theme };
}

function getEmailPasswordConfigs({ disableDefaultUI }) {
return EmailPassword.init({
style: `
Expand Down Expand Up @@ -808,9 +819,7 @@ function getEmailPasswordConfigs({ disableDefaultUI }) {
useShadowDom,
resetPasswordUsingTokenFeature: {
disableDefaultUI,
enterEmailForm: {
style: theme,
},
enterEmailForm: emailFormForResetPassword(),
submitNewPasswordForm: {
style: theme,
},
Expand Down
17 changes: 16 additions & 1 deletion test/end-to-end/resetpasswordusingtoken.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ import {
toggleSignInSignUp,
defaultSignUp,
screenshotOnFailure,
getAuthPageHeaderText,
getResetPasswordFormBackButton,
waitForSTElement,
getResetPasswordSuccessBackToSignInButton,
backendBeforeEach,
getInputField,
} from "../helpers";

/*
Expand Down Expand Up @@ -232,6 +232,21 @@ describe("SuperTokens Reset password", function () {
const buttonLabel = await getSubmitFormButtonLabel(page);
assert.deepStrictEqual(buttonLabel, "SIGN IN");
});

it("Should show default values for email field", async function () {
await page.evaluate(() => window.localStorage.setItem("SHOW_DEFAULT_EMAIL_FOR_RESET_PASSWORD", "YES"));

await page.reload({
waitUntil: "domcontentloaded",
});

const expectedDefaultEmail = "[email protected]";

const emailInput = await getInputField(page, "email");
const defaultEmail = await emailInput.evaluate((f) => f.value);

assert.strictEqual(defaultEmail, expectedDefaultEmail);
});
});

describe("Reset password new password form test", function () {
Expand Down
1 change: 1 addition & 0 deletions test/with-typescript/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ function getEmailPasswordConfigs() {
return EmailPassword.init({
resetPasswordUsingTokenFeature: {
enterEmailForm: {
getDefaultValue: () => "[email protected]",
style: theme.style,
},
submitNewPasswordForm: {
Expand Down

0 comments on commit 363b575

Please sign in to comment.