From 76c9c86d925cecc665ce57809d548e6b9bae626a Mon Sep 17 00:00:00 2001 From: waleedcodes <110061477+waleedcodes@users.noreply.github.com> Date: Fri, 9 Oct 2026 21:26:43 +0500 Subject: [PATCH 1/3] test(extension): scaffold extension lifecycle test suite --- tests/extension.test.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 tests/extension.test.ts diff --git a/tests/extension.test.ts b/tests/extension.test.ts new file mode 100644 index 0000000..a918a71 --- /dev/null +++ b/tests/extension.test.ts @@ -0,0 +1,11 @@ +import { describe, expect, it } from 'vitest'; +import * as vscode from 'vscode'; +import { activate, deactivate } from '../src/extension/index'; + +describe('Extension Lifecycle', () => { + it('should activate extension and register commands, views, and subscriptions', () => { + const registeredCommands: string[] = []; + (vscode.commands.registerCommand as any) = (cmd: string, _callback: any) => { + registeredCommands.push(cmd); + return { dispose: () => {} }; + }; From 267a88141e01d32b4ba5d7b5b3aafb8f754aeb5f Mon Sep 17 00:00:00 2001 From: waleedcodes <110061477+waleedcodes@users.noreply.github.com> Date: Fri, 9 Oct 2026 21:26:43 +0500 Subject: [PATCH 2/3] test(extension): test command registrations and subscription tracking --- tests/extension.test.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/extension.test.ts b/tests/extension.test.ts index a918a71..2cd34b4 100644 --- a/tests/extension.test.ts +++ b/tests/extension.test.ts @@ -9,3 +9,16 @@ describe('Extension Lifecycle', () => { registeredCommands.push(cmd); return { dispose: () => {} }; }; + + const mockContext: any = { + subscriptions: [], + extensionUri: vscode.Uri.file('/extension') + }; + + expect(() => activate(mockContext)).not.toThrow(); + + // Verify key commands registered + expect(registeredCommands).toContain('proofcode.verifyChange'); + expect(registeredCommands).toContain('proofcode.openDashboard'); + expect(registeredCommands).toContain('proofcode.initRules'); + expect(registeredCommands).toContain('proofcode.openEvidence'); From d3e31f9292fe39800cb637ed54d4d2bd222ddf8d Mon Sep 17 00:00:00 2001 From: waleedcodes <110061477+waleedcodes@users.noreply.github.com> Date: Fri, 9 Oct 2026 21:26:43 +0500 Subject: [PATCH 3/3] test(extension): test clean disposal in deactivate --- tests/extension.test.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/extension.test.ts b/tests/extension.test.ts index 2cd34b4..5f0f7b6 100644 --- a/tests/extension.test.ts +++ b/tests/extension.test.ts @@ -22,3 +22,12 @@ describe('Extension Lifecycle', () => { expect(registeredCommands).toContain('proofcode.openDashboard'); expect(registeredCommands).toContain('proofcode.initRules'); expect(registeredCommands).toContain('proofcode.openEvidence'); + expect(registeredCommands).toContain('proofcode.exportReport'); + + // Verify subscriptions registered + expect(mockContext.subscriptions.length).toBeGreaterThan(0); + + // Verify deactivate does not throw + expect(() => deactivate()).not.toThrow(); + }); +});