aboutsummaryrefslogtreecommitdiffstats
path: root/tests/functional/dashboard/data.spec.ts
blob: 150229a9937bc3698bb779f8a705620d0e38907f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { test } from '@japa/runner'
import UserFactory from '#database/factories/UserFactory'

test.group('Dashboard / Data page', () => {
  test('redirects to /user/login when accessing /user/data as guest', async ({ client }) => {
    const response = await client.get('/user/data')

    response.assertRedirectsTo('/user/login') // Check if it redirects to the expected URL
  })

  test('ensure the correct data is shown on the page', async ({ client }) => {
    const user = await UserFactory.create()
    const response = await client.get('/user/data').loginAs(user)

    response.assertStatus(200)
    response.assertTextIncludes(user.email)
    response.assertTextIncludes(user.username)
    response.assertTextIncludes(user.lastname)
    response.assertTextIncludes(user.created_at.toFormat('yyyy-MM-dd HH:mm:ss'))
    response.assertTextIncludes(user.updated_at.toFormat('yyyy-MM-dd HH:mm:ss'))
  })

  // TODO: Add test to include services.
  // TODO: Add test to include workspaces.
})