mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-26 18:42:49 +00:00
34 lines
1.7 KiB
TypeScript
34 lines
1.7 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-2 🔴 — full one-way USD booking (Other nationality, INTERNATIONAL class, WALLET). This surfaces
|
||
* the money-chain incoherence for non-ETB currencies: the browser sends reviewedTotalMinor = the raw
|
||
* ETB baseFareMinor (125000), but the server stores Booking.totalMinor = the USD display value (1250).
|
||
* The two differ 100× — the client-computed "reviewed total" the C-1 path trusts is in the wrong
|
||
* currency, yet the stored/charged total is the display one. We pin both so a regression is caught.
|
||
*/
|
||
test("UA-2: USD booking — reviewed total (ETB) and stored total (USD) diverge 100x", async ({ page }) => {
|
||
const r = await bookTrip(page, { 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 } });
|
||
|
||
// The browser sent the USD display value the passenger saw as the reviewed total…
|
||
expect(r.reviewedTotalMinor).toBe(r.cardDisplayMinor);
|
||
// …but the booking stored the raw ETB base fare (100× larger, un-converted).
|
||
expect(booking.totalMinor).toBe(r.cardBaseFareMinor);
|
||
expect(booking.totalMinor).toBe(r.reviewedTotalMinor * 100); // 🔴 the divergence
|
||
expect(intent.amountMinor).toBe(booking.totalMinor);
|
||
expect(booking.displayCurrency).toBe("USD");
|
||
expect(booking.status).toBe("CONFIRMED");
|
||
});
|