刘光辉
3 小时以前 cf11e63b659afcc9792ab3e395f1b45d844431a8
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
import { describe, expect, it } from 'vitest';
 
import { groupHandlingDetails } from '../groupHandlingDetails';
 
describe('groupHandlingDetails', () => {
  it('combines expected users and shows only reviewers with records', () => {
    const rows = groupHandlingDetails([
      { id: 'a', nodeId: 'visit-1', expectedUser: '王磊', handlingUser: '王磊', hasHandlingRecord: true, deliveryTime: 100 },
      { id: 'c', nodeId: 'visit-2', expectedUser: '赵然', handlingUser: '', deliveryTime: 110 },
      { id: 'b', nodeId: 'visit-1', expectedUser: '李静', handlingUser: '', hasHandlingRecord: false, deliveryTime: 100 },
    ]);
 
    expect(rows.map(({ id, rowSpan }) => [id, rowSpan])).toEqual([
      ['a', 1],
      ['c', 1],
    ]);
    expect(rows[0]?.expectedUser).toBe('王磊、李静');
    expect(rows[0]?.handlingUser).toBe('王磊');
  });
 
  it('adds a separate row for each reviewer who actually handled the same step', () => {
    const rows = groupHandlingDetails([
      { id: 'a', nodeId: 'visit-1', expectedUser: '王磊', handlingUser: '王磊', hasHandlingRecord: true },
      { id: 'b', nodeId: 'visit-1', expectedUser: '李静', handlingUser: '李静', hasHandlingRecord: true },
    ]);
 
    expect(rows.map(({ id, rowSpan }) => [id, rowSpan])).toEqual([
      ['a', 2],
      ['b', 0],
    ]);
    expect(rows.map(({ expectedUser }) => expectedUser)).toEqual(['王磊、李静', '王磊、李静']);
  });
 
  it('keeps separate visits distinct even when their names match', () => {
    const rows = groupHandlingDetails([
      { id: 'a', nodeId: 'visit-1', nodeName: '审核', expectedUser: '王磊' },
      { id: 'b', nodeId: 'visit-2', nodeName: '审核', expectedUser: '王磊' },
    ]);
 
    expect(rows.map(({ rowSpan }) => rowSpan)).toEqual([1, 1]);
  });
 
  it('appends a completion row after all steps only for a completed flow', () => {
    const details = [{ id: 'a', nodeId: 'visit-1', expectedUser: '王磊' }];
 
    expect(groupHandlingDetails(details)).toHaveLength(1);
    expect(groupHandlingDetails(details, 200).at(-1)).toMatchObject({ nodeName: '完成', completionTime: 200, status: '已完成' });
  });
});