刘光辉
11 小时以前 0dfe84494048ce27ba8449831782128412d3eb13
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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('配置无效(已阻断)');
  });
});