Files
yara724api/src/expert-insurer/qa-reporting-regressions.spec.ts
T
SepehrYahyaee 6b968c0952 fix(workflows): resolve QA blockers and protect case evidence
Fix registrar signing, reviewer re-entry, replacement evidence freshness, owner decision and rating races, multipart objections, vehicle serialization and product reporting.

Validate uploaded media with FFmpeg, serve evidence through expiring signed links, and add targeted regressions plus a dry-run repair for prematurely completed visit cases.
2026-11-22 12:50:22 +03:30

62 lines
2.2 KiB
TypeScript

import { ExpertInsurerService } from "./expert-insurer.service";
import { Types } from "mongoose";
describe("QA reporting regressions", () => {
it("classifies a roster-owned claim by its linked blame even when that blame is outside the party-insurer list", async () => {
const s: any = Object.create(ExpertInsurerService.prototype);
const clientKey = String(new Types.ObjectId()),
expertId = new Types.ObjectId(),
blameId = new Types.ObjectId();
s.expertDbService = { findAll: jest.fn().mockResolvedValue([]) };
s.damageExpertDbService = {
findAll: jest
.fn()
.mockResolvedValue([
{ _id: expertId, firstName: "QA", lastName: "Expert" },
]),
};
s.fieldExpertDbService = { findAll: jest.fn().mockResolvedValue([]) };
s.getClientBlameFiles = jest.fn().mockResolvedValue([]);
s.getClientClaimFiles = jest
.fn()
.mockResolvedValue([
{
_id: new Types.ObjectId(),
blameRequestId: blameId,
createdAt: new Date(),
},
]);
s.expertFileActivityDbService = {
findByTenant: jest.fn().mockResolvedValue([]),
};
s.claimDamageExpertActorId = jest.fn().mockReturnValue(String(expertId));
s.blameRequestDbService = {
find: jest.fn().mockResolvedValue([{ _id: blameId, type: "CAR_BODY" }]),
};
const result = await s.buildExpertReportRows({ clientKey });
expect(result.experts[0]).toMatchObject({
totalFiles: 1,
carBodyFiles: 1,
thirdPartyFiles: 0,
});
expect(s.blameRequestDbService.find).toHaveBeenCalledWith(
{ _id: { $in: [blameId] } },
{ lean: true, select: "type" },
);
});
it("preserves current root user ratings and falls back to legacy nested ratings", () => {
const s: any = Object.create(ExpertInsurerService.prototype);
const current = { overallEvaluation: 5 },
legacy = { overallEvaluation: 1 };
expect(
s.normalizeClaimCase({
userRating: current,
evaluation: { userRating: legacy },
}).userRating,
).toBe(current);
expect(
s.normalizeClaimCase({ evaluation: { userRating: legacy } }).userRating,
).toBe(legacy);
});
});