Some checks failed
CI / Unit & Component Tests (push) Failing after 2m33s
CI / OCR Service Tests (push) Successful in 24s
CI / Backend Unit Tests (push) Successful in 3m42s
CI / fail2ban Regex (push) Successful in 43s
CI / Semgrep Security Scan (push) Successful in 22s
CI / Compose Bucket Idempotency (push) Successful in 1m7s
Review follow-up (Sara, fast-follow): the t no-active-region guard and the draw-cue arm/disarm rule lived inline in the page with no direct coverage. Extracted to pure resolveTrainingMark() (no-op when no region; recognition enrolled flip) and canArmDraw()/shouldDisarmDraw(), each with unit tests (10 cases total). The page now arms the draw cue only via canArmDraw and disarms via shouldDisarmDraw, and routes t through resolveTrainingMark. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
31 lines
996 B
TypeScript
31 lines
996 B
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { resolveTrainingMark, RECOGNITION_TRAINING_LABEL } from './trainingMark';
|
|
|
|
describe('resolveTrainingMark', () => {
|
|
it('is a no-op (null) when no region is active', () => {
|
|
expect(resolveTrainingMark(null, [])).toBe(null);
|
|
expect(resolveTrainingMark(null, [RECOGNITION_TRAINING_LABEL])).toBe(null);
|
|
});
|
|
|
|
it('enrols recognition training when a region is active and not yet enrolled', () => {
|
|
expect(resolveTrainingMark('ann-1', [])).toEqual({
|
|
label: RECOGNITION_TRAINING_LABEL,
|
|
enrolled: true
|
|
});
|
|
});
|
|
|
|
it('un-enrols when recognition training is already enrolled', () => {
|
|
expect(resolveTrainingMark('ann-1', [RECOGNITION_TRAINING_LABEL])).toEqual({
|
|
label: RECOGNITION_TRAINING_LABEL,
|
|
enrolled: false
|
|
});
|
|
});
|
|
|
|
it('ignores unrelated document training labels', () => {
|
|
expect(resolveTrainingMark('ann-1', ['KURRENT_SEGMENTATION'])).toEqual({
|
|
label: RECOGNITION_TRAINING_LABEL,
|
|
enrolled: true
|
|
});
|
|
});
|
|
});
|