* refactor(jobs): extraheer job-mapper naar lib/jobs-mapper.ts + voeg breadcrumb-velden toe Verplaatst JobWithRelations, JOB_INCLUDE, RawJob, PriceRow, pickDescription, computeCost en mapJob naar lib/jobs-mapper.ts (zonder 'use server'). Voegt buildPriceMap helper toe en breidt de types uit met productCode, storyCode en pbiCode via task->story->pbi en product.code includes. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(jobs): voeg GET /api/jobs/[id] route toe + tests * feat(jobs): useJobsRealtime fetch-on-unknown met dedup-Set Wanneer een SSE-event een onbekend job_id bevat, haalt de hook de volledige job op via GET /api/jobs/[id] en upsert die in de store. Een inFlight-Set voorkomt gelijktijdige dubbele fetches voor hetzelfde job_id. Bekende jobs blijven de bestaande partial-upsert gebruiken. Zelfde logica in jobs_initial. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(jobs): JobCard breadcrumb + datum-fallback per kind Voeg productCode/pbiCode/storyCode/startedAt/finishedAt toe aan JobCardProps; bouw breadcrumb per job-kind en toon finishedAt → startedAt → createdAt als datum. JobsColumn geeft de nieuwe velden door. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * test(jobs): JobCard breadcrumb + datum-fallback tests --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
78 lines
2.3 KiB
TypeScript
78 lines
2.3 KiB
TypeScript
// @vitest-environment jsdom
|
|
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
|
import { render, screen, fireEvent } from '@testing-library/react'
|
|
import '@testing-library/jest-dom'
|
|
import type { JobWithRelations } from '@/actions/jobs-page'
|
|
|
|
vi.mock('@/actions/claude-jobs', () => ({
|
|
restartClaudeJobAction: vi.fn(),
|
|
}))
|
|
|
|
vi.mock('sonner', () => ({ toast: { error: vi.fn() } }))
|
|
|
|
import { restartClaudeJobAction } from '@/actions/claude-jobs'
|
|
import JobDetailPane from '@/components/jobs/job-detail-pane'
|
|
|
|
const mockAction = restartClaudeJobAction as ReturnType<typeof vi.fn>
|
|
|
|
function makeJob(status: JobWithRelations['status']): JobWithRelations {
|
|
return {
|
|
id: 'job-1',
|
|
kind: 'TASK_IMPLEMENTATION',
|
|
status,
|
|
taskCode: 'T-1',
|
|
taskTitle: 'Test taak',
|
|
ideaCode: null,
|
|
ideaTitle: null,
|
|
sprintGoal: null,
|
|
sprintCode: null,
|
|
productName: 'Scrum4Me',
|
|
productCode: null,
|
|
storyCode: null,
|
|
pbiCode: null,
|
|
modelId: null,
|
|
inputTokens: null,
|
|
outputTokens: null,
|
|
cacheReadTokens: null,
|
|
cacheWriteTokens: null,
|
|
costUsd: null,
|
|
branch: null,
|
|
prUrl: null,
|
|
error: null,
|
|
summary: null,
|
|
description: null,
|
|
verifyResult: null,
|
|
startedAt: null,
|
|
finishedAt: null,
|
|
createdAt: new Date('2026-01-01'),
|
|
sprintRunId: null,
|
|
}
|
|
}
|
|
|
|
beforeEach(() => {
|
|
vi.clearAllMocks()
|
|
mockAction.mockResolvedValue({ success: true })
|
|
})
|
|
|
|
describe('JobDetailPane restart button', () => {
|
|
it('toont de knop voor FAILED-jobs', () => {
|
|
render(<JobDetailPane job={makeJob('FAILED')} isDemo={false} />)
|
|
expect(screen.getByRole('button', { name: /opnieuw starten/i })).toBeInTheDocument()
|
|
})
|
|
|
|
it('toont de knop niet voor DONE-jobs', () => {
|
|
render(<JobDetailPane job={makeJob('DONE')} isDemo={false} />)
|
|
expect(screen.queryByRole('button', { name: /opnieuw starten/i })).not.toBeInTheDocument()
|
|
})
|
|
|
|
it('roept restartClaudeJobAction aan met het juiste id bij klik', () => {
|
|
render(<JobDetailPane job={makeJob('FAILED')} isDemo={false} />)
|
|
fireEvent.click(screen.getByRole('button', { name: /opnieuw starten/i }))
|
|
expect(mockAction).toHaveBeenCalledWith('job-1')
|
|
})
|
|
|
|
it('knop is disabled in demo-modus', () => {
|
|
render(<JobDetailPane job={makeJob('FAILED')} isDemo={true} />)
|
|
expect(screen.getByRole('button', { name: /opnieuw starten/i })).toBeDisabled()
|
|
})
|
|
})
|