You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.5 KiB
50 lines
1.5 KiB
import { describe, expect, it } from "vitest";
|
|
import type { QuoteRecord } from "@prisma/client";
|
|
import {
|
|
MS_NEEDS_DETAILS_ERROR_CODE,
|
|
MS_NEEDS_DETAILS_MESSAGE,
|
|
} from "@/lib/constants/ms-refine-hold";
|
|
import { serializeQuoteDetail } from "@/modules/quote/quote-serializer";
|
|
|
|
function baseRecord(overrides: Partial<QuoteRecord> = {}): QuoteRecord {
|
|
return {
|
|
id: 1,
|
|
quoteId: "Q-MS-ND-001",
|
|
requestId: "req-nd-1",
|
|
customerId: "cust-1",
|
|
cargoHash: "hash",
|
|
status: "done",
|
|
sourceType: "rpa",
|
|
isRealtime: true,
|
|
confidenceScore: 0.95,
|
|
currency: "USD",
|
|
pickupJson: {},
|
|
deliveryJson: {},
|
|
weightLb: 100,
|
|
dimLIn: 48,
|
|
dimWIn: 40,
|
|
dimHIn: 48,
|
|
palletCount: 1,
|
|
cargoType: "general_freight",
|
|
quotesJson: [],
|
|
markupPercent: 0,
|
|
validUntil: new Date(Date.now() + 180_000),
|
|
errorCode: MS_NEEDS_DETAILS_ERROR_CODE,
|
|
errorMessage: MS_NEEDS_DETAILS_MESSAGE,
|
|
isDeleted: false,
|
|
createdAt: new Date("2026-07-29T00:00:00Z"),
|
|
updatedAt: new Date("2026-07-29T00:00:00Z"),
|
|
...overrides,
|
|
} as QuoteRecord;
|
|
}
|
|
|
|
describe("MS_NEEDS_DETAILS quote detail", () => {
|
|
it("serializes done + empty quotes + informational error", () => {
|
|
const detail = serializeQuoteDetail(baseRecord());
|
|
expect(detail.status).toBe("done");
|
|
expect(detail.error_code).toBe(MS_NEEDS_DETAILS_ERROR_CODE);
|
|
expect(detail.error_message).toBe(MS_NEEDS_DETAILS_MESSAGE);
|
|
expect(detail.quotes).toEqual([]);
|
|
});
|
|
});
|