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