merge upstream

This commit is contained in:
2026-11-21 12:48:06 +03:30
12 changed files with 202 additions and 29 deletions
@@ -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();
});
});
@@ -221,9 +221,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.",
"شرح حادثه باید حداقل ۳۰ کاراکتر باشد.",
);
}
}
@@ -8724,6 +8724,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 (req.type === BlameRequestType.CAR_BODY && role === PartyRole.FIRST) {
await this.validateCarBodyAccidentCoverage(party, body.accidentDate);