@@ -108,48 +108,56 @@ const connected: Snapshot["catalog"] = {
108108it . each ( [
109109 [ "while the catalog reloads" , { ...connected , isLoadingConnections : true } ] ,
110110 [ "while the catalog stays ready" , connected ] ,
111- ] ) ( "checks the branch out once when a reconnect drops and restores the project %s" , async ( gap , gapCatalog ) => {
112- // Checkouts live in a module table keyed by route, so each case uses its own route.
113- const routeKey = `thread-route ${ gap } ` ;
114- ( globalThis as { IS_REACT_ACT_ENVIRONMENT ?: boolean } ) . IS_REACT_ACT_ENVIRONMENT = true ;
115- const firstCheckout = Promise . withResolvers < unknown > ( ) ;
116- harness . checkout . mockReturnValueOnce ( firstCheckout . promise ) ;
117- harness . checkout . mockResolvedValue (
118- AsyncResult . success ( { name : "feature" , current : true , isDefault : false , worktreePath : null } ) ,
119- ) ;
120- harness . set ( { projects : [ project ] , catalog : connected } ) ;
121- const draft = { environmentId : "env-1" , projectId : "project-1" , branch : "feature" } ;
122- harness . route = { key : routeKey , name : "Thread" , params : { draft } } ;
123-
124- const container = document . createElement ( "div" ) ;
125- const root = createRoot ( container ) ;
126- using _root = { [ Symbol . dispose ] : ( ) => act ( ( ) => root . unmount ( ) ) } ;
127- act ( ( ) =>
128- root . render (
129- < NewTaskDraftRouteScreen
130- route = { { key : routeKey , name : "Thread" , params : draft } as never }
131- /> ,
132- ) ,
133- ) ;
134- await vi . waitFor ( ( ) => expect ( harness . checkout ) . toHaveBeenCalledTimes ( 1 ) ) ;
135-
136- // The connection drops while the checkout runs, then the project comes back.
137- act ( ( ) => harness . set ( { projects : [ ] , catalog : gapCatalog } ) ) ;
138- act ( ( ) => harness . set ( { projects : [ project ] , catalog : connected } ) ) ;
139- await act ( async ( ) => {
140- firstCheckout . resolve (
111+ ] ) (
112+ "checks the branch out once when a reconnect drops and restores the project %s" ,
113+ async ( gap , gapCatalog ) => {
114+ // Checkouts live in a module table keyed by route, so each case uses its own route.
115+ const routeKey = `thread-route ${ gap } ` ;
116+ ( globalThis as { IS_REACT_ACT_ENVIRONMENT ?: boolean } ) . IS_REACT_ACT_ENVIRONMENT = true ;
117+ const firstCheckout = Promise . withResolvers < unknown > ( ) ;
118+ harness . checkout . mockReturnValueOnce ( firstCheckout . promise ) ;
119+ harness . checkout . mockResolvedValue (
141120 AsyncResult . success ( { name : "feature" , current : true , isDefault : false , worktreePath : null } ) ,
142121 ) ;
143- } ) ;
122+ harness . set ( { projects : [ project ] , catalog : connected } ) ;
123+ const draft = { environmentId : "env-1" , projectId : "project-1" , branch : "feature" } ;
124+ harness . route = { key : routeKey , name : "Thread" , params : { draft } } ;
144125
145- await vi . waitFor ( ( ) =>
146- expect (
147- harness . checkout . mock . calls . length > 1 || container . textContent === "draft on feature" ,
148- ) . toBe ( true ) ,
149- ) ;
150- expect ( harness . checkout ) . toHaveBeenCalledTimes ( 1 ) ;
151- expect ( container . textContent ) . toBe ( "draft on feature" ) ;
152- } ) ;
126+ const container = document . createElement ( "div" ) ;
127+ const root = createRoot ( container ) ;
128+ using _root = { [ Symbol . dispose ] : ( ) => act ( ( ) => root . unmount ( ) ) } ;
129+ act ( ( ) =>
130+ root . render (
131+ < NewTaskDraftRouteScreen
132+ route = { { key : routeKey , name : "Thread" , params : draft } as never }
133+ /> ,
134+ ) ,
135+ ) ;
136+ await vi . waitFor ( ( ) => expect ( harness . checkout ) . toHaveBeenCalledTimes ( 1 ) ) ;
137+
138+ // The connection drops while the checkout runs, then the project comes back.
139+ act ( ( ) => harness . set ( { projects : [ ] , catalog : gapCatalog } ) ) ;
140+ act ( ( ) => harness . set ( { projects : [ project ] , catalog : connected } ) ) ;
141+ await act ( async ( ) => {
142+ firstCheckout . resolve (
143+ AsyncResult . success ( {
144+ name : "feature" ,
145+ current : true ,
146+ isDefault : false ,
147+ worktreePath : null ,
148+ } ) ,
149+ ) ;
150+ } ) ;
151+
152+ await vi . waitFor ( ( ) =>
153+ expect (
154+ harness . checkout . mock . calls . length > 1 || container . textContent === "draft on feature" ,
155+ ) . toBe ( true ) ,
156+ ) ;
157+ expect ( harness . checkout ) . toHaveBeenCalledTimes ( 1 ) ;
158+ expect ( container . textContent ) . toBe ( "draft on feature" ) ;
159+ } ,
160+ ) ;
153161
154162it ( "hands the draft screen the same project ref across re-renders" , async ( ) => {
155163 ( globalThis as { IS_REACT_ACT_ENVIRONMENT ?: boolean } ) . IS_REACT_ACT_ENVIRONMENT = true ;
0 commit comments