ConusAI vendor v0.1.0-dev.20261013+85463d22

This commit is contained in:
ConusAI vendor v0.1.0-dev.20261013+85463d22
2026-10-13 20:45:57 +00:00
parent c3c6526952
commit 0da8a2a81b
67 changed files with 1510 additions and 10153 deletions
+12 -2
View File
@@ -5,6 +5,8 @@ const mocks = vi.hoisted(() => ({
del: vi.fn(async () => {}),
log: vi.fn(async () => {}),
revalidatePath: vi.fn(),
loggerInfo: vi.fn(),
loggerRecordException: vi.fn(),
removed: [] as Array<{ id: string; url: string }>,
}))
@@ -21,6 +23,7 @@ vi.mock('@/shared/api', () => ({
db: () => fakeDb,
audit: () => ({ log: mocks.log }),
blob: () => ({ del: mocks.del }),
logger: () => ({ info: mocks.loggerInfo, recordException: mocks.loggerRecordException }),
}))
vi.mock('@/shared/lib/visitor-session', () => ({ ensureVisitor: async () => 'visitor-1' }))
@@ -31,10 +34,12 @@ describe('deleteFile', () => {
mocks.del.mockClear()
mocks.log.mockClear()
mocks.revalidatePath.mockClear()
mocks.loggerInfo.mockClear()
mocks.loggerRecordException.mockClear()
mocks.removed.length = 0
})
it('removes the stored bytes and audits file.deleted once', async () => {
it('removes the stored bytes and audits file.deleted once, and logs it', async () => {
mocks.removed.push({ id: FILE, url: 'https://blob.example.com/notes/n/a.png' })
await deleteFile(FILE)
@@ -44,11 +49,16 @@ describe('deleteFile', () => {
actor: { kind: 'human', id: 'visitor-1' },
target: { id: FILE },
})
expect(mocks.loggerInfo).toHaveBeenCalledTimes(1)
expect(mocks.loggerInfo).toHaveBeenCalledWith('file.deleted', { 'file.id': FILE, outcome: 'ok' })
expect(mocks.loggerRecordException).not.toHaveBeenCalled()
})
it('touches nothing when the visitor did not attach the file', async () => {
it('touches nothing when the visitor did not attach the file, and logs it denied', async () => {
await deleteFile(FILE)
expect(mocks.del).not.toHaveBeenCalled()
expect(mocks.log).not.toHaveBeenCalled()
expect(mocks.loggerInfo).toHaveBeenCalledWith('file.deleted', { 'file.id': FILE, outcome: 'denied' })
expect(mocks.loggerRecordException).not.toHaveBeenCalled()
})
})