diff --git a/harness/.pi/extensions/gate/__tests__/builders.test.js b/harness/.pi/extensions/gate/__tests__/builders.test.js index 11c81db0..9d7ec885 100644 --- a/harness/.pi/extensions/gate/__tests__/builders.test.js +++ b/harness/.pi/extensions/gate/__tests__/builders.test.js @@ -15,6 +15,7 @@ const { buildArtifactGate, buildInfoRequest, buildFreetextRequest, + buildSchemaLinkingRequest, withChildLinkage, } = require("../builders.js"); @@ -118,6 +119,17 @@ test("freetext request carries a title and no options", () => { assert.deepEqual(result.reserved, ["back", "exit", "other"]); }); +test("buildSchemaLinkingRequest carries tables + reserved", () => { + const out = buildSchemaLinkingRequest({ + id: "u7", phase: "F4", title: "F4 — Schema linking", + tables: [{ id: "t1", name: "dim_patient", kind: "promote", columns: [] }], + }); + assert.equal(out.widget, "schema-linking"); + assert.equal(out.id, "u7"); + assert.equal(out.tables.length, 1); + assert.deepEqual(out.reserved, ["back", "exit", "other"]); +}); + test("withChildLinkage sets option.opens and returns the option", () => { const child = { widget: "freetext", title: "Motivazione del rifiuto" }; const option = withChildLinkage({ id: "reject", label: "Rifiuta" }, child); diff --git a/harness/.pi/extensions/gate/builders.js b/harness/.pi/extensions/gate/builders.js index 3d70e6c6..b723332d 100644 --- a/harness/.pi/extensions/gate/builders.js +++ b/harness/.pi/extensions/gate/builders.js @@ -156,6 +156,24 @@ function buildFreetextRequest({ id, phase, title }) { }; } +// Build a `schema-linking` ui_request: table rows (promote/exclude) each carrying +// their full catalog columns; the frontend renders rows + a per-table columns +// modal (suggested pre-selected). `tables` is validated shallowly here. +function buildSchemaLinkingRequest({ id, phase, title, tables }) { + requireString(title, "title", "schema-linking"); + const tabs = requireArray(tables, "tables", "schema-linking"); + return { + type: "ui_request", + id, + phase, + schema_version: SCHEMA_VERSION, + widget: "schema-linking", + title, + tables: [...tabs], + reserved: RESERVED, + }; +} + // Attach a child-widget spec to an option (linkage, §4.2). Returns the option. function withChildLinkage(option, widgetSpec) { option.opens = widgetSpec; @@ -168,6 +186,7 @@ module.exports = { buildArtifactGate, buildInfoRequest, buildFreetextRequest, + buildSchemaLinkingRequest, withChildLinkage, SCHEMA_VERSION, RESERVED,