mirror of
https://github.com/cpvalente/ontime.git
synced 2026-07-26 10:38:55 +00:00
fix: ensure IDs on import from excel
This commit is contained in:
committed by
Carlos Valente
parent
b65b3fa6d2
commit
3918664945
@@ -13,21 +13,27 @@ describe('parseExcel()', () => {
|
||||
expect(result.rundown.flatOrder.length).toBe(14);
|
||||
expect(result.rundown.order.length).toBe(4);
|
||||
|
||||
const firstEvent = result.rundown.entries[result.rundown.flatOrder[2]];
|
||||
const firstEventId = result.rundown.flatOrder[2];
|
||||
const firstEvent = result.rundown.entries[firstEventId];
|
||||
expect(firstEvent).toMatchObject({
|
||||
id: firstEventId,
|
||||
type: SupportedEntry.Event,
|
||||
title: 'Pre-show Countdown',
|
||||
});
|
||||
expect(millisToString((firstEvent as OntimeEvent).timeStart)).toBe('10:00:00');
|
||||
|
||||
const lastEvent = result.rundown.entries[result.rundown.flatOrder[12]];
|
||||
const lastEventId = result.rundown.flatOrder[12];
|
||||
const lastEvent = result.rundown.entries[lastEventId];
|
||||
expect(lastEvent).toMatchObject({
|
||||
id: lastEventId,
|
||||
type: SupportedEntry.Event,
|
||||
title: 'Wrap up',
|
||||
});
|
||||
|
||||
// the excel step does not relate elements yet
|
||||
expect(millisToString((lastEvent as OntimeEvent).timeEnd)).toBe('00:00:00');
|
||||
});
|
||||
|
||||
it('parses an import map with only custom fields', () => {
|
||||
// partial import map with only custom fields
|
||||
const importMap = {
|
||||
|
||||
@@ -184,6 +184,7 @@ export const parseExcel = (
|
||||
// from excel, we can only get groups, milestones and events
|
||||
if (isOntimeGroup(entry as OntimeEntry)) {
|
||||
const group = {
|
||||
id, // will be replaced by a potentially user given ID
|
||||
...entry,
|
||||
targetDuration: entry.duration ? entry.duration : null,
|
||||
custom: { ...entryCustomFields },
|
||||
@@ -200,7 +201,11 @@ export const parseExcel = (
|
||||
}
|
||||
|
||||
if (isOntimeMilestone(entry as OntimeEntry)) {
|
||||
const milestone = { ...entry, custom: { ...entryCustomFields } } as OntimeMilestone;
|
||||
const milestone = {
|
||||
id, // will be replaced by a potentially user given ID
|
||||
...entry,
|
||||
custom: { ...entryCustomFields },
|
||||
} as OntimeMilestone;
|
||||
if (currentGroupId) {
|
||||
groupEntries.push(id);
|
||||
milestone.parent = currentGroupId;
|
||||
@@ -214,6 +219,7 @@ export const parseExcel = (
|
||||
|
||||
// after group and milestones we only have events remaining
|
||||
const event = {
|
||||
id, // will be replaced by a potentially user given ID
|
||||
...entry,
|
||||
custom: { ...entryCustomFields },
|
||||
type: SupportedEntry.Event,
|
||||
|
||||
Reference in New Issue
Block a user