forked from Yara724/api
invalid image formats after two retries skips
This commit is contained in:
@@ -4,7 +4,7 @@ function setup(product = "third-party") {
|
||||
const service = Object.create(ClaimRequestManagementService.prototype) as any;
|
||||
const claim: any = {
|
||||
_id: "claim-1",
|
||||
fanavaranSync: { attachments: { files: [] } },
|
||||
fanavaranSync: { attachments: { files: [], attempts: [] } },
|
||||
};
|
||||
const events: string[] = [];
|
||||
service.logger = { log: jest.fn(), warn: jest.fn(), error: jest.fn() };
|
||||
@@ -24,17 +24,23 @@ function setup(product = "third-party") {
|
||||
});
|
||||
service.collectFanavaranAttachmentCandidates = jest
|
||||
.fn()
|
||||
.mockImplementation(async () => ({
|
||||
claimCase: claim,
|
||||
candidates: [
|
||||
{
|
||||
fileName: "image.jpg",
|
||||
source: "capture:angle:front",
|
||||
path: "/tmp/image.jpg",
|
||||
alreadySubmitted: claim.fanavaranSync.attachments.files.length > 0,
|
||||
},
|
||||
],
|
||||
}));
|
||||
.mockImplementation(async () => {
|
||||
const waived = service.getWaivedFanavaranAttachmentFileNames(claim);
|
||||
const uploaded = claim.fanavaranSync.attachments.files.length > 0;
|
||||
return {
|
||||
claimCase: claim,
|
||||
candidates: [
|
||||
{
|
||||
fileName: "image.jpg",
|
||||
source: "capture:angle:front",
|
||||
path: "/tmp/image.jpg",
|
||||
alreadySubmitted: uploaded || waived.has("image.jpg"),
|
||||
alreadyWaived: waived.has("image.jpg"),
|
||||
waivedReason: waived.get("image.jpg"),
|
||||
},
|
||||
],
|
||||
};
|
||||
});
|
||||
service.submitFanavaranAttachmentsV2 = jest
|
||||
.fn()
|
||||
.mockImplementation(async () => {
|
||||
@@ -113,6 +119,29 @@ describe("expertise submit completes earlier Fanavaran stages", () => {
|
||||
},
|
||||
);
|
||||
|
||||
it("continues to expertise when an invalid-format image was waived after 2 tries", async () => {
|
||||
const { service, claim, events } = setup();
|
||||
Object.assign(claim, { claimId: 100, dmgCaseId: 200 });
|
||||
claim.fanavaranSync.attachments.attempts.push({
|
||||
fileName: "image.jpg",
|
||||
status: "skipped",
|
||||
error:
|
||||
"FANAVARAN_ATTACHMENT_FORMAT_WAIVED: فرمت فایل معتبر نیست (after 2 attempts); continuing without this file.",
|
||||
});
|
||||
service.submitFanavaranAttachmentsV2.mockImplementation(async () => {
|
||||
events.push("attachments");
|
||||
return {
|
||||
attempted: 0,
|
||||
submitted: 0,
|
||||
skipped: 1,
|
||||
results: [],
|
||||
};
|
||||
});
|
||||
await service.submitFanavaranExpertiseV2("claim-1", "parsian");
|
||||
expect(events).toEqual(["expertise"]);
|
||||
expect(service.submitFanavaranAttachmentsV2).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("stops immediately if the base stage fails", async () => {
|
||||
const { service } = setup();
|
||||
service.executeFanavaranV2Submit.mockRejectedValue(
|
||||
|
||||
Reference in New Issue
Block a user