Task: added pagination to records page, removed initial onboarding income from activity chart
Some checks failed
Deploy / deploy (push) Failing after 23s
Security Tests / security-non-db (push) Successful in 20s
Security Tests / security-db (push) Successful in 26s

This commit is contained in:
2026-03-25 22:36:10 -05:00
parent ad82e914fc
commit 1bd550b428
9 changed files with 117 additions and 20 deletions

View File

@@ -21,6 +21,8 @@ afterAll(async () => {
describe("GET /transactions", () => {
let catId: string;
let planId: string;
let tx1Id: string;
let tx2Id: string;
beforeEach(async () => {
await resetUser(U);
@@ -54,23 +56,28 @@ describe("GET /transactions", () => {
});
planId = plan.id;
tx1Id = `t_${Date.now()}_1`;
tx2Id = `t_${Date.now()}_2`;
await prisma.transaction.createMany({
data: [
{
id: `t_${Date.now()}_1`,
id: tx1Id,
userId: U,
occurredAt: new Date("2025-01-03T12:00:00.000Z"),
kind: "variable_spend",
categoryId: catId,
amountCents: 1000n,
note: "Groceries pickup",
},
{
id: `t_${Date.now()}_2`,
id: tx2Id,
userId: U,
occurredAt: new Date("2025-01-10T12:00:00.000Z"),
kind: "fixed_payment",
planId,
amountCents: 2000n,
note: "January rent",
},
],
});
@@ -103,6 +110,32 @@ describe("GET /transactions", () => {
expect(byPlan.status).toBe(200);
expect(byPlan.body.items.every((t: any) => t.planId === planId)).toBe(true);
});
it("searches by category, note, amount, and date", async () => {
const byCategory = await request(app.server)
.get("/transactions?q=grocer")
.set("x-user-id", U);
expect(byCategory.status).toBe(200);
expect(byCategory.body.items.some((t: any) => t.id === tx1Id)).toBe(true);
const byNote = await request(app.server)
.get("/transactions?q=pickup")
.set("x-user-id", U);
expect(byNote.status).toBe(200);
expect(byNote.body.items.some((t: any) => t.id === tx1Id)).toBe(true);
const byAmount = await request(app.server)
.get("/transactions?q=10.00")
.set("x-user-id", U);
expect(byAmount.status).toBe(200);
expect(byAmount.body.items.some((t: any) => t.id === tx1Id)).toBe(true);
const byDate = await request(app.server)
.get("/transactions?q=2025-01-03")
.set("x-user-id", U);
expect(byDate.status).toBe(200);
expect(byDate.body.items.some((t: any) => t.id === tx1Id)).toBe(true);
});
});
describe("POST /transactions", () => {