chore: perauset customer project
This commit is contained in:
22
e2e/tests/steps/roles.steps.ts
Normal file
22
e2e/tests/steps/roles.steps.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { When, Then } from '@cucumber/cucumber'
|
||||
import { strict as assert } from 'assert'
|
||||
import type { PerausetWorld } from '../support/world.js'
|
||||
import { getUserId } from '../support/db.js'
|
||||
|
||||
When('I set roles {string} for user {string}', async function (this: PerausetWorld, roles: string, email: string) {
|
||||
// Look up userId from DB if not already cached
|
||||
let userId = this.createdUsers[email]
|
||||
if (!userId) {
|
||||
userId = getUserId(email)
|
||||
this.createdUsers[email] = userId
|
||||
}
|
||||
const rolesArray = roles.split(',').map((r) => r.trim())
|
||||
await this.put(`/users/${userId}/roles`, { memberRoles: rolesArray })
|
||||
})
|
||||
|
||||
Then('the response body field {string} should contain {string}', function (this: PerausetWorld, field: string, value: string) {
|
||||
assert.ok(this.lastBody, 'No response body')
|
||||
const arr = this.lastBody[field]
|
||||
assert.ok(Array.isArray(arr), `Expected body.${field} to be an array, got: ${JSON.stringify(arr)}`)
|
||||
assert.ok(arr.includes(value), `Expected body.${field} to contain "${value}", got: ${JSON.stringify(arr)}`)
|
||||
})
|
||||
Reference in New Issue
Block a user