11import { afterEach , describe , expect , it , vi } from "vitest" ;
22import type { GatewayAgentRow , ModelCatalogEntry } from "../../api/types.ts" ;
33import type { ApplicationContext } from "../../app/context.ts" ;
4+ import { waitForFast } from "../../test-helpers/wait-for.ts" ;
45import type { DraftCloudProfile } from "./discovery.ts" ;
56import { contextWith , deferred , renderControl } from "./model-control.test-support.ts" ;
67import { NewSessionModelControl } from "./model-control.ts" ;
@@ -72,7 +73,7 @@ describe("new-session model runtime", () => {
7273 control . load ( context , "main" , true ) ;
7374 control . loadCatalogTargets ( context , "main" , false ) ;
7475
75- await vi . waitFor ( ( ) => expect ( request ) . toHaveBeenCalledOnce ( ) ) ;
76+ await waitForFast ( ( ) => expect ( request ) . toHaveBeenCalledOnce ( ) ) ;
7677 expect ( request ) . not . toHaveBeenCalledWith ( "sessions.catalog.list" , expect . anything ( ) ) ;
7778 expect (
7879 renderControl ( control , context ) . querySelector ( "[data-chat-model-target-group]" ) ,
@@ -117,14 +118,14 @@ describe("new-session model runtime", () => {
117118 control . load ( context , "main" , true ) ;
118119 control . loadCatalogTargets ( context , "main" , true ) ;
119120
120- await vi . waitFor ( ( ) =>
121+ await waitForFast ( ( ) =>
121122 expect ( request ) . toHaveBeenCalledWith (
122123 "sessions.catalog.list" ,
123124 { agentId : "main" , limitPerHost : 1 } ,
124125 { signal : expect . any ( AbortSignal ) } ,
125126 ) ,
126127 ) ;
127- await vi . waitFor ( ( ) => {
128+ await waitForFast ( ( ) => {
128129 const container = renderControl ( control , context ) ;
129130 expect ( container . querySelector ( '[data-chat-model-target-group="cliAgents"]' ) ) . not . toBeNull ( ) ;
130131 expect ( container . querySelector ( '[data-chat-model-target="anthropic"]' ) ) . not . toBeNull ( ) ;
@@ -149,7 +150,7 @@ describe("new-session model runtime", () => {
149150
150151 control . load ( context , "main" , true ) ;
151152 control . loadCatalogTargets ( context , "main" , true ) ;
152- await vi . waitFor ( ( ) => expect ( request ) . toHaveBeenCalledOnce ( ) ) ;
153+ await waitForFast ( ( ) => expect ( request ) . toHaveBeenCalledOnce ( ) ) ;
153154
154155 const container = renderControl ( control , context ) ;
155156 const picker = container . querySelector < HTMLDetailsElement > ( ".chat-controls__model-picker" ) ;
@@ -192,7 +193,7 @@ describe("new-session model runtime", () => {
192193 control . load ( context , "main" , true ) ;
193194
194195 expect ( control . isRestoringPreference ( ) ) . toBe ( false ) ;
195- await vi . waitFor ( ( ) => expect ( request ) . toHaveBeenCalledOnce ( ) ) ;
196+ await waitForFast ( ( ) => expect ( request ) . toHaveBeenCalledOnce ( ) ) ;
196197 } ) ;
197198
198199 it ( "renders initial metadata loading without synthesizing the configured default" , async ( ) => {
@@ -203,7 +204,7 @@ describe("new-session model runtime", () => {
203204
204205 control . load ( context , "main" , true ) ;
205206
206- await vi . waitFor ( ( ) => expect ( request ) . toHaveBeenCalledOnce ( ) ) ;
207+ await waitForFast ( ( ) => expect ( request ) . toHaveBeenCalledOnce ( ) ) ;
207208 const container = renderControl ( control , context ) ;
208209 expect ( container . querySelector ( '[data-chat-model-select="true"]' ) ?. textContent ) . toContain (
209210 "Loading models" ,
@@ -343,7 +344,7 @@ describe("new-session model runtime", () => {
343344 const control = new NewSessionModelControl ( notify ) ;
344345
345346 control . load ( context , "main" , true ) ;
346- await vi . waitFor ( ( ) => {
347+ await waitForFast ( ( ) => {
347348 expect ( request ) . toHaveBeenCalledOnce ( ) ;
348349 expect ( notify ) . toHaveBeenCalledTimes ( 2 ) ;
349350 } ) ;
@@ -396,7 +397,7 @@ describe("new-session model runtime", () => {
396397
397398 control . load ( context , "main" , true ) ;
398399
399- await vi . waitFor ( ( ) => {
400+ await waitForFast ( ( ) => {
400401 const container = renderControl ( control , context ) ;
401402 expect (
402403 container
@@ -460,8 +461,8 @@ describe("new-session model runtime", () => {
460461
461462 control . load ( context , "main" , true ) ;
462463
463- await vi . waitFor ( ( ) => expect ( request ) . toHaveBeenCalledOnce ( ) ) ;
464- await vi . waitFor ( ( ) => {
464+ await waitForFast ( ( ) => expect ( request ) . toHaveBeenCalledOnce ( ) ) ;
465+ await waitForFast ( ( ) => {
465466 const container = renderControl ( control , context ) ;
466467 expect (
467468 container
0 commit comments