@@ -95,17 +95,19 @@ describe('normalizeTransportPendingMessageEntries', () => {
9595 ] ) ;
9696 } ) ;
9797
98- it ( 'fills missing queued entries from pendingMessages when entries are partial ' , ( ) => {
98+ it ( 'treats present entries as authoritative instead of filling legacy tails ' , ( ) => {
9999 expect ( normalizeTransportPendingEntries ( [
100100 { clientMessageId : 'msg-1' , text : 'queued one' } ,
101- ] , [ 'queued one' , 'queued two' ] , 'deck_test' ) ) . toEqual ( [
101+ ] , [ 'queued one' , 'queued two' ] , 'deck_test' , { hasEntriesField : true , hasMessagesField : true } ) ) . toEqual ( [
102102 { clientMessageId : 'msg-1' , text : 'queued one' } ,
103- { clientMessageId : 'deck_test:legacy:1:queued two' , text : 'queued two' } ,
104103 ] ) ;
105104 } ) ;
106105
107106 it ( 'synthesizes legacy entries when only pending messages are present' , ( ) => {
108- expect ( normalizeTransportPendingEntries ( [ ] , [ 'queued one' , 'queued two' ] , 'deck_test' ) ) . toEqual ( [
107+ expect ( normalizeTransportPendingEntries ( undefined , [ 'queued one' , 'queued two' ] , 'deck_test' , {
108+ hasEntriesField : false ,
109+ hasMessagesField : true ,
110+ } ) ) . toEqual ( [
109111 { clientMessageId : 'deck_test:legacy:0:queued one' , text : 'queued one' } ,
110112 { clientMessageId : 'deck_test:legacy:1:queued two' , text : 'queued two' } ,
111113 ] ) ;
@@ -190,14 +192,13 @@ describe('mergeTransportPendingEntriesForRunningState', () => {
190192 ] ) ;
191193 } ) ;
192194
193- it ( 'fills missing running queued entries from pendingMessages when entries are partial ' , ( ) => {
195+ it ( 'treats running entries as authoritative instead of filling legacy tails ' , ( ) => {
194196 expect ( mergeTransportPendingEntriesForRunningState ( [
195197 { clientMessageId : 'msg-1' , text : 'queued one' } ,
196198 ] , [
197199 { clientMessageId : 'msg-1' , text : 'queued one' } ,
198- ] , [ 'queued one' , 'queued two' ] , true , 'deck_test' ) ) . toEqual ( [
200+ ] , [ 'queued one' , 'queued two' ] , true , 'deck_test' , true ) ) . toEqual ( [
199201 { clientMessageId : 'msg-1' , text : 'queued one' } ,
200- { clientMessageId : 'deck_test:legacy:1:queued two' , text : 'queued two' } ,
201202 ] ) ;
202203 } ) ;
203204
@@ -298,8 +299,8 @@ describe('shouldApplyTransportQueueSnapshot', () => {
298299 expect ( shouldApplyTransportQueueSnapshot ( 3 , 3 ) ) . toBe ( true ) ;
299300 expect ( shouldApplyTransportQueueSnapshot ( 3 , 4 ) ) . toBe ( true ) ;
300301 } ) ;
301- it ( 'always applies version 0 — a fresh runtime restarts the sequence ' , ( ) => {
302- expect ( shouldApplyTransportQueueSnapshot ( 9 , 0 ) ) . toBe ( true ) ;
302+ it ( 'rejects version 0 after a higher baseline instead of treating it as a reset ' , ( ) => {
303+ expect ( shouldApplyTransportQueueSnapshot ( 9 , 0 ) ) . toBe ( false ) ;
303304 } ) ;
304305} ) ;
305306
@@ -308,8 +309,8 @@ describe('nextTransportQueueVersion', () => {
308309 expect ( nextTransportQueueVersion ( 5 , undefined ) ) . toBe ( 5 ) ;
309310 expect ( nextTransportQueueVersion ( undefined , undefined ) ) . toBeUndefined ( ) ;
310311 } ) ;
311- it ( 'resets to 0 on a fresh-runtime snapshot ' , ( ) => {
312- expect ( nextTransportQueueVersion ( 9 , 0 ) ) . toBe ( 0 ) ;
312+ it ( 'does not reset to 0 after a higher baseline ' , ( ) => {
313+ expect ( nextTransportQueueVersion ( 9 , 0 ) ) . toBe ( 9 ) ;
313314 } ) ;
314315 it ( 'advances monotonically' , ( ) => {
315316 expect ( nextTransportQueueVersion ( undefined , 2 ) ) . toBe ( 2 ) ;
0 commit comments