@@ -54,17 +54,51 @@ describe('CLI commands', () => {
5454 await agent . api . deleteWorkspace ( name ) ;
5555 } ) ;
5656
57- it ( 'creates workspace with --clone option' , async ( ) => {
57+ it ( 'creates workspace with --clone option and clones the repository ' , async ( ) => {
5858 const name = generateTestWorkspaceName ( ) ;
59- const result = await runCLI ( [ 'start' , name , '--clone' , 'https://github.com/example/repo' ] , {
59+ const repoUrl = 'https://github.com/octocat/Hello-World' ;
60+ const result = await runCLI ( [ 'start' , name , '--clone' , repoUrl ] , {
6061 env : cliEnv ( ) ,
61- timeout : 30000 ,
62+ timeout : 90000 ,
6263 } ) ;
6364 expect ( result . code ) . toBe ( 0 ) ;
6465 expect ( result . stdout ) . toContain ( `Workspace '${ name } ' started` ) ;
6566
67+ const { execInContainer } = await import ( '../../src/docker' ) ;
68+ const containerName = `workspace-${ name } ` ;
69+
70+ const waitForInit = async ( maxWait = 60000 ) => {
71+ const start = Date . now ( ) ;
72+ while ( Date . now ( ) - start < maxWait ) {
73+ const check = await execInContainer (
74+ containerName ,
75+ [ 'test' , '-f' , '/home/workspace/.workspace-initialized' ] ,
76+ { user : 'workspace' }
77+ ) ;
78+ if ( check . exitCode === 0 ) return true ;
79+ await new Promise ( ( r ) => setTimeout ( r , 1000 ) ) ;
80+ }
81+ return false ;
82+ } ;
83+
84+ const initComplete = await waitForInit ( ) ;
85+ expect ( initComplete ) . toBe ( true ) ;
86+
87+ const lsResult = await execInContainer ( containerName , [ 'ls' , '-la' , '/home/workspace' ] , {
88+ user : 'root' ,
89+ } ) ;
90+ expect ( lsResult . exitCode ) . toBe ( 0 ) ;
91+ expect ( lsResult . stdout ) . toContain ( 'Hello-World' ) ;
92+
93+ const gitDirResult = await execInContainer (
94+ containerName ,
95+ [ 'test' , '-d' , '/home/workspace/Hello-World/.git' ] ,
96+ { user : 'root' }
97+ ) ;
98+ expect ( gitDirResult . exitCode ) . toBe ( 0 ) ;
99+
66100 await agent . api . deleteWorkspace ( name ) ;
67- } ) ;
101+ } , 120000 ) ;
68102
69103 it ( 'starts existing workspace without error' , async ( ) => {
70104 const name = generateTestWorkspaceName ( ) ;
0 commit comments