feat(admin): 增加审计与一致性页面
This commit is contained in:
25
apps/web/lib/consistency-api.test.ts
Normal file
25
apps/web/lib/consistency-api.test.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
|
||||
import { summarizeConsistencyResult, type ConsistencyResult } from './consistency-api';
|
||||
|
||||
test('summarizeConsistencyResult counts ok warn and error checks', () => {
|
||||
const result: ConsistencyResult = {
|
||||
generatedAt: '2026-07-08T08:00:00.000Z',
|
||||
status: 'fail',
|
||||
counts: { products: 1 },
|
||||
checks: {
|
||||
partitionKeys: [{ id: 'p', label: 'p', severity: 'ok', count: 0, message: 'ok' }],
|
||||
orphanReferences: [{ id: 'o', label: 'o', severity: 'error', count: 2, message: 'bad' }],
|
||||
auditCoverage: [{ id: 'a', label: 'a', severity: 'warn', count: 0, message: 'missing' }],
|
||||
},
|
||||
summary: { errors: 1, warnings: 1, human: 'summary' },
|
||||
};
|
||||
|
||||
assert.deepEqual(summarizeConsistencyResult(result), {
|
||||
ok: 1,
|
||||
warn: 1,
|
||||
error: 1,
|
||||
total: 3,
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user