File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
ansible_ai_connect_admin_portal/src/__tests__ Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ import { render, screen } from "@testing-library/react";
22import "@testing-library/jest-dom" ;
33import { AppHeader } from "../AppHeader" ;
44import { BrowserRouter } from "react-router-dom" ;
5+ import userEvent from "@testing-library/user-event" ;
6+ import { act } from "react" ;
57
68describe ( "AppHeader" , ( ) => {
79 // Store the original 'location' object so that it can be restored for other tests.
@@ -33,5 +35,16 @@ describe("AppHeader", () => {
3335
3436 // Check "Logout" option is not present
3537 expect ( screen . queryByText ( "Logout" ) ) . toBeNull ( ) ;
38+
39+ // Emulate click on menu button
40+ await act ( ( ) => userEvent . click ( accountMenu ) ) ;
41+
42+ // "Logout" menu option should now be present
43+ const logoutMenuButton = await screen . findByText ( "Logout" ) ;
44+ expect ( logoutMenuButton ) . toBeInTheDocument ( ) ;
45+
46+ // Emulate clicking on the logout button
47+ await act ( ( ) => userEvent . click ( logoutMenuButton ) ) ;
48+ expect ( window . location . assign ) . toBeCalledWith ( "/logout" ) ;
3649 } ) ;
3750} ) ;
You can’t perform that action at this time.
0 commit comments