feat: excel import (#527)

* refactor: simplify excel import

* chore: add external deepmerge utility

* chore: create import map utilities

* chore: increase size limits on uploads

* style: small presentation tweaks

* feat: resolve times on excel import, refs #508
This commit is contained in:
Carlos Valente
2023-11-11 14:28:43 +01:00
committed by GitHub
parent 0ce3449083
commit 45fe669f0a
61 changed files with 1905 additions and 685 deletions
+43 -30
View File
@@ -526,7 +526,7 @@ describe('test event validator', () => {
expect(typeof validated.timeStart).toEqual('number');
expect(validated.timeStart).toEqual(0);
expect(typeof validated.timeEnd).toEqual('number');
expect(validated.timeEnd).toEqual(0);
expect(validated.timeEnd).toEqual(2);
});
it('handles bad objects', () => {
@@ -580,24 +580,24 @@ describe('test parseExcel function', () => {
[
'Time Start',
'Time End',
'Event Title',
'Presenter Name',
'Event Subtitle',
'Title',
'Presenter',
'Subtitle',
'End Action',
'Timer type',
'Is Public? (x)',
'Skip? (x)',
'Public',
'Skip',
'Notes',
'User0:test0',
'User1:test1',
'User2:test2',
'User3:test3',
'User4:test4',
'User5:test5',
'User6:test6',
'user7:test7',
'user8:test8',
'user9:test9',
'test0',
'test1',
'test2',
'test3',
'test4',
'test5',
'test6',
'test7',
'test8',
'test9',
'Colour',
'cue',
],
@@ -652,6 +652,19 @@ describe('test parseExcel function', () => {
[],
];
const partialOptions = {
user0: 'test0',
user1: 'test1',
user2: 'test2',
user3: 'test3',
user4: 'test4',
user5: 'test5',
user6: 'test6',
user7: 'test7',
user8: 'test8',
user9: 'test9',
};
const expectedParsedProjectData = {
title: 'Test Event',
description: 'test description',
@@ -707,7 +720,7 @@ describe('test parseExcel function', () => {
},
];
const parsedData = await parseExcel(testdata);
const parsedData = parseExcel(testdata, partialOptions);
expect(parsedData.project).toStrictEqual(expectedParsedProjectData);
expect(parsedData.rundown).toBeDefined();
expect(parsedData.rundown[0]).toMatchObject(expectedParsedRundown[0]);
@@ -836,7 +849,16 @@ describe('test views import', () => {
app: 'ontime',
version: 2,
},
viewSettings: {},
viewSettings: {
normalColor: '#ffffffcc',
warningColor: '#FFAB33',
warningThreshold: 120000,
dangerColor: '#ED3333',
dangerThreshold: 60000,
endMessage: '',
overrideStyles: false,
notAthing: true,
},
views: {
overrideStyles: true,
},
@@ -850,7 +872,7 @@ describe('test views import', () => {
endMessage: '',
overrideStyles: false,
};
const parsed = parseViewSettings(testData, false);
const parsed = parseViewSettings(testData);
expect(parsed).toStrictEqual(expectedParsedViewSettings);
});
@@ -862,16 +884,7 @@ describe('test views import', () => {
version: 2,
},
};
const expectedParsedViewSettings = {
normalColor: '#ffffffcc',
warningColor: '#FFAB33',
warningThreshold: 120000,
dangerColor: '#ED3333',
dangerThreshold: 60000,
endMessage: '',
overrideStyles: false,
};
const parsed = parseViewSettings(testData, true);
expect(parsed).toStrictEqual(expectedParsedViewSettings);
const parsed = parseViewSettings(testData);
expect(parsed).toStrictEqual({});
});
});