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
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
Button,
Input,
SimpleGrid,
Spinner,
Stack,
Text,
HStack,
Expand Down Expand Up @@ -271,6 +272,17 @@ const OtpAuth = ({
))}
</SimpleGrid>

{/* Loading spinner during verification */}
{isVerifying && (
<Spinner
size="sm"
color="blue.500"
role="status"
aria-live="polite"
data-testid="otp-verifying-spinner"
/>
)}

{/* Error message */}
{error && (
<Text fontSize="sm" color="red.500" textAlign="center">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,41 @@ describe('OtpAuth', () => {
await user.type(otpInputs[7], '8')
expect(otpInputs[7]).toHaveFocus()
})

test('shows spinner while OTP is being verified', async () => {
const deferred = {}
const verifyingPromise = new Promise((resolve) => {
deferred.resolve = resolve
})
const mockVerify = jest.fn().mockReturnValue(verifyingPromise)

const user = userEvent.setup()
renderWithProviders(
<OtpAuth
isOpen={true}
onClose={mockOnClose}
form={mockForm}
handleOtpVerification={mockVerify}
handleSendEmailOtp={mockHandleSendEmailOtp}
/>
)

expect(screen.queryByTestId('otp-verifying-spinner')).not.toBeInTheDocument()

const otpInputs = screen.getAllByRole('textbox')
fireEvent.paste(otpInputs[0], {
clipboardData: {getData: () => '12345678'}
})

await waitFor(() => {
expect(screen.getByTestId('otp-verifying-spinner')).toBeInTheDocument()
})

deferred.resolve({success: true})
await waitFor(() => {
expect(screen.queryByTestId('otp-verifying-spinner')).not.toBeInTheDocument()
})
})
})

describe('Keyboard Navigation', () => {
Expand Down
Loading