diff options
Diffstat (limited to 'tests/functional/dashboard/data.spec.ts')
-rw-r--r-- | tests/functional/dashboard/data.spec.ts | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/functional/dashboard/data.spec.ts b/tests/functional/dashboard/data.spec.ts new file mode 100644 index 0000000..1a0e7ad --- /dev/null +++ b/tests/functional/dashboard/data.spec.ts | |||
@@ -0,0 +1,31 @@ | |||
1 | import { test } from '@japa/runner'; | ||
2 | import UserFactory from 'Database/factories/UserFactory'; | ||
3 | |||
4 | test.group('Dashboard / Data page', () => { | ||
5 | test('redirects to /user/login when accessing /user/data as guest', async ({ | ||
6 | client, | ||
7 | }) => { | ||
8 | const response = await client.get('/user/data'); | ||
9 | |||
10 | response.assertRedirectsTo('/user/login'); // Check if it redirects to the expected URL | ||
11 | }); | ||
12 | |||
13 | test('ensure the correct data is shown on the page', async ({ client }) => { | ||
14 | const user = await UserFactory.create(); | ||
15 | const response = await client.get('/user/data').loginAs(user); | ||
16 | |||
17 | response.assertStatus(200); | ||
18 | response.assertTextIncludes(user.email); | ||
19 | response.assertTextIncludes(user.username); | ||
20 | response.assertTextIncludes(user.lastname); | ||
21 | response.assertTextIncludes( | ||
22 | user.created_at.toFormat('yyyy-MM-dd HH:mm:ss'), | ||
23 | ); | ||
24 | response.assertTextIncludes( | ||
25 | user.updated_at.toFormat('yyyy-MM-dd HH:mm:ss'), | ||
26 | ); | ||
27 | }); | ||
28 | |||
29 | // TODO: Add test to include services. | ||
30 | // TODO: Add test to include workspaces. | ||
31 | }); | ||