154b0b62ad
build / build (push) Successful in 1m20s
新增北京时间自然周校验与缓存隔离,默认展开到业务二级部门。 选中部门在统计页就地绑定;区域名称列表原位增删改,双版本锁、自动预览、独立读回及删除确认。 筛选和两张区域看板使用同一已保存目录,删除失效筛选回全部。 验证:完整 make verify、全 mirror 隔离 PostgreSQL race、自然周边界与缓存键负例通过;真实恢复库327部门逐行对拍及六项浏览器验收通过。 schema57无迁移,不改真实公司区域绑定或原始问答,不连接DobotAI生产源库;PNG导出本轮不冒充已验证。
42 lines
2.1 KiB
TypeScript
42 lines
2.1 KiB
TypeScript
import { it, expect } from 'vitest'
|
|
import { defaultDepartmentCollapsed, departmentTree } from './qaRegionSelection'
|
|
import { parseDepartmentStatistics } from './qaDepartmentStatistics'
|
|
import { departmentStatisticsFixture as f } from './qaDepartmentStatistics.fixture'
|
|
it('defaults to company, business centers and second-level departments while preserving deeper search and expansion', () => {
|
|
const nodes = [
|
|
{ id: 'company', parent_id: '', name: '示例公司' },
|
|
{ id: 'finance', parent_id: 'company', name: '财务中心' },
|
|
{ id: 'department', parent_id: 'finance', name: '财务部' },
|
|
{ id: 'office', parent_id: 'department', name: '更深财务组' },
|
|
{ id: 'global', parent_id: 'company', name: '全球业务支持中心' },
|
|
{ id: 'solution', parent_id: 'global', name: '解决方案部' },
|
|
{ id: 'support', parent_id: 'global', name: '全球技术支持部' },
|
|
]
|
|
const collapsed = defaultDepartmentCollapsed(nodes)
|
|
expect(departmentTree(nodes, collapsed).map((r) => r.department.id)).not.toContain('office')
|
|
expect(new Set(departmentTree(nodes, collapsed).map((r) => r.department.id))).toEqual(
|
|
new Set(nodes.filter((n) => n.id !== 'office').map((n) => n.id))
|
|
)
|
|
expect(departmentTree(nodes, collapsed, '更深财务组').some((r) => r.department.id === 'office')).toBe(true)
|
|
collapsed.delete('department')
|
|
expect(departmentTree(nodes, collapsed).some((r) => r.department.id === 'office')).toBe(true)
|
|
})
|
|
it('accepts an exact natural week response and rejects a mismatched week or non-Monday start', () => {
|
|
const raw = {
|
|
...f,
|
|
snapshot: {
|
|
...f.snapshot,
|
|
period: 'week',
|
|
week: '2026-W42',
|
|
start: '2026-10-12T00:00:00+08:00',
|
|
end: '2026-10-19T00:00:00+08:00',
|
|
},
|
|
}
|
|
const query = JSON.parse('{"period":"week","week":"2026-W42"}')
|
|
expect(parseDepartmentStatistics(raw, query).snapshot?.period).toBe('week')
|
|
expect(() => parseDepartmentStatistics({ ...raw, snapshot: { ...raw.snapshot, week: '2026-W43' } }, query)).toThrow()
|
|
expect(() =>
|
|
parseDepartmentStatistics({ ...raw, snapshot: { ...raw.snapshot, start: '2026-10-11T00:00:00+08:00' } }, query)
|
|
).toThrow()
|
|
})
|