import { test, expect } from "@playwright/test"; import { PrismaClient } from "@prisma/client"; import { bookTrip } from "../../fixtures/booking-flow"; const prisma = new PrismaClient(); test.afterAll(async () => { await prisma.$disconnect(); }); /** * UA-3w — Djiboutian/DJF, WALLET. DJF is a zero-decimal currency, but the portal renders every fare * through formatFare (always /100, 2dp) → "DJF x.yy". WALLET short-circuits past the charge-currency * conversion, so here we can only assert the display currency is stamped DJF and the chain is intact. */ test("UA-3w: DJF WALLET booking is stamped DJF; reviewed (DJF) vs stored (ETB) diverge", async ({ page }) => { const r = await bookTrip(page, { nationality: "Djiboutian", paymentMethod: "WALLET" }); expect(r.displayCurrency).toBe("DJF"); expect(r.confirmed).toBe(true); const booking = await prisma.booking.findUniqueOrThrow({ where: { id: r.bookingId } }); expect(booking.displayCurrency).toBe("DJF"); // Mirror image of UA-2: here the browser sent the DJF display value as the reviewed total… expect(r.reviewedTotalMinor).toBe(r.cardDisplayMinor); // …while the booking stored the raw ETB base. The chain uses different currencies at each hop. expect(booking.totalMinor).toBe(r.cardBaseFareMinor); expect(booking.status).toBe("CONFIRMED"); }); /** * UA-3 — Djiboutian/DJF paid via a forged gateway settlement. The real telebirr gateway is * unreachable in the test env, so (per the matrix's settlement-injection plan) the booking is created * through the real browser flow and settled by forging the payment.succeeded event. Proves the DJF * booking reaches a CONFIRMED, ticketed state through the gateway (non-WALLET) path. */ test("UA-3: DJF booking settles through a forged gateway payment", async ({ page }) => { const r = await bookTrip(page, { nationality: "Djiboutian", paymentMethod: "TELEBIRR" }); expect(r.displayCurrency).toBe("DJF"); expect(r.confirmed).toBe(true); const booking = await prisma.booking.findUniqueOrThrow({ where: { id: r.bookingId } }); expect(booking.displayCurrency).toBe("DJF"); expect(booking.status).toBe("CONFIRMED"); });