Skip to content

Commit dc1b9e6

Browse files
committed
Merge branch 'codex/project-files-storage' into codex/project-files-product-v2
2 parents 8c2ad9d + a2718d2 commit dc1b9e6

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

‎apps/sim/lib/uploads/server/content-effects.test.ts‎

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1+
import { getMockLogger } from '@sim/testing/mocks/logger.mock'
12
import { beforeEach, describe, expect, it, vi } from 'vitest'
23

34
const mocks = vi.hoisted(() => ({
45
cleanup: vi.fn(),
56
reconcile: vi.fn(),
6-
error: vi.fn(),
7-
warn: vi.fn(),
87
}))
98
vi.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

1817
import { finishFileContentEffects } from '@/lib/uploads/server/content-effects'
1918

2019
const effects = { cleanupIds: ['cleanup-1'], liveDocEventId: 'event-1' }
2120
describe('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

Comments
 (0)