fix(settings): handle boolean values for indicateTypos (@fehmer) (#6554)

Handle legacy values for indicateTypos.

Fixes FRONTEND-MJ
This commit is contained in:
Christian Fehmer 2025-05-11 11:30:01 +02:00 committed by GitHub
parent 44a67db9fc
commit 71fc96d6b5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 26 additions and 12 deletions

View file

@ -80,8 +80,8 @@ describe("config.ts", () => {
);
});
});
it("should convert legacy values", () => {
const testCases = [
describe("should convert legacy values", () => {
it.for([
{ given: { quickTab: true }, expected: { quickRestart: "tab" } },
{ given: { smoothCaret: true }, expected: { smoothCaret: "medium" } },
{ given: { smoothCaret: false }, expected: { smoothCaret: "off" } },
@ -140,18 +140,27 @@ describe("config.ts", () => {
expected: { liveAccStyle: "mini" },
},
{ given: { soundVolume: "0.5" }, expected: { soundVolume: 0.5 } },
];
//WHEN
testCases.forEach((test) => {
{ given: { funbox: "none" }, expected: { funbox: [] } },
{
given: { funbox: "58008#read_ahead" },
expected: { funbox: ["58008", "read_ahead"] },
},
{
given: { customLayoutfluid: "qwerty#qwertz" },
expected: { customLayoutfluid: ["qwerty", "qwertz"] },
},
{ given: { indicateTypos: false }, expected: { indicateTypos: "off" } },
{
given: { indicateTypos: true },
expected: { indicateTypos: "replace" },
},
])(`$given`, ({ given, expected }) => {
const description = `given: ${JSON.stringify(
test.given
)}, expected: ${JSON.stringify(test.expected)} `;
given
)}, expected: ${JSON.stringify(expected)} `;
const result = migrateConfig(test.given);
expect(result, description).toEqual(
expect.objectContaining(test.expected)
);
const result = migrateConfig(given);
expect(result, description).toEqual(expect.objectContaining(expected));
});
});
});

View file

@ -131,5 +131,10 @@ export function replaceLegacyValues(
) as ConfigSchemas.CustomLayoutFluid;
}
if (typeof configObj.indicateTypos === "boolean") {
configObj.indicateTypos =
configObj.indicateTypos === false ? "off" : "replace";
}
return configObj;
}