(email: string)
| 14 | const NEW_PASSWORD = "BrandNewPwd456!"; |
| 15 | |
| 16 | async function fetchResetToken(email: string): Promise<string> { |
| 17 | const ctx = await request.newContext({ baseURL: E2E_API_BASE_URL }); |
| 18 | const res = await ctx.post("/api/v1/auth/__test/issue-reset-token", { |
| 19 | data: { email } |
| 20 | }); |
| 21 | |
| 22 | if (!res.ok()) { |
| 23 | throw new Error( |
| 24 | `issue-reset-token failed (${String(res.status())}): ${await res.text()}` |
| 25 | ); |
| 26 | } |
| 27 | |
| 28 | const body = await parseBody( |
| 29 | res, |
| 30 | z.object({ data: z.object({ token: z.string().optional() }).optional() }) |
| 31 | ); |
| 32 | const token = body.data?.token; |
| 33 | |
| 34 | await ctx.dispose(); |
| 35 | |
| 36 | if (typeof token !== "string" || token === "") { |
| 37 | throw new Error("expected raw reset token in response"); |
| 38 | } |
| 39 | |
| 40 | return token; |
| 41 | } |
| 42 | |
| 43 | test.describe("Password reset", () => { |
| 44 | /* |
no test coverage detected