- 在 .env.production 中新增 VITE_AUTH_COOKIE_NAME 配置项用于设置认证cookie名称 - 将 AcceptanceException.vue 中的表单标签宽度从固定90px改为自动适配 - 在 ActionDialog.vue 中将多个表单项标记为必填项并调整标签宽度为自动适配 - 重构 ActionHistory.vue 中的按钮布局结构并添加表格列样式类名 - 更新 api-contract-audit.cjs 添加生产任务和BOM相关接口的契约测试 - 修改 auth.js 使用动态认证cookie键名替换硬编码的Admin-Token - 调整系统角色授权用户页面的表单布局和表格样式类名 - 优化 ReceiptDialog Batch 组件的对话框尺寸、表单验证和分页功能
69 lines
4.6 KiB
JavaScript
69 lines
4.6 KiB
JavaScript
const { test } = require('node:test')
|
|
const assert = require('node:assert/strict')
|
|
const { expectedReadRejection, selectUsableFixture,disabledReplayRejection } = require('./api-contract-audit.cjs')
|
|
const rejected = message => ({ status: 200, code: 500, message })
|
|
test('missing BOM/task samples are negative coverage, never a positive or internal-error pass',()=>{
|
|
assert.ok(expectedReadRejection('/production/tasks/{id}',rejected('生产任务不存在'),{}))
|
|
assert.equal(expectedReadRejection('/production/tasks/{id}',rejected('生产任务不存在'),{task:{id:1}}),undefined)
|
|
assert.ok(expectedReadRejection('/production/bom/{id}/export',rejected('BOM不存在或已删除'),{}))
|
|
assert.equal(expectedReadRejection('/production/bom/{id}',rejected('SQLSyntaxErrorException'),{}),undefined)
|
|
assert.equal(disabledReplayRejection('/system/data-replay/status',rejected('本机数据演练未启用或无权操作')),true)
|
|
assert.equal(disabledReplayRejection('/system/data-replay/status',rejected('NullPointerException')),false)
|
|
assert.equal(disabledReplayRejection('/project/info/list',rejected('本机数据演练未启用或无权操作')),false)
|
|
})
|
|
|
|
test('usable fixtures are selected by business state, not list position', () => {
|
|
const tasks = [{ id: 1, status: 'SETTLED' }, { id: 2, status: 'OPEN' }]
|
|
assert.equal(selectUsableFixture(tasks, row => row.status === 'OPEN').id, 2)
|
|
assert.equal(selectUsableFixture(tasks, row => row.status === 'CANCELLED'), undefined)
|
|
assert.equal(selectUsableFixture(tasks, row => row.status === 'CANCELLED', true).id, 1)
|
|
const out = [{ id: 3, costEventId: null }, { id: 4, costEventId: 8 }]
|
|
assert.equal(selectUsableFixture(out, row => row.costEventId, true).id, 4)
|
|
})
|
|
|
|
test('only exact missing-ID unbatched rejection is accepted without fixture', () => {
|
|
const p = '/warehouse/purchase/sheet/unbatched'
|
|
const result = rejected('明细已组批或已删除,请刷新列表')
|
|
assert.ok(expectedReadRejection(p, result, {}))
|
|
assert.equal(expectedReadRejection(p, result, { unbatched: { id: 1 } }), undefined)
|
|
assert.equal(expectedReadRejection(p, rejected('其他业务错误'), {}), undefined)
|
|
})
|
|
|
|
test('settled-task and arbitrary shortage errors can no longer be hidden', () => {
|
|
const p = '/production/tasks/shortages'
|
|
assert.equal(expectedReadRejection(p, rejected('已结算任务请先恢复生产'), {}), undefined)
|
|
assert.ok(expectedReadRejection(p, rejected('生产任务不存在'), {}))
|
|
assert.equal(expectedReadRejection(p, rejected('生产任务不存在'), { openTask: { id: 2 } }), undefined)
|
|
})
|
|
|
|
test('code zero is never accepted as a generator missing-fixture check', () => {
|
|
const p = '/tool/gen/column/{tableId}'
|
|
assert.equal(expectedReadRejection(p, { status: 200, code: 0 }, {}), undefined)
|
|
const result = rejected('生成配置不存在或已删除,请返回列表刷新')
|
|
assert.ok(expectedReadRejection(p, result, {}))
|
|
assert.equal(expectedReadRejection(p, result, { gen: { tableId: 5 } }), undefined)
|
|
})
|
|
|
|
test('legacy out-record protection requires actual evidence of missing cost chain', () => {
|
|
const p = '/warehouse/out/{id}/returns'
|
|
const result = rejected('该历史出库未补录成本链,不能自动撤销或退料;现有库存已作为期初保留')
|
|
assert.ok(expectedReadRejection(p, result, { out: { id: 1, costEventId: null } }))
|
|
assert.equal(expectedReadRejection(p, result, { out: { id: 2, costEventId: 3 } }), undefined)
|
|
assert.equal(expectedReadRejection(p, result, {}), undefined)
|
|
})
|
|
|
|
test('server errors and unsupported routes are never categorized as missing fixtures', () => {
|
|
const p = '/warehouse/purchase/sheet/unbatched'
|
|
assert.equal(expectedReadRejection(p, { status: 500, code: 500, message: '明细已组批或已删除,请刷新列表' }, {}), undefined)
|
|
assert.equal(expectedReadRejection(p, rejected('SQLSyntaxErrorException'), {}), undefined)
|
|
assert.equal(expectedReadRejection('/unknown/{id}', rejected('不存在'), {}), undefined)
|
|
assert.equal(expectedReadRejection(p, { status: 200, code: 403, message: '明细已组批或已删除,请刷新列表' }, {}), undefined)
|
|
})
|
|
|
|
test('loans and pending groups only accept their exact empty-fixture rejection', () => {
|
|
assert.ok(expectedReadRejection('/project/loans/{id}/returns', rejected('借用记录不存在'), {}))
|
|
assert.equal(expectedReadRejection('/project/loans/{id}/returns', rejected('借用记录不存在'), { loan: { id: 1 } }), undefined)
|
|
assert.ok(expectedReadRejection('/warehouse/in/pending-groups/{key}', rejected('来源编号无效'), {}))
|
|
assert.equal(expectedReadRejection('/warehouse/in/pending-groups/{key}', rejected('来源编号无效'), { pending: { key: 'B:1' } }), undefined)
|
|
})
|