mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-26 18:42:49 +00:00
Adding exact reason why train is not available to users search results
This commit is contained in:
@@ -294,6 +294,37 @@ describe("Reserve seat — issue booking (STAFF / PASSENGER)", () => {
|
||||
expect(byToken.schedule.origin.id).toBe(IDS.stationA);
|
||||
});
|
||||
|
||||
it("PASSENGER path: the seat stays reserved (not publicly available) after the payment link is sent", async () => {
|
||||
// Regression for: unblockSeat() released the reservation's SeatBlock and confirmSeats()
|
||||
// was a no-op with no SeatHold to extend, so the seat had no SeatBlock, no SeatHold, and
|
||||
// no JourneySegment (only created on payment success) the instant the payment link went
|
||||
// out — fully bookable by the general public before the traveler had even paid.
|
||||
await resetAndSeedCore(harness.prisma);
|
||||
const dep = new Date(Date.now() + 3 * 60 * 60_000);
|
||||
const arr = new Date(dep.getTime() + 100 * 60_000);
|
||||
const { schedule, seats } = await createTestSchedule({ trainNumber: `RES-STAYS-BLOCKED-${Date.now()}`, departureAt: dep, arrivalAt: arr });
|
||||
|
||||
await seatsService.blockSeat(seats[0].id, "Reserved pending payment", schedule.id);
|
||||
|
||||
const result: any = await guestBookingService.issueBookingFromReservation(
|
||||
seats[0].id,
|
||||
baseDto({ scheduleId: schedule.id, bookingKind: ReservationBookingKind.PASSENGER, phone: "+253771234567" }) as any,
|
||||
"staff-user-4",
|
||||
);
|
||||
expect(result.booking.status).toBe("PENDING_PAYMENT");
|
||||
|
||||
// A member of the public trying to hold the exact same seat/leg must be rejected —
|
||||
// proves the seat is covered by a real SeatHold (or equivalent), not silently free.
|
||||
await expect(
|
||||
seatsService.holdSeats({
|
||||
scheduleId: schedule.id,
|
||||
originStationId: IDS.stationA,
|
||||
destinationStationId: IDS.stationB,
|
||||
passengers: [{ passengerId: "someone-else", seatId: seats[0].id }],
|
||||
} as any),
|
||||
).rejects.toThrow(/already (held|booked)/i);
|
||||
});
|
||||
|
||||
it("requires a phone number for a PASSENGER booking", async () => {
|
||||
await resetAndSeedCore(harness.prisma);
|
||||
const dep = new Date(Date.now() + 3 * 60 * 60_000);
|
||||
|
||||
Reference in New Issue
Block a user