From 1ba21fae52f66c11790910b2878d16c7e1a50246 Mon Sep 17 00:00:00 2001 From: waleedcodes <110061477+waleedcodes@users.noreply.github.com> Date: Fri, 9 Oct 2026 21:26:28 +0500 Subject: [PATCH 1/3] test(webview): scaffold webview panel test suite and mocks --- tests/webviewPanel.test.ts | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 tests/webviewPanel.test.ts diff --git a/tests/webviewPanel.test.ts b/tests/webviewPanel.test.ts new file mode 100644 index 0000000..79e41e5 --- /dev/null +++ b/tests/webviewPanel.test.ts @@ -0,0 +1,38 @@ +import { describe, expect, it } from 'vitest'; +import * as vscode from 'vscode'; +import { ProofCodeWebviewPanel } from '../src/ui/webviewPanel'; +import { VerificationReport } from '../src/types'; + +describe('ProofCodeWebviewPanel', () => { + it('should generate rich glassmorphic HTML containing the Impact Blast Graph and tabs', () => { + const mockReport: VerificationReport = { + timestamp: new Date().toISOString(), + repoRoot: '/workspace', + branch: 'feature/auth', + score: { total: 76, deductions: [] }, + verdict: 'NEEDS_REVIEW', + summary: { + filesChanged: 2, + linesAdded: 30, + linesDeleted: 5, + symbolsAffected: 2, + apiRoutesAffected: 1, + testsAdded: 1, + testsAffected: 1, + highRiskCount: 0, + mediumRiskCount: 1, + lowRiskCount: 2 + }, + impact: { + changedFiles: ['/workspace/src/auth.ts'], + changedSymbols: [ + { + symbolName: 'getUser', + kind: 'function', + filePath: '/workspace/src/auth.ts', + callers: [ + { callerName: 'Dashboard', filePath: '/workspace/src/Dashboard.tsx', line: 12, hasTest: true }, + { callerName: 'AdminPanel', filePath: '/workspace/src/AdminPanel.tsx', line: 8, hasTest: false } + ], + isApiRoute: false + } From 0e871d0cbe6d0dab5f685756c368f67a143aac4d Mon Sep 17 00:00:00 2001 From: waleedcodes <110061477+waleedcodes@users.noreply.github.com> Date: Fri, 9 Oct 2026 21:26:28 +0500 Subject: [PATCH 2/3] test(webview): test dashboard HTML generation and tab structure --- tests/webviewPanel.test.ts | 45 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/tests/webviewPanel.test.ts b/tests/webviewPanel.test.ts index 79e41e5..9b07b14 100644 --- a/tests/webviewPanel.test.ts +++ b/tests/webviewPanel.test.ts @@ -36,3 +36,48 @@ describe('ProofCodeWebviewPanel', () => { ], isApiRoute: false } + ], + affectedFiles: ['/workspace/src/Dashboard.tsx', '/workspace/src/AdminPanel.tsx'], + affectedCallers: [], + affectedRoutes: [ + { + routePath: '/api/auth/session', + method: 'GET', + filePath: '/workspace/src/api/auth.ts', + line: 5 + } + ], + totalCallersCount: 2, + untestedCallersCount: 1 + }, + risks: [], + breakageRisks: [ + { + id: 'BRK-1', + severity: 'HIGH', + area: 'Authentication', + trigger: 'getUser modified', + detail: 'Downstream callers at risk', + affectedCallersOrRoutes: ['AdminPanel'] + } + ], + rules: [], + checks: { + typescript: { name: 'TypeScript', status: 'PASS' }, + eslint: { name: 'ESLint', status: 'PASS' }, + unitTests: { name: 'Unit Tests', status: 'PASS' }, + build: { name: 'Build', status: 'PASS' } + } + }; + + // Instantiate panel via private constructor method or test _getHtmlForWebview + // We can call createOrShow with mock panel + const mockWebview: any = { + html: '', + onDidReceiveMessage: () => ({ dispose: () => {} }), + asWebviewUri: (uri: any) => uri, + cspSource: 'https:' + }; + + const mockPanel: any = { + webview: mockWebview, From 41cc78b2d88c373c46915e3ac9c78022ee8e616b Mon Sep 17 00:00:00 2001 From: waleedcodes <110061477+waleedcodes@users.noreply.github.com> Date: Fri, 9 Oct 2026 21:26:29 +0500 Subject: [PATCH 3/3] test(webview): test visual blast graph and live search input rendering --- tests/webviewPanel.test.ts | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/webviewPanel.test.ts b/tests/webviewPanel.test.ts index 9b07b14..19e2b5c 100644 --- a/tests/webviewPanel.test.ts +++ b/tests/webviewPanel.test.ts @@ -81,3 +81,31 @@ describe('ProofCodeWebviewPanel', () => { const mockPanel: any = { webview: mockWebview, + onDidDispose: () => ({ dispose: () => {} }), + reveal: () => {}, + dispose: () => {} + }; + + (vscode.window.createWebviewPanel as any) = () => mockPanel; + + ProofCodeWebviewPanel.createOrShow( + vscode.Uri.file('/ext'), + mockReport, + async () => {}, + async () => {} + ); + + const html = mockWebview.html; + expect(html).toContain('ProofCode Change Verification'); + expect(html).toContain('id="impact-search"'); + expect(html).toContain('All Symbols'); + expect(html).toContain('⚠️ Untested Callers'); + expect(html).toContain('getUser'); + expect(html).toContain('Dashboard'); + expect(html).toContain('AdminPanel'); + expect(html).toContain('✓ Test Covered'); + expect(html).toContain('⚠️ Untested Caller'); + expect(html).toContain('/api/auth/session'); + expect(html).toContain('💥 What Could Break'); + }); +});