Skip to content

Commit 2650a3a

Browse files
committed
test-verifier
1 parent 81ba860 commit 2650a3a

File tree

2 files changed

+88
-9
lines changed

2 files changed

+88
-9
lines changed

src/test/e2e/environmentDiscovery.e2e.test.ts

Lines changed: 63 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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
});

src/test/integration/envManagerApi.integration.test.ts

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,8 @@ suite('Integration: Environment Manager + API', function () {
6969
// Get state after refresh
7070
const afterRefresh = await api.getEnvironments('all');
7171

72-
// State should be consistent (same or more environments)
73-
// We can't assert exact equality since discovery might find more
74-
assert.ok(afterRefresh.length >= 0, `Expected environments array, got ${typeof afterRefresh}`);
72+
// Verify we got an actual array back (not undefined, null, or other type)
73+
assert.ok(Array.isArray(afterRefresh), `Expected environments array, got ${typeof afterRefresh}`);
7574

7675
// Verify the API returns consistent data on repeated calls
7776
const secondCall = await api.getEnvironments('all');
@@ -151,16 +150,37 @@ suite('Integration: Environment Manager + API', function () {
151150
return;
152151
}
153152

154-
// Check each environment has basic required properties
153+
// Check each environment has basic required properties with valid values
155154
for (const env of environments) {
156155
const e = env as Record<string, unknown>;
157156

158157
// Must have some form of identifier
159158
assert.ok('id' in e || 'envId' in e, 'Environment must have id or envId');
160159

161-
// If it has an id, it should be a string
160+
// If it has an id, it should be a non-empty string
162161
if ('id' in e) {
163162
assert.strictEqual(typeof e.id, 'string', 'Environment id should be a string');
163+
assert.ok((e.id as string).length > 0, 'Environment id should not be empty');
164+
}
165+
166+
// If it has envId, verify it's a valid object with required properties
167+
if ('envId' in e && e.envId !== null && e.envId !== undefined) {
168+
const envId = e.envId as Record<string, unknown>;
169+
assert.strictEqual(typeof envId, 'object', 'envId should be an object');
170+
assert.ok('id' in envId, 'envId should have an id property');
171+
assert.ok('managerId' in envId, 'envId should have a managerId property');
172+
assert.strictEqual(typeof envId.id, 'string', 'envId.id should be a string');
173+
assert.ok((envId.id as string).length > 0, 'envId.id should not be empty');
174+
}
175+
176+
// Verify name is a non-empty string if present
177+
if ('name' in e && e.name !== undefined) {
178+
assert.strictEqual(typeof e.name, 'string', 'Environment name should be a string');
179+
}
180+
181+
// Verify displayName is a non-empty string if present
182+
if ('displayName' in e && e.displayName !== undefined) {
183+
assert.strictEqual(typeof e.displayName, 'string', 'Environment displayName should be a string');
164184
}
165185
}
166186
});

0 commit comments

Comments
 (0)