mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 02:58:11 +00:00
29 lines
1.4 KiB
TypeScript
29 lines
1.4 KiB
TypeScript
import { test, expect } from "@playwright/test";
|
||
import { resultsUrl } from "../../fixtures/data";
|
||
|
||
/**
|
||
* UA-1b — the first money-chain break. For a non-Ethiopian (USD) search the results card shows the
|
||
* USD-converted `displayAmountMinor`, but the internal `baseFareMinor` stays in raw ETB minor. The
|
||
* two diverge exactly 100× (the USD→ETB rate). The portal stores `Math.min(baseFareMinor)` on select,
|
||
* so the ETB value — not the USD one the passenger saw — is what flows downstream.
|
||
*/
|
||
test("UA-1b: USD card display fare diverges 100x from the internal baseFareMinor", async ({ page }) => {
|
||
const searchDone = page.waitForResponse(
|
||
(r) => r.url().includes("/search") && r.request().method() === "POST",
|
||
);
|
||
await page.goto(resultsUrl({ nationality: "Other" }));
|
||
const out = (await (await searchDone).json())?.data?.outbound?.[0];
|
||
const cls = out?.faresByClass?.[0];
|
||
|
||
expect(out.displayCurrency).toBe("USD");
|
||
// The display fare is the converted USD amount; baseFareMinor is the untouched ETB minor.
|
||
expect(cls.displayAmountMinor).toBeLessThan(cls.baseFareMinor);
|
||
expect(cls.baseFareMinor).toBe(cls.displayAmountMinor * 100);
|
||
|
||
// The DOM shows the USD value (formatFare divides by 100, 2dp) — e.g. "USD 12.50".
|
||
const usdMajor = (cls.displayAmountMinor / 100).toFixed(2);
|
||
await expect(page.getByText(new RegExp(`USD\\s*${usdMajor.replace(".", "\\.")}`)).first()).toBeVisible({
|
||
timeout: 20_000,
|
||
});
|
||
});
|