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
| import { describe, expect, it } from 'vitest';
|
| import { acceptValidationResponse, formulaVersionActions, toEditorDiagnostics } from '../formulaRules';
|
| describe('eLN formula catalog action rules', () => {
| it('limits draft versions to edit, pre-release and cancel', () => {
| expect(formulaVersionActions({ current: false, status: 'DRAFT' })).toEqual(['edit', 'preRelease', 'cancel']);
| });
|
| it('allows pre-release versions to preview, publish, cancel or copy', () => {
| expect(formulaVersionActions({ current: false, status: 'PRE_RELEASE' })).toEqual(['preview', 'publish', 'cancel', 'copy']);
| });
|
| it('allows published versions to preview and only offers current switching when needed', () => {
| expect(formulaVersionActions({ current: false, status: 'PUBLISHED' })).toEqual(['preview', 'setCurrent', 'copy']);
| expect(formulaVersionActions({ current: true, status: 'PUBLISHED' })).toEqual(['preview', 'copy']);
| });
|
| it('keeps readonly preview available after a formula is disabled', () => {
| expect(formulaVersionActions({ current: false, enabled: false, status: 'DRAFT' })).toEqual(['cancel']);
| expect(formulaVersionActions({ current: false, enabled: false, status: 'PRE_RELEASE' })).toEqual(['preview', 'cancel']);
| expect(formulaVersionActions({ current: false, enabled: false, status: 'PUBLISHED' })).toEqual(['preview']);
| });
|
| it('rejects an out-of-order validation response', () => {
| expect(acceptValidationResponse({ received: 3, sent: 4 })).toBe(false);
| });
|
| it('maps backend UTF-16 offsets to editor diagnostics', () => {
| expect(toEditorDiagnostics([{ end: 5, severity: 'ERROR', start: 2 }])[0]).toMatchObject({ from: 2, to: 5 });
| });
| });
|
|