/** * lib/ba-screens.resolveEntitySectionFolder — THE shared « which section * serves this entity? » ladder (derive-lookup-grants producer section, * audit-ba RBAC-011 / CODE-009 sensitive-section resolution). */ import { describe, expect, it } from 'vitest' import { parseScreenFile, resolveEntitySectionFolder } from '../ba-screens.js' const SCREENS = parseScreenFile( [ '### SCR-HR-PAIE-FICHES-LIST-001 — Fiches de paie (SmartListView)', '- **Entité** : Payslip (ENT-001)', '- **Permission** : `paie.fiches.read`', '', '### SCR-HR-PAIE-FICHES-DETAIL-001 — Fiche de paie (SmartForm)', '- **Entité** : Payslip (ENT-001)', '- **Mode** : detail', ].join('\n'), { file: 'HR/PAIE/fiches/screen.md', module: 'PAIE', section: 'fiches', app: 'HR' }, ).screens describe('resolveEntitySectionFolder', () => { it('1. the list screen bound to the entity, in the module, wins', () => { expect(resolveEntitySectionFolder(SCREENS, ['fiches', 'payslips'], 'Payslip', 'PAIE')).toEqual({ section: 'fiches', detail: 'écran liste SCR-HR-PAIE-FICHES-LIST-001', }) }) it('2. else the kebab-plural of the entity among the module sections', () => { expect(resolveEntitySectionFolder(SCREENS, ['bank-accounts'], 'BankAccount', 'PAIE')).toEqual({ section: 'bank-accounts', detail: 'section menu « bank-accounts »', }) }) it('3. else nothing — said, never guessed (a list screen in ANOTHER module does not count)', () => { const r = resolveEntitySectionFolder(SCREENS, ['autre'], 'Payslip', 'ABSENCES') expect(r.section).toBeUndefined() expect(r.detail).toContain('aucun écran liste') expect(r.detail).toContain('« payslips »') }) })