70 lines
2.3 KiB
TypeScript
70 lines
2.3 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { buildAssistantDeepTurnSuccessResponse } from "../src/services/assistantDeepTurnResponseBuilder";
|
|
import type { AssistantConversationItem } from "../src/types/assistant";
|
|
|
|
function buildAssistantItem(): AssistantConversationItem {
|
|
return {
|
|
message_id: "msg-1",
|
|
session_id: "asst-1",
|
|
role: "assistant",
|
|
text: "ok",
|
|
reply_type: "factual",
|
|
created_at: "2026-04-10T10:00:00.000Z",
|
|
trace_id: "trace-1",
|
|
debug: null
|
|
};
|
|
}
|
|
|
|
describe("assistant deep turn response builder", () => {
|
|
it("builds canonical assistant message response envelope", () => {
|
|
const assistantItem = buildAssistantItem();
|
|
const response = buildAssistantDeepTurnSuccessResponse({
|
|
sessionId: "asst-1",
|
|
assistantReply: "ответ",
|
|
replyType: "factual",
|
|
conversationItem: assistantItem,
|
|
debug: {
|
|
trace_id: "trace-1",
|
|
prompt_version: "normalizer_v2_0_2",
|
|
schema_version: "normalized_query_v2_0_2",
|
|
fallback_type: "none",
|
|
route_summary: null,
|
|
fragments: [],
|
|
requirements_extracted: [],
|
|
coverage_report: {
|
|
requirements_total: 0,
|
|
requirements_covered: 0,
|
|
requirements_uncovered: [],
|
|
requirements_partially_covered: [],
|
|
clarification_needed_for: [],
|
|
out_of_scope_requirements: []
|
|
},
|
|
routes: [],
|
|
retrieval_status: [],
|
|
retrieval_results: [],
|
|
answer_grounding_check: {
|
|
status: "no_grounded_answer",
|
|
route_subject_match: false,
|
|
missing_requirements: [],
|
|
reasons: [],
|
|
why_included_summary: [],
|
|
selection_reason_summary: []
|
|
},
|
|
dropped_intent_segments: [],
|
|
answer_structure_v11: null,
|
|
investigation_state_snapshot: null,
|
|
normalized: null
|
|
} as any,
|
|
conversation: [assistantItem]
|
|
});
|
|
|
|
expect(response.ok).toBe(true);
|
|
expect(response.session_id).toBe("asst-1");
|
|
expect(response.assistant_reply).toBe("ответ");
|
|
expect(response.reply_type).toBe("factual");
|
|
expect(response.conversation_item.message_id).toBe("msg-1");
|
|
expect(response.conversation).toEqual([assistantItem]);
|
|
expect(response.debug.trace_id).toBe("trace-1");
|
|
});
|
|
});
|