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:
@@ -347,7 +347,7 @@ describe('getOverriddenConfig', () => {
|
||||
const manager = new ConditionsManager(createCardAPI());
|
||||
manager.setState({ fullscreen: true });
|
||||
|
||||
expect(
|
||||
expect(() =>
|
||||
getOverriddenConfig(manager, config, {
|
||||
configOverrides: [
|
||||
{
|
||||
@@ -364,40 +364,7 @@ describe('getOverriddenConfig', () => {
|
||||
],
|
||||
schema: testSchema,
|
||||
}),
|
||||
).toEqual(config);
|
||||
});
|
||||
|
||||
it('failing and logging', () => {
|
||||
const consoleSpy = vi.spyOn(global.console, 'warn').mockReturnValue(undefined);
|
||||
|
||||
const manager = new ConditionsManager(createCardAPI());
|
||||
manager.setState({ fullscreen: true });
|
||||
|
||||
expect(
|
||||
getOverriddenConfig(manager, config, {
|
||||
configOverrides: [
|
||||
{
|
||||
conditions: [
|
||||
{
|
||||
condition: 'fullscreen' as const,
|
||||
fullscreen: true,
|
||||
},
|
||||
],
|
||||
set: {
|
||||
'menu.style': 'NOT_A_STYLE',
|
||||
},
|
||||
},
|
||||
],
|
||||
schema: testSchema,
|
||||
logOnParseError: true,
|
||||
}),
|
||||
).toEqual(config);
|
||||
|
||||
expect(consoleSpy).toBeCalledWith(
|
||||
'Cannot parse overridden configuration',
|
||||
expect.anything(),
|
||||
expect.anything(),
|
||||
);
|
||||
).toThrowError(/Invalid override configuration/);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -218,6 +218,24 @@ describe('ConfigManager', () => {
|
||||
expect(manager.getConfig()).not.toEqual(manager.getNonOverriddenConfig());
|
||||
});
|
||||
|
||||
it('should set error on invalid override', () => {
|
||||
const api = createCardAPI();
|
||||
const manager = new ConfigManager(api);
|
||||
manager.setConfig({
|
||||
type: 'custom:frigate-card',
|
||||
cameras: [{ camera_entity: 'camera.office' }],
|
||||
});
|
||||
|
||||
const error = new Error('Invalid override configuration');
|
||||
vi.mocked(getOverriddenConfig).mockImplementation(() => {
|
||||
throw error;
|
||||
});
|
||||
|
||||
manager.computeOverrideConfig();
|
||||
|
||||
expect(api.getMessageManager().setErrorIfHigherPriority).toBeCalledWith(error);
|
||||
});
|
||||
|
||||
describe('should uninitialize on override', () => {
|
||||
it('cameras', () => {
|
||||
const api = createCardAPI();
|
||||
|
||||
Reference in New Issue
Block a user