From b433059cc41447a93e4804312d8dccdc3f94f710 Mon Sep 17 00:00:00 2001 From: Vasyl Vdovychenko Date: Sun, 4 Oct 2026 18:43:01 -0400 Subject: [PATCH] =?UTF-8?q?test(web):=20stable=20t=20in=20ConnectedApps=20?= =?UTF-8?q?mock=20=E2=80=94=20the=20deploy-failing=20flake?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The mock returned a new t per render; the component's load effect depends on t, so every render reloaded the list and a late reload restored a disconnected row. Assert one load. Co-Authored-By: Claude Opus 5.5 (1M context) --- .../components/mcp/__tests__/ConnectedApps.test.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/apps/web/src/components/mcp/__tests__/ConnectedApps.test.tsx b/apps/web/src/components/mcp/__tests__/ConnectedApps.test.tsx index 57c05c1a2..067c28199 100644 --- a/apps/web/src/components/mcp/__tests__/ConnectedApps.test.tsx +++ b/apps/web/src/components/mcp/__tests__/ConnectedApps.test.tsx @@ -1,8 +1,12 @@ import { describe, it, expect, vi, afterEach, beforeEach } from 'vitest' import { render, screen, cleanup, waitFor, fireEvent } from '@testing-library/react' +// One `t` for every render, like the real hook (useCallback). A fresh function per render +// re-fires the component's load effect on each render, and a late reload put a just- +// disconnected row back — the flake that failed two deploys (2026-10-01, 2026-10-04). +const { t } = vi.hoisted(() => ({ t: (k: string) => k })) vi.mock('../../../hooks/useTranslation', () => ({ - useTranslation: () => ({ t: (k: string) => k }), + useTranslation: () => ({ t }), })) const { auth, api } = vi.hoisted(() => ({ @@ -44,9 +48,9 @@ describe('ConnectedApps', () => { render() await screen.findByText('Claude') fireEvent.click(screen.getAllByText('connect.apps.disconnect')[0]) - // 3s, not the 1s default: on a loaded CI runner this took 1035ms and failed a deploy (2026-10-01). - await waitFor(() => expect(screen.queryByText('Claude')).toBeNull(), { timeout: 3000 }) + await waitFor(() => expect(screen.queryByText('Claude')).toBeNull()) expect(api.revokeOAuthGrant).toHaveBeenCalledWith('g1') + expect(api.listOAuthGrants).toHaveBeenCalledTimes(1) expect(screen.getByText('ChatGPT')).toBeTruthy() })