forked from commaai/new-connect
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.browser.test.tsx
More file actions
54 lines (44 loc) · 2 KB
/
App.browser.test.tsx
File metadata and controls
54 lines (44 loc) · 2 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { beforeAll, beforeEach, describe, expect, test } from 'vitest'
import { configure, fireEvent, render, waitFor } from '@solidjs/testing-library'
import { setAccessToken, signOut } from '~/api/auth/client'
import * as Demo from '~/api/auth/demo'
import { AppLayout, Routes } from './App'
const DEMO_LOG_ID = '000000dd--455f14369d'
const renderApp = (location: string) => render(() => <Routes />, { location, wrapper: AppLayout })
beforeAll(() => configure({ asyncUtilTimeout: 3000 }))
beforeEach(() => signOut())
test('Show login page', async () => {
const { findByText } = renderApp('/')
expect(await findByText('Sign in with Google')).toBeTruthy()
})
describe('Demo mode', () => {
beforeEach(() => setAccessToken(Demo.ACCESS_TOKEN))
test('View dashboard', async () => {
const { findByText } = renderApp('/')
expect(await findByText('demo 3X')).toBeTruthy()
})
test('View demo route', async () => {
const { findByLabelText, findByText, findByTestId } = renderApp(`/${Demo.DONGLE_ID}/${DEMO_LOG_ID}`)
expect(await findByText(DEMO_LOG_ID)).toBeTruthy()
const video = (await findByTestId('route-video')) as HTMLVideoElement
await waitFor(() => expect(video.src).toBeTruthy())
expect(video.muted).toBe(true)
await fireEvent.click(await findByLabelText('Unmute'))
expect(video.muted).toBe(false)
expect(await findByLabelText('Mute')).toBeTruthy()
})
})
describe.skip('Public routes', () => {
test('View shared device', async () => {
const { findByText } = renderApp(`/${Demo.DONGLE_ID}`)
expect(await findByText('Not signed in')).toBeTruthy()
expect(await findByText('Shared Device')).toBeTruthy()
})
test('View public route without signing in', async () => {
const { findByText } = renderApp(`/${Demo.DONGLE_ID}/${DEMO_LOG_ID}`)
expect(await findByText(DEMO_LOG_ID)).toBeTruthy()
// Videos do not load, yet
// const video = (await findByTestId('route-video')) as HTMLVideoElement
// await waitFor(() => expect(video.src).toBeTruthy())
})
})