fix: resolve all failing frontend tests

- Fix vitest.config.ts React alias to point to local node_modules
  instead of nonexistent ancestor path (../../../../node_modules/react)
- Remove stale HQWaitingForInputSection tests (component was deleted
  in e8d332e0 but test cases were left behind)
This commit is contained in:
Lukas May
2026-03-07 00:14:44 +01:00
parent 40900a5641
commit 40ec85deb8
2 changed files with 4 additions and 116 deletions

View File

@@ -17,7 +17,6 @@ vi.mock('@/lib/utils', () => ({
formatRelativeTime: () => '5 minutes ago',
}))
import { HQWaitingForInputSection } from './HQWaitingForInputSection'
import { HQNeedsReviewSection } from './HQNeedsReviewSection'
import { HQNeedsApprovalSection } from './HQNeedsApprovalSection'
import { HQResolvingConflictsSection } from './HQResolvingConflictsSection'
@@ -26,115 +25,6 @@ import { HQEmptyState } from './HQEmptyState'
const since = new Date(Date.now() - 5 * 60 * 1000).toISOString()
// ─── HQWaitingForInputSection ────────────────────────────────────────────────
describe('HQWaitingForInputSection', () => {
beforeEach(() => vi.clearAllMocks())
it('renders section heading "Waiting for Input"', () => {
render(<HQWaitingForInputSection items={[]} />)
expect(screen.getByText('Waiting for Input')).toBeInTheDocument()
})
it('renders agent name and truncated question text', () => {
const longQuestion = 'A'.repeat(150)
render(
<HQWaitingForInputSection
items={[
{
agentId: 'a1',
agentName: 'Agent Alpha',
initiativeId: null,
initiativeName: null,
questionText: longQuestion,
waitingSince: since,
},
]}
/>
)
expect(screen.getByText('Agent Alpha')).toBeInTheDocument()
// Truncated to 120 chars + ellipsis
const truncated = 'A'.repeat(120) + '…'
expect(screen.getByText(truncated)).toBeInTheDocument()
// Full text in tooltip content (forceMount renders it into DOM)
expect(screen.getAllByText(longQuestion).length).toBeGreaterThanOrEqual(1)
})
it('renders "waiting X" relative time', () => {
render(
<HQWaitingForInputSection
items={[
{
agentId: 'a1',
agentName: 'Agent Alpha',
initiativeId: null,
initiativeName: null,
questionText: 'What should I do?',
waitingSince: since,
},
]}
/>
)
expect(screen.getByText('waiting 5 minutes ago')).toBeInTheDocument()
})
it('clicking "Answer" calls navigate to /inbox', () => {
render(
<HQWaitingForInputSection
items={[
{
agentId: 'a1',
agentName: 'Agent Alpha',
initiativeId: null,
initiativeName: null,
questionText: 'Question?',
waitingSince: since,
},
]}
/>
)
fireEvent.click(screen.getByRole('button', { name: /answer/i }))
expect(mockNavigate).toHaveBeenCalledWith({ to: '/inbox' })
})
it('shows initiative name when non-null', () => {
render(
<HQWaitingForInputSection
items={[
{
agentId: 'a1',
agentName: 'Agent Alpha',
initiativeId: 'init-1',
initiativeName: 'My Initiative',
questionText: 'Question?',
waitingSince: since,
},
]}
/>
)
expect(screen.getByText(/My Initiative/)).toBeInTheDocument()
})
it('hides initiative name when null', () => {
render(
<HQWaitingForInputSection
items={[
{
agentId: 'a1',
agentName: 'Agent Alpha',
initiativeId: null,
initiativeName: null,
questionText: 'Question?',
waitingSince: since,
},
]}
/>
)
// No separator dot should appear since initiative is null
expect(screen.queryByText(/·/)).not.toBeInTheDocument()
})
})
// ─── HQNeedsReviewSection ────────────────────────────────────────────────────
describe('HQNeedsReviewSection', () => {

View File

@@ -5,14 +5,12 @@ import path from 'node:path';
export default defineConfig({
plugins: [react()],
resolve: {
// Alias react to the parent monorepo's copy, matching what @testing-library
// loads react-dom from. This ensures React DOM and our components share the
// same ReactSharedInternals and hook dispatcher — preventing null-dispatcher
// errors when running tests from a git worktree.
// Ensure all React imports resolve to the same copy, preventing
// duplicate-React errors (mismatched ReactSharedInternals / hook dispatcher).
alias: {
'@': path.resolve(__dirname, './apps/web/src'),
react: path.resolve(__dirname, '../../../../node_modules/react'),
'react-dom': path.resolve(__dirname, '../../../../node_modules/react-dom'),
react: path.resolve(__dirname, 'node_modules/react'),
'react-dom': path.resolve(__dirname, 'node_modules/react-dom'),
},
dedupe: ['react', 'react-dom'],
},