feat(web): login gate, session identity UI and member management

- main.tsx 挂 AuthProvider 门控:未登录→登录页;must_change_password→强制改密页
- 登录页/改密页/顶栏身份(头像+姓名+角色徽章+退出)按 A·Data-console token 样式
- 全局 fetch 拦截器:任意业务请求 401 自动回登录页(会话过期/被撤销不留死表单)
- 系统设置新增「成员与角色」分区(仅 admin 可见):名单、角色调整、启停、重置临时密码、新增成员
- 消灭全部手填操作人:审核/封批/确认计划集/范围规则/来源调度/UI 设置/开始处理/批量重试/
  目录差异确认共 9 处输入框删除,请求体不再携带 actor 字段(服务端从会话注入)
- 测试断言方向翻转:显式验证请求体不含 operator_ref/created_by 等字段
- 附带修复:登录失败计数 SQL 参数类型无法推断导致 500(pgx 扩展协议),显式 cast 解决

前端门禁:tsc 0 错、125 用例全绿、build 通过
This commit is contained in:
2026-09-13 16:27:11 +08:00
committed by 姚章浩
parent fbe80ad784
commit f6cb90cd70
30 changed files with 637 additions and 158 deletions
+5 -5
View File
@@ -94,11 +94,11 @@ describe('startTestPublications', () => {
const fetchMock = vi.fn().mockResolvedValue(new Response(JSON.stringify({ data: { selected: 2, started: 1, already_started: 1, unavailable: 0 } }), { status: 202 }))
vi.stubGlobal('fetch', fetchMock)
await expect(startTestPublications(['pub-a', 'pub-b'], 'engineer-1', '已核对差异')).resolves.toEqual({ selected: 2, started: 1, already_started: 1, unavailable: 0 })
await expect(startTestPublications(['pub-a', 'pub-b'], '已核对差异')).resolves.toEqual({ selected: 2, started: 1, already_started: 1, unavailable: 0 })
expect(fetchMock).toHaveBeenCalledWith('/api/v1/test-publications/start', expect.objectContaining({
method: 'POST',
headers: expect.objectContaining({ 'Idempotency-Key': expect.any(String) }),
body: JSON.stringify({ publication_ids: ['pub-a', 'pub-b'], operator_ref: 'engineer-1', reason: '已核对差异' }),
body: JSON.stringify({ publication_ids: ['pub-a', 'pub-b'], reason: '已核对差异' }),
}))
})
})
@@ -111,19 +111,19 @@ describe('retryPublicationsBatch', () => {
})
vi.stubGlobal('fetch', fetchMock)
const result = await retryPublicationsBatch(['tp-1', 'tp-2'], '姚工', '解析服务恢复')
const result = await retryPublicationsBatch(['tp-1', 'tp-2'], '解析服务恢复')
expect(fetchMock).toHaveBeenCalledWith('/api/v1/test-publications/retry-batch',
expect.objectContaining({ method: 'POST' }))
const call = fetchMock.mock.calls[0] as [string, RequestInit]
expect(JSON.parse(String(call[1].body))).toEqual({ publication_ids: ['tp-1', 'tp-2'], operator_ref: '姚工', reason: '解析服务恢复' })
expect(JSON.parse(String(call[1].body))).toEqual({ publication_ids: ['tp-1', 'tp-2'], reason: '解析服务恢复' })
expect(result.started).toBe(1)
expect(result.outcomes[1].result).toBe('already_running')
})
it('rejects a malformed batch envelope', async () => {
vi.stubGlobal('fetch', vi.fn().mockResolvedValue({ ok: true, json: async () => ({ data: {} }) }))
await expect(retryPublicationsBatch(['tp-1'], '姚工', 'r')).rejects.toThrow()
await expect(retryPublicationsBatch(['tp-1'], 'r')).rejects.toThrow()
})
})