Show results whose plan item stopped as failed

The engine can stop a plan item without updating its drafts: a run paused
on material_quote_changed leaves the draft "preparing" for good, so the
result showed Preparing forever. A draft still at work now counts as
failed once its plan item is failed, blocked, cancelled or skipped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Iqbal
2026-10-23 11:02:10 +07:00
parent f219b26f71
commit 3df72c68ef
2 changed files with 25 additions and 6 deletions

View File

@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest'
import { correctIndex, questionsOf, toMarkdown, type Material } from './results'
import { correctIndex, questionsOf, toMarkdown, withPlanItem, type Material } from './results'
import { sentencesOf, scriptLang } from '../components/AudioPlayer'
describe('correctIndex', () => {
@@ -52,3 +52,16 @@ describe('audio script helpers', () => {
expect(scriptLang('This is the lesson that we will share with the team.')).toBe('en')
})
})
describe('withPlanItem', () => {
it('fails a draft still at work when its plan item stopped', () => {
expect(withPlanItem('preparing', 'failed')).toBe('failed')
expect(withPlanItem('generating', 'blocked')).toBe('failed')
})
it('keeps the draft status otherwise', () => {
expect(withPlanItem('preparing', 'generating')).toBe('preparing')
expect(withPlanItem('ready', 'failed')).toBe('ready')
expect(withPlanItem('preparing', undefined)).toBe('preparing')
})
})