AI Implementation feature(897): Admin Area General Settings and Categories 1.15 (#37)
This commit was merged in pull request #37.
This commit is contained in:
@@ -122,4 +122,67 @@ describe('syncCategoryForm - edit prefill', () => {
|
||||
);
|
||||
expect(result.iconPreview).toBe('/uploads/icons/cry.png');
|
||||
});
|
||||
});
|
||||
|
||||
describe('CategoryFormModalComponent - prefill contract', () => {
|
||||
it('exposes a form group with name, abbreviation, description controls', async () => {
|
||||
const { CategoryFormModalComponent } = await import(
|
||||
'../../frontend/src/app/features/admin/categories/category-form-modal.component'
|
||||
);
|
||||
const fb = new FormBuilder();
|
||||
const component = Object.create(CategoryFormModalComponent.prototype) as any;
|
||||
component.fb = fb;
|
||||
component.form = fb.nonNullable.group({
|
||||
name: fb.nonNullable.control('', []),
|
||||
abbreviation: fb.nonNullable.control('', []),
|
||||
description: fb.nonNullable.control(''),
|
||||
});
|
||||
expect(component.form.controls.name).toBeDefined();
|
||||
expect(component.form.controls.abbreviation).toBeDefined();
|
||||
expect(component.form.controls.description).toBeDefined();
|
||||
expect(component.form.controls.name.value).toBe('');
|
||||
expect(component.form.controls.abbreviation.value).toBe('');
|
||||
expect(component.form.controls.description.value).toBe('');
|
||||
});
|
||||
|
||||
it('prefills controls and locks abbreviation for a system row via syncCategoryForm', () => {
|
||||
const form = buildForm();
|
||||
const result = syncCategoryForm(form, 'edit', makeRow());
|
||||
expect(form.controls.name.value).toBe('Cryptography');
|
||||
expect(form.controls.abbreviation.value).toBe('CRY');
|
||||
expect(form.controls.description.value).toBe('Cryptographic challenges');
|
||||
expect(result.abbreviationReadonly).toBe(true);
|
||||
expect(result.iconPreview).toBeNull();
|
||||
});
|
||||
|
||||
it('updates iconPreview when switching between two system rows', () => {
|
||||
const form = buildForm();
|
||||
const first = syncCategoryForm(
|
||||
form,
|
||||
'edit',
|
||||
makeRow({
|
||||
name: 'Cryptography',
|
||||
abbreviation: 'CRY',
|
||||
description: 'Cryptographic challenges',
|
||||
iconPath: '/uploads/icons/CRY.png',
|
||||
}),
|
||||
);
|
||||
expect(first.iconPreview).toBe('/uploads/icons/CRY.png');
|
||||
expect(form.controls.name.value).toBe('Cryptography');
|
||||
|
||||
const second = syncCategoryForm(
|
||||
form,
|
||||
'edit',
|
||||
makeRow({
|
||||
name: 'Hardware',
|
||||
abbreviation: 'HW',
|
||||
description: 'Hardware challenges',
|
||||
iconPath: '/uploads/icons/HW.png',
|
||||
}),
|
||||
);
|
||||
expect(second.iconPreview).toBe('/uploads/icons/HW.png');
|
||||
expect(form.controls.name.value).toBe('Hardware');
|
||||
expect(form.controls.abbreviation.value).toBe('HW');
|
||||
expect(form.controls.description.value).toBe('Hardware challenges');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user