刘光辉
5 小时以前 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import { describe, expect, it } from 'vitest';
 
import {
  filePropertyLifecycle,
  filePropertyName,
  filePropertyPreparer,
  filePropertyReview,
  filePropertyReviewers,
  filePropertyVersion,
} from '../fileProperties';
 
describe('dMS file properties', () => {
  it('shows stored personnel names for both current and historical versions without resolving IDs', () => {
    const item = {
      preparedBy: 'user-id',
      extendedProperties: {
        prepared_by_name: '登记时制定人',
        reviewers: [
          { user_id: 'r1', name: '审核甲' },
          { user_id: 'r2', name: '审核乙' },
        ],
      },
    };
    expect(filePropertyPreparer(item)).toBe('登记时制定人');
    expect(filePropertyReviewers(item)).toBe('审核甲、审核乙');
    expect(filePropertyPreparer({ preparedBy: 'user-id' })).toBe('user-id');
    expect(filePropertyReviewers()).toBe('未记录');
  });
 
  it('falls back to stored IDs when names are unavailable and marks only missing identities as unrecorded', () => {
    expect(filePropertyPreparer({ preparedBy: 'author-id', extendedProperties: { prepared_by_name: '  ' } })).toBe('author-id');
    expect(filePropertyPreparer()).toBe('未记录');
    expect(
      filePropertyReviewers({
        extendedProperties: {
          reviewers: [
            { user_id: 'r1', name: '审核甲' },
            { user_id: '878193794397329605', name: '' },
            { user_id: 'r3', name: '  ' },
            { user_id: '', name: '' },
          ],
        },
      }),
    ).toBe('审核甲、878193794397329605、r3、未记录');
  });
 
  it('uses the stable document name and version metadata', () => {
    expect(filePropertyName({ documentName: '清洁消毒记录', fileName: '清洁消毒记录.docx', name: 'fallback' })).toBe('清洁消毒记录');
    expect(filePropertyVersion({ versionLabel: 'D(02)', versionNo: 2 })).toBe('D(02)');
    expect(filePropertyVersion({ versionNo: 2 })).toBe('v2');
  });
 
  it('combines the next review date with its configured interval', () => {
    expect(filePropertyReview({ nextReviewOn: '2028-06-19', reviewCycleMonths: 36 })).toBe('2028-06-19(每 36 个月)');
    expect(filePropertyReview({ reviewCycleMonths: 24 })).toBe('每 24 个月');
    expect(filePropertyReview()).toBe('—');
  });
 
  it('maps lifecycle states to user-facing labels', () => {
    expect(filePropertyLifecycle('EFFECTIVE')).toEqual({ color: 'success', label: '已生效/执行中' });
    expect(filePropertyLifecycle('SUPERSEDED').label).toBe('已被替代');
    expect(filePropertyLifecycle().label).toBe('—');
  });
});