// Platform Test Plugin โ€” Runtime Diagnostics Panel // Renders inside the Plugin Manager UI via the contributions system. class DiagnosticsPanel extends HTMLElement { constructor() { super(); this.attachShadow({ mode: 'open' }); } connectedCallback() { this.render(); this.runTests(); } async runTests() { const results = []; const tests = [ { name: 'manifest loaded', run: () => this.manifest !== null }, { name: 'api version >= 0.1.0', run: () => this.compareVersions(this.apiVersion, '0.1.0') >= 0 }, { name: 'capability registered', run: () => this.checkCapability('verstak/platform-test/v1') }, { name: 'container exists', run: () => !!document.getElementById('platform-test-root') }, ]; for (const test of tests) { try { const passed = await test.run(); results.push({ name: test.name, passed, error: null }); } catch (e) { results.push({ name: test.name, passed: false, error: e.message }); } } this.renderResults(results); } compareVersions(a, b) { const pa = a.split('.').map(Number); const pb = b.split('.').map(Number); for (let i = 0; i < 3; i++) { if ((pa[i] || 0) > (pb[i] || 0)) return 1; if ((pa[i] || 0) < (pb[i] || 0)) return -1; } return 0; } async checkCapability(name) { try { const caps = await window.go.api.App.GetCapabilities(); return caps.some(c => c.name === name); } catch { return false; } } get manifest() { try { return window.__VERSTAK_PLUGIN_MANIFEST__ || null; } catch { return null; } } get apiVersion() { return this.manifest?.apiVersion || '0.0.0'; } render() { this.shadowRoot.innerHTML = `

๐Ÿงช Platform Diagnostics

Runtime tests for plugin infrastructure

Running tests...

`; } renderResults(results) { const container = this.shadowRoot.getElementById('test-results'); const allPassed = results.every(r => r.passed); container.innerHTML = `
${allPassed ? 'โœ… All Tests Pass' : 'โŒ Some Tests Failed'} โ€” ${results.filter(r => r.passed).length}/${results.length}
${results.map(r => ` `).join('')}
Test Result
${r.name} ${r.passed ? 'โœ“ PASS' : 'โœ— FAIL'}${r.error ? ` โ€” ${r.error}` : ''}
Plugin Info: ${this.manifest ? JSON.stringify(this.manifest, null, 2) : 'Not available'}
`; } } customElements.define('platform-test-diagnostics', DiagnosticsPanel); // Auto-mount if we detect we're standalone if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', mount); } else { mount(); } function mount() { const root = document.getElementById('platform-test-root'); if (root && !root.querySelector('platform-test-diagnostics')) { const panel = document.createElement('platform-test-diagnostics'); root.appendChild(panel); } }