@@ -270,17 +270,34 @@ describe('store:logging', () => {
270270 expect ( store . entries ) . toEqual ( [ { message : 'hello' } ] )
271271 } )
272272
273- it ( 'loads more newer entries from server' , async ( ) => {
273+ it ( 'loads more newer entries from server (with pollLog) ' , async ( ) => {
274274 vi . mocked ( mocks . pollLog ) . mockImplementationOnce ( ( ) => ( {
275- data : [ { message : 'hello' } ] ,
275+ data : [ { reqId : '456' , message : 'hello' } ] ,
276+ } ) )
277+
278+ const store = useLogStore ( )
279+ store . allEntries = [ { reqId : '123' , message : 'hello' } ]
280+
281+ await store . loadMore ( false )
282+ expect ( mocks . pollLog ) . toBeCalledWith ( { lastReqId : '123' } )
283+ expect ( store . entries ) . toEqual ( [ { reqId : '456' , message : 'hello' } , { reqId : '123' , message : 'hello' } ] )
284+ } )
285+
286+ it ( 'loads more newer entries from server (with getLog)' , async ( ) => {
287+ vi . mocked ( mocks . getLog ) . mockImplementationOnce ( ( ) => ( {
288+ data : {
289+ data : [ { message : 'hello' } ] ,
290+ remain : false ,
291+ } ,
276292 } ) )
277293
278294 const store = useLogStore ( )
279295 store . allEntries = [ ]
280296 expect ( store . entries ) . toEqual ( [ ] )
281297
282298 await store . loadMore ( false )
283- expect ( mocks . pollLog ) . toBeCalledWith ( { lastReqId : '' } )
299+ expect ( mocks . pollLog ) . not . toBeCalled ( )
300+ expect ( mocks . getLog ) . toBeCalledWith ( { offset : 0 , query : '' } )
284301 expect ( store . entries ) . toEqual ( [ { message : 'hello' } ] )
285302 } )
286303
@@ -336,12 +353,12 @@ describe('store:logging', () => {
336353 } ) )
337354
338355 const store = useLogStore ( )
339- store . allEntries = [ ]
356+ store . allEntries = [ { reqId : '123' } ]
340357 store . startPolling ( )
341358 expect ( mocks . pollLog ) . not . toBeCalled ( )
342359 vi . advanceTimersByTime ( POLLING_INTERVAL )
343360 expect ( mocks . pollLog ) . toBeCalledTimes ( 1 )
344- expect ( mocks . pollLog ) . toBeCalledWith ( { lastReqId : '' } )
361+ expect ( mocks . pollLog ) . toBeCalledWith ( { lastReqId : '123 ' } )
345362 } )
346363
347364 it ( 'can poll for new entries with old available' , async ( ) => {
@@ -362,26 +379,27 @@ describe('store:logging', () => {
362379
363380 it ( 'can stop polling for new entries' , async ( ) => {
364381 vi . mocked ( mocks . pollLog ) . mockImplementationOnce ( ( ) => ( {
365- data : [ { reqId : '123 ' } ] ,
382+ data : [ { reqId : '456 ' } ] ,
366383 } ) )
367384
368385 const store = useLogStore ( )
369- store . allEntries = [ ]
386+ store . allEntries = [ { reqId : '123' } ]
370387 store . startPolling ( )
371388 expect ( mocks . pollLog ) . not . toBeCalled ( )
372389 vi . advanceTimersByTime ( POLLING_INTERVAL )
373390 store . stopPolling ( )
374391 vi . advanceTimersByTime ( POLLING_INTERVAL )
375392 expect ( mocks . pollLog ) . toBeCalledTimes ( 1 )
393+ expect ( mocks . pollLog ) . toBeCalledWith ( { lastReqId : '123' } )
376394 } )
377395
378396 it ( 'only starts one polling timer' , async ( ) => {
379397 vi . mocked ( mocks . pollLog ) . mockImplementationOnce ( ( ) => ( {
380- data : [ { reqId : '123 ' } ] ,
398+ data : [ { reqId : '456 ' } ] ,
381399 } ) )
382400
383401 const store = useLogStore ( )
384- store . allEntries = [ ]
402+ store . allEntries = [ { reqId : '123' } ]
385403 store . startPolling ( )
386404 expect ( mocks . pollLog ) . not . toBeCalled ( )
387405 await vi . advanceTimersByTimeAsync ( POLLING_INTERVAL / 2 )
@@ -427,6 +445,7 @@ describe('store:logging', () => {
427445 } )
428446
429447 const store = useLogStore ( )
448+ store . allEntries = [ { reqId : '123' } ]
430449 store . startPolling ( )
431450 await vi . advanceTimersByTimeAsync ( POLLING_INTERVAL )
432451 expect ( mocks . pollLog ) . toBeCalled ( )
@@ -445,6 +464,7 @@ describe('store:logging', () => {
445464 } )
446465
447466 const store = useLogStore ( )
467+ store . allEntries = [ { reqId : '123' } ]
448468 store . startPolling ( )
449469 await vi . advanceTimersByTimeAsync ( POLLING_INTERVAL )
450470 expect ( mocks . pollLog ) . toBeCalled ( )
0 commit comments