aboutsummaryrefslogtreecommitdiffstats
path: root/tests/functional/dashboard/delete.spec.ts
diff options
context:
space:
mode:
Diffstat (limited to 'tests/functional/dashboard/delete.spec.ts')
-rw-r--r--tests/functional/dashboard/delete.spec.ts49
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 @@
1import { test } from '@japa/runner' 1import { test } from '@japa/runner';
2import User from '#app/Models/User' 2import User from '#app/Models/User';
3import UserFactory from '#database/factories/UserFactory' 3import UserFactory from '#database/factories/UserFactory';
4 4
5test.group('Dashboard / Delete account page', () => { 5test.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});