64 lines
2.1 KiB
TypeScript
64 lines
2.1 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
buildAssistantTurnAttemptAddressRuntimeInput,
|
|
buildAssistantTurnAttemptDeepRuntimeInput
|
|
} from "../src/services/assistantTurnAttemptInputBuilder";
|
|
|
|
function buildUserTurn(overrides: Record<string, unknown> = {}) {
|
|
return {
|
|
session: {
|
|
session_id: "asst-1",
|
|
updated_at: "2026-04-11T00:00:00.000Z",
|
|
items: [{ role: "user", text: "msg" }],
|
|
investigation_state: { focus: "settlements_60_62" }
|
|
},
|
|
sessionId: "asst-1",
|
|
userMessageRaw: "where tail",
|
|
userMessage: "where tail",
|
|
runtimeAnalysisContext: {
|
|
as_of_date: "2020-07-31"
|
|
},
|
|
userItem: {
|
|
message_id: "msg-q1"
|
|
},
|
|
...overrides
|
|
} as any;
|
|
}
|
|
|
|
describe("assistant turn attempt input builder", () => {
|
|
it("builds address runtime input from user turn and organization scope", () => {
|
|
const runtimeInput = buildAssistantTurnAttemptAddressRuntimeInput({
|
|
payload: { user_message: "where tail" },
|
|
userTurn: buildUserTurn(),
|
|
sessionOrganizationScope: {
|
|
knownOrganizations: ["Org A"],
|
|
selectedOrganization: "Org A",
|
|
activeOrganization: "Org A"
|
|
}
|
|
});
|
|
|
|
expect(runtimeInput.sessionId).toBe("asst-1");
|
|
expect(runtimeInput.userMessage).toBe("where tail");
|
|
expect(runtimeInput.runtimeAnalysisContext).toEqual({ as_of_date: "2020-07-31" });
|
|
expect(runtimeInput.sessionOrganizationScope).toEqual({
|
|
knownOrganizations: ["Org A"],
|
|
selectedOrganization: "Org A",
|
|
activeOrganization: "Org A"
|
|
});
|
|
});
|
|
|
|
it("builds deep runtime input with investigation state and address meta", () => {
|
|
const runtimeInput = buildAssistantTurnAttemptDeepRuntimeInput({
|
|
payload: { user_message: "where tail" },
|
|
userTurn: buildUserTurn(),
|
|
addressRuntimeMetaForDeep: { attempted: true }
|
|
});
|
|
|
|
expect(runtimeInput.sessionId).toBe("asst-1");
|
|
expect(runtimeInput.questionId).toBe("msg-q1");
|
|
expect(runtimeInput.userMessage).toBe("where tail");
|
|
expect(runtimeInput.addressRuntimeMetaForDeep).toEqual({ attempted: true });
|
|
expect(runtimeInput.sessionInvestigationState).toEqual({ focus: "settlements_60_62" });
|
|
});
|
|
});
|