48 lines
1.6 KiB
TypeScript
48 lines
1.6 KiB
TypeScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import { changedSnapshotFields } from '../../src/asset-master/asset-version-diff';
|
|
|
|
const base = {
|
|
code: 'ACT-001',
|
|
name: 'Pozo 1',
|
|
description: null,
|
|
type: { id: 'type-1', code: 'WELL', name: 'Pozo' },
|
|
parent: null,
|
|
informationStatus: 'DRAFT',
|
|
attributes: [{ code: 'depth', value: 1200 }],
|
|
geometry: null,
|
|
updatedAt: '2026-08-14T10:00:00.000Z',
|
|
};
|
|
|
|
test('version diff ignores technical timestamps and detects functional fields', () => {
|
|
const current = {
|
|
...base,
|
|
informationStatus: 'SURVEYED',
|
|
updatedAt: '2026-08-14T11:00:00.000Z',
|
|
};
|
|
|
|
assert.deepEqual(changedSnapshotFields(base, current), ['informationStatus']);
|
|
});
|
|
|
|
test('version diff detects attribute and geometry changes', () => {
|
|
const current = {
|
|
...base,
|
|
attributes: [{ code: 'depth', value: 1300 }],
|
|
geometry: { geometryType: 'POINT', geometry: { type: 'POINT', coordinates: [-68, -32] } },
|
|
};
|
|
|
|
assert.deepEqual(changedSnapshotFields(base, current), ['attributes', 'geometry']);
|
|
});
|
|
|
|
test('version diff detects media changes independently', () => {
|
|
const previous = { ...base, media: [] };
|
|
const current = { ...base, media: [{ id: 'media-1', sha256: 'abc' }] };
|
|
assert.deepEqual(changedSnapshotFields(previous, current), ['media']);
|
|
});
|
|
|
|
test('version diff detects provenance changes independently', () => {
|
|
const previous = { ...base, provenance: { origin: 'MANUAL', verifiedAt: null } };
|
|
const current = { ...base, provenance: { origin: 'FIELD_SURVEY', verifiedAt: null } };
|
|
assert.deepEqual(changedSnapshotFields(previous, current), ['provenance']);
|
|
});
|