fix(#4485): isolate hook E2E tests from ambient capabilities (#4529)

* test(#4485): isolate hook E2E capability homes

* test(#4485): isolate the remaining plan hook E2E

* test(#4485): make ambient-home assertions real

* test(#4485): remove stale helper imports

---------

Co-authored-by: Tom Boucher <trekkie@nomorestars.com>
This commit is contained in:
Michel Moreira
2026-09-15 00:44:18 -03:00
committed by GitHub
parent e2bfc06558
commit e5c4941f2a
4 changed files with 83 additions and 11 deletions

View File

@@ -23,7 +23,7 @@ const path = require('path');
const os = require('os');
const { spawnSync } = require('child_process');
const { runGsdTools, createTempProject, cleanup } = require('./helpers.cjs');
const { runGsdTools, createTempProject, cleanup, installSpawnEnv, withAmbientCapabilityHome } = require('./helpers.cjs');
const { LOOP_HOOK_POINT_CLI_TIMEOUT_MS } = require('./helpers/timeouts.cjs');
const GSD_TOOLS = path.join(__dirname, '..', 'gsd-core', 'bin', 'gsd-tools.cjs');
@@ -77,7 +77,7 @@ function spawnRenderHooks(point, cwd) {
cwd,
encoding: 'utf8',
timeout: LOOP_HOOK_POINT_CLI_TIMEOUT_MS,
env: { ...process.env, GSD_SESSION_KEY: '', CODEX_THREAD_ID: '', CLAUDE_SESSION_ID: '' },
env: installSpawnEnv({ GSD_SESSION_KEY: '', CODEX_THREAD_ID: '', CLAUDE_SESSION_ID: '' }),
});
return {
status: result.status,
@@ -137,6 +137,15 @@ describe('render-hooks plan:post — gate discovery', () => {
assert.ok(envelope.rendered.includes('gap-analysis.plan-post'), 'rendered must include check query');
});
test('#4485: render-hooks ignores capabilities installed in ambient user locations', (t) => {
withAmbientCapabilityHome(t, 'gsd-ambient-plan-post-', 'ambient-plan-post', 'plan:post');
const result = spawnRenderHooks('plan:post', tmpDir);
assert.strictEqual(result.status, 0, `exit non-zero: ${result.stderr}`);
const activeHooks = JSON.parse(result.stdout).activeHooks;
assert.deepStrictEqual(activeHooks.map((hook) => [hook.capId, hook.check?.query]), [['gap-analysis', 'gap-analysis.plan-post']]);
});
test('[negative] render-hooks plan:post returns empty activeHooks when workflow.post_planning_gaps=false (gate deactivated)', () => {
fs.writeFileSync(
path.join(tmpDir, '.planning', 'config.json'),