aboutsummaryrefslogtreecommitdiffstats
path: root/tests/functional/dashboard/export.spec.ts
diff options
context:
space:
mode:
Diffstat (limited to 'tests/functional/dashboard/export.spec.ts')
-rw-r--r--tests/functional/dashboard/export.spec.ts91
1 files changed, 51 insertions, 40 deletions
diff --git a/tests/functional/dashboard/export.spec.ts b/tests/functional/dashboard/export.spec.ts
index f85673e..767f0ef 100644
--- a/tests/functional/dashboard/export.spec.ts
+++ b/tests/functional/dashboard/export.spec.ts
@@ -1,50 +1,61 @@
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 / Export page', () => { 4test.group('Dashboard / Export page', () => {
5 test('redirects to /user/login when accessing /user/transfer as guest', async ({ client }) => { 5 test('redirects to /user/login when accessing /user/transfer as guest', async ({
6 const response = await client.get('/user/transfer') 6 client,
7 }) => {
8 const response = await client.get('/user/transfer');
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('returns a correct export with user data', async ({ assert, client }) => { 13 test('returns a correct export with user data', async ({
12 const user = await UserFactory.create() 14 assert,
13 const response = await client.get('/user/export').loginAs(user) 15 client,
16 }) => {
17 const user = await UserFactory.create();
18 const response = await client.get('/user/export').loginAs(user);
14 19
15 response.assertStatus(200) 20 response.assertStatus(200);
16 const exportData = JSON.parse(response.text()) 21 const exportData = JSON.parse(response.text());
17 22
18 assert.equal(exportData.username, user.username) 23 assert.equal(exportData.username, user.username);
19 assert.equal(exportData.lastname, user.lastname) 24 assert.equal(exportData.lastname, user.lastname);
20 assert.equal(exportData.mail, user.email) 25 assert.equal(exportData.mail, user.email);
21 }) 26 });
22 27
23 // TODO: We can improve this test by hard checking the export data 28 // TODO: We can improve this test by hard checking the export data
24 test('returns a correct export with service data', async ({ assert, client }) => { 29 test('returns a correct export with service data', async ({
25 const user = await UserFactory.with('services', 5).create() 30 assert,
26 const response = await client.get('/user/export').loginAs(user) 31 client,
27 32 }) => {
28 response.assertStatus(200) 33 const user = await UserFactory.with('services', 5).create();
29 const exportData = JSON.parse(response.text()) 34 const response = await client.get('/user/export').loginAs(user);
30 35
31 assert.equal(exportData.username, user.username) 36 response.assertStatus(200);
32 assert.equal(exportData.lastname, user.lastname) 37 const exportData = JSON.parse(response.text());
33 assert.equal(exportData.mail, user.email) 38
34 assert.equal(exportData.services.length, user.services.length) 39 assert.equal(exportData.username, user.username);
35 }) 40 assert.equal(exportData.lastname, user.lastname);
41 assert.equal(exportData.mail, user.email);
42 assert.equal(exportData.services.length, user.services.length);
43 });
36 44
37 // TODO: We can improve this test by hard checking the export data 45 // TODO: We can improve this test by hard checking the export data
38 test('returns a correct export with workspace data', async ({ assert, client }) => { 46 test('returns a correct export with workspace data', async ({
39 const user = await UserFactory.with('workspaces', 5).create() 47 assert,
40 const response = await client.get('/user/export').loginAs(user) 48 client,
41 49 }) => {
42 response.assertStatus(200) 50 const user = await UserFactory.with('workspaces', 5).create();
43 const exportData = JSON.parse(response.text()) 51 const response = await client.get('/user/export').loginAs(user);
44 52
45 assert.equal(exportData.username, user.username) 53 response.assertStatus(200);
46 assert.equal(exportData.lastname, user.lastname) 54 const exportData = JSON.parse(response.text());
47 assert.equal(exportData.mail, user.email) 55
48 assert.equal(exportData.workspaces.length, user.workspaces.length) 56 assert.equal(exportData.username, user.username);
49 }) 57 assert.equal(exportData.lastname, user.lastname);
50}) 58 assert.equal(exportData.mail, user.email);
59 assert.equal(exportData.workspaces.length, user.workspaces.length);
60 });
61});