Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

chore(test): fix flaky sign in test timeout (#19010)

Nimar5e243a26c2c3
diff --git a/web/src/__tests__/auth-sign-in-page.clienttest.tsx b/web/src/__tests__/auth-sign-in-page.clienttest.tsx
index dce3f002f6..3467bf4d57 100644
--- a/web/src/__tests__/auth-sign-in-page.clienttest.tsx
+++ b/web/src/__tests__/auth-sign-in-page.clienttest.tsx
@@ -469,7 +469,7 @@ describe("sign-in page last used SSO email", () => {
// The password step appearing is what marks the email as not SSO-backed.
await waitFor(() => {
- expect(screen.getByLabelText(/Password/)).toBeInTheDocument();
+ expect(screen.getByLabelText(/Password/)).toHaveFocus();
});
expect(storedSsoEmail()).toBe("");
expect(signInMock).not.toHaveBeenCalled();
@@ -500,6 +500,7 @@ describe("sign-in page last used SSO email", () => {
// One-step form: password is visible immediately.
expect(screen.getByLabelText(/Password/)).toBeInTheDocument();
+ expect(screen.getByLabelText(/Password/)).not.toHaveFocus();
await waitFor(() => {
expect(storedSsoEmail()).toBe("");
});
diff --git a/web/src/features/auth/SignInPage.tsx b/web/src/features/auth/SignInPage.tsx
index 491334e2af..169e690eef 100644
--- a/web/src/features/auth/SignInPage.tsx
+++ b/web/src/features/auth/SignInPage.tsx
@@ -811,18 +811,6 @@ export default function SignInPage({
setLastUsedSsoEmail("");
}
setShowPasswordStep(true);
-
- // Auto-focus password input when password step becomes visible
- setTimeout(() => {
- // Find and focus the password input
- // Ref did not work, so we use a more specific selector
- const passwordInput = document.querySelector(
- 'input[name="password"]',
- ) as HTMLInputElement;
- if (passwordInput) {
- passwordInput.focus();
- }
- }, 100);
} catch (error) {
// JSON.parse of a non-JSON 200 (proxy/WAF HTML) is transport, not an
// app bug — breadcrumb it. Unknown failures still capture.
@@ -925,7 +913,11 @@ export default function SignInPage({
</Link>
</FormLabel>
<FormControl>
- <PasswordInput allowPasswordManager {...field} />
+ <PasswordInput
+ allowPasswordManager
+ autoFocus={authProviders.sso}
+ {...field}
+ />
</FormControl>
<FormMessage />
</FormItem>