* fix(ST-1272): allow PLAN_READY → GRILLING re-grill transition
actions/ideas.ts already lists PLAN_READY in GRILL_TRIGGERABLE_FROM,
but lib/idea-status.ts ALLOWED_TRANSITIONS was missing the
PLAN_READY → GRILLING edge. As a result, clicking Grill on a PLAN_READY
idea returned 422 "Status-transitie ongeldig" while the UI button was
enabled. Mirrors the existing PLANNED → GRILLING re-grill behaviour.
- lib/idea-status.ts: PLAN_READY allows GRILLING in addition to
PLANNING/PLANNED
- __tests__/lib/idea-status.test.ts: explicit assert for
PLAN_READY → GRILLING and PLAN_READY added to the regrill loop
covering every GRILL_TRIGGERABLE_FROM status
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* feat(ST-1275): render SKIPPED job status in chart-colors and insights
Closing the gap left when ClaudeJobStatus.SKIPPED was added to the schema:
the badge map and case-mapper already covered it, but the chart palette,
the per-day insights aggregator and the stacked-bar chart did not. SKIPPED
jobs (e.g. cmovkur8 manually flipped during the no-op-exit hotfix) now
render with a muted style consistent with cancelled.
- lib/chart-colors.ts: JOB_STATUS_COLORS gains a 'skipped' entry
(var(--muted-foreground), same intensity as cancelled — neither rood/orange)
- lib/insights/agent-throughput.ts: DayCount + STATUSES + perDay zero-fill
now include 'skipped'; the SQL terminal_7d filter already counted SKIPPED
- app/(app)/insights/components/agent-throughput.tsx: STACKED_STATUSES and
the empty-state guard include 'skipped'
- __tests__: chart-colors keys list, job-status round-trip ('all 7 statuses')
and the insights non-zero filter all account for SKIPPED
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
108 lines
3.8 KiB
TypeScript
108 lines
3.8 KiB
TypeScript
import { describe, it, expect } from 'vitest'
|
|
|
|
import {
|
|
ideaStatusToApi,
|
|
ideaStatusFromApi,
|
|
canTransition,
|
|
isIdeaEditable,
|
|
isGrillMdEditable,
|
|
isPlanMdEditable,
|
|
IDEA_STATUS_API_VALUES,
|
|
} from '@/lib/idea-status'
|
|
|
|
describe('idea-status mappers', () => {
|
|
it('round-trips every API value', () => {
|
|
for (const api of IDEA_STATUS_API_VALUES) {
|
|
const db = ideaStatusFromApi(api)
|
|
expect(db).not.toBeNull()
|
|
expect(ideaStatusToApi(db!)).toBe(api)
|
|
}
|
|
})
|
|
|
|
it('returns null for invalid input', () => {
|
|
expect(ideaStatusFromApi('NOT_A_STATUS')).toBeNull()
|
|
})
|
|
|
|
it('is case-insensitive on the API side', () => {
|
|
expect(ideaStatusFromApi('PLAN_READY')).toBe('PLAN_READY')
|
|
expect(ideaStatusFromApi('Plan_Ready')).toBe('PLAN_READY')
|
|
})
|
|
})
|
|
|
|
describe('canTransition', () => {
|
|
it('allows valid forward transitions', () => {
|
|
expect(canTransition('DRAFT', 'GRILLING')).toBe(true)
|
|
expect(canTransition('GRILLING', 'GRILLED')).toBe(true)
|
|
expect(canTransition('GRILLED', 'PLANNING')).toBe(true)
|
|
expect(canTransition('PLANNING', 'PLAN_READY')).toBe(true)
|
|
expect(canTransition('PLAN_READY', 'PLANNED')).toBe(true)
|
|
})
|
|
|
|
it('allows re-grill from GRILLED and PLAN_READY-ish states', () => {
|
|
expect(canTransition('GRILLED', 'GRILLING')).toBe(true)
|
|
expect(canTransition('PLAN_FAILED', 'PLANNING')).toBe(true)
|
|
expect(canTransition('PLAN_READY', 'GRILLING')).toBe(true)
|
|
})
|
|
|
|
it('allows fail-side transitions', () => {
|
|
expect(canTransition('GRILLING', 'GRILL_FAILED')).toBe(true)
|
|
expect(canTransition('PLANNING', 'PLAN_FAILED')).toBe(true)
|
|
})
|
|
|
|
it('allows recovery from failed states', () => {
|
|
expect(canTransition('GRILL_FAILED', 'GRILLING')).toBe(true)
|
|
expect(canTransition('PLAN_FAILED', 'GRILLED')).toBe(true)
|
|
})
|
|
|
|
it('allows PLANNED → PLAN_READY (relink) and PLANNED → GRILLING (re-grill)', () => {
|
|
expect(canTransition('PLANNED', 'PLAN_READY')).toBe(true)
|
|
expect(canTransition('PLANNED', 'GRILLING')).toBe(true)
|
|
expect(canTransition('PLANNED', 'DRAFT')).toBe(false)
|
|
})
|
|
|
|
it('canTransition to GRILLING from all statuses that allow re-grill', () => {
|
|
// GRILL_TRIGGERABLE_FROM in actions/ideas.ts — alle statussen die re-grill ondersteunen.
|
|
const regrill = ['DRAFT', 'GRILLED', 'GRILL_FAILED', 'PLAN_READY', 'PLANNED'] as const
|
|
for (const status of regrill) {
|
|
expect(canTransition(status, 'GRILLING')).toBe(true)
|
|
}
|
|
})
|
|
|
|
it('rejects invalid jumps', () => {
|
|
expect(canTransition('DRAFT', 'PLANNED')).toBe(false)
|
|
expect(canTransition('DRAFT', 'PLAN_READY')).toBe(false)
|
|
expect(canTransition('GRILLING', 'PLANNED')).toBe(false)
|
|
})
|
|
})
|
|
|
|
describe('isIdeaEditable', () => {
|
|
it('allows edit in non-running, non-PLANNED states', () => {
|
|
expect(isIdeaEditable('DRAFT')).toBe(true)
|
|
expect(isIdeaEditable('GRILLED')).toBe(true)
|
|
expect(isIdeaEditable('GRILL_FAILED')).toBe(true)
|
|
expect(isIdeaEditable('PLAN_FAILED')).toBe(true)
|
|
expect(isIdeaEditable('PLAN_READY')).toBe(true)
|
|
})
|
|
|
|
it('blocks edit while a job is running or after PLANNED', () => {
|
|
expect(isIdeaEditable('GRILLING')).toBe(false)
|
|
expect(isIdeaEditable('PLANNING')).toBe(false)
|
|
expect(isIdeaEditable('PLANNED')).toBe(false)
|
|
})
|
|
})
|
|
|
|
describe('isGrillMdEditable / isPlanMdEditable', () => {
|
|
it('grill_md only editable in GRILLED or PLAN_READY', () => {
|
|
expect(isGrillMdEditable('GRILLED')).toBe(true)
|
|
expect(isGrillMdEditable('PLAN_READY')).toBe(true)
|
|
expect(isGrillMdEditable('DRAFT')).toBe(false)
|
|
expect(isGrillMdEditable('PLANNED')).toBe(false)
|
|
})
|
|
|
|
it('plan_md only editable in PLAN_READY', () => {
|
|
expect(isPlanMdEditable('PLAN_READY')).toBe(true)
|
|
expect(isPlanMdEditable('GRILLED')).toBe(false)
|
|
expect(isPlanMdEditable('PLAN_FAILED')).toBe(false)
|
|
expect(isPlanMdEditable('PLANNED')).toBe(false)
|
|
})
|
|
})
|