91 lines
2.4 KiB
TypeScript
91 lines
2.4 KiB
TypeScript
import { describe, it } from 'node:test'
|
|
import assert from 'node:assert/strict'
|
|
import {
|
|
findTaskStepGateIssue,
|
|
needsProductionReceptionGate
|
|
} from './production-complete-work-order-gate-logic'
|
|
|
|
describe('needsProductionReceptionGate', () => {
|
|
it('true for cell_storage and research_donation', () => {
|
|
assert.equal(needsProductionReceptionGate({ receptionSource: 'cell_storage' } as any), true)
|
|
assert.equal(
|
|
needsProductionReceptionGate({ receptionSource: 'research_donation' } as any),
|
|
true
|
|
)
|
|
})
|
|
|
|
it('false for outbound/temporary', () => {
|
|
assert.equal(needsProductionReceptionGate({ receptionSource: 'outbound' } as any), false)
|
|
assert.equal(needsProductionReceptionGate({} as any), false)
|
|
})
|
|
})
|
|
|
|
describe('findTaskStepGateIssue', () => {
|
|
it('requires assignee', () => {
|
|
const issue = findTaskStepGateIssue({
|
|
steps: [{ id: 's1', processName: '分离', assigneeUserIds: [], plannedStartTime: '2026-01-01' }]
|
|
})
|
|
assert.ok(issue)
|
|
assert.match(issue!.message, /负责人/)
|
|
assert.equal(issue!.stepId, 's1')
|
|
})
|
|
|
|
it('requires planned start time', () => {
|
|
const issue = findTaskStepGateIssue({
|
|
steps: [{ id: 's1', processName: '分离', assigneeUserIds: ['u1'], plannedStartTime: '' }]
|
|
})
|
|
assert.ok(issue)
|
|
assert.match(issue!.message, /计划开始时间/)
|
|
})
|
|
|
|
it('requires barcode on existing output rows', () => {
|
|
const issue = findTaskStepGateIssue({
|
|
steps: [
|
|
{
|
|
id: 's1',
|
|
processName: '分离',
|
|
assigneeUserIds: ['u1'],
|
|
plannedStartTime: '2026-01-01',
|
|
outputs: [{ outputName: '细胞袋', outputBarcode: '' }]
|
|
}
|
|
]
|
|
})
|
|
assert.ok(issue)
|
|
assert.match(issue!.message, /条码/)
|
|
})
|
|
|
|
it('allows empty outputs', () => {
|
|
assert.equal(
|
|
findTaskStepGateIssue({
|
|
steps: [
|
|
{
|
|
id: 's1',
|
|
processName: '分离',
|
|
assigneeUserIds: ['u1'],
|
|
plannedStartTime: '2026-01-01',
|
|
outputs: []
|
|
}
|
|
]
|
|
}),
|
|
null
|
|
)
|
|
})
|
|
|
|
it('passes when all filled', () => {
|
|
assert.equal(
|
|
findTaskStepGateIssue({
|
|
steps: [
|
|
{
|
|
id: 's1',
|
|
processName: '分离',
|
|
assigneeUserIds: ['u1'],
|
|
plannedStartTime: '2026-01-01',
|
|
outputs: [{ outputName: '细胞袋', outputBarcode: 'BC-1' }]
|
|
}
|
|
]
|
|
}),
|
|
null
|
|
)
|
|
})
|
|
})
|