Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion packages/template-retail-react-app/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## v8.3.0-dev (Nov 05, 2025)
- [Bugfix] Fix Forgot Password link not working from Account Profile password update form [#3487](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/3487)
- [Bugfix] Fix Forgot Password link not working from Account Profile password update form [#3493](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/3493)

## v8.2.0 (Nov 04, 2025)
- Add support for Rule Based Promotions for Choice of Bonus Products. We are currently supporting only one product level rule based promotion per product [#3418](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/3418)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,32 @@ describe('UpdatePasswordFields component', () => {
expect(screen.getByText('Passwords do not match.')).toBeInTheDocument()
expect(onSubmit).not.toHaveBeenCalled()
})

test('does not render "Forgot Password?" button when handleForgotPasswordClick is not provided', () => {
renderWithProviders(<WrapperComponent />)

expect(screen.queryByText(/forgot password/i)).not.toBeInTheDocument()
})

test('renders "Forgot Password?" button when handleForgotPasswordClick is provided', () => {
const handleForgotPasswordClick = jest.fn()
renderWithProviders(
<WrapperComponent handleForgotPasswordClick={handleForgotPasswordClick} />
)

const forgotPasswordButton = screen.getByText(/forgot password/i)
expect(forgotPasswordButton).toBeInTheDocument()
})

test('calls handleForgotPasswordClick when "Forgot Password?" button is clicked', async () => {
const handleForgotPasswordClick = jest.fn()
const {user} = renderWithProviders(
<WrapperComponent handleForgotPasswordClick={handleForgotPasswordClick} />
)

const forgotPasswordButton = screen.getByText(/forgot password/i)
await user.click(forgotPasswordButton)

expect(handleForgotPasswordClick).toHaveBeenCalledTimes(1)
})
})
22 changes: 22 additions & 0 deletions packages/template-retail-react-app/app/pages/account/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,4 +257,26 @@ describe('updating password', function () {

expect(await screen.findByTestId('password-update-error')).toBeInTheDocument()
})

test('navigates to reset-password page when "Forgot Password?" is clicked', async () => {
useCustomerType.mockReturnValue({isRegistered: true, isExternal: false})
const {user} = renderWithProviders(<MockedComponent />, {
wrapperProps: {siteAlias: 'uk', appConfig: mockConfig.app}
})

expect(await screen.findByTestId('account-page')).toBeInTheDocument()
expect(await screen.findByTestId('account-detail-page')).toBeInTheDocument()

const el = within(screen.getByTestId('sf-toggle-card-password'))
await user.click(el.getByText(/edit/i))

const forgotPasswordButton = el.getByText(/forgot password/i)
expect(forgotPasswordButton).toBeInTheDocument()

await user.click(forgotPasswordButton)

await waitFor(() => {
expect(window.location.pathname).toBe(`${expectedBasePath}/reset-password`)
})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,47 @@ test('Non ECOM user cannot see the password card', async () => {

expect(screen.queryByText(/Password/i)).not.toBeInTheDocument()
})

describe('AccountDetail component', () => {
test('passes handleForgotPasswordClick prop to PasswordCard when provided', async () => {
sdk.useCustomerType.mockReturnValue({isRegistered: true, isExternal: false})
const handleForgotPasswordClick = jest.fn()

const {user} = renderWithProviders(
<AccountDetail handleForgotPasswordClick={handleForgotPasswordClick} />,
{
wrapperProps: {siteAlias: 'uk', appConfig: mockConfig.app}
}
)

await waitFor(() => {
expect(screen.getByText(/Account Details/i)).toBeInTheDocument()
})

const passwordCard = screen.getByTestId('sf-toggle-card-password')
await user.click(within(passwordCard).getByText(/edit/i))

const forgotPasswordButton = screen.getByText(/forgot password/i)
expect(forgotPasswordButton).toBeInTheDocument()

await user.click(forgotPasswordButton)
expect(handleForgotPasswordClick).toHaveBeenCalledTimes(1)
})

test('does not show "Forgot Password?" button when handleForgotPasswordClick is not provided', async () => {
sdk.useCustomerType.mockReturnValue({isRegistered: true, isExternal: false})

const {user} = renderWithProviders(<AccountDetail />, {
wrapperProps: {siteAlias: 'uk', appConfig: mockConfig.app}
})

await waitFor(() => {
expect(screen.getByText(/Account Details/i)).toBeInTheDocument()
})

const passwordCard = screen.getByTestId('sf-toggle-card-password')
await user.click(within(passwordCard).getByText(/edit/i))

expect(screen.queryByText(/forgot password/i)).not.toBeInTheDocument()
})
})
Loading