Files
hapi/web/src/components/SessionRowSummary.test.tsx
T

65 lines
2.0 KiB
TypeScript

import { cleanup, render, screen } from '@testing-library/react'
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
import type { SessionSummary } from '@/types/api'
import { I18nProvider } from '@/lib/i18n-context'
import { SessionRowSummary } from './SessionRowSummary'
afterEach(() => cleanup())
function makeSummary(overrides: Partial<SessionSummary> = {}): SessionSummary {
return {
id: 'background-demo',
active: true,
thinking: false,
activeAt: 0,
updatedAt: 0,
metadata: { path: '/demo/status', name: 'Background demo', flavor: 'claude' },
metadataVersion: 0,
agentStateVersion: 0,
todosUpdatedAt: 0,
todoProgress: null,
pendingRequestsCount: 0,
pendingRequestKinds: [],
pendingRequests: [],
backgroundTaskCount: 2,
futureScheduledMessageCount: 0,
nextScheduledAt: null,
model: null,
effort: null,
...overrides
}
}
function renderSummary(showDetailedStatus: boolean) {
return render(
<I18nProvider>
<SessionRowSummary
session={makeSummary()}
showDetailedStatus={showDetailedStatus}
/>
</I18nProvider>
)
}
describe('SessionRowSummary background status', () => {
beforeEach(() => {
localStorage.clear()
})
it('shows the basic running label in Basic mode', () => {
renderSummary(false)
expect(screen.getByText('Running', { exact: true })).toBeInTheDocument()
expect(screen.queryByRole('tooltip', { hidden: true })).not.toBeInTheDocument()
})
it('shows a detailed background dot with the task-count tooltip in Extended mode', () => {
renderSummary(true)
expect(screen.queryByText('Running', { exact: true })).not.toBeInTheDocument()
const tooltip = screen.getByRole('tooltip', { hidden: true })
expect(tooltip).toHaveTextContent('Background tasks running')
expect(tooltip).toHaveTextContent('2 tasks running')
})
})