mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-26 18:42:49 +00:00
28 lines
1.2 KiB
TypeScript
28 lines
1.2 KiB
TypeScript
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);
|
|
});
|