@@ -3,6 +3,7 @@ import { screen, waitFor } from "@testing-library/react";
33import { describe , expect , it , vi } from "vitest" ;
44import App from "./App" ;
55import React from "react" ;
6+ import userEvent from "@testing-library/user-event" ;
67
78vi . mock ( "recharts" , async ( importOriginal ) => {
89 const originalModule = ( await importOriginal ( ) ) as Record < string , unknown > ;
@@ -22,38 +23,63 @@ describe("App", () => {
2223 expect ( screen . getByText ( "Setup" ) ) . toBeVisible ( ) ;
2324 expect ( screen . getByRole ( "banner" , { name : "App header" } ) ) . toBeVisible ( ) ;
2425 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 } )
2627 ) . toBeVisible ( ) ;
2728 expect (
2829 screen . getByRole ( "link" , {
2930 name : / c e r t i f i c a t e s e c u r i t y / i,
30- } ) ,
31+ } )
3132 ) . toBeVisible ( ) ;
3233 expect (
3334 screen . getByRole ( "link" , {
3435 name : / s e t u p i n c o n t i n u e / i,
35- } ) ,
36+ } )
3637 ) . toBeVisible ( ) ;
3738
3839 expect (
3940 screen . getByRole ( "link" , {
4041 name : / s e t u p i n c o p i l o t / i,
41- } ) ,
42+ } )
4243 ) . toBeVisible ( ) ;
4344 expect (
4445 screen . getByRole ( "link" , {
4546 name : / d o w n l o a d / i,
46- } ) ,
47+ } )
4748 ) . toBeVisible ( ) ;
4849 expect (
4950 screen . getByRole ( "link" , {
5051 name : / d o c u m e n t a t i o n / i,
51- } ) ,
52+ } )
5253 ) . toBeVisible ( ) ;
5354 await waitFor ( ( ) =>
5455 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 ( )
5783 ) ;
5884 } ) ;
5985} ) ;
0 commit comments