From 2cfef4198a5d89048b58619365df377b5abba5f4 Mon Sep 17 00:00:00 2001 From: Rbanh Date: Wed, 18 Feb 2026 20:41:50 -0500 Subject: [PATCH] Add schema regression tests for shorthand symbol model --- tests/schema-regression.test.js | 34 +++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 tests/schema-regression.test.js diff --git a/tests/schema-regression.test.js b/tests/schema-regression.test.js new file mode 100644 index 0000000..38a75a0 --- /dev/null +++ b/tests/schema-regression.test.js @@ -0,0 +1,34 @@ +import test from "node:test"; +import assert from "node:assert/strict"; +import schema from "../frontend/schemeta.schema.json" with { type: "json" }; + +test("schema keeps streamlined symbol shorthand support", () => { + const symbol = schema?.$defs?.symbol; + assert.ok(symbol); + assert.deepEqual(symbol.required, []); + assert.equal(symbol.properties.template_name.type, "string"); + assert.ok(Array.isArray(symbol.examples)); + assert.ok(symbol.examples.some((v) => v.template_name === "resistor")); + assert.ok(symbol.examples.some((v) => v.category === "generic")); +}); + +test("schema supports built-in instance.part shortcuts without explicit symbols", () => { + const instance = schema?.$defs?.instance; + assert.ok(instance); + assert.ok(Array.isArray(instance.anyOf)); + assert.ok(instance.anyOf.some((rule) => Array.isArray(rule.required) && rule.required.includes("symbol"))); + assert.ok(instance.anyOf.some((rule) => Array.isArray(rule.required) && rule.required.includes("part"))); + + const partEnum = instance.properties?.part?.enum ?? []; + assert.ok(partEnum.includes("resistor")); + assert.ok(partEnum.includes("capacitor")); + assert.ok(partEnum.includes("generic")); +}); + +test("schema preserves per-pin UI edit metadata contract", () => { + const pinUi = schema?.$defs?.instance?.properties?.properties?.properties?.pin_ui; + assert.ok(pinUi); + const pinUiEntry = pinUi.additionalProperties; + assert.ok(pinUiEntry); + assert.equal(pinUiEntry.properties.show_net_label.type, "boolean"); +});