* feat(ST-1111.1): add ClaudeJob model and state-machine enum Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(ST-1111.2): add ClaudeJob status API mappers Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(ST-1111.3): add enqueue/cancel ClaudeJob server actions with idempotency + NOTIFY Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(ST-1111.4): forward ClaudeJob events on solo SSE stream + initial state Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(ST-1111.6): add 'Voer uit' + cancel buttons to task detail dialog Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(ST-1111.7): add job status pill with spinner on solo task cards Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * test(ST-1111.8): cover job-status mappers and enqueue/cancel actions Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * docs(ST-1111.9): document Claude job queue architecture and agent flow Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(ST-1111.10a): add ClaudeWorker presence model Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(ST-1111.10c): forward worker presence events on solo SSE + initial count Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(ST-1111.10d): show worker presence indicator and gate 'Voer uit' on connected workers Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
43 lines
1.5 KiB
TypeScript
43 lines
1.5 KiB
TypeScript
import { describe, it, expect } from 'vitest'
|
|
import {
|
|
jobStatusToApi,
|
|
jobStatusFromApi,
|
|
JOB_STATUS_API_VALUES,
|
|
ACTIVE_JOB_STATUSES,
|
|
} from '@/lib/job-status'
|
|
|
|
describe('job-status mappers', () => {
|
|
it('round-trips every API value', () => {
|
|
for (const api of JOB_STATUS_API_VALUES) {
|
|
const db = jobStatusFromApi(api)
|
|
expect(db).not.toBeNull()
|
|
expect(jobStatusToApi(db!)).toBe(api)
|
|
}
|
|
})
|
|
|
|
it('returns null for invalid input', () => {
|
|
expect(jobStatusFromApi('NOT_A_STATUS')).toBeNull()
|
|
expect(jobStatusFromApi('')).toBeNull()
|
|
expect(jobStatusFromApi('active')).toBeNull()
|
|
})
|
|
|
|
it('is case-insensitive on the API side (accepts both upper and lower)', () => {
|
|
expect(jobStatusFromApi('running')).toBe('RUNNING')
|
|
expect(jobStatusFromApi('RUNNING')).toBe('RUNNING')
|
|
expect(jobStatusFromApi('QUEUED')).toBe('QUEUED')
|
|
})
|
|
|
|
it('maps all 6 DB statuses to API', () => {
|
|
expect(jobStatusToApi('QUEUED')).toBe('queued')
|
|
expect(jobStatusToApi('CLAIMED')).toBe('claimed')
|
|
expect(jobStatusToApi('RUNNING')).toBe('running')
|
|
expect(jobStatusToApi('DONE')).toBe('done')
|
|
expect(jobStatusToApi('FAILED')).toBe('failed')
|
|
expect(jobStatusToApi('CANCELLED')).toBe('cancelled')
|
|
})
|
|
|
|
it('ACTIVE_JOB_STATUSES contains exactly QUEUED, CLAIMED, RUNNING', () => {
|
|
expect(ACTIVE_JOB_STATUSES).toEqual(expect.arrayContaining(['QUEUED', 'CLAIMED', 'RUNNING']))
|
|
expect(ACTIVE_JOB_STATUSES).toHaveLength(3)
|
|
})
|
|
})
|