@@ -100,7 +100,7 @@ describe("subscription widget snapshots", () => {
100100 expect ( snapshot . providers [ 0 ] ?. name ) . toBe ( "Codex" ) ;
101101 expect ( JSON . stringify ( snapshot ) ) . not . toContain ( "example.com" ) ;
102102 const source = input . get ( EnvironmentId . make ( "env" ) ) ! . serverConfig . usageLimitSources [ 0 ] ! ;
103- const failed = buildSubscriptionUsageSnapshot (
103+ const failedInput = ( windows : typeof limits . windows , includeHealthy = false ) =>
104104 new Map ( [
105105 [
106106 EnvironmentId . make ( "env" ) ,
@@ -111,22 +111,26 @@ describe("subscription widget snapshots", () => {
111111 usageLimitSources : [
112112 {
113113 ...source ,
114- accounts : source . accounts . map ( ( account ) => ( {
115- ...account ,
116- usageLimits : {
117- checkedAt,
118- windows : [ ] ,
119- unavailable : { reason : "probeFailed" as const } ,
120- } ,
121- } ) ) ,
114+ accounts : [
115+ ...( includeHealthy ? source . accounts : [ ] ) ,
116+ ...source . accounts . map ( ( account ) => ( {
117+ ...account ,
118+ id : "failed-account" ,
119+ 120+ usageLimits : {
121+ checkedAt,
122+ windows,
123+ unavailable : { reason : "probeFailed" as const } ,
124+ } ,
125+ } ) ) ,
126+ ] ,
122127 } ,
123128 ] ,
124129 } ,
125130 } ,
126131 ] ,
127- ] ) ,
128- deepLink ,
129- ) ;
132+ ] ) ;
133+ const failed = buildSubscriptionUsageSnapshot ( failedInput ( [ ] ) , deepLink ) ;
130134 expect ( failed . providers ) . toEqual ( [
131135 {
132136 name : "Codex" ,
@@ -136,6 +140,17 @@ describe("subscription widget snapshots", () => {
136140 totalWindows : 0 ,
137141 } ,
138142 ] ) ;
143+ const partial = buildSubscriptionUsageSnapshot ( failedInput ( [ ] , true ) , deepLink ) ;
144+ expect ( partial . providers [ 0 ] ?. detail ) . toBe ( "Available subscription limits" ) ;
145+ expect ( partial . providers [ 0 ] ?. windows [ 0 ] ?. remaining ) . toBe ( 60 ) ;
146+ const retained = buildSubscriptionUsageSnapshot ( failedInput ( limits . windows ) , deepLink ) ;
147+ expect ( retained . providers [ 0 ] ?. detail ) . toBe ( "Last known limits" ) ;
148+ expect ( retained . providers [ 0 ] ?. windows [ 0 ] ) . toMatchObject ( {
149+ label : "Stale · 5 hours" ,
150+ remaining : 60 ,
151+ } ) ;
152+ expect ( retained . checkedAt ) . toBe ( now ) ;
153+ expect ( retained . providers [ 0 ] ?. expiresAt ) . toBe ( now + 10 * 60_000 ) ;
139154 } ) ;
140155 it ( "bounds OS storage and puts the most constrained windows first" , ( ) => {
141156 const windows = Array . from ( { length : 20 } , ( _ , index ) => ( {
0 commit comments