phase 7: income, payday. and budget handling routes simplified and compacted
All checks were successful
Deploy / deploy (push) Successful in 1m31s
Security Tests / security-non-db (push) Successful in 21s
Security Tests / security-db (push) Successful in 26s

This commit is contained in:
2026-03-17 22:05:17 -05:00
parent 020d55a77e
commit a8e5443b0d
9 changed files with 630 additions and 513 deletions

View File

@@ -3,6 +3,7 @@ import request from "supertest";
import { PrismaClient } from "@prisma/client";
import type { FastifyInstance } from "fastify";
import { resetUser } from "./helpers";
import { randomUUID } from "node:crypto";
// Ensure env BEFORE importing the server
process.env.NODE_ENV = process.env.NODE_ENV || "test";
@@ -12,6 +13,7 @@ process.env.DATABASE_URL =
const prisma = new PrismaClient();
let app: FastifyInstance;
const csrf = randomUUID().replace(/-/g, "");
beforeAll(async () => {
// dynamic import AFTER env is set
@@ -61,6 +63,8 @@ describe("POST /income integration", () => {
const res = await request(app.server)
.post("/income")
.set("x-user-id", "demo-user-1")
.set("x-csrf-token", csrf)
.set("Cookie", `csrf=${csrf}`)
.send({ amountCents: 5000 });
expect(res.status).toBe(200);

View File

@@ -4,8 +4,10 @@ import { describe, it, expect, beforeEach, afterAll, beforeAll } from "vitest";
import appFactory from "./appFactory";
import { prisma, resetUser, ensureUser, U, cid, pid, closePrisma } from "./helpers";
import type { FastifyInstance } from "fastify";
import { randomUUID } from "node:crypto";
let app: FastifyInstance;
const csrf = randomUUID().replace(/-/g, "");
beforeAll(async () => {
app = await appFactory(); // <-- await the app
@@ -51,6 +53,8 @@ describe("POST /income", () => {
const res = await request(app.server)
.post("/income")
.set("x-user-id", U)
.set("x-csrf-token", csrf)
.set("Cookie", `csrf=${csrf}`)
.send({ amountCents: 15000 });
expect(res.statusCode).toBe(200);