@@ -3,6 +3,7 @@ import fs from "node:fs";
33import os from "node:os" ;
44import path from "node:path" ;
55import { DatabaseSync } from "node:sqlite" ;
6+ import { WORKBOARD_STATUSES } from "@openclaw/workboard-contract" ;
67import { MAX_DATE_TIMESTAMP_MS } from "openclaw/plugin-sdk/number-runtime" ;
78import { describe , expect , it , vi } from "vitest" ;
89import type {
@@ -2618,31 +2619,57 @@ describe("WorkboardStore", () => {
26182619 } ) ;
26192620 } ) ;
26202621
2621- it ( "diagnoses archived cards that are still in an active status" , async ( ) => {
2622- // An archived card with an active status (ready) is silently excluded from
2623- // dispatch with no signal. computeCardDiagnostics must surface an
2624- // archived_but_active warning so workboard show / store.diagnostics report
2625- // it (#116359).
2622+ it . each ( WORKBOARD_STATUSES ) (
2623+ "reports archived %s cards according to terminal state" ,
2624+ async ( status ) => {
2625+ const store = new WorkboardStore ( createMemoryStore ( ) ) ;
2626+ const card = await store . create ( { title : `Archived ${ status } ` , status } ) ;
2627+
2628+ await store . archive ( card . id , true ) ;
2629+
2630+ const result = await store . diagnostics ( Date . now ( ) ) ;
2631+ if ( status === "done" ) {
2632+ expect ( result ) . toEqual ( { diagnostics : [ ] , count : 0 } ) ;
2633+ return ;
2634+ }
2635+ expect ( result ) . toMatchObject ( {
2636+ diagnostics : [
2637+ expect . objectContaining ( {
2638+ card : expect . objectContaining ( { id : card . id } ) ,
2639+ diagnostics : [
2640+ expect . objectContaining ( {
2641+ kind : "archived_but_active" ,
2642+ severity : "warning" ,
2643+ actions : [ ] ,
2644+ } ) ,
2645+ ] ,
2646+ } ) ,
2647+ ] ,
2648+ count : 1 ,
2649+ } ) ;
2650+ } ,
2651+ ) ;
2652+
2653+ it ( "keeps archived-card diagnostics transient across lifecycle changes" , async ( ) => {
26262654 const store = new WorkboardStore ( createMemoryStore ( ) ) ;
26272655 const card = await store . create ( { title : "Archived but ready" , status : "ready" } ) ;
26282656 const now = Date . now ( ) ;
26292657
26302658 await store . archive ( card . id , true ) ;
26312659
2660+ await expect ( store . refreshDiagnostics ( now ) ) . resolves . toEqual ( { diagnostics : [ ] , count : 0 } ) ;
2661+ await expect ( store . get ( card . id ) ) . resolves . not . toHaveProperty ( "metadata.diagnostics" ) ;
26322662 await expect ( store . diagnostics ( now ) ) . resolves . toMatchObject ( {
2633- diagnostics : [
2634- expect . objectContaining ( {
2635- card : expect . objectContaining ( { id : card . id } ) ,
2636- diagnostics : [
2637- expect . objectContaining ( {
2638- kind : "archived_but_active" ,
2639- severity : "warning" ,
2640- } ) ,
2641- ] ,
2642- } ) ,
2643- ] ,
2663+ diagnostics : [ expect . objectContaining ( { card : expect . objectContaining ( { id : card . id } ) } ) ] ,
26442664 count : 1 ,
26452665 } ) ;
2666+
2667+ await store . archive ( card . id , false ) ;
2668+ await expect ( store . diagnostics ( now + 1 ) ) . resolves . toEqual ( { diagnostics : [ ] , count : 0 } ) ;
2669+
2670+ await store . archive ( card . id , true ) ;
2671+ await store . move ( card . id , "done" , undefined ) ;
2672+ await expect ( store . diagnostics ( now + 2 ) ) . resolves . toEqual ( { diagnostics : [ ] , count : 0 } ) ;
26462673 } ) ;
26472674
26482675 it ( "does not drop concurrent updates while refreshing diagnostics" , async ( ) => {
0 commit comments