chore: perauset customer project
This commit is contained in:
57
e2e/tests/steps/stays.steps.ts
Normal file
57
e2e/tests/steps/stays.steps.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
import { When, Given } from '@cucumber/cucumber'
|
||||
import type { PerausetWorld } from '../support/world.js'
|
||||
import { openDb } from '../support/db.js'
|
||||
|
||||
When('I submit a stay request with type {string} from {string} to {string}', async function (this: PerausetWorld, requestType: string, startAt: string, endAt: string) {
|
||||
await this.post('/stays/requests', {
|
||||
requestType,
|
||||
requestedStartAt: startAt,
|
||||
requestedEndAt: endAt,
|
||||
})
|
||||
})
|
||||
|
||||
When('I approve the stay request', async function (this: PerausetWorld) {
|
||||
const requestId = (this as any).requestId
|
||||
await this.post(`/stays/requests/${requestId}/approve`, {
|
||||
requestId,
|
||||
})
|
||||
})
|
||||
|
||||
When('I reject the stay request with reason {string}', async function (this: PerausetWorld, reason: string) {
|
||||
const requestId = (this as any).requestId
|
||||
await this.post(`/stays/requests/${requestId}/reject`, {
|
||||
requestId,
|
||||
reviewNotes: reason,
|
||||
})
|
||||
})
|
||||
|
||||
When('I create a stay from the approved request', async function (this: PerausetWorld) {
|
||||
const requestId = (this as any).requestId
|
||||
await this.post('/stays', {
|
||||
requestId,
|
||||
})
|
||||
})
|
||||
|
||||
Given('the stay is confirmed in the database', async function (this: PerausetWorld) {
|
||||
const stayId = (this as any).stayId
|
||||
const db = openDb()
|
||||
try {
|
||||
db.prepare(`UPDATE stay SET status = 'confirmed' WHERE stay_id = ?`).run(stayId)
|
||||
} finally {
|
||||
db.close()
|
||||
}
|
||||
})
|
||||
|
||||
When('I check in the stay', async function (this: PerausetWorld) {
|
||||
const stayId = (this as any).stayId
|
||||
await this.post(`/stays/${stayId}/check-in`, {
|
||||
stayId,
|
||||
})
|
||||
})
|
||||
|
||||
When('I check out the stay', async function (this: PerausetWorld) {
|
||||
const stayId = (this as any).stayId
|
||||
await this.post(`/stays/${stayId}/check-out`, {
|
||||
stayId,
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user