Files
edr-platform/e2e-ui/specs/portal/ua1b-usd-divergence.spec.ts

29 lines
1.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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,
});
});