Files
perauset-e2e-mrfzptpr/e2e/tests/steps/boats.steps.ts
2026-07-11 08:35:17 +02:00

65 lines
1.9 KiB
TypeScript

import { When } from '@cucumber/cucumber'
import type { PerausetWorld } from '../support/world.js'
When('I create a boat route with name {string} origin {string} destination {string}', async function (this: PerausetWorld, name: string, origin: string, destination: string) {
await this.post('/boats/routes', {
name,
origin,
destination,
})
})
When('I create a boat with name {string} capacity {int}', async function (this: PerausetWorld, name: string, capacity: number) {
await this.post('/boats', {
name,
passengerCapacity: capacity,
})
})
When('I create a boat trip for the route and boat departing {string}', async function (this: PerausetWorld, departureAt: string) {
const routeId = (this as any).routeId
const boatId = (this as any).boatId
await this.post('/boats/trips', {
routeId,
boatId,
scheduledDepartureAt: departureAt,
})
})
When('I open the boat trip', async function (this: PerausetWorld) {
const tripId = (this as any).tripId
await this.post(`/boats/trips/${tripId}/open`, {
tripId,
})
})
When('I request a seat on the boat trip', async function (this: PerausetWorld) {
const tripId = (this as any).tripId
await this.post(`/boats/trips/${tripId}/request-seat`, {
tripId,
requestedSeats: 1,
})
})
When('I confirm the boat request', async function (this: PerausetWorld) {
const boatRequestId = (this as any).boatRequestId
await this.post(`/boats/requests/${boatRequestId}/confirm`, {
requestId: boatRequestId,
})
})
When('I create a boat trip for the route without boat departing {string}', async function (this: PerausetWorld, departureAt: string) {
const routeId = (this as any).routeId
await this.post('/boats/trips', {
routeId,
scheduledDepartureAt: departureAt,
})
})
When('I cancel the boat trip', async function (this: PerausetWorld) {
const tripId = (this as any).tripId
await this.post(`/boats/trips/${tripId}/cancel`, {
tripId,
})
})