Skip to content

Commit cc64437

Browse files
chore: clean up test suite per audit recommendations
Executes recommendations from a comprehensive test suite audit. Removes dead, redundant, and trivial tests; rewrites SessionDetail polling test to exercise real gating; trims duplicated assertions; adds missing assertion in assistant-loading tests. 13 files changed, 233 insertions(+), 462 deletions(-)
1 parent 68cd6b5 commit cc64437

13 files changed

Lines changed: 233 additions & 462 deletions

backend/test/bun-mock-test.test.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

backend/test/db/queries.test.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { describe, it, expect, beforeEach, vi } from 'vitest'
22
import * as db from '../../src/db/queries'
3-
import * as schema from '../../src/db/schema'
43

54
const mockDb = {
65
prepare: vi.fn(),
@@ -289,17 +288,4 @@ describe('Database Queries', () => {
289288
expect(mockDb.prepare).not.toHaveBeenCalled()
290289
})
291290
})
292-
293-
describe('Database Schema', () => {
294-
it('should have schema module available', () => {
295-
expect(schema.initializeDatabase).toBeDefined()
296-
expect(typeof schema.initializeDatabase).toBe('function')
297-
})
298-
})
299-
300-
describe('Transaction Support', () => {
301-
it('should support transaction existence', () => {
302-
expect(typeof mockDb.transaction).toBe('function')
303-
})
304-
})
305291
})

backend/test/routes/sse.test.ts

Lines changed: 0 additions & 48 deletions
This file was deleted.

backend/test/routes/stt.test.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,6 @@ describe('STT Routes', () => {
7272
sttApp = createSTTRoutes(mockDb)
7373
})
7474

75-
describe('createSTTRoutes', () => {
76-
it('should create a Hono app with routes', () => {
77-
expect(sttApp).toBeDefined()
78-
expect(typeof sttApp.fetch).toBe('function')
79-
})
80-
})
81-
8275
describe('GET /status', () => {
8376
it('should return status with correct structure', async () => {
8477
const req = new Request('http://localhost/status?userId=test')

frontend/src/components/ui/dialog.test.tsx

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -130,31 +130,6 @@ describe("DialogContent", () => {
130130
expect(screen.queryByRole("button", { name: /close/i })).not.toBeInTheDocument();
131131
});
132132

133-
it("merges custom className with default classes", () => {
134-
render(
135-
<Dialog open>
136-
<DialogContent className="custom-class" data-testid="dialog-content">
137-
Content
138-
</DialogContent>
139-
</Dialog>
140-
);
141-
const content = screen.getByTestId("dialog-content");
142-
expect(content).toHaveClass("custom-class");
143-
expect(content).toHaveClass("fixed");
144-
expect(content).toHaveClass("z-[70]");
145-
});
146-
147-
it("renders children correctly", () => {
148-
render(
149-
<Dialog open>
150-
<DialogContent>
151-
<span>Test Child Content</span>
152-
</DialogContent>
153-
</Dialog>
154-
);
155-
expect(screen.getByText("Test Child Content")).toBeInTheDocument();
156-
});
157-
158133
it("accepts mobileSwipeToClose prop without breaking rendering", () => {
159134
const onOpenChange = vi.fn();
160135
render(

frontend/src/components/ui/page-header.test.tsx

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,6 @@ import { render, screen } from "@testing-library/react";
33
import { PageHeader } from "./page-header";
44

55
describe("PageHeader", () => {
6-
it("applies pt-safe class for iOS safe area", () => {
7-
render(<PageHeader data-testid="header">Content</PageHeader>);
8-
const header = screen.getByTestId("header");
9-
expect(header).toHaveClass("pt-safe");
10-
});
11-
12-
it("applies sticky top-0 positioning", () => {
13-
render(<PageHeader data-testid="header">Content</PageHeader>);
14-
const header = screen.getByTestId("header");
15-
expect(header).toHaveClass("sticky");
16-
expect(header).toHaveClass("top-0");
17-
});
18-
196
it("renders children correctly", () => {
207
render(
218
<PageHeader>
@@ -24,37 +11,4 @@ describe("PageHeader", () => {
2411
);
2512
expect(screen.getByText("Test Child")).toBeInTheDocument();
2613
});
27-
28-
it("merges custom className", () => {
29-
render(
30-
<PageHeader data-testid="header" className="custom-class">
31-
Content
32-
</PageHeader>
33-
);
34-
const header = screen.getByTestId("header");
35-
expect(header).toHaveClass("custom-class");
36-
expect(header).toHaveClass("pt-safe");
37-
});
38-
39-
it("forwards additional props", () => {
40-
render(
41-
<PageHeader data-testid="header" aria-label="Page header">
42-
Content
43-
</PageHeader>
44-
);
45-
const header = screen.getByTestId("header");
46-
expect(header).toHaveAttribute("aria-label", "Page header");
47-
});
48-
49-
it("applies z-10 for proper stacking", () => {
50-
render(<PageHeader data-testid="header">Content</PageHeader>);
51-
const header = screen.getByTestId("header");
52-
expect(header).toHaveClass("z-10");
53-
});
54-
55-
it("applies transparent background", () => {
56-
render(<PageHeader data-testid="header">Content</PageHeader>);
57-
const header = screen.getByTestId("header");
58-
expect(header).toHaveClass("bg-transparent");
59-
});
6014
});

frontend/src/components/ui/side-drawer.test.tsx

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -48,46 +48,6 @@ describe('SideDrawer', () => {
4848
expect(handleClose).toHaveBeenCalled()
4949
})
5050

51-
it('applies pt-safe and pb-safe classes', () => {
52-
render(
53-
<SideDrawer isOpen onClose={() => {}} ariaLabel="Test drawer">
54-
<div>Test content</div>
55-
</SideDrawer>,
56-
)
57-
const dialog = document.querySelector('[role="dialog"]')
58-
expect(dialog).toHaveClass('pt-safe')
59-
expect(dialog).toHaveClass('pb-safe')
60-
})
61-
62-
it('defaults to right side', () => {
63-
render(
64-
<SideDrawer isOpen onClose={() => {}} ariaLabel="Test drawer">
65-
<div>Test content</div>
66-
</SideDrawer>,
67-
)
68-
const dialog = document.querySelector('[role="dialog"]')
69-
expect(dialog).toHaveClass('right-0')
70-
})
71-
72-
it('applies left side when specified', () => {
73-
render(
74-
<SideDrawer isOpen onClose={() => {}} side="left" ariaLabel="Test drawer">
75-
<div>Test content</div>
76-
</SideDrawer>,
77-
)
78-
const dialog = document.querySelector('[role="dialog"]')
79-
expect(dialog).toHaveClass('left-0')
80-
})
81-
82-
it('applies custom widthClass', () => {
83-
render(
84-
<SideDrawer isOpen onClose={() => {}} widthClass="w-80" ariaLabel="Test drawer">
85-
<div>Test content</div>
86-
</SideDrawer>,
87-
)
88-
const dialog = document.querySelector('[role="dialog"]')
89-
expect(dialog).toHaveClass('w-80')
90-
})
9151
})
9252

9353
describe('SideDrawerHeader', () => {
@@ -119,14 +79,4 @@ describe('SideDrawerContent', () => {
11979
)
12080
expect(screen.getByText('Content')).toBeInTheDocument()
12181
})
122-
123-
it('applies custom className', () => {
124-
render(
125-
<SideDrawerContent className="custom-class">
126-
<div>Content</div>
127-
</SideDrawerContent>,
128-
)
129-
const content = screen.getByText('Content').parentElement
130-
expect(content).toHaveClass('custom-class')
131-
})
13282
})

frontend/src/hooks/__tests__/useScheduleTarget.test.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@ describe('useScheduleTarget', () => {
5252
})
5353

5454
expect(result.current.scheduleTarget?.kind).toBe('assistant')
55-
expect(result.current.scheduleTarget?.fullPath).toBe('/abs/assistant')
56-
expect(result.current.scheduleTarget?.repoId).toBe(0)
57-
expect(result.current.scheduleTarget?.backHref).toBe('/assistant')
5855
expect(result.current.isLoading).toBe(false)
5956
expect(result.current.isError).toBe(false)
6057
})
@@ -98,9 +95,6 @@ describe('useScheduleTarget', () => {
9895
})
9996

10097
expect(result.current.scheduleTarget?.kind).toBe('repo')
101-
expect(result.current.scheduleTarget?.repoId).toBe(5)
102-
expect(result.current.scheduleTarget?.fullPath).toBe('/abs/repos/my-repo')
103-
expect(result.current.scheduleTarget?.backHref).toBe('/repos/5')
10498
})
10599

106100
it('does not call getAssistantModeStatus for repo', async () => {

frontend/src/hooks/useLSPStatus.test.tsx

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -137,52 +137,6 @@ describe('useLSPStatus', () => {
137137
expect(result.current.error).toBeTruthy()
138138
})
139139

140-
it('should have 30s refetch interval', async () => {
141-
mockGetLSPStatus.mockResolvedValue([])
142-
vi.mocked(useOpenCodeClient).mockReturnValue(mockClient)
143-
144-
const queryClient = new QueryClient({
145-
defaultOptions: { queries: { retry: false } }
146-
})
147-
const wrapper = ({ children }: { children: React.ReactNode }) => (
148-
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
149-
)
150-
151-
const { result } = renderHook(() => useLSPStatus('http://localhost:5551', '/test'), {
152-
wrapper
153-
})
154-
155-
await waitFor(() => {
156-
expect(result.current.isSuccess).toBe(true)
157-
})
158-
159-
const observer = queryClient.getQueryCache().find({ queryKey: ['opencode', 'lsp', 'http://localhost:5551', '/test'] })
160-
expect((observer?.options as any).refetchInterval).toBe(30000)
161-
})
162-
163-
it('should have 10s stale time', async () => {
164-
mockGetLSPStatus.mockResolvedValue([])
165-
vi.mocked(useOpenCodeClient).mockReturnValue(mockClient)
166-
167-
const queryClient = new QueryClient({
168-
defaultOptions: { queries: { retry: false } }
169-
})
170-
const wrapper = ({ children }: { children: React.ReactNode }) => (
171-
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
172-
)
173-
174-
const { result } = renderHook(() => useLSPStatus('http://localhost:5551', '/test'), {
175-
wrapper
176-
})
177-
178-
await waitFor(() => {
179-
expect(result.current.isSuccess).toBe(true)
180-
})
181-
182-
const observer = queryClient.getQueryCache().find({ queryKey: ['opencode', 'lsp', 'http://localhost:5551', '/test'] })
183-
expect((observer?.options as any).staleTime).toBe(10000)
184-
})
185-
186140
it('should refetch on window focus', async () => {
187141
mockGetLSPStatus.mockResolvedValue([])
188142
vi.mocked(useOpenCodeClient).mockReturnValue(mockClient)

frontend/src/pages/__tests__/SessionDetail.assistant-loading.test.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,10 +264,10 @@ describe('SessionDetail assistant loading at repoId=0', () => {
264264
})
265265
})
266266

267-
it('renders "Assistant" as workspaceDisplayName for non-assistant sessions without repo', async () => {
267+
it('shows the loading state for a non-assistant session whose repo has not loaded', async () => {
268268
mocks.useSession.mockReturnValue({ data: undefined, isLoading: false })
269269

270-
return render(
270+
render(
271271
<MemoryRouter initialEntries={['/repos/1/sessions/sess-1']}>
272272
<QueryClientProvider client={createQueryClient()}>
273273
<Routes>
@@ -276,5 +276,9 @@ describe('SessionDetail assistant loading at repoId=0', () => {
276276
</QueryClientProvider>
277277
</MemoryRouter>
278278
)
279+
280+
await waitFor(() => {
281+
expect(screen.getByText('Loading repository...')).toBeInTheDocument()
282+
})
279283
})
280284
})

0 commit comments

Comments
 (0)