1+ import { getMockLogger } from '@sim/testing/mocks/logger.mock'
12import { beforeEach , describe , expect , it , vi } from 'vitest'
23
34const mocks = vi . hoisted ( ( ) => ( {
45 cleanup : vi . fn ( ) ,
56 reconcile : vi . fn ( ) ,
6- error : vi . fn ( ) ,
7- warn : vi . fn ( ) ,
87} ) )
98vi . mock ( '@/lib/uploads/contexts/workspace/workspace-file-storage-cleanup-outbox' , ( ) => ( {
109 processWorkspaceFileStorageCleanupsNow : mocks . cleanup ,
@@ -13,14 +12,13 @@ vi.mock('@/lib/uploads/server/live-doc-outbox', () => ({
1312 processFileLiveDocReconciliationNow : mocks . reconcile ,
1413} ) )
1514
16- vi . mock ( '@sim/ logger' , ( ) => ( { createLogger : ( ) => ( { error : mocks . error , warn : mocks . warn } ) } ) )
15+ const logger = getMockLogger ( 'FileContentEffects' )
1716
1817import { finishFileContentEffects } from '@/lib/uploads/server/content-effects'
1918
2019const effects = { cleanupIds : [ 'cleanup-1' ] , liveDocEventId : 'event-1' }
2120describe ( 'committed file reconciliation policy' , ( ) => {
2221 beforeEach ( ( ) => {
23- vi . clearAllMocks ( )
2422 mocks . cleanup . mockResolvedValue ( undefined )
2523 } )
2624 it . each ( [ 'completed' , 'pending' , 'processing' , 'lease_lost' ] ) (
@@ -30,10 +28,10 @@ describe('committed file reconciliation policy', () => {
3028 await expect ( finishFileContentEffects ( effects , { fileId : 'file-1' } ) ) . resolves . toBeUndefined ( )
3129 expect ( mocks . cleanup ) . toHaveBeenCalledExactlyOnceWith ( [ 'cleanup-1' ] , { fileId : 'file-1' } )
3230 expect ( mocks . reconcile ) . toHaveBeenCalledExactlyOnceWith ( 'event-1' )
33- expect ( mocks . error ) . not . toHaveBeenCalled ( )
34- if ( status === 'completed' ) expect ( mocks . warn ) . not . toHaveBeenCalled ( )
31+ expect ( logger . error ) . not . toHaveBeenCalled ( )
32+ if ( status === 'completed' ) expect ( logger . warn ) . not . toHaveBeenCalled ( )
3533 else
36- expect ( mocks . warn ) . toHaveBeenCalledExactlyOnceWith (
34+ expect ( logger . warn ) . toHaveBeenCalledExactlyOnceWith (
3735 'Live document reconciliation remains pending' ,
3836 { fileId : 'file-1' , eventId : 'event-1' , result : status }
3937 )
@@ -46,7 +44,7 @@ describe('committed file reconciliation policy', () => {
4644 await expect ( finishFileContentEffects ( effects , { fileId : 'file-1' } ) ) . resolves . toBeUndefined ( )
4745 expect ( mocks . cleanup ) . toHaveBeenCalledExactlyOnceWith ( [ 'cleanup-1' ] , { fileId : 'file-1' } )
4846 expect ( mocks . reconcile ) . toHaveBeenCalledExactlyOnceWith ( 'event-1' )
49- expect ( mocks . error ) . toHaveBeenCalledExactlyOnceWith (
47+ expect ( logger . error ) . toHaveBeenCalledExactlyOnceWith (
5048 'Committed file live-document reconciliation requires intervention' ,
5149 { fileId : 'file-1' , eventId : 'event-1' , result : status }
5250 )
@@ -57,7 +55,7 @@ describe('committed file reconciliation policy', () => {
5755 await expect ( finishFileContentEffects ( effects , { fileId : 'file-1' } ) ) . resolves . toBeUndefined ( )
5856 expect ( mocks . cleanup ) . toHaveBeenCalledExactlyOnceWith ( [ 'cleanup-1' ] , { fileId : 'file-1' } )
5957 expect ( mocks . reconcile ) . toHaveBeenCalledExactlyOnceWith ( 'event-1' )
60- expect ( mocks . error ) . toHaveBeenCalledExactlyOnceWith (
58+ expect ( logger . error ) . toHaveBeenCalledExactlyOnceWith (
6159 'Committed file live-document reconciliation failed inline' ,
6260 expect . objectContaining ( {
6361 fileId : 'file-1' ,
0 commit comments