From 0dfe78cb1490905d8b31ef106fabff47434f9517 Mon Sep 17 00:00:00 2001 From: dcshzj <27919917+dcshzj@users.noreply.github.com> Date: Thu, 7 Nov 2024 16:30:14 +0800 Subject: [PATCH] fix: use lowercase email in tests --- apps/studio/tests/integration/helpers/auth.ts | 13 ++----------- apps/studio/tests/integration/helpers/seed/index.ts | 7 ++++++- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/apps/studio/tests/integration/helpers/auth.ts b/apps/studio/tests/integration/helpers/auth.ts index df12f9ecb6..c84e263cb3 100644 --- a/apps/studio/tests/integration/helpers/auth.ts +++ b/apps/studio/tests/integration/helpers/auth.ts @@ -3,19 +3,10 @@ import cuid2 from "@paralleldrive/cuid2" import { db } from "~server/db" import type { User } from "~server/db" +import { setUpWhitelist } from "./seed" export const auth = async ({ id, ...user }: SetOptional) => { - await db - .insertInto("Whitelist") - .values({ - email: user.email, - }) - .onConflict((oc) => - oc - .column("email") - .doUpdateSet((eb) => ({ email: eb.ref("excluded.email") })), - ) - .executeTakeFirstOrThrow() + await setUpWhitelist({ email: user.email }) if (id !== undefined) { return db diff --git a/apps/studio/tests/integration/helpers/seed/index.ts b/apps/studio/tests/integration/helpers/seed/index.ts index 4dbeb4cdd9..5ba82f1462 100644 --- a/apps/studio/tests/integration/helpers/seed/index.ts +++ b/apps/studio/tests/integration/helpers/seed/index.ts @@ -304,9 +304,14 @@ export const setUpWhitelist = async ({ return db .insertInto("Whitelist") .values({ - email, + email: email.toLowerCase(), expiry: expiry ?? null, }) + .onConflict((oc) => + oc + .column("email") + .doUpdateSet((eb) => ({ email: eb.ref("excluded.email") })), + ) .returningAll() .executeTakeFirstOrThrow() }