Files
dss/admin-ui/js/components/tools/ds-regression-testing.js
Digital Production Factory 276ed71f31 Initial commit: Clean DSS implementation
Migrated from design-system-swarm with fresh git history.
Old project history preserved in /home/overbits/apps/design-system-swarm

Core components:
- MCP Server (Python FastAPI with mcp 1.23.1)
- Claude Plugin (agents, commands, skills, strategies, hooks, core)
- DSS Backend (dss-mvp1 - token translation, Figma sync)
- Admin UI (Node.js/React)
- Server (Node.js/Express)
- Storybook integration (dss-mvp1/.storybook)

Self-contained configuration:
- All paths relative or use DSS_BASE_PATH=/home/overbits/dss
- PYTHONPATH configured for dss-mvp1 and dss-claude-plugin
- .env file with all configuration
- Claude plugin uses ${CLAUDE_PLUGIN_ROOT} for portability

Migration completed: $(date)
🤖 Clean migration with full functionality preserved
2025-12-09 18:45:48 -03:00

116 lines
5.8 KiB
JavaScript

export default class RegressionTesting extends HTMLElement {
constructor() {
super();
this.regressions = [];
this.isRunning = false;
}
connectedCallback() {
this.render();
this.setupEventListeners();
}
render() {
this.innerHTML = `
<div style="padding: 24px; height: 100%; overflow-y: auto;">
<h1 style="margin: 0 0 8px 0; font-size: 24px;">Visual Regression Testing</h1>
<p style="margin: 0 0 24px 0; color: var(--vscode-text-dim);">Detect visual changes in design system components</p>
<div style="background: var(--vscode-sidebar); border: 1px solid var(--vscode-border); border-radius: 4px; padding: 16px; margin-bottom: 24px;">
<label style="display: block; font-size: 12px; font-weight: 500; margin-bottom: 8px;">Components to Test</label>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px;">
<label style="display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 12px;">
<input type="checkbox" checked /> Buttons
</label>
<label style="display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 12px;">
<input type="checkbox" checked /> Inputs
</label>
<label style="display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 12px;">
<input type="checkbox" checked /> Cards
</label>
<label style="display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 12px;">
<input type="checkbox" checked /> Modals
</label>
</div>
<button id="run-tests-btn" style="width: 100%; padding: 8px; background: var(--vscode-button-background); color: var(--vscode-button-foreground); border: none; border-radius: 4px; cursor: pointer; font-weight: 500; font-size: 12px;">Run Tests</button>
</div>
<div id="progress-container" style="display: none; margin-bottom: 24px;">
<div style="margin-bottom: 8px; font-size: 12px; color: var(--vscode-text-dim);">Testing... <span id="progress-count">0/4</span></div>
<div style="width: 100%; height: 6px; background: var(--vscode-bg); border-radius: 3px; overflow: hidden;">
<div id="progress-bar" style="width: 0%; height: 100%; background: #0066CC; transition: width 0.3s;"></div>
</div>
</div>
<div id="results-container" style="display: none;"></div>
</div>
`;
}
setupEventListeners() {
this.querySelector('#run-tests-btn').addEventListener('click', () => this.runTests());
}
async runTests() {
this.isRunning = true;
this.querySelector('#progress-container').style.display = 'block';
this.querySelector('#results-container').style.display = 'none';
const components = ['Buttons', 'Inputs', 'Cards', 'Modals'];
this.regressions = [];
for (let i = 0; i < components.length; i++) {
this.querySelector('#progress-count').textContent = (i + 1) + '/4';
this.querySelector('#progress-bar').style.width = ((i + 1) / 4 * 100) + '%';
await new Promise(resolve => setTimeout(resolve, 600));
if (Math.random() > 0.7) {
this.regressions.push({
component: components[i],
severity: Math.random() > 0.5 ? 'critical' : 'minor'
});
}
}
this.renderResults();
this.querySelector('#progress-container').style.display = 'none';
this.querySelector('#results-container').style.display = 'block';
}
renderResults() {
const container = this.querySelector('#results-container');
const passed = 4 - this.regressions.length;
let html = `<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 24px;">
<div style="background: var(--vscode-sidebar); padding: 12px; border-radius: 4px; text-align: center; border: 2px solid #4CAF50;">
<div style="font-size: 24px; font-weight: 600; color: #4CAF50;">${passed}</div>
<div style="font-size: 11px; color: var(--vscode-text-dim);">Passed</div>
</div>
<div style="background: var(--vscode-sidebar); padding: 12px; border-radius: 4px; text-align: center; border: 2px solid ${this.regressions.length > 0 ? '#F44336' : '#4CAF50'};">
<div style="font-size: 24px; font-weight: 600; color: ${this.regressions.length > 0 ? '#F44336' : '#4CAF50'};">${this.regressions.length}</div>
<div style="font-size: 11px; color: var(--vscode-text-dim);">Regressions</div>
</div>
</div>`;
if (this.regressions.length === 0) {
html += `<div style="background: var(--vscode-sidebar); border: 1px solid var(--vscode-border); border-radius: 4px; padding: 24px; text-align: center;"><div style="font-size: 20px; margin-bottom: 8px;">All Tests Passed</div></div>`;
} else {
html += `<h2 style="margin: 0 0 12px 0; font-size: 14px;">Regressions Found</h2>`;
for (let reg of this.regressions) {
const color = reg.severity === 'critical' ? '#F44336' : '#FF9800';
html += `<div style="background: var(--vscode-sidebar); border: 1px solid var(--vscode-border); border-radius: 4px; padding: 12px; margin-bottom: 12px;">
<div style="display: flex; justify-content: space-between; margin-bottom: 8px;">
<div style="font-weight: 500;">${reg.component}</div>
<span style="padding: 2px 8px; background: ${color}; color: white; border-radius: 2px; font-size: 10px;">${reg.severity}</span>
</div>
<button style="width: 100%; padding: 6px; background: var(--vscode-button-background); color: var(--vscode-button-foreground); border: none; border-radius: 3px; cursor: pointer; font-size: 10px;">Approve as Baseline</button>
</div>`;
}
}
container.innerHTML = html;
}
}
customElements.define('ds-regression-testing', RegressionTesting);