This commit is contained in:
commit
59bb5a38a3
132 files changed
+19435
No files matched your search
@@ -0,0 +1,56 @@
|
||||
import type { Prisma } from "@/generated/prisma/client";
|
||||
import { CAMP_ID, getDb } from "@/lib/db";
|
||||
import type { BookingRequest } from "@/lib/booking-service";
|
||||
import type { PlanType } from "@/lib/payment-plan";
|
||||
|
||||
export const db = getDb();
|
||||
export const SECRET = "test-secret-test-secret-test-secret-123";
|
||||
|
||||
/** Leert alle Anwendungstabellen der Testdatenbank. */
|
||||
export async function resetDb(): Promise<void> {
|
||||
await db.$executeRawUnsafe(`TRUNCATE TABLE
|
||||
"Refund", "EmailMessage", "AuditLog", "StripeEvent", "RateLimitBucket",
|
||||
"VoucherRedemption", "SeatReservation", "Installment", "Booking", "Voucher", "Camp",
|
||||
"session", "account", "verification", "twoFactor", "user", "rateLimit"
|
||||
RESTART IDENTITY CASCADE`);
|
||||
}
|
||||
|
||||
export async function setupCamp(data: Prisma.CampUpdateInput = {}): Promise<void> {
|
||||
await db.camp.upsert({
|
||||
where: { id: CAMP_ID },
|
||||
create: { id: CAMP_ID },
|
||||
update: {},
|
||||
});
|
||||
await db.camp.update({
|
||||
where: { id: CAMP_ID },
|
||||
data: {
|
||||
campStartDate: new Date("2027-06-05T00:00:00Z"),
|
||||
testPhaseOverride: null,
|
||||
...data,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
let counter = 0;
|
||||
|
||||
export function bookingRequest(overrides: { planType?: PlanType; voucherCode?: string; email?: string } = {}): BookingRequest {
|
||||
counter++;
|
||||
const planType = overrides.planType ?? "FULL";
|
||||
return {
|
||||
idempotencyKey: crypto.randomUUID(),
|
||||
participant: {
|
||||
firstName: "Test",
|
||||
lastName: `Person ${counter}`,
|
||||
email: overrides.email ?? `test${counter}@example.org`,
|
||||
phone: "+49 30 1234567",
|
||||
country: "Deutschland",
|
||||
notes: undefined,
|
||||
},
|
||||
planType,
|
||||
voucherCode: overrides.voucherCode,
|
||||
consents: { adult: true, terms: true, accommodation: true, privacy: true, installmentMandate: planType !== "FULL" },
|
||||
};
|
||||
}
|
||||
|
||||
/** Mitten in der Early-Bird-Phase. */
|
||||
export const EARLY_BIRD_NOW = new Date("2026-11-15T10:00:00Z");
|
||||
Reference in new issue
Block a user