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
+10 -8
View File
@@ -81,16 +81,18 @@ describe('review and batch requests', () => {
vi.stubGlobal('fetch', fetchMock)
await fetchReviewCandidates('pending')
await reviewPublication('tp-safe', 'approved', 'internal', 'engineer-1', 'approved_for_release')
await createReleaseBatch('Batch', 'engineer-1', ['tp-safe'], ['tp-delete'])
await sealReleaseBatch('rb-safe', 'engineer-2')
await reviewPublication('tp-safe', 'approved', 'internal', 'approved_for_release')
await createReleaseBatch('Batch', ['tp-safe'], ['tp-delete'])
await sealReleaseBatch('rb-safe')
await fetchReleaseBatches('draft')
expect(fetchMock.mock.calls[0][0]).toBe('/api/v1/review-candidates?review_state=pending&limit=20&offset=0')
expect(fetchMock.mock.calls[1][0]).toBe('/api/v1/review-candidates/tp-safe/decision')
expect(JSON.parse((fetchMock.mock.calls[1][1] as RequestInit).body as string)).toEqual({ decision: 'approved', decided_visibility: 'internal', reviewer_ref: 'engineer-1', decision_code: 'approved_for_release' })
// actor fields are server-stamped from the session; bodies must not carry them
// P0: the browser must never name the actor again; the server stamps it.
expect(JSON.parse((fetchMock.mock.calls[1][1] as RequestInit).body as string)).toEqual({ decision: 'approved', decided_visibility: 'internal', decision_code: 'approved_for_release' })
expect(fetchMock.mock.calls[2][0]).toBe('/api/v1/release-batches')
expect(JSON.parse((fetchMock.mock.calls[2][1] as RequestInit).body as string)).toEqual({ name: 'Batch', created_by: 'engineer-1', publication_ids: ['tp-safe'], delete_publication_ids: ['tp-delete'], release_change_set_id: '' })
expect(JSON.parse((fetchMock.mock.calls[2][1] as RequestInit).body as string)).toEqual({ name: 'Batch', publication_ids: ['tp-safe'], delete_publication_ids: ['tp-delete'], release_change_set_id: '' })
expect(fetchMock.mock.calls[3][0]).toBe('/api/v1/release-batches/rb-safe/seal')
expect(fetchMock.mock.calls[4][0]).toBe('/api/v1/release-batches?state=draft&limit=20&offset=0')
})
@@ -145,7 +147,7 @@ describe('release change set (R1)', () => {
it('generates with idempotency and rejects a manifest-less envelope', async () => {
const fetchMock = vi.fn().mockResolvedValue(new Response(JSON.stringify({ data: changeSetPayload, operation: 'created' }), { status: 201 }))
vi.stubGlobal('fetch', fetchMock)
const set = await generateReleaseChangeSet('9月发布', 'engineer-1')
const set = await generateReleaseChangeSet('9月发布')
expect(set.id).toBe('rcs-1')
expect(set.manifest_sha256).toBe('a'.repeat(64))
const [, init] = fetchMock.mock.calls[0] as [string, RequestInit]
@@ -153,12 +155,12 @@ describe('release change set (R1)', () => {
expect((init.body as string)).toContain('"name":"9月发布"')
const bad = vi.fn().mockResolvedValue(new Response(JSON.stringify({ data: { ...changeSetPayload, manifest_sha256: '' } }), { status: 201 }))
vi.stubGlobal('fetch', bad)
await expect(generateReleaseChangeSet('x', 'y')).rejects.toThrow('发布计划集响应缺少标识或清单摘要')
await expect(generateReleaseChangeSet('x')).rejects.toThrow('发布计划集响应缺少标识或清单摘要')
})
it('confirms via scoped endpoint and loads latest detail tolerating 404', async () => {
const confirmMock = vi.fn().mockResolvedValue(new Response(JSON.stringify({ data: { ...changeSetPayload, state: 'confirmed', confirmed_by: 'boss', confirmed_at: '2026-09-12T08:00:00Z' }, operation: 'created' }), { status: 200 }))
vi.stubGlobal('fetch', confirmMock)
const confirmed = await confirmReleaseChangeSet('rcs-1', 'boss')
const confirmed = await confirmReleaseChangeSet('rcs-1')
expect(confirmed.state).toBe('confirmed')
expect(confirmMock.mock.calls[0][0]).toBe('/api/v1/release-change-sets/rcs-1/confirm')
const latest404 = vi.fn().mockResolvedValue(new Response('{}', { status: 404 }))