test(#411): QA-015 — add credentials fallback test + fix refreshSession test name
Add test for non-string error.message fallback in handleCredentialsLogin. Rename misleading refreshSession test to match actual behavior. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -341,6 +341,33 @@ describe("LoginPage", (): void => {
|
||||
expect(mockPush).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("should show fallback PDA-friendly message when error.message is not a string", async (): Promise<void> => {
|
||||
mockFetchConfig(EMAIL_ONLY_CONFIG);
|
||||
// Return an error object where message is NOT a string (e.g. numeric code, no message field)
|
||||
mockSignInEmail.mockResolvedValueOnce({
|
||||
error: { code: 123 },
|
||||
});
|
||||
const user = userEvent.setup();
|
||||
|
||||
render(<LoginPage />);
|
||||
|
||||
await waitFor((): void => {
|
||||
expect(screen.getByLabelText(/email/i)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
await user.type(screen.getByLabelText(/email/i), "test@example.com");
|
||||
await user.type(screen.getByLabelText(/password/i), "wrong");
|
||||
await user.click(screen.getByRole("button", { name: /continue/i }));
|
||||
|
||||
await waitFor((): void => {
|
||||
expect(
|
||||
screen.getByText("Unable to sign in. Please check your credentials and try again.")
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
expect(mockPush).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("shows parseAuthError message on unexpected sign-in exception", async (): Promise<void> => {
|
||||
mockFetchConfig(EMAIL_ONLY_CONFIG);
|
||||
mockSignInEmail.mockRejectedValueOnce(new TypeError("Failed to fetch"));
|
||||
|
||||
Reference in New Issue
Block a user