Add case identity filters and description validation

This commit is contained in:
SepehrYahyaee
2026-09-27 09:54:56 +03:30
parent 8ac185c861
commit b758346af1
15 changed files with 339 additions and 13 deletions

View File

@@ -26,6 +26,45 @@ describe("applyListQueryV2", () => {
expect(r.list[0].publicId).toBe("A200");
});
it("filters nested party identities and normalizes Persian digits", () => {
const identityRows = [
{
publicId: "PHONE",
createdAt: "2026-01-01",
status: "OPEN",
parties: [
{
person: {
phoneNumber: "0912-123-4567",
nationalCodeOfDriver: "۰۰۱۲۳۴۵۶۷۸",
},
},
],
},
{
publicId: "OTHER",
createdAt: "2026-01-02",
status: "OPEN",
parties: [{ person: { phoneNumber: "09351234567", nationalCode: "1111111111" } }],
},
];
const identityGetters = {
publicId: (r: (typeof identityRows)[0]) => r.publicId,
createdAt: (r: (typeof identityRows)[0]) => r.createdAt,
status: (r: (typeof identityRows)[0]) => r.status,
};
const byPhone = applyListQueryV2(identityRows, identityGetters, {
phoneNumber: "09121234567",
});
expect(byPhone.list.map((row) => row.publicId)).toEqual(["PHONE"]);
const byNationalCode = applyListQueryV2(identityRows, identityGetters, {
nationalCode: "0012345678",
});
expect(byNationalCode.list.map((row) => row.publicId)).toEqual(["PHONE"]);
});
it("sorts by publicId ascending", () => {
const r = applyListQueryV2(rows, getters, {
sortBy: "publicId",