Skip to content

Commit

Permalink
fix: use lowercase email in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dcshzj committed Nov 7, 2024
1 parent 4ee237c commit 0dfe78c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
13 changes: 2 additions & 11 deletions apps/studio/tests/integration/helpers/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<User, "id">) => {
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
Expand Down
7 changes: 6 additions & 1 deletion apps/studio/tests/integration/helpers/seed/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

0 comments on commit 0dfe78c

Please sign in to comment.