@@ -20,6 +20,20 @@ function mockReachableResponse(status = 200) {
2020 } ) ;
2121}
2222
23+ function requireFetchPreflightRequest ( ) : {
24+ url ?: string ;
25+ timeoutMs ?: number ;
26+ auditContext ?: string ;
27+ } {
28+ const request = fetchWithSsrFGuardMock . mock . calls [ 0 ] ?. [ 0 ] as
29+ | { url ?: string ; timeoutMs ?: number ; auditContext ?: string }
30+ | undefined ;
31+ if ( ! request ) {
32+ throw new Error ( "Expected cron model preflight fetch request" ) ;
33+ }
34+ return request ;
35+ }
36+
2337describe ( "preflightCronModelProvider" , ( ) => {
2438 beforeEach ( ( ) => {
2539 fetchWithSsrFGuardMock . mockReset ( ) ;
@@ -67,8 +81,9 @@ describe("preflightCronModelProvider", () => {
6781 } ) ;
6882
6983 expect ( result ) . toEqual ( { status : "available" } ) ;
70- expect ( fetchWithSsrFGuardMock . mock . calls [ 0 ] ?. [ 0 ] ?. url ) . toBe ( "http://127.0.0.1:8000/v1/models" ) ;
71- expect ( fetchWithSsrFGuardMock . mock . calls [ 0 ] ?. [ 0 ] ?. timeoutMs ) . toBe ( 2500 ) ;
84+ const request = requireFetchPreflightRequest ( ) ;
85+ expect ( request . url ) . toBe ( "http://127.0.0.1:8000/v1/models" ) ;
86+ expect ( request . timeoutMs ) . toBe ( 2500 ) ;
7287 } ) ;
7388
7489 it ( "marks unreachable local Ollama endpoints unavailable and caches the result" , async ( ) => {
@@ -115,10 +130,9 @@ describe("preflightCronModelProvider", () => {
115130 expect ( second . baseUrl ) . toBe ( "http://localhost:11434" ) ;
116131 expect ( second . retryAfterMs ) . toBe ( 300000 ) ;
117132 expect ( fetchWithSsrFGuardMock ) . toHaveBeenCalledTimes ( 1 ) ;
118- expect ( fetchWithSsrFGuardMock . mock . calls [ 0 ] ?. [ 0 ] ?. url ) . toBe ( "http://localhost:11434/api/tags" ) ;
119- expect ( fetchWithSsrFGuardMock . mock . calls [ 0 ] ?. [ 0 ] ?. auditContext ) . toBe (
120- "cron-model-provider-preflight" ,
121- ) ;
133+ const request = requireFetchPreflightRequest ( ) ;
134+ expect ( request . url ) . toBe ( "http://localhost:11434/api/tags" ) ;
135+ expect ( request . auditContext ) . toBe ( "cron-model-provider-preflight" ) ;
122136 } ) ;
123137
124138 it ( "retries an unavailable endpoint after the cache ttl" , async ( ) => {
0 commit comments