fix: api change custom fields (#1888)

* fix: validate nested custom path

* chore: add test
This commit is contained in:
Alex Christoffer Rasmussen
2025-11-27 09:15:02 +01:00
committed by GitHub
parent 80ec2d1186
commit f128f7acd2
3 changed files with 105 additions and 4 deletions
@@ -0,0 +1,91 @@
import { EntryCustomFields, OntimeEvent } from 'ontime-types';
import { isValidChangeProperty } from '../integration.utils.js';
describe('isValidChangeProperty()', () => {
test('correct value and property', () => {
const testEvent = {
id: 'test',
duration: 111,
} as OntimeEvent;
expect(isValidChangeProperty(testEvent, 'duration', 123)).toBeTruthy();
});
test('correct property and undefined value', () => {
const testEvent = {
id: 'test',
duration: 111,
} as OntimeEvent;
expect(isValidChangeProperty(testEvent, 'duration', undefined)).toBeFalsy();
});
test('missing property and undefined value', () => {
const testEvent = {
id: 'test',
duration: 111,
} as OntimeEvent;
expect(isValidChangeProperty(testEvent, 'missing', 123)).toBeFalsy();
});
test('non existing custom value', () => {
const testEvent = {
id: 'test',
duration: 111,
custom: {
field: 'test',
} as EntryCustomFields,
} as OntimeEvent;
expect(isValidChangeProperty(testEvent, 'custom:test', 123)).toBeFalsy();
});
test('existing custom value', () => {
const testEvent = {
id: 'test',
duration: 111,
custom: {
test: 'test',
} as EntryCustomFields,
} as OntimeEvent;
expect(isValidChangeProperty(testEvent, 'custom:test', 123)).toBeTruthy();
});
test('empty custom definition', () => {
const testEvent = {
id: 'test',
duration: 111,
custom: {
test: 'test',
} as EntryCustomFields,
} as OntimeEvent;
expect(isValidChangeProperty(testEvent, 'custom:', 123)).toBeFalsy();
});
test('build-in in custom', () => {
const testEvent = {
id: 'test',
duration: 111,
custom: {
test: 'test',
} as EntryCustomFields,
} as OntimeEvent;
expect(isValidChangeProperty(testEvent, 'custom:toString', 123)).toBeFalsy();
});
test('build-in in top object', () => {
const testEvent = {
id: 'test',
duration: 111,
custom: {
test: 'test',
} as EntryCustomFields,
} as OntimeEvent;
expect(isValidChangeProperty(testEvent, 'toString', 123)).toBeFalsy();
});
});