forked from Yara724/api
fix: recover saved photo uploads and lower car-body description minimum
Read saved document status from maps and plain objects, acknowledge verified document retries without replacing stored images, and preserve upload authorization and resend behavior. Lower the car-body narrative minimum to 30 characters with Persian errors and boundary regression coverage.
This commit is contained in:
@@ -53,7 +53,7 @@ export class FirstPartyFileDto {
|
||||
export class DescriptionDto {
|
||||
@ApiPropertyOptional({
|
||||
description:
|
||||
"Accident description. Optional for THIRD_PARTY; CAR_BODY requires at least 100 non-whitespace characters.",
|
||||
"Accident description. Optional for THIRD_PARTY; CAR_BODY requires at least 30 characters after trimming.",
|
||||
})
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@@ -101,7 +101,7 @@ export class DescriptionDto {
|
||||
export class DescriptionV4Dto {
|
||||
@ApiPropertyOptional({
|
||||
description:
|
||||
"Accident description. Optional for THIRD_PARTY; CAR_BODY requires at least 100 non-whitespace characters.",
|
||||
"Accident description. Optional for THIRD_PARTY; CAR_BODY requires at least 30 characters after trimming.",
|
||||
})
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
|
||||
@@ -68,10 +68,15 @@ describe("RequestManagementService V4 FileMaker workflow", () => {
|
||||
const prefix = party.role === PartyRole.FIRST ? "FIRST" : "SECOND";
|
||||
expect(request.workflow.currentStep).toBe(`${prefix}_DESCRIPTION`);
|
||||
const description = {
|
||||
desc: "شرح حادثه ".repeat(15),
|
||||
desc: type === BlameRequestType.CAR_BODY ? "ش".repeat(30) : "شرح حادثه ".repeat(15),
|
||||
accidentDate: "2025-01-01",
|
||||
accidentTime: "10:30",
|
||||
};
|
||||
if (flow === 4 && type === BlameRequestType.CAR_BODY) {
|
||||
await expect(service.addPartyDescriptionV4(
|
||||
String(request._id), actor, { ...description, desc: "ش".repeat(29) }, party.role,
|
||||
)).rejects.toThrow("شرح حادثه باید حداقل ۳۰ کاراکتر باشد.");
|
||||
}
|
||||
if (flow === 4)
|
||||
await service.addPartyDescriptionV4(
|
||||
String(request._id),
|
||||
|
||||
@@ -23,3 +23,20 @@ describe("RequestManagementService CAR_BODY insurer client", () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe("CAR_BODY description minimum", () => {
|
||||
const service = Object.create(RequestManagementService.prototype) as any;
|
||||
|
||||
it.each([30, 31, 99, 100])("accepts %s trimmed characters", length => {
|
||||
expect(() => service.assertCarBodyDescriptionMinimum("CAR_BODY", ` ${"ش".repeat(length)} `)).not.toThrow();
|
||||
});
|
||||
|
||||
it.each([undefined, "", " ", "ش".repeat(29), ` ${"ش".repeat(29)} `])("rejects a short description with a Persian 30-character message", description => {
|
||||
expect(() => service.assertCarBodyDescriptionMinimum("CAR_BODY", description)).toThrow("شرح حادثه باید حداقل ۳۰ کاراکتر باشد.");
|
||||
});
|
||||
|
||||
it("preserves optional third-party descriptions", () => {
|
||||
expect(() => service.assertCarBodyDescriptionMinimum("THIRD_PARTY", "")).not.toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -220,9 +220,9 @@ export class RequestManagementService {
|
||||
): void {
|
||||
if (requestType !== BlameRequestType.CAR_BODY) return;
|
||||
const length = String(description ?? "").trim().length;
|
||||
if (length < 100) {
|
||||
if (length < 30) {
|
||||
throw new BadRequestException(
|
||||
"CAR_BODY description must contain at least 100 non-whitespace characters.",
|
||||
"شرح حادثه باید حداقل ۳۰ کاراکتر باشد.",
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -8627,6 +8627,8 @@ export class RequestManagementService {
|
||||
const idx = this.getPartyIndex(req, role);
|
||||
if (idx === -1) throw new BadRequestException(`${role} party not found`);
|
||||
|
||||
this.assertCarBodyDescriptionMinimum(req.type, body.desc);
|
||||
|
||||
const party = req.parties[idx];
|
||||
if (!party.statement) party.statement = {} as any;
|
||||
party.statement.description = body.desc;
|
||||
|
||||
Reference in New Issue
Block a user