diff --git a/src/resources/extensions/gsd/tests/claude-import-tui.test.ts b/src/resources/extensions/gsd/tests/claude-import-tui.test.ts index 51b62c8d8..12d64f99a 100644 --- a/src/resources/extensions/gsd/tests/claude-import-tui.test.ts +++ b/src/resources/extensions/gsd/tests/claude-import-tui.test.ts @@ -14,6 +14,7 @@ import assert from 'node:assert'; import { existsSync, mkdtempSync, rmSync, writeFileSync, readFileSync, mkdirSync } from 'node:fs'; import { tmpdir } from 'node:os'; import { join } from 'node:path'; +import type { ExtensionCommandContext } from '@gsd/pi-coding-agent'; import { runClaudeImportFlow, getClaudeSearchRoots, discoverClaudeSkills, discoverClaudePlugins } from '../claude-import.js'; import { getMarketplaceFixtures } from './marketplace-test-fixtures.js'; @@ -40,14 +41,7 @@ interface MockUISelectCall { } function createMockContext(selections: string[]): { - ctx: { - ui: { - select: ReturnType; - notify: ReturnType; - }; - waitForIdle: ReturnType; - reload: ReturnType; - }; + ctx: ExtensionCommandContext; selectCalls: MockUISelectCall[]; } { const selectCalls: MockUISelectCall[] = []; @@ -64,16 +58,55 @@ function createMockContext(selections: string[]): { const notifyMock = mock.fn(); + // Create a mock that satisfies ExtensionCommandContext + // Using type assertion since we only use select, notify, waitForIdle, reload in the tests const ctx = { ui: { select: selectMock, notify: notifyMock, + confirm: async () => false, + input: async () => undefined, + onTerminalInput: () => () => {}, + setStatus: () => {}, + setWorkingMessage: () => {}, + setWidget: () => {}, + setFooter: () => {}, + setHeader: () => {}, + setTitle: () => {}, + custom: async () => { throw new Error('Not implemented'); }, + pasteToEditor: () => {}, + setEditorText: () => {}, + getEditorText: () => '', + editor: async () => undefined, + setEditorComponent: () => {}, + theme: {}, + getAllThemes: () => [], + getTheme: () => undefined, + setTheme: () => ({ success: false }), + getToolsExpanded: () => true, + setToolsExpanded: () => {}, }, + hasUI: true, + cwd: process.cwd(), + sessionManager: {} as unknown, + modelRegistry: {} as unknown, + model: undefined, + isIdle: () => true, + abort: () => {}, + hasPendingMessages: () => false, + shutdown: () => {}, + getContextUsage: () => undefined, + compact: () => {}, + getSystemPrompt: () => '', waitForIdle: mock.fn(async () => {}), + newSession: async () => ({ cancelled: false }), + fork: async () => ({ cancelled: false }), + navigateTree: async () => ({ cancelled: false }), + switchSession: async () => ({ cancelled: false }), reload: mock.fn(async () => {}), - }; + } as unknown as ExtensionCommandContext; - return { ctx: ctx as unknown as Parameters[0], selectCalls }; + return { ctx, selectCalls }; } // ============================================================================ @@ -262,7 +295,7 @@ describe( }); // Verify notification was called - const notifyCalls = (ctx.ui.notify as ReturnType).mock.calls; + const notifyCalls = (ctx.ui.notify as unknown as ReturnType).mock.calls; assert.ok(notifyCalls.length > 0, 'Should have shown notification'); console.log('\nNotifications shown:'); diff --git a/src/resources/extensions/gsd/tests/marketplace-discovery.test.ts b/src/resources/extensions/gsd/tests/marketplace-discovery.test.ts index e40233506..1be693d0e 100644 --- a/src/resources/extensions/gsd/tests/marketplace-discovery.test.ts +++ b/src/resources/extensions/gsd/tests/marketplace-discovery.test.ts @@ -15,7 +15,7 @@ import { inspectPlugin, discoverMarketplace, resolvePluginRoot -} from '../marketplace-discovery'; +} from '../marketplace-discovery.js'; import { getMarketplaceFixtures } from './marketplace-test-fixtures.js'; const fixtureSetup = getMarketplaceFixtures(import.meta.dirname); @@ -110,6 +110,7 @@ describe('inspectPlugin', { skip: skipReason }, () => { it('should return error for non-existent plugin directory', () => { const result = inspectPlugin('/tmp/nonexistent-plugin'); assert.strictEqual(result.status, 'error'); + assert.ok(result.error !== undefined, 'error should be defined'); assert.ok(result.error.includes('not found')); }); }); @@ -121,7 +122,7 @@ describe('discoverMarketplace', { skip: skipReason }, () => { assert.strictEqual(result.status, 'ok'); assert.strictEqual(result.pluginFormat, 'jamie-style'); assert.ok(result.plugins.length > 0); - assert.ok(result.plugins.every(p => p.status === 'ok')); + assert.ok(result.plugins.every((p: { status: string }) => p.status === 'ok')); assert.strictEqual(result.summary.total, result.plugins.length); assert.strictEqual(result.summary.ok, result.plugins.length); @@ -148,7 +149,7 @@ describe('discoverMarketplace', { skip: skipReason }, () => { it('should inventory skills, agents, commands correctly', () => { const result = discoverMarketplace(CLAUDE_SKILLS_PATH!); - const pythonPlugin = result.plugins.find(p => p.name === 'python3-development'); + const pythonPlugin = result.plugins.find((p: { name: string }) => p.name === 'python3-development'); assert.ok(pythonPlugin !== undefined); if (pythonPlugin) {