/** * TC-IDENTITY_API-003 · 查看身份注册的办理结果(接口级) * REQ-047 [FL-1.2] 反向/错误推测 P1 * * 前置:已完成一次身份注册操作 / 用户有查看记录的权限 * 步骤:调用"身份注册"接口 → 查询刚办理的记录 → 查看详情和相关记录 * 预期:能查到正确的身份注册结果,列表、详情和相关记录一致。 */ export const meta = { tc: 'TC-IDENTITY_API-003', req: 'REQ-047', title: '查看身份注册的办理结果', type: '反向/错误推测', priority: 'P1', route: '', needs: ['be'] } export async function run(t) { let account = '' let userId = '' await t.step('前置:注册一个新用户,作为查看对象', async () => { await t.login() account = `e2e_view_${t.uid('API').slice(-8).toLowerCase()}` const r = await t.api('POST', '/api/permission/Users', { account, realName: '查看身份注册_API', password: '123456', gender: '3', email: `${account}@example.com` }) t.assert(r && r.code === 200, `新建成功(code=${r?.code} msg=${r?.msg})`) userId = r?.data ?? '' }) await t.step('核对 1:列表可查', async () => { const list = await t.apiList('/api/permission/Users', { keyword: account }) const hit = list.find((u) => u.account === account) t.assert(!!hit, `列表命中 ${account}`) }) await t.step('核对 2:详情可查', async () => { if (!userId) { // 当 data 不可直接用作 id 时再用列表兜底找 const list = await t.apiList('/api/permission/Users', { keyword: account }) userId = list.find((u) => u.account === account)?.id } t.assert(!!userId, `拿到用户 id=${userId}`) const detail = await t.api('GET', `/api/permission/Users/${userId}`) t.assert(detail && detail.account === account, `详情接口 account 一致(${detail?.account})`) }) }