mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 05:18:11 +00:00
39 lines
1.6 KiB
TypeScript
39 lines
1.6 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();
|
|
});
|
|
|
|
/**
|
|
* Round-trip variant of UA-2: a USD-display round-trip booking must keep the same currency
|
|
* coherence one-way already has — the passenger sees/agrees to a USD amount, but the stored
|
|
* charge basis (currency/totalMinor) stays honestly labeled ETB, for the COMBINED two-leg fare.
|
|
* UA-6 established the round-trip ETB baseline: totalMinor === cardBaseFareMinor * 2.
|
|
*/
|
|
test("round-trip: USD booking — combined two-leg charge basis stays coherently in ETB", async ({ page }) => {
|
|
const r = await bookTrip(page, {
|
|
tripType: "ROUND_TRIP",
|
|
nationality: "Other",
|
|
paymentMethod: "WALLET",
|
|
});
|
|
expect(r.displayCurrency).toBe("USD");
|
|
expect(r.confirmed).toBe(true);
|
|
|
|
const booking = await prisma.booking.findUniqueOrThrow({ where: { id: r.bookingId } });
|
|
const intent = await prisma.paymentIntent.findUniqueOrThrow({ where: { bookingId: r.bookingId } });
|
|
|
|
expect(booking.bookingType).toBe("ROUND_TRIP");
|
|
expect(booking.displayCurrency).toBe("USD");
|
|
|
|
// Stored charge basis: ETB, for the combined two-leg fare — not mislabeled, not single-leg.
|
|
expect(booking.currency).toBe("ETB");
|
|
expect(booking.totalMinor).toBe(r.cardBaseFareMinor * 2);
|
|
|
|
// The charge/intent moves exactly the stored ETB amount; booking is confirmed.
|
|
expect(intent.amountMinor).toBe(booking.totalMinor);
|
|
expect(booking.status).toBe("CONFIRMED");
|
|
});
|