@@ -68,8 +68,22 @@ suite('E2E: Environment Discovery', function () {
6868 return ;
6969 }
7070
71- // This should complete without throwing
71+ // Capture state before refresh to verify API is callable
72+ const beforeRefresh = await api . getEnvironments ( 'all' ) ;
73+ assert . ok ( Array . isArray ( beforeRefresh ) , 'Should get environments before refresh' ) ;
74+
75+ // Trigger refresh - this should complete without throwing
7276 await api . refreshEnvironments ( undefined ) ;
77+
78+ // Verify API still works after refresh (observable side effect: API remains functional)
79+ const afterRefresh = await api . getEnvironments ( 'all' ) ;
80+ assert . ok ( Array . isArray ( afterRefresh ) , 'Should get environments after refresh' ) ;
81+
82+ // Environments should still be available after refresh
83+ // (count may change if discovery finds more, but should not lose all)
84+ if ( beforeRefresh . length > 0 ) {
85+ assert . ok ( afterRefresh . length > 0 , 'Should not lose all environments after refresh' ) ;
86+ }
7387 } ) ;
7488
7589 /**
@@ -117,20 +131,43 @@ suite('E2E: Environment Discovery', function () {
117131
118132 const env = environments [ 0 ] as Record < string , unknown > ;
119133
120- // Check required properties exist
121- // These are the minimum properties an environment should have
134+ // Check required properties exist AND have valid values
122135 // PythonEnvironment has envId (a PythonEnvironmentId object), not id directly
123136 assert . ok ( 'envId' in env , 'Environment should have an envId property' ) ;
137+ assert . ok ( env . envId !== null && env . envId !== undefined , 'envId should not be null/undefined' ) ;
138+
139+ // Verify envId structure
140+ const envId = env . envId as Record < string , unknown > ;
141+ assert . strictEqual ( typeof envId , 'object' , 'envId should be an object' ) ;
142+ assert . ok ( 'id' in envId , 'envId should have an id property' ) ;
143+ assert . strictEqual ( typeof envId . id , 'string' , 'envId.id should be a string' ) ;
144+ assert . ok ( ( envId . id as string ) . length > 0 , 'envId.id should not be empty' ) ;
145+ assert . ok ( 'managerId' in envId , 'envId should have a managerId property' ) ;
146+
147+ // Verify name exists and is a string
124148 assert . ok ( 'name' in env , 'Environment should have a name property' ) ;
149+ assert . strictEqual ( typeof env . name , 'string' , 'name should be a string' ) ;
150+
151+ // Verify displayName exists and is a string
125152 assert . ok ( 'displayName' in env , 'Environment should have a displayName property' ) ;
153+ assert . strictEqual ( typeof env . displayName , 'string' , 'displayName should be a string' ) ;
126154
127- // If execInfo exists, it should have expected shape
155+ // If execInfo exists, it should have expected shape with valid values
128156 if ( 'execInfo' in env && env . execInfo ) {
129157 const execInfo = env . execInfo as Record < string , unknown > ;
158+ assert . strictEqual ( typeof execInfo , 'object' , 'execInfo should be an object' ) ;
130159 assert . ok (
131160 'run' in execInfo || 'activatedRun' in execInfo ,
132161 'execInfo should have run or activatedRun property' ,
133162 ) ;
163+
164+ // Verify run command structure if present
165+ if ( 'run' in execInfo && execInfo . run ) {
166+ const run = execInfo . run as Record < string , unknown > ;
167+ assert . ok ( 'executable' in run , 'run should have an executable property' ) ;
168+ assert . strictEqual ( typeof run . executable , 'string' , 'executable should be a string' ) ;
169+ assert . ok ( ( run . executable as string ) . length > 0 , 'executable should not be empty' ) ;
170+ }
134171 }
135172 } ) ;
136173
@@ -147,5 +184,27 @@ suite('E2E: Environment Discovery', function () {
147184
148185 // Verify it returns an array
149186 assert . ok ( Array . isArray ( globalEnvs ) , 'getEnvironments should return an array' ) ;
187+
188+ // If there are global envs, verify they have valid structure
189+ if ( globalEnvs . length > 0 ) {
190+ const env = globalEnvs [ 0 ] as Record < string , unknown > ;
191+
192+ // Global environments should have the same structure as all environments
193+ assert . ok ( 'envId' in env || 'id' in env , 'Global environment should have an identifier' ) ;
194+
195+ // Verify envId is properly structured if present
196+ if ( 'envId' in env && env . envId ) {
197+ const envId = env . envId as Record < string , unknown > ;
198+ assert . strictEqual ( typeof envId , 'object' , 'envId should be an object' ) ;
199+ assert . ok ( 'id' in envId , 'envId should have an id property' ) ;
200+ }
201+ }
202+
203+ // Global envs should be a subset of all envs
204+ const allEnvs = await api . getEnvironments ( 'all' ) ;
205+ assert . ok (
206+ globalEnvs . length <= allEnvs . length ,
207+ `Global envs (${ globalEnvs . length } ) should not exceed all envs (${ allEnvs . length } )` ,
208+ ) ;
150209 } ) ;
151210} ) ;
0 commit comments