Files
edr-platform/e2e-ui/specs/portal/ua11-expired-promo.spec.ts

26 lines
1.1 KiB
TypeScript

import { test, expect } from "@playwright/test";
import { PrismaClient } from "@prisma/client";
import { bookTrip } from "../../fixtures/booking-flow";
import { PROMO_EXPIRED } from "../../fixtures/data";
const prisma = new PrismaClient();
test.afterAll(async () => {
await prisma.$disconnect();
});
/**
* UA-11 — one-way, ETB, an EXPIRED promo injected via ?promoCode=. The expired code must not discount
* anything: the fare breakdown reports no discount and the booked total is the full fare (consistent
* with the UA-8 promo-drop behaviour, but here the promo is correctly rejected as expired).
*/
test("UA-11: an expired promo code is ignored — full fare is booked", async ({ page }) => {
const r = await bookTrip(page, { paymentMethod: "WALLET", promoCode: PROMO_EXPIRED });
expect(r.confirmed).toBe(true);
// No discount from the expired code.
if (r.fareBreakdown) expect(r.fareBreakdown.discountMinor ?? 0).toBe(0);
const booking = await prisma.booking.findUniqueOrThrow({ where: { id: r.bookingId } });
expect(booking.totalMinor).toBe(r.cardBaseFareMinor); // full fare, no discount applied
});