feat(qaops): 增加版本化部门区域归属配置与预览

This commit is contained in:
姚章浩
2026-10-17 11:39:38 +08:00
parent fd04bf7886
commit dab74b706b
23 changed files with 1693 additions and 51 deletions
+66
View File
@@ -0,0 +1,66 @@
import { renderToStaticMarkup } from 'react-dom/server'
import { describe, expect, it, vi } from 'vitest'
import { RegionMappingView } from './QARegions'
import { parseOrganization } from './qaOrg'
const state = parseOrganization({
state: 'ready',
directory_id: 'd',
directory_source: 'weekly_report_snapshot',
directory_synced_at: '2026-09-27T14:03:44Z',
revision_id: 'r',
updated_by: 'fixture-admin',
updated_at: null,
rules: [{ department_id: 'a', region: 'APAC' }],
view: {
departments: [
{
id: 'a',
parent_id: '',
name: '<script>test</script>',
path: '示例公司/<script>test</script>',
region: 'APAC',
explicit: true,
inherited_from: '',
},
],
regions: { 国内工业: 0, APAC: 1, EMEA: 0, America: 0 },
total_people: 2,
unassigned_people: 0,
conflicting_people: 1,
missing_departments: [],
},
})
const props = {
state,
preview: null,
rules: state.rules,
selectedRegion: 'APAC',
search: '',
busy: false,
error: '',
notice: '',
dirty: false,
onRegion: vi.fn(),
onSearch: vi.fn(),
onToggle: vi.fn(),
onPreview: vi.fn(),
onSave: vi.fn(),
onReload: vi.fn(),
onRemoveMissing: vi.fn(),
}
describe('region mapping workbench', () => {
it('shows a dated historical roster, conflicts and no invented performance verdict', () => {
const html = renderToStaticMarkup(<RegionMappingView {...props} />)
expect(html).toContain('历史快照')
expect(html).toContain('跨区域待核对:1')
expect(html).toContain('配置区域归属不等于纳入绩效考核')
expect(html).not.toContain('<script>test</script>')
expect(html).not.toContain('达标率')
expect(html).toMatch(/disabled=""[^>]*>保存归属/)
})
it('requires a preview of the current draft before enabling save', () => {
const html = renderToStaticMarkup(<RegionMappingView {...props} dirty preview={state} />)
expect(html).toContain('预览结果(未保存)')
expect(html).not.toMatch(/disabled=""[^>]*>保存归属/)
})
})