1- import { fireEvent , render , screen , waitFor } from "@testing-library/react" ;
1+ import { fireEvent , render , screen , waitFor , within } from "@testing-library/react" ;
22import userEvent from "@testing-library/user-event" ;
33import { createStore , Provider } from "jotai" ;
44import { describe , expect , it , vi } from "vitest" ;
@@ -8,6 +8,49 @@ import { supervisorDialogAtom, supervisorsAtom } from "../../atoms";
88import { MobileSupervisorSheet } from "./mobile-supervisor-sheet" ;
99
1010describe ( "MobileSupervisorSheet" , ( ) => {
11+ it ( "renders the current session supervisor details in the root sheet" , ( ) => {
12+ const store = createStore ( ) ;
13+
14+ window . localStorage . setItem ( "ui.locale" , JSON . stringify ( "en" ) ) ;
15+ store . set ( localeAtom , "en" ) ;
16+ store . set ( wsClientAtom , { sendCommand : vi . fn ( ) } as never ) ;
17+ store . set (
18+ supervisorsAtom ,
19+ new Map ( [
20+ [
21+ "sess-1" ,
22+ {
23+ id : "sup-1" ,
24+ sessionId : "sess-1" ,
25+ workspaceId : "ws-1" ,
26+ state : "idle" ,
27+ objective : "Reduce mobile regression bugs" ,
28+ evaluatorProviderId : "claude" ,
29+ cycles : [ ] ,
30+ createdAt : 1 ,
31+ updatedAt : 1 ,
32+ } ,
33+ ] ,
34+ ] )
35+ ) ;
36+
37+ render (
38+ < Provider store = { store } >
39+ < MobileSupervisorSheet sessionId = "sess-1" workspaceId = "ws-1" onClose = { vi . fn ( ) } />
40+ </ Provider >
41+ ) ;
42+
43+ const rootActions = document . querySelector ( ".mobile-supervisor-sheet__actions" ) ;
44+ expect ( rootActions ) . not . toBeNull ( ) ;
45+
46+ expect ( screen . getByText ( "Reduce mobile regression bugs" ) ) . toBeInTheDocument ( ) ;
47+ expect ( within ( rootActions as HTMLElement ) . getByRole ( "button" , { name : "Edit Objective" } ) ) . toBeInTheDocument ( ) ;
48+ expect (
49+ within ( rootActions as HTMLElement ) . getByRole ( "button" , { name : "Disable Supervisor" } )
50+ ) . toBeInTheDocument ( ) ;
51+ expect ( screen . queryByText ( "Supervisor is not enabled" ) ) . not . toBeInTheDocument ( ) ;
52+ } ) ;
53+
1154 it ( "opens the enable flow inside the same sheet without rendering a second overlay" , async ( ) => {
1255 const sendCommand = vi . fn ( ) . mockResolvedValue ( { id : "sup-1" } ) ;
1356 const store = createStore ( ) ;
0 commit comments