import assert from "node:assert/strict"; import type { DataTable } from "@cucumber/cucumber"; import { Given, Then, When } from "@cucumber/cucumber"; import { signup } from "../../src/modules/auth/auth.service.js"; import type { CustomWorld } from "../support/world.js"; Given("a profile already exists with email {string}", async (email: string) => { await signup({ firstName: "Existing", lastName: "User", email, password: "some-existing-password", }); }); Given( "a profile already exists with email {string} and password {string}", async (email: string, password: string) => { await signup({ firstName: "Existing", lastName: "User", email, password }); }, ); When("I sign up with the following details:", async function (this: CustomWorld, table: DataTable) { const details = table.rowsHash(); this.response = await this.agent.post("/auth/signup").send({ firstName: details.firstName, lastName: details.lastName, email: details.email, password: details.password, }); }); When( "I log in with email {string} and password {string}", async function (this: CustomWorld, email: string, password: string) { this.response = await this.agent.post("/auth/login").send({ email, password }); }, ); Then("I am authenticated as {string}", async function (this: CustomWorld, email: string) { const res = await this.agent.get("/auth/me"); assert.equal(res.status, 200); assert.equal(res.body.email, email); });