Fix session resume and PSD container configuration
This commit is contained in:
@@ -245,3 +245,61 @@ test("reviewer_schema_linking returns a textResult (not a throw) when a proposed
|
||||
_handler = null;
|
||||
}
|
||||
});
|
||||
|
||||
test("reviewer_schema_linking explains that phase four stays open when joins are missing", async () => {
|
||||
_handler = (_file, args) => {
|
||||
if (args[0] === "phase" && args[1] === "meta")
|
||||
return JSON.stringify({ phases: [{ num: 4, id: "F4" }] });
|
||||
if (args[0] === "phase" && args[1] === "show") return "Fase corrente: 4\n";
|
||||
if (args[0] === "schema" && args[1] === "columns")
|
||||
return JSON.stringify({ ...CATALOG, table: args[2] });
|
||||
if (args[0] === "phase" && args[1] === "advance") {
|
||||
const error = new Error("phase advance failed");
|
||||
error.stderr = "Fase 4: più tabelle promosse richiedono join strutturati";
|
||||
throw error;
|
||||
}
|
||||
return "";
|
||||
};
|
||||
|
||||
try {
|
||||
const gate = require(GATE);
|
||||
const { createFakePi } = require("./fake_pi_runtime.js");
|
||||
const { pi, ctx, tools } = createFakePi();
|
||||
ctx.cwd = "/nonexistent-thothii-test-cwd-open-f4";
|
||||
gate.default(pi);
|
||||
|
||||
ctx.ui.input = async (title) => {
|
||||
const descriptor = JSON.parse(title);
|
||||
return JSON.stringify({
|
||||
id: descriptor.id,
|
||||
kind: "schema-linking",
|
||||
tables: descriptor.tables.map((table) => ({
|
||||
id: table.id,
|
||||
enacted: true,
|
||||
columns: ["cod_paz"],
|
||||
})),
|
||||
});
|
||||
};
|
||||
|
||||
const result = await tools.get("reviewer_schema_linking").def.execute(
|
||||
"call-open-f4",
|
||||
{
|
||||
session: "s1",
|
||||
title: "Schema linking",
|
||||
tables: [
|
||||
{ id: "fact", name: "fact_event", kind: "promote", suggested_columns: ["cod_paz"] },
|
||||
{ id: "patient", name: "dim_patient", kind: "promote", suggested_columns: ["cod_paz"] },
|
||||
],
|
||||
advance: true,
|
||||
},
|
||||
null,
|
||||
null,
|
||||
ctx,
|
||||
);
|
||||
|
||||
assert.match(result.content[0].text, /Fase resta aperta/i);
|
||||
assert.match(result.content[0].text, /join/i);
|
||||
} finally {
|
||||
_handler = null;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
const test = require("node:test");
|
||||
const assert = require("node:assert");
|
||||
const cp = require("node:child_process");
|
||||
const { createRequire } = require("node:module");
|
||||
const path = require("node:path");
|
||||
|
||||
const GATE = path.join(__dirname, "..", "..", "tht-gate.js");
|
||||
|
||||
if (typeof globalThis.require === "undefined") {
|
||||
globalThis.require = createRequire(GATE);
|
||||
}
|
||||
|
||||
test("writing reviewed structured joins closes phase four", async () => {
|
||||
const calls = [];
|
||||
const original = cp.execFileSync;
|
||||
cp.execFileSync = (_file, args) => {
|
||||
calls.push(args.join(" "));
|
||||
if (args[0] === "phase" && args[1] === "show") return "Fase corrente: 4\n";
|
||||
return "";
|
||||
};
|
||||
|
||||
try {
|
||||
const gate = require(GATE);
|
||||
const { createFakePi } = require("./fake_pi_runtime.js");
|
||||
const { pi, ctx, tools } = createFakePi();
|
||||
ctx.cwd = "/nonexistent-thothii-test-cwd";
|
||||
gate.default(pi);
|
||||
|
||||
const result = await tools.get("write_schema_linking").def.execute(
|
||||
"call-write-linking",
|
||||
{
|
||||
session: "s1",
|
||||
schema_linking: {
|
||||
question: "q",
|
||||
candidates: [
|
||||
{ kind: "table", name: "fact_event", decision: "promoted" },
|
||||
{ kind: "table", name: "dim_patient", decision: "promoted" },
|
||||
],
|
||||
joins: [{ from: "fact_event.cod_paz", to: "dim_patient.cod_paz" }],
|
||||
},
|
||||
},
|
||||
null,
|
||||
null,
|
||||
ctx,
|
||||
);
|
||||
|
||||
assert.ok(calls.includes("session set-schema-linking s1 --file -"));
|
||||
assert.ok(calls.includes("phase advance --session s1"));
|
||||
assert.match(result.content[0].text, /Fase avanzata automaticamente/);
|
||||
} finally {
|
||||
cp.execFileSync = original;
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user