feat(qaops): 增加区域与全员提问排行及五十人分页
build / build (push) Successful in 1m6s

保留部门树并复用同一统计快照;区域内去重,跨区域和未归属单列,不改配置或主归属。按提问次数降序,保留零提问人员,每页50人。

验证:401项前端测试与类型检查通过,排序、区域去重、跨区域、零使用和123人三页边界红绿验证通过。
同镜像、正式网页和部署尚未验收。
This commit is contained in:
姚章浩
2026-10-21 18:06:30 +08:00
parent 99d6109bef
commit 4e655fb977
8 changed files with 563 additions and 59 deletions
+41
View File
@@ -0,0 +1,41 @@
import { it, expect } from 'vitest'
import { renderToStaticMarkup } from 'react-dom/server'
import { PeopleAnalysisView, PeopleRankingTable } from './QAPeopleAnalysis'
import { peopleAnalysis } from './qaPeopleAnalysis'
import { parseDepartmentStatistics } from './qaDepartmentStatistics'
import { departmentStatisticsFixture } from './qaDepartmentStatistics.fixture'
const fixture = () =>
parseDepartmentStatistics(structuredClone(departmentStatisticsFixture), { period: 'all' }).snapshot!
it('renders at most fifty ranked people with actual question counts and no department write controls', () => {
const template = peopleAnalysis(fixture()).people[0]
const rows = Array.from({ length: 123 }, (_, i) => ({
...template,
key: 'person-' + i.toString(16).padStart(64, '0'),
visits: 122 - i,
}))
const html = renderToStaticMarkup(<PeopleRankingTable people={rows} page={2} onPage={() => {}} label="全体人员" />)
expect(html.match(/data-ranking-person-key=/g)).toHaveLength(50)
expect(html).toContain('data-ranking="51"')
expect(html).toContain('data-ranking="100"')
expect(html).not.toContain('data-ranking="101"')
expect(html).toContain('50 人/页')
expect(html).toContain('上一页')
expect(html).toContain('下一页')
expect(html).not.toContain('checkbox')
expect(html).not.toContain('绑定选中部门')
})
it('region analysis lists the saved region members once and all-person analysis retains unassigned and zero-use people', () => {
const data = fixture()
const region = renderToStaticMarkup(<PeopleAnalysisView data={data} mode="regions" />)
expect(region).toContain('按区域查看人员')
expect(region.match(/data-ranking-person-key=/g)).toHaveLength(2)
expect(region).toContain('Fixture Alpha')
expect(region).not.toContain('Fixture Beta')
expect(region).toContain('跨区域待核对')
expect(region).toContain('未归属')
const all = renderToStaticMarkup(<PeopleAnalysisView data={data} mode="people" />)
expect(all.match(/data-ranking-person-key=/g)).toHaveLength(3)
expect(all).toContain('未命名人员')
expect(all).toContain('Fixture Beta')
expect(all.indexOf('Fixture Beta')).toBeLessThan(all.indexOf('Fixture Alpha'))
})