@@ -3,6 +3,7 @@ import { screen, waitFor } from "@testing-library/react";
3
3
import { describe , expect , it , vi } from "vitest" ;
4
4
import App from "./App" ;
5
5
import React from "react" ;
6
+ import userEvent from "@testing-library/user-event" ;
6
7
7
8
vi . mock ( "recharts" , async ( importOriginal ) => {
8
9
const originalModule = ( await importOriginal ( ) ) as Record < string , unknown > ;
@@ -22,38 +23,63 @@ describe("App", () => {
22
23
expect ( screen . getByText ( "Setup" ) ) . toBeVisible ( ) ;
23
24
expect ( screen . getByRole ( "banner" , { name : "App header" } ) ) . toBeVisible ( ) ;
24
25
expect (
25
- screen . getByRole ( "heading" , { name : / c o d e G a t e d a s h b o a r d / i } ) ,
26
+ screen . getByRole ( "heading" , { name : / c o d e G a t e d a s h b o a r d / i } )
26
27
) . toBeVisible ( ) ;
27
28
expect (
28
29
screen . getByRole ( "link" , {
29
30
name : / c e r t i f i c a t e s e c u r i t y / i,
30
- } ) ,
31
+ } )
31
32
) . toBeVisible ( ) ;
32
33
expect (
33
34
screen . getByRole ( "link" , {
34
35
name : / s e t u p i n c o n t i n u e / i,
35
- } ) ,
36
+ } )
36
37
) . toBeVisible ( ) ;
37
38
38
39
expect (
39
40
screen . getByRole ( "link" , {
40
41
name : / s e t u p i n c o p i l o t / i,
41
- } ) ,
42
+ } )
42
43
) . toBeVisible ( ) ;
43
44
expect (
44
45
screen . getByRole ( "link" , {
45
46
name : / d o w n l o a d / i,
46
- } ) ,
47
+ } )
47
48
) . toBeVisible ( ) ;
48
49
expect (
49
50
screen . getByRole ( "link" , {
50
51
name : / d o c u m e n t a t i o n / i,
51
- } ) ,
52
+ } )
52
53
) . toBeVisible ( ) ;
53
54
await waitFor ( ( ) =>
54
55
expect (
55
- screen . getByRole ( "link" , { name : / c o d e G a t e d a s h b o a r d / i } ) ,
56
- ) . toBeVisible ( ) ,
56
+ screen . getByRole ( "link" , { name : / c o d e G a t e d a s h b o a r d / i } )
57
+ ) . toBeVisible ( )
58
+ ) ;
59
+ } ) ;
60
+
61
+ it ( "should render workspaces dropdown" , async ( ) => {
62
+ render ( < App /> ) ;
63
+
64
+ await waitFor ( ( ) =>
65
+ expect (
66
+ screen . getByRole ( "link" , { name : "CodeGate Dashboard" } )
67
+ ) . toBeVisible ( )
68
+ ) ;
69
+
70
+ const workspaceSelectionButton = screen . getByRole ( "button" , {
71
+ name : "Workspace default" ,
72
+ } ) ;
73
+ await waitFor ( ( ) => expect ( workspaceSelectionButton ) . toBeVisible ( ) ) ;
74
+
75
+ await userEvent . click ( workspaceSelectionButton ) ;
76
+
77
+ await waitFor ( ( ) =>
78
+ expect (
79
+ screen . getByRole ( "option" , {
80
+ name : / a n o t h e r w o r k s p a e / i,
81
+ } )
82
+ ) . toBeVisible ( )
57
83
) ;
58
84
} ) ;
59
85
} ) ;
0 commit comments