feat(consignment): 寄售数量支持关闭修改,固定为 1
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import test from 'node:test'
|
||||
|
||||
function read(relativePath: string) {
|
||||
return readFileSync(fileURLToPath(new URL(relativePath, import.meta.url)), 'utf8').replace(
|
||||
/\r\n/g,
|
||||
'\n',
|
||||
)
|
||||
}
|
||||
|
||||
const panel = read('../src/pages/admin/panels/ConsignmentConfigPanel.tsx')
|
||||
const page = read('../src/pages/worker/WorkerConsignmentPage.tsx')
|
||||
|
||||
test('管理端:数量开关语义必须是「允许修改寄售数量」/「可改 / 固定 1」', () => {
|
||||
assert.ok(panel.includes('label="允许修改寄售数量"'), '文案必须改成是否允许修改')
|
||||
assert.ok(panel.includes('extra="关闭后打手端数量固定为 1,输入框禁用"'), '必须说明关闭后的行为')
|
||||
assert.ok(panel.includes('checkedChildren="可改"'), '开启文案应为「可改」')
|
||||
assert.ok(panel.includes('unCheckedChildren="固定 1"'), '关闭文案应为「固定 1」')
|
||||
assert.ok(!panel.includes('label="显示寄售数量"'), '旧的「显示寄售数量」必须移除')
|
||||
})
|
||||
|
||||
test('打手端:数量字段必须始终渲染,关闭时禁用并灰显 1', () => {
|
||||
assert.ok(
|
||||
page.includes('const quantityLocked = selectedProfile?.config.fields.quantity === false'),
|
||||
'必须由 fields.quantity === false 推导锁定状态',
|
||||
)
|
||||
assert.ok(page.includes('disabled={quantityLocked}'), '锁定时输入框必须禁用')
|
||||
assert.ok(
|
||||
page.includes("extra={quantityLocked ? '该分类数量固定为 1,不可修改' : undefined}"),
|
||||
'锁定时要给出固定 1 的提示',
|
||||
)
|
||||
assert.ok(
|
||||
!page.includes('selectedProfile?.config.fields.quantity !== false ? ('),
|
||||
'不能再按开关隐藏数量字段',
|
||||
)
|
||||
assert.ok(page.includes('initialValue={1}'), '数量默认值必须为 1')
|
||||
assert.ok(
|
||||
page.includes('const quantityForDeposit = quantityLocked ? 1 :'),
|
||||
'锁定后押金必须按 1 件计算',
|
||||
)
|
||||
})
|
||||
|
||||
test('打手端:数量始终显示,价格区固定三列,不再按数量切两列', () => {
|
||||
assert.ok(page.includes('className="worker-consignment-price-grid"'), '价格区必须固定三列')
|
||||
assert.ok(
|
||||
!page.includes("selectedProfile?.config.fields.quantity === false ? ' is-two' : ''"),
|
||||
'不能再用 is-two 布局',
|
||||
)
|
||||
})
|
||||
Reference in New Issue
Block a user