@@ -13,14 +13,15 @@ import {
1313const solar = 'upstage/solar-pro4'
1414const start = Date . parse ( '2026-09-05T07:00:00Z' )
1515const end = Date . parse ( '2026-09-08T07:00:00Z' )
16+ const restored = Date . parse ( '2026-09-09T15:49:00Z' )
1617const quoteBeforeStart = ( ) => ( {
1718 ...freebucksFixture ( 0 , { [ solar ] : SOLAR_REGULAR_OFFER . price } ) ,
1819 priceNotices : { [ solar ] : SOLAR_REGULAR_OFFER . tagline } ,
1920 priceChanges : [ ...SOLAR_PRICE_CHANGES ] ,
2021} )
2122
2223describe ( 'announced Freebucks price changes' , ( ) => {
23- it ( 'keeps a serialized quote coherent at both boundaries without mutating balances or the input' , ( ) => {
24+ it ( 'keeps a serialized quote coherent at every boundary without mutating balances or the input' , ( ) => {
2425 const quote = JSON . parse ( JSON . stringify ( quoteBeforeStart ( ) ) )
2526 expect ( applyFreebucksPriceChanges ( quote , start - 1 ) ) . toBe ( quote )
2627 const free = applyFreebucksPriceChanges ( quote , start )
@@ -33,15 +34,20 @@ describe('announced Freebucks price changes', () => {
3334 expect ( expired . balance ) . toBe ( 0 )
3435 expect ( expired . daily ) . toEqual ( quote . daily )
3536 expect ( expired . wallet ) . toEqual ( quote . wallet )
36- expect ( nextFreebucksPriceChange ( expired ) ) . toBe ( Infinity )
37+ expect ( nextFreebucksPriceChange ( expired ) ) . toBe ( restored )
38+ const freeAgain = applyFreebucksPriceChanges ( expired , restored )
39+ expect ( freeAgain . prices [ solar ] ) . toBe ( 0 )
40+ expect ( freeAgain . priceNotices [ solar ] ) . toBe ( '0 Freebucks' )
41+ expect ( nextFreebucksPriceChange ( freeAgain ) ) . toBe ( Infinity )
3742 expect ( quote . prices [ solar ] ) . toBe ( 5 )
38- expect ( quote . priceChanges ) . toHaveLength ( 2 )
43+ expect ( quote . priceChanges ) . toHaveLength ( 3 )
3944 } )
4045
41- it ( 'catches up across both transitions, even when a delayed response lists them out of order' , ( ) => {
46+ it ( 'catches up across all transitions, even when a delayed response lists them out of order' , ( ) => {
4247 const quote = quoteBeforeStart ( )
4348 quote . priceChanges . reverse ( )
4449 expect ( applyFreebucksPriceChanges ( quote , end ) . prices [ solar ] ) . toBe ( 5 )
50+ expect ( applyFreebucksPriceChanges ( quote , restored ) . prices [ solar ] ) . toBe ( 0 )
4551 } )
4652
4753 it ( 'does not add an unpriced model or invent metadata on older server responses' , ( ) => {
0 commit comments