cb9f0c389f
build / build (push) Successful in 1m10s
去掉看板个人月明细;十一卡悬停和键盘可读的真实统计范围、公式与排除数。 自然月独立计算;跨月周取周一所在月,保留旧周证据和已存周报正文。 验证:make verify;一次性PG全镜像套件-race;真实恢复数据7个月与周报calc_metrics对拍。 真实浏览器十一卡逐项悬停、Tab/Escape、30秒刷新、跨月周、390px和完整PNG通过。 没有写DobotAI源问答、触发付费模型、外发或应用新迁移。
42 lines
2.1 KiB
TypeScript
42 lines
2.1 KiB
TypeScript
import { renderToStaticMarkup } from 'react-dom/server'
|
|
import { describe, it, expect, vi } from 'vitest'
|
|
import { qaDailySeries, qaCategorySeries } from './qaDashboard'
|
|
import { QADashboard, QADashboardView } from './QADashboard'
|
|
import { parseQADashboard } from './qaDashboardData'
|
|
import { dashboardFixture } from './qaDashboard.fixture'
|
|
import type { QARecord, QAQuery } from './qaOps'
|
|
const query: QAQuery = { start: '2026-10-11T16:00:00Z', end: '2026-10-13T16:00:00Z', keyword: '', cursor: '' }
|
|
const records = [
|
|
{ id: 'a', asked_at: '2026-10-11T16:30:00Z', product_category: '<img src=x onerror=alert(1)>', problem_type: '通信' },
|
|
{ id: 'b', asked_at: '2026-10-12T16:01:00Z' },
|
|
] as QARecord[]
|
|
describe('question dashboard projections', () => {
|
|
it('does not render the personal monthly details entry on the statistics dashboard', () => {
|
|
const html = renderToStaticMarkup(<QADashboard query={query} error={null} revision={0} onRetry={vi.fn()} />)
|
|
expect(html).not.toContain('个人月明细')
|
|
expect(html).not.toContain('qa-monthly-disclosure')
|
|
})
|
|
it('groups by Beijing day and keeps zero days instead of using the browser timezone', () => {
|
|
expect(qaDailySeries(records, query)).toEqual([
|
|
{ label: '2026-10-12', count: 1 },
|
|
{ label: '2026-10-13', count: 1 },
|
|
])
|
|
expect(qaDailySeries([], query).map((p) => p.count)).toEqual([0, 0])
|
|
})
|
|
it('keeps unclassified records distinct without inventing a category', () => {
|
|
expect(qaCategorySeries(records, 'problem_type')).toEqual([
|
|
{ label: '通信', count: 1 },
|
|
{ label: '未分类', count: 1 },
|
|
])
|
|
})
|
|
it('renders the real dashboard panels and escaped category text', () => {
|
|
const html = renderToStaticMarkup(
|
|
<QADashboardView data={parseQADashboard(dashboardFixture)} loading={false} error="" onRetry={vi.fn()} />
|
|
)
|
|
for (const title of ['问题总数', '本周新增', '覆盖率趋势', '正确率趋势', '产品问题排行', '导出看板图片'])
|
|
expect(html).toContain(title)
|
|
expect(html).not.toContain('<img src=x')
|
|
expect((html.match(/data-panel=/g) || []).length).toBe(11)
|
|
})
|
|
})
|