aboutsummaryrefslogtreecommitdiffstats
path: root/tests/functional/dashboard/data.spec.ts
diff options
context:
space:
mode:
Diffstat (limited to 'tests/functional/dashboard/data.spec.ts')
-rw-r--r--tests/functional/dashboard/data.spec.ts38
1 files changed, 22 insertions, 16 deletions
diff --git a/tests/functional/dashboard/data.spec.ts b/tests/functional/dashboard/data.spec.ts
index 150229a..edca3ec 100644
--- a/tests/functional/dashboard/data.spec.ts
+++ b/tests/functional/dashboard/data.spec.ts
@@ -1,25 +1,31 @@
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 / Data page', () => { 4test.group('Dashboard / Data page', () => {
5 test('redirects to /user/login when accessing /user/data as guest', async ({ client }) => { 5 test('redirects to /user/login when accessing /user/data as guest', async ({
6 const response = await client.get('/user/data') 6 client,
7 }) => {
8 const response = await client.get('/user/data');
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('ensure the correct data is shown on the page', async ({ client }) => { 13 test('ensure the correct data is shown on the page', async ({ client }) => {
12 const user = await UserFactory.create() 14 const user = await UserFactory.create();
13 const response = await client.get('/user/data').loginAs(user) 15 const response = await client.get('/user/data').loginAs(user);
14 16
15 response.assertStatus(200) 17 response.assertStatus(200);
16 response.assertTextIncludes(user.email) 18 response.assertTextIncludes(user.email);
17 response.assertTextIncludes(user.username) 19 response.assertTextIncludes(user.username);
18 response.assertTextIncludes(user.lastname) 20 response.assertTextIncludes(user.lastname);
19 response.assertTextIncludes(user.created_at.toFormat('yyyy-MM-dd HH:mm:ss')) 21 response.assertTextIncludes(
20 response.assertTextIncludes(user.updated_at.toFormat('yyyy-MM-dd HH:mm:ss')) 22 user.created_at.toFormat('yyyy-MM-dd HH:mm:ss'),
21 }) 23 );
24 response.assertTextIncludes(
25 user.updated_at.toFormat('yyyy-MM-dd HH:mm:ss'),
26 );
27 });
22 28
23 // TODO: Add test to include services. 29 // TODO: Add test to include services.
24 // TODO: Add test to include workspaces. 30 // TODO: Add test to include workspaces.
25}) 31});