@@ -130,6 +130,71 @@ describe('renderQuotaTable', () => {
130130 expect ( output ) . not . toContain ( '0 / 3' ) ;
131131 } ) ;
132132
133+ it ( 'uses remaining percent to disambiguate newer used-count responses' , ( ) => {
134+ const lines : string [ ] = [ ] ;
135+ const originalLog = console . log ;
136+
137+ console . log = ( message ?: unknown ) => {
138+ lines . push ( String ( message ?? '' ) ) ;
139+ } ;
140+
141+ try {
142+ renderQuotaTable (
143+ [
144+ {
145+ ...createModel ( ) ,
146+ model_name : 'video' ,
147+ current_interval_total_count : 5 ,
148+ current_interval_usage_count : 0 ,
149+ current_interval_remaining_percent : 100 ,
150+ current_weekly_total_count : 35 ,
151+ current_weekly_usage_count : 0 ,
152+ current_weekly_remaining_percent : 100 ,
153+ } ,
154+ ] ,
155+ { ...createConfig ( ) , noColor : true } ,
156+ ) ;
157+ } finally {
158+ console . log = originalLog ;
159+ }
160+
161+ const output = lines . join ( '\n' ) ;
162+ expect ( output ) . toContain ( '5 / 5' ) ;
163+ expect ( output ) . toContain ( '35 / 35' ) ;
164+ expect ( output ) . not . toContain ( '0 / 5' ) ;
165+ expect ( output ) . not . toContain ( '0 / 35' ) ;
166+ } ) ;
167+
168+ it ( 'falls back to the authoritative percent when counts cannot be reconciled' , ( ) => {
169+ const lines : string [ ] = [ ] ;
170+ const originalLog = console . log ;
171+
172+ console . log = ( message ?: unknown ) => {
173+ lines . push ( String ( message ?? '' ) ) ;
174+ } ;
175+
176+ try {
177+ renderQuotaTable (
178+ [
179+ {
180+ ...createModel ( ) ,
181+ current_interval_total_count : 10 ,
182+ current_interval_usage_count : 7 ,
183+ current_interval_remaining_percent : 40 ,
184+ } ,
185+ ] ,
186+ { ...createConfig ( ) , noColor : true } ,
187+ ) ;
188+ } finally {
189+ console . log = originalLog ;
190+ }
191+
192+ const output = lines . join ( '\n' ) ;
193+ expect ( output ) . toContain ( 'Left [████......] 40%' ) ;
194+ expect ( output ) . not . toContain ( '7 / 10' ) ;
195+ expect ( output ) . not . toContain ( '3 / 10' ) ;
196+ } ) ;
197+
133198 it ( 'renders the reset countdown in a boxed column with the window duration tag' , ( ) => {
134199 const lines : string [ ] = [ ] ;
135200 const originalLog = console . log ;
0 commit comments