@@ -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
@@ -335,12 +352,12 @@ describe('store:logging', () => {
335352 } ) )
336353
337354 const store = useLogStore ( )
338- store . allEntries = [ ]
355+ store . allEntries = [ { reqId : '123' } ]
339356 store . startPolling ( )
340357 expect ( mocks . pollLog ) . not . toBeCalled ( )
341358 vi . advanceTimersByTime ( POLLING_INTERVAL )
342359 expect ( mocks . pollLog ) . toBeCalledTimes ( 1 )
343- expect ( mocks . pollLog ) . toBeCalledWith ( { lastReqId : '' } )
360+ expect ( mocks . pollLog ) . toBeCalledWith ( { lastReqId : '123 ' } )
344361 } )
345362
346363 it ( 'can poll for new entries with old available' , async ( ) => {
@@ -361,26 +378,27 @@ describe('store:logging', () => {
361378
362379 it ( 'can stop polling for new entries' , async ( ) => {
363380 vi . mocked ( mocks . pollLog ) . mockImplementationOnce ( ( ) => ( {
364- data : [ { reqId : '123 ' } ] ,
381+ data : [ { reqId : '456 ' } ] ,
365382 } ) )
366383
367384 const store = useLogStore ( )
368- store . allEntries = [ ]
385+ store . allEntries = [ { reqId : '123' } ]
369386 store . startPolling ( )
370387 expect ( mocks . pollLog ) . not . toBeCalled ( )
371388 vi . advanceTimersByTime ( POLLING_INTERVAL )
372389 store . stopPolling ( )
373390 vi . advanceTimersByTime ( POLLING_INTERVAL )
374391 expect ( mocks . pollLog ) . toBeCalledTimes ( 1 )
392+ expect ( mocks . pollLog ) . toBeCalledWith ( { lastReqId : '123' } )
375393 } )
376394
377395 it ( 'only starts one polling timer' , async ( ) => {
378396 vi . mocked ( mocks . pollLog ) . mockImplementationOnce ( ( ) => ( {
379- data : [ { reqId : '123 ' } ] ,
397+ data : [ { reqId : '456 ' } ] ,
380398 } ) )
381399
382400 const store = useLogStore ( )
383- store . allEntries = [ ]
401+ store . allEntries = [ { reqId : '123' } ]
384402 store . startPolling ( )
385403 expect ( mocks . pollLog ) . not . toBeCalled ( )
386404 await vi . advanceTimersByTimeAsync ( POLLING_INTERVAL / 2 )
@@ -426,6 +444,7 @@ describe('store:logging', () => {
426444 } )
427445
428446 const store = useLogStore ( )
447+ store . allEntries = [ { reqId : '123' } ]
429448 store . startPolling ( )
430449 await vi . advanceTimersByTimeAsync ( POLLING_INTERVAL )
431450 expect ( mocks . pollLog ) . toBeCalled ( )
@@ -444,6 +463,7 @@ describe('store:logging', () => {
444463 } )
445464
446465 const store = useLogStore ( )
466+ store . allEntries = [ { reqId : '123' } ]
447467 store . startPolling ( )
448468 await vi . advanceTimersByTimeAsync ( POLLING_INTERVAL )
449469 expect ( mocks . pollLog ) . toBeCalled ( )
0 commit comments