fix: Unparseable config when using the low-performance profile (#1570)

* The `low-performance` profile itself had parse errors: fix them!
* Do not silently swallow override parse errors, they are always a user issue
* Minor error message rendering improvements to show multiple pieces of context
This commit is contained in:
Dermot Duffy
2024-09-22 15:08:37 -07:00
committed by GitHub
parent a4417e8a3d
commit 766f3422a9
20 changed files with 137 additions and 88 deletions
+15 -1
View File
@@ -1,7 +1,10 @@
import { expect, it } from 'vitest';
import { SCRUBBING_PROFILE } from '../../../src/config/profiles/scrubbing';
import { setProfiles } from '../../../src/config/profiles';
import { frigateCardConfigSchema } from '../../../src/config/types';
import { createRawConfig } from '../../test-utils';
it('scrubbing profile', () => {
it('should contain expected defaults', () => {
expect(SCRUBBING_PROFILE).toEqual({
'live.controls.timeline.mode': 'below',
'live.controls.timeline.style': 'ribbon',
@@ -11,3 +14,14 @@ it('scrubbing profile', () => {
'media_viewer.controls.timeline.pan_mode': 'seek',
});
});
it('should be parseable after application', () => {
const rawInputConfig = createRawConfig();
const parsedConfig = frigateCardConfigSchema.parse(rawInputConfig);
setProfiles(rawInputConfig, parsedConfig, ['low-performance']);
// Reparse the config to ensure the profile did not introduce errors.
const parseResult = frigateCardConfigSchema.safeParse(parsedConfig);
expect(parseResult.success, parseResult.error?.toString()).toBeTruthy();
});