feat: Admin Area General Settings and Categories 1.15

This commit is contained in:
OpenVelo Agent
2026-07-22 18:53:11 +00:00
parent ef9926dfc1
commit 2ed7d27235
4 changed files with 149 additions and 275 deletions
@@ -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');
});
});