add endAction and timerType validation to excel upload (#401)

* add endAction and timerType validation to excel upload

* return parser tests + add tests for the excel fields
This commit is contained in:
Olayinka Zadat O
2023-05-20 20:19:42 +01:00
committed by GitHub
parent bd6e737ec6
commit 2f26c28c23
3 changed files with 946 additions and 0 deletions
+12
View File
@@ -1,6 +1,7 @@
import { generateId } from 'ontime-utils';
import {
Alias,
EndAction,
EventData,
OntimeRundown,
OSCSettings,
@@ -8,6 +9,7 @@ import {
OscSubscriptionOptions,
Settings,
TimerLifeCycle,
TimerType,
UserFields,
ViewSettings,
} from 'ontime-types';
@@ -41,7 +43,17 @@ export const parseRundown = (data): OntimeRundown => {
console.log('ERROR: ID collision on import, skipping');
continue;
}
// validate the right endAction is used
if (e.endAction && !Object.values(EndAction).includes(e.endAction)) {
e.endAction = EndAction.None;
console.log('WARNING: invalid End Action provided, using default');
}
// validate the right timerType is used
if (e.timerType && !Object.values(TimerType).includes(e.timerType)) {
e.timerType = TimerType.CountDown;
console.log('WARNING: invalid Timer Type provided, using default');
}
if (e.type === 'event') {
const event = validateEvent(e);
if (event != null) {