/** * scaffold-extension-config — first tests of the CLI (it had none — audit * B-WARN-11): the slot catalogue comes from lib/slot-names (rendered names, * no module prefix), the identifier is a valid TS name even for a hyphenated * module (B-WARN-17), and the output path is the documented one. */ import { describe, it, expect } from 'vitest' import { generate } from '../generate.js' import { validate } from '../validate.js' import { slotNamesFor } from '../../../../../../lib/slot-names.js' describe('scaffold-extension-config', () => { it('emits src/extensions/{module}Extensions.ts with the rendered slot names of list/detail/form', () => { const [file] = generate({ module: 'hrm', appCode: 'myapp', entities: ['Employee', 'Contract'], projectPath: '/web' }) expect(file.path).toBe('src/extensions/hrmExtensions.ts') const expected = ['Employee', 'Contract'].flatMap((e) => [...slotNamesFor(e, 'list'), ...slotNamesFor(e, 'detail'), ...slotNamesFor(e, 'form')]) for (const name of expected) expect(file.content).toContain(`'${name}': null,`) expect(file.content).not.toContain('hrm.employee.list.before') expect(file.content).toContain('export const hrmConfig: ExtensionConfig = {') }) it('a hyphenated module yields a valid identifier', () => { const [file] = generate({ module: 'time-entry', appCode: 'myapp', entities: ['TimeEntry'], projectPath: '/web' }) expect(file.content).toContain('export const timeEntryConfig: ExtensionConfig = {') expect(file.content).not.toContain('time-entryConfig') }) it('validate() refuses a non-kebab module / appCode and a non-Pascal entity', () => { expect(validate({ module: 'Hrm', appCode: 'myapp', entities: ['Employee'], projectPath: '/web' }).valid).toBe(false) expect(validate({ module: 'hrm', appCode: 'MyApp', entities: ['Employee'], projectPath: '/web' }).valid).toBe(false) expect(validate({ module: 'hrm', appCode: 'myapp', entities: ['employee'], projectPath: '/web' }).valid).toBe(false) }) })