import { describe, expect, it } from 'vitest';
|
|
import { buildTaskCellMap, getTaskCellState, getTaskDisplayStatus, getTaskRowKey } from '../waterPlanBoard';
|
|
const pending = {
|
jihua_riqi: '2026-07-21',
|
renwu_id: 'renwu-pending',
|
renwu_zhuangtai: 'pending',
|
yangpin_leixing: 'pw',
|
suoshu_chejian: 'workshop',
|
quyang_didian: 'tank',
|
quyangdian_bianhao: 'SG-1',
|
};
|
const generated = {
|
...pending,
|
qingyandan_id: 'qingyandan-1',
|
renwu_id: 'renwu-generated',
|
renwu_zhuangtai: 'generated',
|
};
|
const blocked = { ...pending, renwu_id: 'renwu-blocked', renwu_zhuangtai: 'blocked_config_invalid' };
|
|
describe('water plan board task cells', () => {
|
it('uses the stable sampling point id when available', () => {
|
expect(getTaskRowKey({ ...pending, quyangdian_id: 'point-1' })).toBe('point-1');
|
});
|
|
it('falls back to the legacy composite key for historical rows without a point id', () => {
|
expect(getTaskRowKey(pending)).toBe('pw__workshop__tank__SG-1');
|
});
|
|
it('marks a cell pending when one task remains pending', () => {
|
const map = buildTaskCellMap([generated, pending]);
|
expect(getTaskCellState(map.get('pw__workshop__tank__SG-1|2026-07-21')!)).toBe('pending');
|
});
|
|
it('marks a cell done only when every Renwu has generated its request form', () => {
|
expect(getTaskCellState([generated])).toBe('done');
|
});
|
|
it('marks a blocked configuration cell separately', () => {
|
expect(getTaskCellState([blocked])).toBe('blocked');
|
});
|
|
it('shows unexecuted before a request form is generated', () => {
|
expect(getTaskDisplayStatus(pending)).toBe('未执行');
|
});
|
|
it('shows generated Renwu as requested without inferring sampling or inspection stages', () => {
|
expect(getTaskDisplayStatus(generated)).toBe('已请验');
|
});
|
|
it('shows a configuration-invalid Renwu as blocked', () => {
|
expect(getTaskDisplayStatus(blocked)).toBe('配置无效(已阻断)');
|
});
|
});
|