* feat(#1942): VS Code extension — repo-local IDE host with reachability proof The VS Code extension (vscode/extension.js + vscode/package.json) is a repo-local, buildable extension (not Marketplace-published). The gsd.invoke handler dispatches in-process through the GSD command-routing hub. The handler is exported separately from activate() so it is testable without a VS Code host. tests/vscode-extension-reachability.test.cjs: proves the handler dispatches through the hub + returns a result (keystone wired); the manifest declares the command + engine; resolveEngineRoot finds the gsd-core/ dir. * docs(changeset): VS Code extension (#1966) * fix(#1942): register vscode/package.json in VERSIONED_MANIFESTS (#844) * fix(#1942): align vscode/package.json version with package.json (1.7.0-rc.1)
This commit is contained in:
51
tests/vscode-extension-reachability.test.cjs
Normal file
51
tests/vscode-extension-reachability.test.cjs
Normal file
@@ -0,0 +1,51 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* VS Code extension reachability test — ADR-1239 Phase D / #1942.
|
||||
*
|
||||
* Proves the VS Code extension is keystone-WIRED: the gsd.invoke handler
|
||||
* dispatches through the GSD command-routing hub and returns a result (not just
|
||||
* a stub). The handler is exported separately from activate() so it is testable
|
||||
* WITHOUT a VS Code host.
|
||||
*/
|
||||
|
||||
const { test } = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
|
||||
const { activate, dispatchGsdCommand, resolveEngineRoot } = require('../vscode/extension.js');
|
||||
|
||||
test('the extension exports activate + dispatchGsdCommand + resolveEngineRoot', () => {
|
||||
assert.equal(typeof activate, 'function');
|
||||
assert.equal(typeof dispatchGsdCommand, 'function');
|
||||
assert.equal(typeof resolveEngineRoot, 'function');
|
||||
});
|
||||
|
||||
test('REACHABILITY: dispatchGsdCommand dispatches through the engine hub (keystone wired)', async () => {
|
||||
const result = await dispatchGsdCommand({ family: 'query', subcommand: 'help' });
|
||||
assert.equal(typeof result, 'string', 'returns a string result');
|
||||
const parsed = JSON.parse(result);
|
||||
assert.ok(parsed !== null && typeof parsed === 'object',
|
||||
'dispatch produced a result object (the engine was reached)');
|
||||
});
|
||||
|
||||
test('dispatchGsdCommand works with default args (no args → query/help)', async () => {
|
||||
const result = await dispatchGsdCommand();
|
||||
assert.equal(typeof result, 'string');
|
||||
JSON.parse(result); // must be valid JSON
|
||||
});
|
||||
|
||||
test('resolveEngineRoot finds the gsd-core/ dir from the extension location', () => {
|
||||
const root = resolveEngineRoot(__dirname + '/../vscode');
|
||||
const fs = require('fs');
|
||||
assert.ok(fs.existsSync(require('path').join(root, 'gsd-core')),
|
||||
'resolveEngineRoot finds a dir containing gsd-core/');
|
||||
});
|
||||
|
||||
test('the extension manifest declares the gsd.invoke command', () => {
|
||||
const pkg = require('../vscode/package.json');
|
||||
assert.ok(pkg.contributes && pkg.contributes.commands, 'manifest has commands');
|
||||
const cmd = pkg.contributes.commands.find((c) => c.command === 'gsd.invoke');
|
||||
assert.ok(cmd, 'manifest declares gsd.invoke');
|
||||
assert.ok(pkg.engines && pkg.engines.vscode, 'manifest declares VS Code engine');
|
||||
assert.equal(pkg.main, './extension.js', 'manifest main points to extension.js');
|
||||
});
|
||||
Reference in New Issue
Block a user