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:
@@ -17,7 +17,6 @@ vi.mock('@/lib/utils', () => ({
|
|||||||
formatRelativeTime: () => '5 minutes ago',
|
formatRelativeTime: () => '5 minutes ago',
|
||||||
}))
|
}))
|
||||||
|
|
||||||
import { HQWaitingForInputSection } from './HQWaitingForInputSection'
|
|
||||||
import { HQNeedsReviewSection } from './HQNeedsReviewSection'
|
import { HQNeedsReviewSection } from './HQNeedsReviewSection'
|
||||||
import { HQNeedsApprovalSection } from './HQNeedsApprovalSection'
|
import { HQNeedsApprovalSection } from './HQNeedsApprovalSection'
|
||||||
import { HQResolvingConflictsSection } from './HQResolvingConflictsSection'
|
import { HQResolvingConflictsSection } from './HQResolvingConflictsSection'
|
||||||
@@ -26,115 +25,6 @@ import { HQEmptyState } from './HQEmptyState'
|
|||||||
|
|
||||||
const since = new Date(Date.now() - 5 * 60 * 1000).toISOString()
|
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 ────────────────────────────────────────────────────
|
// ─── HQNeedsReviewSection ────────────────────────────────────────────────────
|
||||||
|
|
||||||
describe('HQNeedsReviewSection', () => {
|
describe('HQNeedsReviewSection', () => {
|
||||||
|
|||||||
@@ -5,14 +5,12 @@ import path from 'node:path';
|
|||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [react()],
|
plugins: [react()],
|
||||||
resolve: {
|
resolve: {
|
||||||
// Alias react to the parent monorepo's copy, matching what @testing-library
|
// Ensure all React imports resolve to the same copy, preventing
|
||||||
// loads react-dom from. This ensures React DOM and our components share the
|
// duplicate-React errors (mismatched ReactSharedInternals / hook dispatcher).
|
||||||
// same ReactSharedInternals and hook dispatcher — preventing null-dispatcher
|
|
||||||
// errors when running tests from a git worktree.
|
|
||||||
alias: {
|
alias: {
|
||||||
'@': path.resolve(__dirname, './apps/web/src'),
|
'@': path.resolve(__dirname, './apps/web/src'),
|
||||||
react: path.resolve(__dirname, '../../../../node_modules/react'),
|
react: path.resolve(__dirname, 'node_modules/react'),
|
||||||
'react-dom': path.resolve(__dirname, '../../../../node_modules/react-dom'),
|
'react-dom': path.resolve(__dirname, 'node_modules/react-dom'),
|
||||||
},
|
},
|
||||||
dedupe: ['react', 'react-dom'],
|
dedupe: ['react', 'react-dom'],
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user