mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-05 10:24:05 +00:00
Give password recovery the native sign-in layout
This commit is contained in:
@@ -9,9 +9,14 @@ import ForgotPasswordPage from './ForgotPasswordPage'
|
||||
// forgotPassword/useForgotPassword.test.ts). The hook is mocked so the form,
|
||||
// the sent screen and the SMTP hint can each be rendered on demand.
|
||||
|
||||
const mocks = vi.hoisted(() => ({ forgot: {} as Record<string, unknown> }))
|
||||
const mocks = vi.hoisted(() => ({ forgot: {} as Record<string, unknown>, native: false }))
|
||||
|
||||
vi.mock('./forgotPassword/useForgotPassword', () => ({ useForgotPassword: () => mocks.forgot }))
|
||||
vi.mock('../native/platform', async (importOriginal) => ({
|
||||
...(await importOriginal<typeof import('../native/platform')>()),
|
||||
isNativeApp: () => mocks.native,
|
||||
}))
|
||||
vi.mock('../../native-shell/scenery', () => ({ startScenery: vi.fn(), cameraForPlan: () => [0, 0] }))
|
||||
|
||||
const navigate = vi.fn((_to: string) => {})
|
||||
const setEmail = vi.fn((_v: string) => {})
|
||||
@@ -32,6 +37,7 @@ function setForgot(over: Record<string, unknown> = {}) {
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
mocks.native = false
|
||||
setForgot()
|
||||
})
|
||||
|
||||
@@ -124,4 +130,28 @@ describe('ForgotPasswordPage', () => {
|
||||
expect(screen.getByRole('heading', { name: 'Check your email' })).toBeInTheDocument()
|
||||
expect(screen.getByText(/console/i)).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('keeps the SMTP warning visible throughout native password recovery', () => {
|
||||
mocks.native = true
|
||||
setForgot({ smtpConfigured: false })
|
||||
const { rerender } = render(<ForgotPasswordPage />)
|
||||
|
||||
expect(screen.getByRole('main')).toHaveClass('al-body')
|
||||
expect(screen.getByRole('textbox', { name: 'Email' })).toHaveAttribute('autocomplete', 'email')
|
||||
expect(screen.getByText(/hasn't configured SMTP/i)).toBeVisible()
|
||||
|
||||
setForgot({ smtpConfigured: false, submitted: true })
|
||||
rerender(<ForgotPasswordPage />)
|
||||
expect(screen.getByText(/hasn't configured SMTP/i)).toBeVisible()
|
||||
expect(screen.queryByRole('heading', { name: 'Check your email' })).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('lets a native user try again after a requester-wide rate limit', () => {
|
||||
mocks.native = true
|
||||
setForgot({ submitted: true, deliveryIssue: 'rateLimit' })
|
||||
render(<ForgotPasswordPage />)
|
||||
|
||||
expect(screen.getByRole('alert')).toHaveTextContent('Too many attempts')
|
||||
expect(screen.getByRole('button', { name: 'Send reset link' })).toBeEnabled()
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user