刘光辉
7 小时以前 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
import { describe, expect, it } from 'vitest';
 
import { healthActions, templateActions } from '../templateRules';
 
describe('ELN template rules', () => {
  it('allows draft annotation, health inspection, publish, versioning and disable', () => {
    expect(templateActions({ current: false, enabled: true, status: 'DRAFT' })).toEqual(['annotate', 'health', 'publish', 'createVersion', 'disable']);
  });
 
  it('keeps published templates read-only while retaining lifecycle actions', () => {
    expect(templateActions({ current: false, enabled: true, status: 'PUBLISHED' })).toEqual(['health', 'createVersion', 'setCurrent', 'disable']);
  });
 
  it('offers only evidence-backed health actions', () => {
    expect(healthActions({ actions: ['REPAIR', 'CONFIRM_REMOVE'], bindingId: 'b1', code: 'MISSING_CONTROL' } as any)).toEqual(['repair', 'confirmRemove']);
    expect(healthActions({ actions: ['LOCATE'], code: 'ORPHAN_CONTROL' } as any)).toEqual(['locate']);
    expect(healthActions({ actions: [], code: 'MISSING_CONTROL', bindingId: 'b1' } as any)).toEqual([]);
    expect(healthActions({ actions: ['LOCATE'], code: 'ROLE_MISMATCH' } as any)).toEqual(['locate']);
    expect(healthActions({ actions: ['LOCATE'], code: 'DUPLICATE_TAG' } as any)).toEqual(['locate']);
    expect(healthActions({ actions: ['LOCATE'], code: 'TYPE_MISMATCH' } as any)).toEqual(['locate']);
    expect(healthActions({ actions: ['LOCATE'], code: 'PENDING_BINDING' } as any)).toEqual(['locate']);
    expect(healthActions({ actions: ['REPAIR'], code: 'UNSUPPORTED_REPEAT_CONTROL' } as any)).toEqual([]);
  });
});