@@ -25,9 +25,16 @@ vi.mock(import('../../../src/orchestrators/login'), async () => {
2525vi . mock ( '@homebridge/node-pty-prebuilt-multiarch' , async ( ) => {
2626 return {
2727 spawn : ( ) => {
28+ const onExit = ( ) => {
29+ } ;
30+
31+ setInterval ( ( ) => {
32+ onExit ( )
33+ } , 10 )
2834 return {
29- onData : ( ) => { } ,
30- onExit : ( ) => { } ,
35+ onData : ( ) => {
36+ } ,
37+ onExit
3138 }
3239 }
3340 }
@@ -156,32 +163,22 @@ describe('Connect server tests', () => {
156163 await fakeLogin ( ) ;
157164
158165 await new Promise < void > ( ( done , reject ) => {
159- startServer ( reporter , async ( connectionCode , clientId , server ) => {
166+ startSession ( reporter , async ( connectionCode , clientId , server , socket , sessionId ) => {
160167 try {
161- const sessionResponse = await fetch ( `http://localhost:${ config . connectServerPort } /session` , {
162- method : 'POST' ,
163- headers : { 'Authorization' : `${ connectionCode } ` , 'Content-Type' : 'application/json' } ,
164- body : JSON . stringify ( { clientId } )
165- } ) ;
166-
167- expect ( sessionResponse . ok ) . to . be . true ;
168- const { sessionId } = await sessionResponse . json ( ) ;
169- expect ( sessionId ) . to . be . a ( 'string' ) ;
170-
171- const socket = new WebSocket ( `ws://localhost:${ config . connectServerPort } /ws/session/${ sessionId } ` , [ connectionCode ] ) ;
172-
173- socket . onmessage = ( message ) => {
174- expect ( message ) . to . not . be . null ;
175- }
176-
177168 const commandResponse = await fetch ( `http://localhost:${ config . connectServerPort } /terminal/${ sessionId } /start` , {
178169 method : 'POST' ,
179170 headers : { 'Authorization' : `${ connectionCode } ` , 'Content-Type' : 'application/json' } ,
171+ body : JSON . stringify ( {
172+ config : [
173+ {
174+ type : 'homebrew' ,
175+ formulae : [ 'zsh' ]
176+ }
177+ ]
178+ } )
180179 } ) ;
181180
182181 server . close ( ) ;
183-
184- console . log ( await commandResponse . text ( ) ) ;
185182 expect ( commandResponse . ok ) . to . be . true ;
186183 done ( ) ;
187184 } catch ( e ) {
@@ -282,7 +279,7 @@ describe('Connect server tests', () => {
282279 console . log ( await commandResponse . text ( ) ) ;
283280 expect ( commandResponse . ok ) . to . be . true ;
284281 done ( ) ;
285- } catch ( e ) {
282+ } catch ( e ) {
286283 reject ( e ) ;
287284 }
288285 } ) ;
@@ -317,7 +314,7 @@ describe('Connect server tests', () => {
317314 console . log ( await commandResponse . text ( ) ) ;
318315 expect ( commandResponse . ok ) . to . be . true ;
319316 done ( ) ;
320- } catch ( e ) {
317+ } catch ( e ) {
321318 reject ( e ) ;
322319 }
323320 } ) ;
@@ -349,7 +346,7 @@ describe('Connect server tests', () => {
349346 server . close ( ) ;
350347 expect ( commandResponse . ok ) . to . be . true ;
351348 done ( ) ;
352- } catch ( e ) {
349+ } catch ( e ) {
353350 reject ( e ) ;
354351 }
355352 } ) ;
@@ -381,7 +378,7 @@ describe('Connect server tests', () => {
381378 server . close ( ) ;
382379 expect ( commandResponse . ok ) . to . be . true ;
383380 done ( ) ;
384- } catch ( e ) {
381+ } catch ( e ) {
385382 reject ( e ) ;
386383 }
387384 } ) ;
@@ -404,7 +401,7 @@ describe('Connect server tests', () => {
404401 server . close ( ) ;
405402 expect ( commandResponse . ok ) . to . be . true ;
406403 done ( ) ;
407- } catch ( e ) {
404+ } catch ( e ) {
408405 reject ( e ) ;
409406 }
410407 } ) ;
0 commit comments