aboutsummaryrefslogtreecommitdiffstats
path: root/tests/functional/dashboard/logout.spec.ts
diff options
context:
space:
mode:
Diffstat (limited to 'tests/functional/dashboard/logout.spec.ts')
-rw-r--r--tests/functional/dashboard/logout.spec.ts26
1 files changed, 14 insertions, 12 deletions
diff --git a/tests/functional/dashboard/logout.spec.ts b/tests/functional/dashboard/logout.spec.ts
index ad117da..440a054 100644
--- a/tests/functional/dashboard/logout.spec.ts
+++ b/tests/functional/dashboard/logout.spec.ts
@@ -1,19 +1,21 @@
1import { test } from '@japa/runner' 1import { test } from '@japa/runner';
2import UserFactory from '#database/factories/UserFactory' 2import UserFactory from '#database/factories/UserFactory';
3 3
4test.group('Dashboard / Log out page', () => { 4test.group('Dashboard / Log out page', () => {
5 test('redirects to /user/login when accessing /user/logout as guest', async ({ client }) => { 5 test('redirects to /user/login when accessing /user/logout as guest', async ({
6 const response = await client.get('/user/logout') 6 client,
7 }) => {
8 const response = await client.get('/user/logout');
7 9
8 response.assertRedirectsTo('/user/login') // Check if it redirects to the expected URL 10 response.assertRedirectsTo('/user/login'); // Check if it redirects to the expected URL
9 }) 11 });
10 12
11 test('logs the user out when opening the page', async ({ client }) => { 13 test('logs the user out when opening the page', async ({ client }) => {
12 const user = await UserFactory.create() 14 const user = await UserFactory.create();
13 const response = await client.get('/user/logout').loginAs(user) 15 const response = await client.get('/user/logout').loginAs(user);
14 16
15 response.assertRedirectsTo('/user/login') 17 response.assertRedirectsTo('/user/login');
16 // This asserts the session is deleted as well 18 // This asserts the session is deleted as well
17 response.assertSessionMissing('auth_web') 19 response.assertSessionMissing('auth_web');
18 }) 20 });
19}) 21});