@@ -42,70 +42,29 @@ suite('Integration: Environment Creation', function () {
4242
4343 api = extension . exports as PythonEnvironmentApi ;
4444 assert . ok ( api , 'API not available' ) ;
45- } ) ;
46-
47- /**
48- * Test: createEnvironment API is available
49- *
50- * The API should have a createEnvironment method.
51- */
52- test ( 'createEnvironment API is available' , async function ( ) {
5345 assert . ok ( typeof api . createEnvironment === 'function' , 'createEnvironment should be a function' ) ;
54- } ) ;
55-
56- /**
57- * Test: removeEnvironment API is available
58- *
59- * The API should have a removeEnvironment method.
60- */
61- test ( 'removeEnvironment API is available' , async function ( ) {
6246 assert . ok ( typeof api . removeEnvironment === 'function' , 'removeEnvironment should be a function' ) ;
6347 } ) ;
6448
65- /**
66- * Test: Managers that support creation are available
67- *
68- * At least one environment manager (venv or conda) should support creation.
69- * This test verifies that global Python installations are discoverable.
70- */
71- test ( 'At least one manager supports environment creation' , async function ( ) {
72- // Get all environments to force managers to load
73- await api . getEnvironments ( 'all' ) ;
74-
75- // Check if we have global Python installations that can create venvs
76- const globalEnvs = await api . getEnvironments ( 'global' ) ;
77-
78- // Assert we have at least one global Python that can serve as base for venv creation
79- assert . ok (
80- globalEnvs . length > 0 ,
81- 'At least one global Python installation should be available for environment creation. ' +
82- 'If this fails, ensure Python is installed and discoverable on this system.' ,
83- ) ;
84-
85- // Verify the global environments have required properties for creation
86- for ( const env of globalEnvs ) {
87- assert . ok ( env . envId , 'Global environment must have envId' ) ;
88- assert . ok ( env . environmentPath , 'Global environment must have environmentPath' ) ;
89- }
90-
91- console . log ( `Found ${ globalEnvs . length } global Python installations for venv creation` ) ;
92- } ) ;
49+ // =========================================================================
50+ // ENVIRONMENT CREATION BEHAVIOR TESTS
51+ // These tests verify actual user-facing creation and removal workflows.
52+ // =========================================================================
9353
9454 /**
9555 * Test: Created environment appears in discovery
9656 *
97- * After creating an environment, it should be discoverable via getEnvironments.
98- * This test creates a real environment and cleans it up .
57+ * BEHAVIOR TESTED: User creates an environment via quickCreate,
58+ * then the environment should be discoverable via getEnvironments .
9959 */
10060 test ( 'Created environment appears in discovery' , async function ( ) {
61+ // --- SETUP: Ensure we have prerequisites ---
10162 const workspaceFolders = vscode . workspace . workspaceFolders ;
102-
10363 if ( ! workspaceFolders || workspaceFolders . length === 0 ) {
10464 this . skip ( ) ;
10565 return ;
10666 }
10767
108- // Check if we have Python available for venv creation
10968 const globalEnvs = await api . getEnvironments ( 'global' ) ;
11069 if ( globalEnvs . length === 0 ) {
11170 console . log ( 'No global Python installations found, skipping creation test' ) ;
@@ -117,17 +76,16 @@ suite('Integration: Environment Creation', function () {
11776 let createdEnv : PythonEnvironment | undefined ;
11877
11978 try {
120- // Create environment with quickCreate to avoid prompts
79+ // --- ACTION: User creates environment ---
12180 createdEnv = await api . createEnvironment ( workspaceUri , { quickCreate : true } ) ;
12281
12382 if ( ! createdEnv ) {
124- // Creation may have been cancelled or failed silently
12583 console . log ( 'Environment creation returned undefined (may require user input)' ) ;
12684 this . skip ( ) ;
12785 return ;
12886 }
12987
130- // Refresh and verify the environment appears
88+ // --- VERIFY: Created environment is discoverable ---
13189 await api . refreshEnvironments ( workspaceUri ) ;
13290 const environments = await api . getEnvironments ( workspaceUri ) ;
13391
@@ -153,11 +111,12 @@ suite('Integration: Environment Creation', function () {
153111 /**
154112 * Test: Environment removal removes from discovery
155113 *
156- * After removing an environment, it should no longer appear in discovery.
114+ * BEHAVIOR TESTED: User removes an environment, then it should
115+ * no longer appear in discovery results.
157116 */
158117 test ( 'Removed environment disappears from discovery' , async function ( ) {
118+ // --- SETUP: Create an environment to remove ---
159119 const workspaceFolders = vscode . workspace . workspaceFolders ;
160-
161120 if ( ! workspaceFolders || workspaceFolders . length === 0 ) {
162121 this . skip ( ) ;
163122 return ;
@@ -173,25 +132,21 @@ suite('Integration: Environment Creation', function () {
173132 let createdEnv : PythonEnvironment | undefined ;
174133
175134 try {
176- // Create environment
177135 createdEnv = await api . createEnvironment ( workspaceUri , { quickCreate : true } ) ;
178-
179136 if ( ! createdEnv ) {
180137 this . skip ( ) ;
181138 return ;
182139 }
183140
184- // Record the environment ID
185141 const envId = createdEnv . envId . id ;
186142
187- // Remove environment
143+ // --- ACTION: User removes environment ---
188144 await api . removeEnvironment ( createdEnv ) ;
189- createdEnv = undefined ; // Mark as cleaned up
145+ createdEnv = undefined ;
190146
191- // Give time for removal to complete
192147 await sleep ( 1000 ) ;
193148
194- // Refresh and verify it's gone
149+ // --- VERIFY: Environment is no longer discoverable ---
195150 await api . refreshEnvironments ( workspaceUri ) ;
196151 const environments = await api . getEnvironments ( workspaceUri ) ;
197152
0 commit comments