diff options
author | MCMXC <16797721+mcmxcdev@users.noreply.github.com> | 2024-02-10 18:37:40 -0700 |
---|---|---|
committer | Vijay A <vraravam@users.noreply.github.com> | 2024-02-17 21:54:14 +0530 |
commit | fb4d4f7781f2e0830897e1599535c83526b4c286 (patch) | |
tree | 78ed8d88587bba40396b1ae5f88bbf26a53a80dc /tests/functional/dashboard/delete.spec.ts | |
parent | refactor: project maintenance (diff) | |
download | ferdium-server-fb4d4f7781f2e0830897e1599535c83526b4c286.tar.gz ferdium-server-fb4d4f7781f2e0830897e1599535c83526b4c286.tar.zst ferdium-server-fb4d4f7781f2e0830897e1599535c83526b4c286.zip |
updates
Diffstat (limited to 'tests/functional/dashboard/delete.spec.ts')
-rw-r--r-- | tests/functional/dashboard/delete.spec.ts | 49 |
1 files changed, 28 insertions, 21 deletions
diff --git a/tests/functional/dashboard/delete.spec.ts b/tests/functional/dashboard/delete.spec.ts index 9bb9f6a..be7fc61 100644 --- a/tests/functional/dashboard/delete.spec.ts +++ b/tests/functional/dashboard/delete.spec.ts | |||
@@ -1,30 +1,37 @@ | |||
1 | import { test } from '@japa/runner' | 1 | import { test } from '@japa/runner'; |
2 | import User from '#app/Models/User' | 2 | import User from '#app/Models/User'; |
3 | import UserFactory from '#database/factories/UserFactory' | 3 | import UserFactory from '#database/factories/UserFactory'; |
4 | 4 | ||
5 | test.group('Dashboard / Delete account page', () => { | 5 | test.group('Dashboard / Delete account page', () => { |
6 | test('redirects to /user/login when accessing /user/delete as guest', async ({ client }) => { | 6 | test('redirects to /user/login when accessing /user/delete as guest', async ({ |
7 | const response = await client.get('/user/delete') | 7 | client, |
8 | }) => { | ||
9 | const response = await client.get('/user/delete'); | ||
8 | 10 | ||
9 | response.assertRedirectsTo('/user/login') // Check if it redirects to the expected URL | 11 | response.assertRedirectsTo('/user/login'); // Check if it redirects to the expected URL |
10 | }) | 12 | }); |
11 | 13 | ||
12 | test('returns a 200 opening the delete route while logged in', async ({ client }) => { | 14 | test('returns a 200 opening the delete route while logged in', async ({ |
13 | const user = await UserFactory.create() | 15 | client, |
14 | const response = await client.get('/user/delete').loginAs(user) | 16 | }) => { |
17 | const user = await UserFactory.create(); | ||
18 | const response = await client.get('/user/delete').loginAs(user); | ||
15 | 19 | ||
16 | response.assertStatus(200) | 20 | response.assertStatus(200); |
17 | response.assertTextIncludes('Delete your account') | 21 | response.assertTextIncludes('Delete your account'); |
18 | }) | 22 | }); |
19 | 23 | ||
20 | test('returns a 200 opening the delete route while logged in', async ({ client, assert }) => { | 24 | test('returns a 200 opening the delete route while logged in', async ({ |
21 | const user = await UserFactory.create() | 25 | client, |
22 | const response = await client.post('/user/delete').loginAs(user) | 26 | assert, |
27 | }) => { | ||
28 | const user = await UserFactory.create(); | ||
29 | const response = await client.post('/user/delete').loginAs(user); | ||
23 | 30 | ||
24 | response.assertRedirectsTo('/user/login') | 31 | response.assertRedirectsTo('/user/login'); |
25 | // This asserts the session is deleted as well | 32 | // This asserts the session is deleted as well |
26 | response.assertSessionMissing('auth_web') | 33 | response.assertSessionMissing('auth_web'); |
27 | 34 | ||
28 | assert.isNull(await User.find(user.id)) | 35 | assert.isNull(await User.find(user.id)); |
29 | }) | 36 | }); |
30 | }) | 37 | }); |