feat(experiments): integrate Condition D/E apparatus
This commit is contained in:
@@ -893,7 +893,7 @@ describe("start-case-experiment-helper.cjs apparatus", () => {
|
||||
startCase: async () => ({ success: true }),
|
||||
},
|
||||
),
|
||||
).rejects.toThrow('Treatment "no21" is only valid with --condition D, not --condition B');
|
||||
).rejects.toThrow('Treatment "no21" is only valid with --condition D or E, not --condition B');
|
||||
});
|
||||
|
||||
it("rejects unknown condition value via CLI", async () => {
|
||||
@@ -984,6 +984,133 @@ describe("start-case-experiment-helper.cjs apparatus", () => {
|
||||
expect(typeof originalOutput.freeformText).toBe("string");
|
||||
});
|
||||
});
|
||||
|
||||
// ── K — Condition E investigability-first apparatus ────────
|
||||
|
||||
describe("K — Condition E investigability-first apparatus", () => {
|
||||
it("--condition E selects the investigability-first prompt rather than deconstruct", async () => {
|
||||
const { runStartCaseExperiment } = require(helperPath);
|
||||
let receivedScenario;
|
||||
|
||||
await runStartCaseExperiment(
|
||||
{ scenario: "Condition E test" },
|
||||
null,
|
||||
{
|
||||
condition: "E",
|
||||
startCase: async (input) => {
|
||||
receivedScenario = input.scenario;
|
||||
return {
|
||||
success: true,
|
||||
situationGraph: { nodes: [], edges: [] },
|
||||
assessment: null,
|
||||
selectedQuestion: null,
|
||||
summary: "test",
|
||||
diagnostics: { validationStatus: "valid" },
|
||||
};
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
expect(receivedScenario).toContain("You are a neutral analyst performing deconstruction of the user's situation");
|
||||
expect(receivedScenario).toContain("Do not create artificial uncertainties to increase their number.");
|
||||
});
|
||||
|
||||
it("--condition E --treatment e-investigability-first is accepted", async () => {
|
||||
const { runStartCaseExperiment } = require(helperPath);
|
||||
|
||||
await runStartCaseExperiment(
|
||||
{ scenario: "Condition E treatment test" },
|
||||
null,
|
||||
{
|
||||
condition: "E",
|
||||
treatment: "e-investigability-first",
|
||||
startCase: async (input) => {
|
||||
return {
|
||||
success: true,
|
||||
situationGraph: { nodes: [], edges: [] },
|
||||
assessment: null,
|
||||
selectedQuestion: null,
|
||||
summary: "test",
|
||||
diagnostics: { validationStatus: "valid" },
|
||||
};
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
// If we reach here without an error, the treatment was accepted
|
||||
});
|
||||
|
||||
it("--condition E produces freeformText output field via CLI mock", async () => {
|
||||
const result = await runHelper(["--condition", "E", "Freeform test"]);
|
||||
expect(result.exitCode).toBe(0);
|
||||
const parsed = parseOutput(result);
|
||||
expect(parsed).toHaveProperty("freeformText");
|
||||
expect(typeof parsed.freeformText).toBe("string");
|
||||
expect(parsed.conditionType).toBe("investigability-first");
|
||||
});
|
||||
|
||||
it("--condition E sets condition to E in output", async () => {
|
||||
const result = await runHelper(["--condition", "E", "Condition E flag test"]);
|
||||
expect(result.exitCode).toBe(0);
|
||||
const parsed = parseOutput(result);
|
||||
expect(parsed.condition).toBe("E");
|
||||
});
|
||||
|
||||
it("--condition E does not return reconstruction field in output", async () => {
|
||||
const result = await runHelper(["--condition", "E", "No reconstruction test"]);
|
||||
expect(result.exitCode).toBe(0);
|
||||
const parsed = parseOutput(result);
|
||||
expect(parsed).not.toHaveProperty("reconstruction");
|
||||
});
|
||||
|
||||
it("--condition E --reconstruction-only sets execution.condition to E", async () => {
|
||||
const result = await runHelper(["--condition", "E", "--reconstruction-only", "Reconstruction only test"]);
|
||||
expect(result.exitCode).toBe(0);
|
||||
const parsed = parseOutput(result);
|
||||
expect(parsed.execution).toBeDefined();
|
||||
expect(parsed.execution.condition).toBe("E");
|
||||
});
|
||||
|
||||
it("--condition E rejects unknown treatment via programmatic API", async () => {
|
||||
const { runStartCaseExperiment } = require(helperPath);
|
||||
|
||||
await expect(
|
||||
runStartCaseExperiment(
|
||||
{ scenario: "Invalid treatment test" },
|
||||
null,
|
||||
{
|
||||
condition: "E",
|
||||
treatment: "invalid-treatment",
|
||||
startCase: async () => ({ success: true }),
|
||||
},
|
||||
),
|
||||
).rejects.toThrow("Invalid treatment: invalid-treatment. Must be one of: e-investigability-first");
|
||||
});
|
||||
|
||||
it("--condition E rejects treatment with non-E condition via programmatic API", async () => {
|
||||
const { runStartCaseExperiment } = require(helperPath);
|
||||
|
||||
await expect(
|
||||
runStartCaseExperiment(
|
||||
{ scenario: "Cross-condition test" },
|
||||
null,
|
||||
{
|
||||
condition: "B",
|
||||
treatment: "e-investigability-first",
|
||||
startCase: async () => ({ success: true }),
|
||||
},
|
||||
),
|
||||
).rejects.toThrow('Treatment "e-investigability-first" is only valid with --condition D or E, not --condition B');
|
||||
});
|
||||
|
||||
it("--condition E exposes non-empty freeformText (mock)", async () => {
|
||||
const result = await runHelper(["--condition", "E", "Freeform content test"]);
|
||||
expect(result.exitCode).toBe(0);
|
||||
const parsed = parseOutput(result);
|
||||
expect(parsed.freeformText.length).toBeGreaterThan(0);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// ── Evidence persistence wrapper tests ─────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user