mirror of
https://github.com/simstudioai/sim.git
synced 2026-02-19 02:34:37 -05:00
fix(audit-log): use validated chat record, add mock sync tests
This commit is contained in:
@@ -230,8 +230,8 @@ export async function PATCH(request: NextRequest, { params }: { params: Promise<
|
||||
action: AuditAction.CHAT_UPDATED,
|
||||
resourceType: AuditResourceType.CHAT,
|
||||
resourceId: chatId,
|
||||
resourceName: title || existingChat[0].title,
|
||||
description: `Updated chat deployment "${title || existingChat[0].title}"`,
|
||||
resourceName: title || existingChatRecord.title,
|
||||
description: `Updated chat deployment "${title || existingChatRecord.title}"`,
|
||||
request,
|
||||
})
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @vitest-environment node
|
||||
*/
|
||||
import { databaseMock, loggerMock } from '@sim/testing'
|
||||
import { auditMock, databaseMock, loggerMock } from '@sim/testing'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
vi.mock('@sim/db', () => ({
|
||||
@@ -242,3 +242,31 @@ describe('recordAudit', () => {
|
||||
expect(result).toBeUndefined()
|
||||
})
|
||||
})
|
||||
|
||||
describe('auditMock sync', () => {
|
||||
it('has the same AuditAction keys as the source', () => {
|
||||
const sourceKeys = Object.keys(AuditAction).sort()
|
||||
const mockKeys = Object.keys(auditMock.AuditAction).sort()
|
||||
expect(mockKeys).toEqual(sourceKeys)
|
||||
})
|
||||
|
||||
it('has the same AuditAction values as the source', () => {
|
||||
for (const key of Object.keys(AuditAction)) {
|
||||
expect(auditMock.AuditAction[key]).toBe(AuditAction[key as keyof typeof AuditAction])
|
||||
}
|
||||
})
|
||||
|
||||
it('has the same AuditResourceType keys as the source', () => {
|
||||
const sourceKeys = Object.keys(AuditResourceType).sort()
|
||||
const mockKeys = Object.keys(auditMock.AuditResourceType).sort()
|
||||
expect(mockKeys).toEqual(sourceKeys)
|
||||
})
|
||||
|
||||
it('has the same AuditResourceType values as the source', () => {
|
||||
for (const key of Object.keys(AuditResourceType)) {
|
||||
expect(auditMock.AuditResourceType[key]).toBe(
|
||||
AuditResourceType[key as keyof typeof AuditResourceType]
|
||||
)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user