feat(recurring): düzenli işlem kuralları, planlı kayıt üretimi, onay/atla/ertele ve seri düzenleme

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-05 10:55:05 +03:00
parent eaafe5dd9b
commit 04a17d2775
13 changed files with 1493 additions and 7 deletions
+50
View File
@@ -0,0 +1,50 @@
import { describe, expect, it } from "vitest";
import { recurringRuleFormSchema } from "./recurring";
/** Formun gönderdiği biçim: tüm alanlar string, seçilmeyenler boş. */
const formValues = {
type: "expense",
amount: "1.250,00",
isEstimate: false,
accountId: "a".repeat(24),
toAccountId: "",
categoryId: "b".repeat(24),
payee: "",
description: "",
tags: "",
startDate: "2026-11-05",
frequency: "monthly",
interval: "1",
monthlyMode: "day",
endKind: "never",
count: "",
endDate: "",
};
describe("recurringRuleFormSchema", () => {
it("boş isteğe bağlı alanlarla geçerli; bitiş türüne göre count/endDate ayıklanır", () => {
const x = recurringRuleFormSchema.parse(formValues);
expect(x).toMatchObject({ amount: 125000, interval: 1, count: null, endDate: null });
const c = recurringRuleFormSchema.parse({ ...formValues, endKind: "count", count: "12" });
expect(c.count).toBe(12);
const d = recurringRuleFormSchema.parse({
...formValues,
endKind: "date",
endDate: "2027-01-01",
count: "5",
});
expect(d).toMatchObject({ endDate: "2027-01-01", count: null });
});
it("seçilen bitiş türünün değeri zorunlu", () => {
expect(recurringRuleFormSchema.safeParse({ ...formValues, endKind: "count" }).success).toBe(
false,
);
expect(recurringRuleFormSchema.safeParse({ ...formValues, endKind: "date" }).success).toBe(
false,
);
expect(recurringRuleFormSchema.safeParse({ ...formValues, interval: "13" }).success).toBe(
false,
);
});
});