diff --git a/examples/for-tests/src/App.js b/examples/for-tests/src/App.js index 505beeb61..4afef7e43 100644 --- a/examples/for-tests/src/App.js +++ b/examples/for-tests/src/App.js @@ -740,6 +740,17 @@ function getSignInFormFields() { return {}; } +function emailFormForResetPassword() { + let showDefaultFields = localStorage.getItem("SHOW_DEFAULT_EMAIL_FOR_RESET_PASSWORD"); + if (showDefaultFields === "YES") { + return { + getDefaultValue: () => "company@email.com", + style: theme, + }; + } + return { style: theme }; +} + function getEmailPasswordConfigs({ disableDefaultUI }) { return EmailPassword.init({ style: ` @@ -808,9 +819,7 @@ function getEmailPasswordConfigs({ disableDefaultUI }) { useShadowDom, resetPasswordUsingTokenFeature: { disableDefaultUI, - enterEmailForm: { - style: theme, - }, + enterEmailForm: emailFormForResetPassword(), submitNewPasswordForm: { style: theme, }, diff --git a/test/end-to-end/resetpasswordusingtoken.test.js b/test/end-to-end/resetpasswordusingtoken.test.js index 2fa553178..804d2abab 100644 --- a/test/end-to-end/resetpasswordusingtoken.test.js +++ b/test/end-to-end/resetpasswordusingtoken.test.js @@ -48,11 +48,11 @@ import { toggleSignInSignUp, defaultSignUp, screenshotOnFailure, - getAuthPageHeaderText, getResetPasswordFormBackButton, waitForSTElement, getResetPasswordSuccessBackToSignInButton, backendBeforeEach, + getInputField, } from "../helpers"; /* @@ -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 = "company@email.com"; + + 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 () { diff --git a/test/with-typescript/src/App.tsx b/test/with-typescript/src/App.tsx index c06d3fff7..466fd2098 100644 --- a/test/with-typescript/src/App.tsx +++ b/test/with-typescript/src/App.tsx @@ -330,6 +330,7 @@ function getEmailPasswordConfigs() { return EmailPassword.init({ resetPasswordUsingTokenFeature: { enterEmailForm: { + getDefaultValue: () => "company@email.com", style: theme.style, }, submitNewPasswordForm: {