test: validate capability property schemas and options

This commit is contained in:
yu committed 2026-11-02 15:55:23 +08:00
1 parent 541908961b
commit f8859fed77
4 files changed
+12569 -800

No files matched your search

+14
View File
@@ -136,6 +136,20 @@ function groupFor(component) {
return "data";
}
function normalizeOptions(value) {
if (Array.isArray(value)) {
return value.map((item) => {
if (typeof item === "string") return { label: item, value: item };
if (typeof item !== "object" || item === null) return null;
const label = String(item.label ?? item.text ?? item.value ?? "");
const rawValue = item.value ?? item.label ?? "";
return { label, value: cleanDefault(rawValue) };
}).filter((item) => item.label || item.value);
}
if (Array.isArray(value?.options)) return normalizeOptions(value.options);
return [];
}
function normalizeVendorField(field) {
const widget = widgetFor(field.displayType, field.widget);
const valueTypes = Array.isArray(field.valueTypes) ? [...field.valueTypes] : [];