refactor(audit): type-safe enums, expanded coverage, and crash-safe logging

Replace magic strings with AuditAction/AuditStatus enums across all consumers,
add logAuditWithCurrentUser() convenience wrapper, extend audit coverage to
data import, result export, app update, and ERP credentials operations, and
harden crash handlers with try/catch to prevent audit failures from cascading.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Misaka
2026-04-06 17:40:30 +08:00
parent d0c745e243
commit abad61758c
17 changed files with 269 additions and 157 deletions

View File

@@ -149,7 +149,10 @@ describe('SqlServerService Unit Tests', () => {
it('should execute SELECT and return rows with columns', async () => {
await service.connect()
mockRequestQuery.mockResolvedValue({
recordset: [{ ID: 1, Name: 'test' }, { ID: 2, Name: 'foo' }],
recordset: [
{ ID: 1, Name: 'test' },
{ ID: 2, Name: 'foo' }
],
rowsAffected: [2]
})
@@ -209,9 +212,9 @@ describe('SqlServerService Unit Tests', () => {
describe('queryWithParams', () => {
it('should throw error when not connected', async () => {
await expect(
service.queryWithParams('SELECT @p0', { p0: { value: 1 } })
).rejects.toThrow('Not connected to SQL Server')
await expect(service.queryWithParams('SELECT @p0', { p0: { value: 1 } })).rejects.toThrow(
'Not connected to SQL Server'
)
})
it('should add typed params via request.input', async () => {