feat: Admin Area General Settings and Categories 1.16
This commit is contained in:
@@ -3,6 +3,7 @@ import { FormBuilder, FormControl, FormGroup } from '@angular/forms';
|
||||
import {
|
||||
syncCategoryForm,
|
||||
CategoryFormMode,
|
||||
CategoryFormSubmit,
|
||||
} from '../../frontend/src/app/features/admin/categories/category-form-modal.component';
|
||||
import { AdminCategory } from '../../frontend/src/app/core/services/admin.service';
|
||||
|
||||
@@ -185,4 +186,36 @@ describe('CategoryFormModalComponent - prefill contract', () => {
|
||||
expect(form.controls.abbreviation.value).toBe('HW');
|
||||
expect(form.controls.description.value).toBe('Hardware challenges');
|
||||
});
|
||||
|
||||
it('keeps user (non-system) abbreviation editable and emits the uppercased abbreviation', () => {
|
||||
const form = buildForm();
|
||||
const result = syncCategoryForm(
|
||||
form,
|
||||
'edit',
|
||||
makeRow({
|
||||
id: 'user-cat',
|
||||
name: 'Cat A Test T007',
|
||||
abbreviation: 'CATA',
|
||||
description: 'd',
|
||||
isSystem: false,
|
||||
systemKey: null,
|
||||
}),
|
||||
);
|
||||
expect(result.abbreviationReadonly).toBe(false);
|
||||
|
||||
form.controls.name.setValue('Cat Z Renamed T007');
|
||||
form.controls.abbreviation.setValue('zzza');
|
||||
form.controls.description.setValue('Renamed to ZZZA for T007');
|
||||
|
||||
const v = form.getRawValue();
|
||||
const emitted: CategoryFormSubmit = {
|
||||
mode: 'edit',
|
||||
name: v.name,
|
||||
abbreviation: v.abbreviation.toUpperCase(),
|
||||
description: v.description,
|
||||
};
|
||||
expect(emitted.abbreviation).toBe('ZZZA');
|
||||
expect(emitted.name).toBe('Cat Z Renamed T007');
|
||||
expect(emitted.description).toBe('Renamed to ZZZA for T007');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user