Skip to content

Commit

Permalink
refactor: remove core dependencies in e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sgomez committed Mar 28, 2024
1 parent 0516283 commit dfcc65a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
13 changes: 13 additions & 0 deletions e2e/tests/helpers/gravatar.ts
Original file line number Diff line number Diff line change
@@ -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`
}
3 changes: 3 additions & 0 deletions e2e/tests/helpers/prisma.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { PrismaClient } from '@prisma/client'

export const prisma = new PrismaClient()
2 changes: 1 addition & 1 deletion e2e/tests/pages/book.page.ts
Original file line number Diff line number Diff line change
@@ -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) {}
Expand Down
4 changes: 2 additions & 2 deletions e2e/tests/pages/settings.page.ts
Original file line number Diff line number Diff line change
@@ -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) {}
Expand Down

0 comments on commit dfcc65a

Please sign in to comment.