import { setWorldConstructor } from "@cucumber/cucumber"; import { BrowserWorld, browserConfigFromEnv, type ClientContext, } from "@pikku/cucumber/browser"; import { PikkuRPC } from "../../../packages/functions-sdk/src/pikku/pikku-rpc.gen.js"; import { PikkuFetch } from "../../../packages/functions-sdk/src/pikku/pikku-fetch.gen.js"; /** The app's generated, fully-typed pikku clients, per actor session. */ interface Clients { rpc: PikkuRPC; fetch: PikkuFetch; } /** * Seminarhof world — the shared @pikku/cucumber BrowserWorld (actors, Mantine * steps, page-issue tracking) plus the seminarhof-specific helpers used by * the project steps. Everything generic lives in the package. */ export class AppWorld extends BrowserWorld { constructor(options?: unknown) { super( options, browserConfigFromEnv({ locale: process.env.E2E_LOCALE ?? "de-DE", // Seeded accounts (db/sqlite-seed.sql) — actors log in by persona. personas: { "the admin": { email: "christina@seminarhof.example", password: "admin1234", name: "Christina Admin", }, "the owner": { email: "sarah@seminarhof.example", password: "owner1234", name: "Sarah Drawehn", }, "the client": { email: "demo@yoga-retreat.example", password: "demo1234", name: "Demo Organiser", }, }, }), ); } protected createClients({ apiUrl, cookieHeader }: ClientContext): Clients { const pikkuFetch = new PikkuFetch(); pikkuFetch.setServerUrl(apiUrl); if (cookieHeader) pikkuFetch.setHeader("Cookie", cookieHeader); const rpc = new PikkuRPC(); rpc.setPikkuFetch(pikkuFetch); return { rpc, fetch: pikkuFetch }; } /** Runs the booking-lifecycle cron once, as the current actor. */ async runLifecycle() { const actor = await this.actor(undefined); const { rpc } = await actor.clients(); return rpc.invoke("runBookingLifecycleNow", {}); } /** "the app data is reset" → the app's own testReset RPC (E2E-gated). */ override async resetAppData() { const actor = await this.actor(undefined); const { rpc } = await actor.clients(); await rpc.invoke("testReset"); } } setWorldConstructor(AppWorld);