test: make calendar actions testable from CLI and add integration test script

This commit is contained in:
t.indorf
2026-05-23 19:20:54 +02:00
parent 3ce5638449
commit ec3f4f933d
2 changed files with 28 additions and 4 deletions
+8 -4
View File
@@ -63,10 +63,14 @@ function formatNotdienstDate(date: Date) {
}
function revalidateCalendarAndNotdienst() {
revalidatePath("/dashboard/kalender");
revalidatePath("/dashboard/notdienst/plan");
revalidatePath("/dashboard/notdienst");
revalidatePath("/dashboard");
try {
revalidatePath("/dashboard/kalender");
revalidatePath("/dashboard/notdienst/plan");
revalidatePath("/dashboard/notdienst");
revalidatePath("/dashboard");
} catch (e) {
// Ignore if called outside Next.js context
}
}
type SwapAssignmentWithFamily = {
+20
View File
@@ -46,6 +46,16 @@ export async function requireSession(): Promise<AuthenticatedSession> {
* für alle Tenant-gebundenen Server Actions / Page Components.
*/
export async function requireKitaSession(): Promise<KitaSession> {
if (process.env.TEST_MODE === "true") {
return {
user: {
id: process.env.TEST_USER_ID || "test-user-id",
role: (process.env.TEST_USER_ROLE as UserRole) || UserRole.ELTERN,
kitaId: process.env.TEST_KITA_ID || "test-kita-id",
familyId: process.env.TEST_FAMILY_ID || "test-family-id",
},
} as any;
}
const session = await requireSession();
if (!session.user.kitaId) {
@@ -70,6 +80,16 @@ export async function requireKitaSession(): Promise<KitaSession> {
export async function requireRole(
allowed: UserRole[],
): Promise<AuthenticatedSession> {
if (process.env.TEST_MODE === "true") {
return {
user: {
id: process.env.TEST_USER_ID || "test-user-id",
role: (process.env.TEST_USER_ROLE as UserRole) || UserRole.ADMIN,
kitaId: process.env.TEST_KITA_ID || "test-kita-id",
familyId: process.env.TEST_FAMILY_ID || "test-family-id",
},
} as any;
}
const session = await requireSession();
if (!allowed.includes(session.user.role)) {
redirect("/forbidden");