新增北京时间自然周校验与缓存隔离,默认展开到业务二级部门。 选中部门在统计页就地绑定;区域名称列表原位增删改,双版本锁、自动预览、独立读回及删除确认。 筛选和两张区域看板使用同一已保存目录,删除失效筛选回全部。 验证:完整 make verify、全 mirror 隔离 PostgreSQL race、自然周边界与缓存键负例通过;真实恢复库327部门逐行对拍及六项浏览器验收通过。 schema57无迁移,不改真实公司区域绑定或原始问答,不连接DobotAI生产源库;PNG导出本轮不冒充已验证。
This commit is contained in:
+33
-38
@@ -2,7 +2,7 @@ import { renderToStaticMarkup } from 'react-dom/server'
|
||||
// @ts-expect-error The test runner provides Node; the browser bundle intentionally omits @types/node.
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import { RegionMappingView } from './QARegions'
|
||||
import { RegionCatalogView } from './QARegions'
|
||||
import { parseOrganization } from './qaOrg'
|
||||
const state = parseOrganization({
|
||||
state: 'ready',
|
||||
@@ -36,52 +36,47 @@ 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('allows removing unused region definitions but protects regions referenced by department rules', () => {
|
||||
describe('region catalog settings', () => {
|
||||
it('uses a region-name list without a second department mapping page', () => {
|
||||
const html = renderToStaticMarkup(<RegionCatalogView {...props} />)
|
||||
expect(html).toContain('区域名称列表')
|
||||
expect(html).toContain('保存区域设置')
|
||||
expect(html).not.toContain('qa-region-table')
|
||||
expect(html).not.toContain('批量归属')
|
||||
expect(html).not.toContain('全选当前列表')
|
||||
})
|
||||
it('shows direct binding counts and enters local confirmation before removing a bound region', () => {
|
||||
const regions = [
|
||||
{ id: 'APAC', name: 'Assigned' },
|
||||
{ id: 'spare', name: 'Spare' },
|
||||
]
|
||||
const html = renderToStaticMarkup(<RegionMappingView {...props} regions={regions} />)
|
||||
const html = renderToStaticMarkup(<RegionCatalogView {...props} regions={regions} />)
|
||||
expect(html).toContain('删除区域 Spare')
|
||||
expect(html).toMatch(/aria-label="删除区域 Assigned"[^>]*disabled=""/)
|
||||
expect(html).toContain('直接绑定 1 个部门')
|
||||
expect(html).not.toMatch(/aria-label="删除区域 Assigned"[^>]*disabled=""/)
|
||||
expect(html).not.toContain('确认删除')
|
||||
})
|
||||
|
||||
it('separates multiselect from bulk application and renders hierarchy and editable region names', () => {
|
||||
it('shows editable saved region names but keeps department binding out of the settings list', () => {
|
||||
const custom = {
|
||||
...state,
|
||||
regions: [{ id: 'APAC', name: '国外工业Amercia' }],
|
||||
view: { ...state.view, regions: { APAC: 1 } },
|
||||
}
|
||||
const html = renderToStaticMarkup(<RegionMappingView {...props} state={custom} />)
|
||||
for (const label of [
|
||||
'区域设置',
|
||||
'添加区域',
|
||||
'一级部门',
|
||||
'二级部门',
|
||||
'三级部门',
|
||||
'四级及更深',
|
||||
'批量归属',
|
||||
'全选当前列表',
|
||||
'取消本次勾选',
|
||||
'国外工业Amercia',
|
||||
])
|
||||
const html = renderToStaticMarkup(<RegionCatalogView {...props} state={custom} />)
|
||||
for (const label of ['区域设置', '添加区域', '区域名称列表', '保存区域设置', '国外工业Amercia'])
|
||||
expect(html).toContain(label)
|
||||
expect(html).toMatch(/disabled=""[^>]*>批量归属/)
|
||||
for (const removed of ['一级部门', '二级部门', '批量归属', '全选当前列表', 'qa-region-table'])
|
||||
expect(html).not.toContain(removed)
|
||||
expect(html).not.toContain('将 示例公司/')
|
||||
})
|
||||
|
||||
@@ -99,36 +94,36 @@ describe('region mapping workbench', () => {
|
||||
result: null,
|
||||
},
|
||||
}
|
||||
const html = renderToStaticMarkup(<RegionMappingView {...props} syncStatus={syncStatus} />)
|
||||
const html = renderToStaticMarkup(<RegionCatalogView {...props} syncStatus={syncStatus} />)
|
||||
expect(html).toContain('正在读取并校验通讯录')
|
||||
expect(html).not.toMatch(/\d+%/)
|
||||
expect(html).toMatch(/disabled=""[^>]*>同步通讯录/)
|
||||
const dirty = renderToStaticMarkup(
|
||||
<RegionMappingView {...props} dirty syncStatus={{ configured: true, worker_ready: true, job: null }} />
|
||||
<RegionCatalogView {...props} dirty syncStatus={{ configured: true, worker_ready: true, job: null }} />
|
||||
)
|
||||
expect(dirty).toContain('未保存的区域修改')
|
||||
expect(dirty).toMatch(/disabled=""[^>]*>同步通讯录/)
|
||||
})
|
||||
it('lets long directory paths wrap instead of inheriting the global nowrap table rule', () => {
|
||||
it('uses a responsive catalog list with wrapping warnings and no obsolete mapping-table styles', () => {
|
||||
const css = readFileSync(new URL('./qaRegions.css', import.meta.url), 'utf8')
|
||||
const bodyRule = css.match(/\.qa-region-table td\s*\{([^}]+)\}/)?.[1] ?? ''
|
||||
expect(bodyRule).toMatch(/white-space:\s*normal/)
|
||||
expect(bodyRule).toMatch(/overflow-wrap:\s*anywhere/)
|
||||
const statusRule = css.match(/\.qa-region-table td\.qa-region-basis\s*\{([^}]+)\}/)?.[1] ?? ''
|
||||
expect(statusRule).toMatch(/white-space:\s*nowrap/)
|
||||
expect(css).toMatch(/\.qa-region-catalog-list/)
|
||||
expect(css).toMatch(/minmax\(0,\s*1fr\)/)
|
||||
expect(css).toMatch(/\.qa-region-row-actions/)
|
||||
expect(css).toMatch(/overflow-wrap:\s*anywhere/)
|
||||
expect(css).not.toContain('.qa-region-table')
|
||||
})
|
||||
it('shows a dated historical roster, conflicts and no invented performance verdict', () => {
|
||||
const html = renderToStaticMarkup(<RegionMappingView {...props} />)
|
||||
const html = renderToStaticMarkup(<RegionCatalogView {...props} />)
|
||||
expect(html).toContain('历史快照')
|
||||
expect(html).toContain('跨区域待核对:1')
|
||||
expect(html).not.toContain('配置区域归属不等于纳入绩效考核')
|
||||
expect(html).not.toContain('<script>test</script>')
|
||||
expect(html).not.toContain('达标率')
|
||||
expect(html).toMatch(/disabled=""[^>]*>保存归属/)
|
||||
expect(html).toMatch(/disabled=""[^>]*>保存区域设置/)
|
||||
})
|
||||
it('requires a preview of the current draft before enabling save', () => {
|
||||
const html = renderToStaticMarkup(<RegionMappingView {...props} dirty preview={state} />)
|
||||
it('keeps optional preview visible and lets save invoke the same preview automatically', () => {
|
||||
const html = renderToStaticMarkup(<RegionCatalogView {...props} dirty preview={state} />)
|
||||
expect(html).toContain('预览结果(未保存)')
|
||||
expect(html).not.toMatch(/disabled=""[^>]*>保存归属/)
|
||||
expect(html).not.toMatch(/disabled=""[^>]*>保存区域设置/)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user