fix: repair stale custom widget options
This commit is contained in:
1 parent
03ebb8c2db
commit
c2cf25b4fb
5 files changed
+81
-10
No files matched your search
@@ -5,6 +5,7 @@ import {
|
||||
customWidgetOptionControls,
|
||||
customWidgetOptionSchema,
|
||||
getCustomWidgetDefaultOptions,
|
||||
normalizeCustomWidgetOptions,
|
||||
validateCustomWidgetOptions,
|
||||
} from "../core";
|
||||
|
||||
@@ -69,6 +70,29 @@ describe("lean Custom Widget options", () => {
|
||||
expect(validateCustomWidgetOptions(options, configuration)).toEqual([]);
|
||||
});
|
||||
|
||||
it("replaces stale values with current defaults", () => {
|
||||
const options = customWidgetDefinitionSchema.parse({
|
||||
$schema: "homarr-custom-widget-v2",
|
||||
name: "Updated options",
|
||||
sources: {},
|
||||
requests: {},
|
||||
options: {
|
||||
limit: { label: "Limit", control: "slider", default: 5, min: 1, max: 10 },
|
||||
label: { label: "Label", control: "text", default: "Default" },
|
||||
},
|
||||
template: "<Text>{options.limit}</Text>",
|
||||
}).options;
|
||||
|
||||
const normalized = normalizeCustomWidgetOptions(options, {
|
||||
limit: "5",
|
||||
label: "Custom",
|
||||
removed: true,
|
||||
});
|
||||
|
||||
expect(normalized).toEqual({ limit: 5, label: "Custom" });
|
||||
expect(validateCustomWidgetOptions(options, normalized)).toEqual([]);
|
||||
});
|
||||
|
||||
it("rejects duplicate static choice values", () => {
|
||||
expect(
|
||||
customWidgetOptionSchema.safeParse({
|
||||
|
||||
Reference in new issue
Block a user