From 7584d2d7a7110aef0331ebfa178b2295842c59fa Mon Sep 17 00:00:00 2001 From: MCMXC <16797721+mcmxcdev@users.noreply.github.com> Date: Sat, 10 Feb 2024 18:19:14 -0700 Subject: refactor: project maintenance - work in progress --- tests/functional/dashboard/login.spec.ts | 62 ++++++++++++++------------------ 1 file changed, 27 insertions(+), 35 deletions(-) (limited to 'tests/functional/dashboard/login.spec.ts') diff --git a/tests/functional/dashboard/login.spec.ts b/tests/functional/dashboard/login.spec.ts index adae66a..cf482cd 100644 --- a/tests/functional/dashboard/login.spec.ts +++ b/tests/functional/dashboard/login.spec.ts @@ -1,65 +1,57 @@ -import { test } from '@japa/runner'; -import UserFactory from 'Database/factories/UserFactory'; +import { test } from '@japa/runner' +import UserFactory from '#database/factories/UserFactory' test.group('Dashboard / Login page', () => { test('returns a 200 opening the login route', async ({ client }) => { - const response = await client.get('/user/login'); + const response = await client.get('/user/login') - response.assertStatus(200); - }); + response.assertStatus(200) + }) - test('returns `invalid mail or password` when validation fails', async ({ - client, - }) => { + test('returns `invalid mail or password` when validation fails', async ({ client }) => { const response = await client.post('/user/login').fields({ mail: 'invalid', password: 'invalid', - }); + }) - response.assertRedirectsTo('/user/login'); - response.assertTextIncludes('Invalid mail or password'); - }); + response.assertRedirectsTo('/user/login') + response.assertTextIncludes('Invalid mail or password') + }) - test('returns `invalid mail or password` when account is not found', async ({ - client, - }) => { + test('returns `invalid mail or password` when account is not found', async ({ client }) => { const response = await client.post('/user/login').fields({ mail: 'test+notexistingpassword@ferdium.org', password: 'notexistingpassword', - }); + }) - response.assertRedirectsTo('/user/login'); - response.assertTextIncludes('Invalid mail or password'); - }); + response.assertRedirectsTo('/user/login') + response.assertTextIncludes('Invalid mail or password') + }) - test('returns `invalid mail or password` when password is not valid', async ({ - client, - }) => { + test('returns `invalid mail or password` when password is not valid', async ({ client }) => { await UserFactory.merge({ email: 'test@ferdium.org', - }).create(); + }).create() const response = await client.post('/user/login').fields({ mail: 'test+invalid_password@ferdium.org', password: 'invalid_password', - }); + }) - response.assertRedirectsTo('/user/login'); - response.assertTextIncludes('Invalid mail or password'); - }); + response.assertRedirectsTo('/user/login') + response.assertTextIncludes('Invalid mail or password') + }) - test('redirects to account page when user is able to login', async ({ - client, - }) => { + test('redirects to account page when user is able to login', async ({ client }) => { await UserFactory.merge({ email: 'test+password@ferdium.org', - }).create(); + }).create() const response = await client.post('/user/login').fields({ mail: 'test+password@ferdium.org', password: 'password', - }); + }) - response.assertRedirectsTo('/user/account'); - }); -}); + response.assertRedirectsTo('/user/account') + }) +}) -- cgit v1.2.3-70-g09d2