@@ -6,6 +6,38 @@ import { hasPreparationChanges } from '@/lib/requisition-history';
|
||||
|
||||
afterEach(() => vi.restoreAllMocks());
|
||||
|
||||
test('new empty classification fields preserve an older recovered preparation while real classification changes remain dirty', () => {
|
||||
const old = { items: [{ description: 'Artigo anterior' }] };
|
||||
const current = {
|
||||
items: [
|
||||
{
|
||||
description: 'Artigo anterior',
|
||||
procurement_category: '',
|
||||
category_reason: '',
|
||||
},
|
||||
],
|
||||
};
|
||||
expect(hasPreparationChanges(old, current)).toBe(false);
|
||||
expect(hasPreparationChanges(current, old)).toBe(false);
|
||||
expect(
|
||||
hasPreparationChanges(old, {
|
||||
items: [
|
||||
{
|
||||
...current.items[0],
|
||||
procurement_category: 'office_equipment',
|
||||
},
|
||||
],
|
||||
}),
|
||||
).toBe(true);
|
||||
expect(
|
||||
hasPreparationChanges(old, {
|
||||
items: [
|
||||
{ ...current.items[0], category_reason: 'Razão deliberada' },
|
||||
],
|
||||
}),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
test('restored technical identities do not mark a cleared preparation as changed', () => {
|
||||
const original = {
|
||||
operation_key: 'initial-operation',
|
||||
|
||||
Reference in New Issue
Block a user