Boarding status update issue fix

This commit is contained in:
Stephanos A
2026-08-05 21:32:23 +03:00
parent 9b62ca6922
commit bf8906f983
2 changed files with 59 additions and 6 deletions

View File

@@ -228,6 +228,24 @@ describe("Ticketing — generate / scanAndBoard / validate / smart-reassign", ()
const ticket = await harness.prisma.ticket.findFirst({ where: { bookingId: booking.id } });
expect(ticket?.validatedAt).toBeTruthy();
expect(ticket?.status).toBe('USED');
});
it("does not allow boarding the same ticket twice", async () => {
const { schedule, seats } = await createTestSchedule({ trainNumber: `TIX-BOARD-REUSE-${Date.now()}`, departureAt: future(60), arrivalAt: future(120) });
const booking = await createOneWayBooking(schedule.id, seats[0].id);
await markSucceeded(booking.id);
await ticketsService.generate(booking.id);
const first = await ticketsService.scanAndBoard(booking.bookingRef, "gate-validator-1");
expect(first.success).toBe(true);
const second = await ticketsService.scanAndBoard(booking.bookingRef, "gate-validator-1");
expect(second.success).toBe(false);
expect(second.error).toMatch(/already used/i);
const ticket = await harness.prisma.ticket.findFirst({ where: { bookingId: booking.id } });
expect(ticket?.status).toBe('USED');
});
it("refuses boarding before the boarding window opens", async () => {