Files
edr-platform/e2e-ui/specs/portal/ua6-round-trip.spec.ts

36 lines
1.8 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-6 🔴 — round-trip return leg is UNBOOKABLE. A ROUND_TRIP search returns an inbound (C→A) leg
* that reports seat availability, but its `coachTypes`/`faresByClass` come back EMPTY: the fare engine
* cannot price the reverse direction on this route (the segment runs high→low stop sequence, so the
* distance resolves non-positive and every class is dropped). With no priced coach the portal renders
* no coach option, so the round-trip wizard cannot advance past inbound selection — the full-UI
* round-trip booking flow is blocked. This test pins the gap through the portal's own search call.
*
* When reverse-leg pricing is fixed (priced inbound coachTypes), replace this with the full
* two-leg booking flow: `bookTrip(page, { tripType: "ROUND_TRIP" })` asserting total = 2× base fare
* and one seat per leg.
*/
test("UA-6: round-trip inbound leg has availability but no priced coach (booking blocked)", async ({
page,
}) => {
const searchDone = page.waitForResponse(
(r) => r.url().includes("/search") && r.request().method() === "POST",
);
await page.goto(resultsUrl({ tripType: "ROUND_TRIP" }));
const data = (await (await searchDone).json())?.data;
expect(data.journeyType).toBe("ROUND_TRIP");
const inbound = data.inbound?.[0];
expect(inbound).toBeTruthy();
// The return leg exists and shows availability…
expect(inbound.hasAvailability).toBe(true);
expect(Object.values(inbound.availabilityByClass ?? {}).some((n) => Number(n) > 0)).toBe(true);
// …but no coach type is priced, so nothing is selectable in the UI. 🔴
expect(inbound.coachTypes ?? []).toHaveLength(0);
expect(inbound.faresByClass ?? []).toHaveLength(0);
});