feat(projects): 增加意见反馈

This commit is contained in:
2026-06-27 08:55:33 +08:00
parent 570f284230
commit a4884035cd
25 changed files with 1536 additions and 7 deletions

View File

@@ -0,0 +1,48 @@
import assert from 'node:assert/strict';
import { describe, it } from 'node:test';
import { normalizeFeedbackStat } from '../src/service/api/feedback-normalize';
describe('normalizeFeedbackStat', () => {
it('maps backend type/status count arrays to code-keyed records', () => {
const result = normalizeFeedbackStat({
total: 128,
typeCounts: [
{ type: 1, count: 52 },
{ type: 2, count: 31 },
{ type: 3, count: 45 }
],
statusCounts: [
{ status: 1, count: 40 },
{ status: 2, count: 33 },
{ status: 3, count: 50 },
{ status: 4, count: 5 }
]
});
assert.deepEqual(result, {
total: 128,
typeCounts: {
'1': 52,
'2': 31,
'3': 45
},
statusCounts: {
'1': 40,
'2': 33,
'3': 50,
'4': 5
}
});
});
it('keeps zero-count dictionary codes visible to the facet panel', () => {
const result = normalizeFeedbackStat({
total: 0,
typeCounts: [{ type: '1', count: 0 }],
statusCounts: [{ status: '4', count: 0 }]
});
assert.deepEqual(result.typeCounts, { '1': 0 });
assert.deepEqual(result.statusCounts, { '4': 0 });
});
});