import { describe, expect, it } from "bun:test"; import { listInstanceFeedbackMineRequestSchema, listInstanceFeedbackMineResponseSchema, } from "./instance-feedback"; import { instanceFeedbackInputSchema } from "./internal/instance-feedback-input"; describe("instanceFeedbackInputSchema", () => { it("accepts canonical category and comment-only evaluations", () => { expect( instanceFeedbackInputSchema.safeParse({ category: "helpfulness", target: { collection: "docs-page", id: "page_1" }, value: false, }).success, ).toBe(true); expect( instanceFeedbackInputSchema.safeParse({ comment: "Please add SSO.", }).success, ).toBe(true); }); it("rejects score-shaped transport fields", () => { expect( instanceFeedbackInputSchema.safeParse({ category: "helpfulness", scoreValue: 1, valence: "positive", }).success, ).toBe(false); }); }); describe("listInstanceFeedbackMineRequestSchema", () => { it("accepts target and category selector batches", () => { expect( listInstanceFeedbackMineRequestSchema.safeParse({ selectors: [ { category: "product_feedback" }, { category: "helpfulness", target: { collection: "docs-page", id: "page_1" }, }, ], }).success, ).toBe(true); }); it("requires one to fifty selectors", () => { expect( listInstanceFeedbackMineRequestSchema.safeParse({ selectors: [] }) .success, ).toBe(false); expect( listInstanceFeedbackMineRequestSchema.safeParse({ selectors: Array.from({ length: 51 }, () => ({ category: "helpfulness", })), }).success, ).toBe(false); }); it("rejects target context that does not participate in matching", () => { expect( listInstanceFeedbackMineRequestSchema.safeParse({ selectors: [ { target: { collection: "docs-page", id: "page_1", properties: { title: "Ignored" }, }, }, ], }).success, ).toBe(false); }); }); describe("listInstanceFeedbackMineResponseSchema", () => { it("accepts nullable evaluations aligned with requested selectors", () => { expect( listInstanceFeedbackMineResponseSchema.safeParse({ items: [ { evaluation: { capturedAt: "2026-07-01T12:00:00.000Z", category: "helpfulness", comment: null, evaluationId: "eval_1", reasons: [], value: false, }, }, { evaluation: null }, ], }).success, ).toBe(true); }); });