forked from Yara724/api
Preserve damage history and current vehicle price, restore depreciation mapping, normalize inquiry/report output, and support resumable expert review with paginated case retrieval.
73 lines
1.9 KiB
TypeScript
73 lines
1.9 KiB
TypeScript
import {
|
|
buildDamagedPartSelectionRevision,
|
|
serializeDamagedPartSelectionHistory,
|
|
} from "./claim-damaged-part-audit";
|
|
|
|
describe("damaged-part selection audit", () => {
|
|
const hood = {
|
|
id: 101,
|
|
name: "hood",
|
|
side: "front",
|
|
label_fa: "کاپوت",
|
|
catalogKey: "front_hood",
|
|
};
|
|
const door = {
|
|
id: 202,
|
|
name: "door",
|
|
side: "left",
|
|
label_fa: "درب چپ",
|
|
catalogKey: "left_door",
|
|
};
|
|
|
|
it("keeps the removed part capture and serializes it for panel display", () => {
|
|
const revision = buildDamagedPartSelectionRevision({
|
|
revisionId: "revision-1",
|
|
changedAt: new Date("2026-09-18T10:00:00.000Z"),
|
|
changedBy: {
|
|
actorId: "expert-1",
|
|
actorName: "Expert One",
|
|
actorType: "damage_expert",
|
|
},
|
|
previousParts: [hood, door],
|
|
selectedParts: [door],
|
|
previousMedia: [
|
|
{ path: "claims/hood.jpg", fileName: "hood.jpg" },
|
|
{ path: "claims/door.jpg", fileName: "door.jpg" },
|
|
],
|
|
});
|
|
|
|
expect(revision?.removedParts).toEqual([
|
|
expect.objectContaining({
|
|
id: 101,
|
|
capture: expect.objectContaining({ path: "claims/hood.jpg" }),
|
|
}),
|
|
]);
|
|
|
|
const serialized = serializeDamagedPartSelectionHistory({
|
|
history: [revision],
|
|
currentSelectedParts: [door],
|
|
});
|
|
expect(serialized[0].removedParts[0]).toEqual(
|
|
expect.objectContaining({
|
|
id: 101,
|
|
captured: true,
|
|
currentlySelected: false,
|
|
url: expect.stringContaining("claims/hood.jpg"),
|
|
}),
|
|
);
|
|
});
|
|
|
|
it("does not create a revision for an unchanged or order-only submission", () => {
|
|
expect(
|
|
buildDamagedPartSelectionRevision({
|
|
revisionId: "revision-2",
|
|
changedAt: new Date(),
|
|
changedBy: { actorId: "expert-1", actorType: "damage_expert" },
|
|
previousParts: [hood, door],
|
|
selectedParts: [door, hood],
|
|
previousMedia: [],
|
|
}),
|
|
).toBeNull();
|
|
});
|
|
});
|