diff --git a/e2e/tests/helpers/gravatar.ts b/e2e/tests/helpers/gravatar.ts new file mode 100644 index 0000000..021914f --- /dev/null +++ b/e2e/tests/helpers/gravatar.ts @@ -0,0 +1,13 @@ +import { createHash } from 'crypto' + +export function gravatar(email: string | null) { + if (!email) { + return `http://www.gravatar.com/avatar` + } + + const hash = createHash('sha256') + .update(email.trim().toLowerCase()) + .digest('hex') + + return `https://gravatar.com/avatar/${hash}.jpg` +} diff --git a/e2e/tests/helpers/prisma.ts b/e2e/tests/helpers/prisma.ts new file mode 100644 index 0000000..6260dd0 --- /dev/null +++ b/e2e/tests/helpers/prisma.ts @@ -0,0 +1,3 @@ +import { PrismaClient } from '@prisma/client' + +export const prisma = new PrismaClient() diff --git a/e2e/tests/pages/book.page.ts b/e2e/tests/pages/book.page.ts index b351c3d..22e4f68 100644 --- a/e2e/tests/pages/book.page.ts +++ b/e2e/tests/pages/book.page.ts @@ -1,7 +1,7 @@ import { Page } from '@playwright/test' import { ulid } from 'ulid' -import { prisma } from '@/lib/prisma/prisma' +import { prisma } from '../helpers/prisma' export class BookPage { constructor(private readonly page: Page) {} diff --git a/e2e/tests/pages/settings.page.ts b/e2e/tests/pages/settings.page.ts index 6333b28..c49b79f 100644 --- a/e2e/tests/pages/settings.page.ts +++ b/e2e/tests/pages/settings.page.ts @@ -1,7 +1,7 @@ import { Page } from '@playwright/test' -import { prisma } from '@/lib/prisma/prisma' -import { gravatar } from '@/lib/utils/gravatar' +import { gravatar } from '../helpers/gravatar' +import { prisma } from '../helpers/prisma' export class SettingsPage { constructor(private readonly page: Page) {}