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-4 — one-way, 1 adult + 1 child under 5, ETB, WALLET. The "first child per adult" policy makes * the child free: the booked total is exactly one adult fare and the free child is not seated. */ test("UA-4: first child under 5 travels free, total = one adult fare", async ({ page }) => { const r = await bookTrip(page, { adults: 1, children: 1, paymentMethod: "WALLET" }); expect(r.confirmed).toBe(true); // The child is free → the browser sent one adult fare as the reviewed total. expect(r.reviewedTotalMinor).toBe(r.cardBaseFareMinor); const booking = await prisma.booking.findUniqueOrThrow({ where: { id: r.bookingId } }); expect(booking.totalMinor).toBe(r.cardBaseFareMinor); // The free first-child is filtered out of the booked passengers → only the adult is seated. const seats = await prisma.bookingSeat.findMany({ where: { bookingId: r.bookingId } }); expect(seats.length).toBe(1); });