@@ -269,17 +269,34 @@ describe('store:logging', () => {
269269 expect ( store . entries ) . toEqual ( [ { message : 'hello' } ] )
270270 } )
271271
272- it ( 'loads more newer entries from server' , async ( ) => {
272+ it ( 'loads more newer entries from server (with pollLog) ' , async ( ) => {
273273 vi . mocked ( mocks . pollLog ) . mockImplementationOnce ( ( ) => ( {
274- data : [ { message : 'hello' } ] ,
274+ data : [ { reqId : '456' , message : 'hello' } ] ,
275+ } ) )
276+
277+ const store = useLogStore ( )
278+ store . allEntries = [ { reqId : '123' , message : 'hello' } ]
279+
280+ await store . loadMore ( false )
281+ expect ( mocks . pollLog ) . toBeCalledWith ( { lastReqId : '123' } )
282+ expect ( store . entries ) . toEqual ( [ { reqId : '456' , message : 'hello' } , { reqId : '123' , message : 'hello' } ] )
283+ } )
284+
285+ it ( 'loads more newer entries from server (with getLog)' , async ( ) => {
286+ vi . mocked ( mocks . getLog ) . mockImplementationOnce ( ( ) => ( {
287+ data : {
288+ data : [ { message : 'hello' } ] ,
289+ remain : false ,
290+ } ,
275291 } ) )
276292
277293 const store = useLogStore ( )
278294 store . allEntries = [ ]
279295 expect ( store . entries ) . toEqual ( [ ] )
280296
281297 await store . loadMore ( false )
282- expect ( mocks . pollLog ) . toBeCalledWith ( { lastReqId : '' } )
298+ expect ( mocks . pollLog ) . not . toBeCalled ( )
299+ expect ( mocks . getLog ) . toBeCalledWith ( { offset : 0 , query : '' } )
283300 expect ( store . entries ) . toEqual ( [ { message : 'hello' } ] )
284301 } )
285302
@@ -334,12 +351,12 @@ describe('store:logging', () => {
334351 } ) )
335352
336353 const store = useLogStore ( )
337- store . allEntries = [ ]
354+ store . allEntries = [ { reqId : '123' } ]
338355 store . startPolling ( )
339356 expect ( mocks . pollLog ) . not . toBeCalled ( )
340357 vi . advanceTimersByTime ( POLLING_INTERVAL )
341358 expect ( mocks . pollLog ) . toBeCalledTimes ( 1 )
342- expect ( mocks . pollLog ) . toBeCalledWith ( { lastReqId : '' } )
359+ expect ( mocks . pollLog ) . toBeCalledWith ( { lastReqId : '123 ' } )
343360 } )
344361
345362 it ( 'can poll for new entries with old available' , async ( ) => {
@@ -360,26 +377,27 @@ describe('store:logging', () => {
360377
361378 it ( 'can stop polling for new entries' , async ( ) => {
362379 vi . mocked ( mocks . pollLog ) . mockImplementationOnce ( ( ) => ( {
363- data : [ { reqId : '123 ' } ] ,
380+ data : [ { reqId : '456 ' } ] ,
364381 } ) )
365382
366383 const store = useLogStore ( )
367- store . allEntries = [ ]
384+ store . allEntries = [ { reqId : '123' } ]
368385 store . startPolling ( )
369386 expect ( mocks . pollLog ) . not . toBeCalled ( )
370387 vi . advanceTimersByTime ( POLLING_INTERVAL )
371388 store . stopPolling ( )
372389 vi . advanceTimersByTime ( POLLING_INTERVAL )
373390 expect ( mocks . pollLog ) . toBeCalledTimes ( 1 )
391+ expect ( mocks . pollLog ) . toBeCalledWith ( { lastReqId : '123' } )
374392 } )
375393
376394 it ( 'only starts one polling timer' , async ( ) => {
377395 vi . mocked ( mocks . pollLog ) . mockImplementationOnce ( ( ) => ( {
378- data : [ { reqId : '123 ' } ] ,
396+ data : [ { reqId : '456 ' } ] ,
379397 } ) )
380398
381399 const store = useLogStore ( )
382- store . allEntries = [ ]
400+ store . allEntries = [ { reqId : '123' } ]
383401 store . startPolling ( )
384402 expect ( mocks . pollLog ) . not . toBeCalled ( )
385403 await vi . advanceTimersByTimeAsync ( POLLING_INTERVAL / 2 )
@@ -425,6 +443,7 @@ describe('store:logging', () => {
425443 } )
426444
427445 const store = useLogStore ( )
446+ store . allEntries = [ { reqId : '123' } ]
428447 store . startPolling ( )
429448 await vi . advanceTimersByTimeAsync ( POLLING_INTERVAL )
430449 expect ( mocks . pollLog ) . toBeCalled ( )
@@ -443,6 +462,7 @@ describe('store:logging', () => {
443462 } )
444463
445464 const store = useLogStore ( )
465+ store . allEntries = [ { reqId : '123' } ]
446466 store . startPolling ( )
447467 await vi . advanceTimersByTimeAsync ( POLLING_INTERVAL )
448468 expect ( mocks . pollLog ) . toBeCalled ( )
0 commit comments