@@ -7,13 +7,8 @@ import { render } from "lit";
77import { describe , expect , it } from "vitest" ;
88import type { WorkspaceWidget } from "../types.ts" ;
99import { mapActivity , renderActivity } from "./activity.ts" ;
10- import { mapAgentStatus , renderAgentStatus } from "./agent-status.ts" ;
11- import {
12- buildWidgetApprovalsSource ,
13- mapApprovals ,
14- renderApprovals ,
15- toWidgetApprovalDecision ,
16- } from "./approvals.ts" ;
10+ import { renderAgentStatus } from "./agent-status.ts" ;
11+ import { buildWidgetApprovalsSource , renderApprovals } from "./approvals.ts" ;
1712import { mapCron , renderCron } from "./cron.ts" ;
1813import { evaluateEmbedUrl , renderIframeEmbed } from "./iframe-embed.ts" ;
1914import { mapInstances , renderInstances } from "./instances.ts" ;
@@ -48,25 +43,24 @@ const STRICT_EMBED: BuiltinWidgetContext = {
4843
4944describe ( "agent-status mapping" , ( ) => {
5045 it ( "maps only keyed sessions and clamps goal progress" , ( ) => {
51- const model = mapAgentStatus ( widget ( { props : { limit : 2 } } ) , {
52- sessions : [
53- {
54- key : "agent:one" ,
55- displayName : "One" ,
56- hasActiveRun : true ,
57- goal : { objective : "Ship the workspace" , tokensUsed : 125 , tokenBudget : 100 } ,
58- } ,
59- { key : "agent:two" , status : "idle" } ,
60- { displayName : "missing key" } ,
61- ] ,
62- } ) ;
63- expect ( model ) . toMatchObject ( { activeCount : 1 , total : 2 } ) ;
64- expect ( model . rows [ 0 ] ) . toMatchObject ( {
65- key : "agent:one" ,
66- active : true ,
67- task : "Ship the workspace" ,
68- progress : 1 ,
69- } ) ;
46+ const container = renderToContainer (
47+ renderAgentStatus ( widget ( { props : { limit : 2 } } ) , {
48+ sessions : [
49+ {
50+ key : "agent:one" ,
51+ displayName : "One" ,
52+ hasActiveRun : true ,
53+ goal : { objective : "Ship the workspace" , tokensUsed : 125 , tokenBudget : 100 } ,
54+ } ,
55+ { key : "agent:two" , status : "idle" } ,
56+ { displayName : "missing key" } ,
57+ ] ,
58+ } ) ,
59+ ) ;
60+ expect ( container . querySelectorAll ( ".workspace-list__row" ) ) . toHaveLength ( 2 ) ;
61+ expect ( container . textContent ) . toContain ( "Ship the workspace" ) ;
62+ expect ( container . textContent ) . toContain ( "100" ) ;
63+ expect ( container . textContent ) . not . toContain ( "missing key" ) ;
7064 } ) ;
7165
7266 it ( "renders accessible status text and an empty state" , ( ) => {
@@ -102,7 +96,6 @@ describe("approvals mapping", () => {
10296 ] ) ;
10397 source . onDecide ( source . pending [ 0 ] ! , "reject" ) ;
10498 expect ( decisions ) . toEqual ( [ [ "pending" , "rejected" ] ] ) ;
105- expect ( toWidgetApprovalDecision ( "approve" ) ) . toBe ( "approved" ) ;
10699 } ) ;
107100
108101 it ( "limits rows and renders explicit approval controls" , ( ) => {
@@ -113,13 +106,13 @@ describe("approvals mapping", () => {
113106 ] ,
114107 onDecide : ( ) => undefined ,
115108 } ;
116- expect ( mapApprovals ( widget ( { props : { limit : 1 } } ) , source ) ) . toMatchObject ( { total : 2 } ) ;
117109 const container = renderToContainer (
118110 renderApprovals ( widget ( { props : { limit : 1 } } ) , undefined , {
119111 ...STRICT_EMBED ,
120112 approvals : source ,
121113 } ) ,
122114 ) ;
115+ expect ( container . querySelectorAll ( ".workspace-list__row" ) ) . toHaveLength ( 1 ) ;
123116 expect ( container . querySelectorAll ( "button" ) ) . toHaveLength ( 2 ) ;
124117 expect ( container . textContent ) . toContain ( "Approve" ) ;
125118 expect ( container . textContent ) . toContain ( "Reject" ) ;
0 commit comments