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
@@ -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/);
});
});
});