Skip to content

Commit

Permalink
test: use inbucket to check emails
Browse files Browse the repository at this point in the history
  • Loading branch information
sgomez committed Mar 24, 2024
1 parent 54ec3ae commit 6990f78
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ MAILER_DSN=smtp://localhost:1025
MAIL_FROM=[email protected]
MAILER_SECRET=CHANGE_ME
MAILER_URL=http://localhost:3000/api/mailer/
WEBMAIL_URL=http://localhost:8025/
WEBMAIL_URL=http://localhost:8025/monitor
7 changes: 4 additions & 3 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
services:
smtp:
build: https://github.com/mailhog/MailHog.git#master
image: inbucket/inbucket
ports:
- 1025:1025
- 8025:8025
- 1025:2500
- 8025:9000

db:
image: postgres:12
environment:
Expand Down
4 changes: 2 additions & 2 deletions e2e/global.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ setup('authenticate as user', async ({ page, request }) => {
await page.close()

// Purge WebMail
await request.delete('http://localhost:8025/api/v1/messages')
await request.delete('http://localhost:8025/api/v1/mailbox/noreply')
})

setup('authenticate as admin', async ({ page, request }) => {
Expand All @@ -42,5 +42,5 @@ setup('authenticate as admin', async ({ page, request }) => {
await page.close()

// Purge WebMail
await request.delete('http://localhost:8025/api/v1/messages')
await request.delete('http://localhost:8025/api/v1/mailbox/admin')
})
8 changes: 4 additions & 4 deletions e2e/login/logging.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ test.describe('Do login with email', () => {
await expect(page).toHaveURL('/verify')
await expect(page.locator('body')).toHaveText(/Verifica tu correo/)

const response = await request.get('http://localhost:8025/api/v1/messages')
const response = await request.get(
'http://localhost:8025/api/v1/mailbox/noreply',
)
expect(response.ok()).toBeTruthy()
expect(await response.json()).toEqual(
expect.arrayContaining([
expect.objectContaining({
Raw: expect.objectContaining({ To: [email] }),
}),
expect.objectContaining({ to: expect.arrayContaining([`<${email}>`]) }),
]),
)
})
Expand Down
12 changes: 6 additions & 6 deletions e2e/tests/pages/login.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ class LoginPage {
// Open WebMail
await this.page.getByRole('button', { name: 'Abrir UCOWebMail' }).click()
const webMailPage = await this.page.waitForEvent('popup')
await webMailPage.getByText('[email protected]').first().click()

// Open login link
await webMailPage
.frameLocator('#preview-html')
.getByRole('link', { name: 'VERIFICAR' })
.getByRole('cell', { name: '<[email protected]>' })
.first()
.click()

return await webMailPage.waitForEvent('popup')
// Open login link
await webMailPage.getByRole('link', { name: 'VERIFICAR' }).click()

return webMailPage
}
}

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
"test:ci": "NODE_ENV=test vitest --watch=false",
"test:ui": "NODE_ENV=test vitest --ui --coverage.enabled=true",
"pretest:e2e": "playwright install",
"test:e2e": "NODE_ENV=test playwright test",
"test:e2e": "rimraf playwright && NODE_ENV=test playwright test",
"pretest:e2e:ui": "playwright install",
"test:e2e:ui": "NODE_ENV=test playwright test --ui",
"test:e2e:ui": "rimraf playwright && NODE_ENV=test playwright test --ui",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build",
"prisma:migrate": "prisma migrate dev",
Expand Down

0 comments on commit 6990f78

Please sign in to comment.