/** U2 Task 6, R-3: only what is really missing, in the form's order (board 33 adjustment 3). */ import { describe, expect, it } from 'vitest' import type { CreationForm } from '@/editor/annotations/creation' import { missingFields } from '@/editor/annotations/missingFields' const form = (patch: Partial = {}): CreationForm => ({ fr: 'Grasset', en: 'Stifle', categoryId: 'cat-1', laterality: 'bilateral', opensViewId: '', zoneId: '', regionCode: '', ...patch, }) describe('missingFields', () => { it('a full point or zone misses nothing', () => { expect(missingFields('point', form())).toEqual([]) expect(missingFields('zone', form())).toEqual([]) }) it('a chosen category is never listed; only the laterality is', () => { expect(missingFields('point', form({ laterality: '' }))).toEqual([ 'laterality', ]) }) it('a link with both names blank is fine; with one blank it names that one', () => { const link = form({ fr: ' ', en: '', opensViewId: 'head' }) expect(missingFields('detail_trigger', link)).toEqual([]) const half = form({ fr: '', opensViewId: 'head' }) expect(missingFields('detail_trigger', half)).toEqual(['name_fr']) }) it('names, category, laterality, opened view: in the form’s order', () => { const empty = form({ fr: '', en: 'x', categoryId: '', laterality: '' }) expect(missingFields('detail_trigger', empty)).toEqual([ 'name_fr', 'category', 'laterality', 'opens', ]) const blank = form({ fr: '', en: ' ', categoryId: '', laterality: '' }) expect(missingFields('point', blank)).toEqual([ 'name_fr', 'name_en', 'category', 'laterality', ]) }) })