-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathApp.test.tsx
109 lines (93 loc) · 2.8 KB
/
App.test.tsx
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import { render } from '@/lib/test-utils'
import { screen, waitFor } from '@testing-library/react'
import { describe, expect, it } from 'vitest'
import App from './App'
import userEvent from '@testing-library/user-event'
describe('App', () => {
it('should render header', async () => {
render(<App />)
expect(screen.getByText('Settings')).toBeVisible()
expect(screen.getByText('Help')).toBeVisible()
expect(screen.getByRole('banner', { name: 'App header' })).toBeVisible()
expect(screen.getByRole('heading', { name: /codeGate/i })).toBeVisible()
await userEvent.click(screen.getByText('Settings'))
expect(
screen.getByRole('menuitem', {
name: /providers/i,
})
).toBeVisible()
expect(
screen.getByRole('menuitem', {
name: /certificate security/i,
})
).toBeVisible()
expect(
screen.getByRole('menuitem', {
name: /download/i,
})
).toBeVisible()
await userEvent.click(screen.getByText('Settings'))
await userEvent.click(screen.getByText('Help'))
expect(
screen.getByRole('menuitem', {
name: /use with continue/i,
})
).toBeVisible()
expect(
screen.getByRole('menuitem', {
name: /use with copilot/i,
})
).toBeVisible()
expect(
screen.getByRole('menuitem', {
name: /documentation/i,
})
).toBeVisible()
const discordMenuItem = screen.getByRole('menuitem', {
name: /discord/i,
})
expect(discordMenuItem).toBeVisible()
expect(discordMenuItem).toHaveAttribute(
'href',
'https://discord.gg/stacklok'
)
const githubMenuItem = screen.getByRole('menuitem', {
name: /github/i,
})
expect(githubMenuItem).toBeVisible()
expect(githubMenuItem).toHaveAttribute(
'href',
'https://github.com/stacklok/codegate'
)
const youtubeMenuItem = screen.getByRole('menuitem', {
name: /youtube/i,
})
expect(youtubeMenuItem).toBeVisible()
expect(youtubeMenuItem).toHaveAttribute(
'href',
'https://www.youtube.com/@Stacklok'
)
await userEvent.click(screen.getByText('Help'))
await waitFor(() =>
expect(screen.getByRole('link', { name: /codeGate/i })).toBeVisible()
)
})
it('should render workspaces dropdown', async () => {
render(<App />)
await waitFor(() =>
expect(screen.getByRole('link', { name: 'CodeGate' })).toBeVisible()
)
const workspaceSelectionButton = screen.getByRole('button', {
name: 'Active workspace: default',
})
await waitFor(() => expect(workspaceSelectionButton).toBeVisible())
await userEvent.click(workspaceSelectionButton)
await waitFor(() =>
expect(
screen.getByRole('option', {
name: /anotherworkspae/i,
})
).toBeVisible()
)
})
})