UI 1000x upgrade: frontend/src/pages/GeneratePage.tsx
Browse files- frontend/src/pages/GeneratePage.tsx +151 -128
frontend/src/pages/GeneratePage.tsx
CHANGED
|
@@ -1,15 +1,15 @@
|
|
| 1 |
import React, { useState } from 'react';
|
| 2 |
|
| 3 |
-
const
|
| 4 |
|
| 5 |
const TABS = [
|
| 6 |
-
{ id: 'requirements', label: '
|
| 7 |
-
{ id: 'api
|
| 8 |
-
{ id: 'code', label: '
|
| 9 |
-
{ id: 'flow', label: '
|
| 10 |
];
|
| 11 |
|
| 12 |
-
const FRAMEWORKS = {
|
| 13 |
python: ['pytest', 'unittest'],
|
| 14 |
javascript: ['jest', 'mocha', 'cypress', 'playwright'],
|
| 15 |
typescript: ['jest', 'vitest', 'playwright'],
|
|
@@ -17,177 +17,200 @@ const FRAMEWORKS = {
|
|
| 17 |
};
|
| 18 |
|
| 19 |
export function GeneratePage() {
|
| 20 |
-
const [
|
| 21 |
const [input, setInput] = useState('');
|
| 22 |
-
const [
|
| 23 |
const [framework, setFramework] = useState('pytest');
|
| 24 |
-
const [testTypes, setTestTypes] = useState(['unit', 'integration', 'edge_case']);
|
|
|
|
| 25 |
const [result, setResult] = useState<any>(null);
|
| 26 |
const [loading, setLoading] = useState(false);
|
| 27 |
const [error, setError] = useState('');
|
| 28 |
-
const [
|
|
|
|
| 29 |
|
| 30 |
const generate = async () => {
|
| 31 |
if (!input.trim()) return;
|
| 32 |
-
setLoading(true);
|
| 33 |
-
setError('');
|
| 34 |
-
setResult(null);
|
| 35 |
|
| 36 |
try {
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
body.source_code = input;
|
| 52 |
-
body.filename = `source.${language === 'python' ? 'py' : language === 'go' ? 'go' : 'ts'}`;
|
| 53 |
-
break;
|
| 54 |
-
case 'flow':
|
| 55 |
-
endpoint = '/api/v1/generate/from-flow';
|
| 56 |
-
body.flow_description = input;
|
| 57 |
-
body.framework = language === 'python' ? 'playwright' : 'cypress';
|
| 58 |
-
break;
|
| 59 |
}
|
| 60 |
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
headers: { 'Content-Type': 'application/json' },
|
| 64 |
-
body: JSON.stringify(body),
|
| 65 |
-
});
|
| 66 |
|
| 67 |
-
if (!
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
}
|
| 71 |
-
|
| 72 |
-
const data = await resp.json();
|
| 73 |
-
setResult(data);
|
| 74 |
-
setActiveFileIdx(0);
|
| 75 |
-
|
| 76 |
-
// Save to history
|
| 77 |
-
const history = JSON.parse(localStorage.getItem('testgenius_history') || '[]');
|
| 78 |
-
history.unshift({ ...data, input: input.slice(0, 200), tab: activeTab, timestamp: Date.now() });
|
| 79 |
-
localStorage.setItem('testgenius_history', JSON.stringify(history.slice(0, 20)));
|
| 80 |
-
|
| 81 |
-
} catch (e: any) {
|
| 82 |
-
setError(e.message || 'Generation failed');
|
| 83 |
-
} finally {
|
| 84 |
-
setLoading(false);
|
| 85 |
-
}
|
| 86 |
-
};
|
| 87 |
|
| 88 |
-
|
| 89 |
-
|
|
|
|
|
|
|
|
|
|
| 90 |
};
|
| 91 |
|
| 92 |
-
const currentTab = TABS.find(t => t.id ===
|
|
|
|
|
|
|
|
|
|
| 93 |
|
| 94 |
return (
|
| 95 |
-
<div className="max-w-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
<div
|
| 99 |
-
|
| 100 |
-
<
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
</button>
|
| 106 |
))}
|
| 107 |
</div>
|
| 108 |
|
| 109 |
-
{/*
|
| 110 |
-
<div className="flex gap-
|
| 111 |
-
<select value={language} onChange={e => { setLanguage(e.target.value); setFramework(FRAMEWORKS[e.target.value as keyof typeof FRAMEWORKS][0]); }}
|
| 112 |
-
className="bg-white/[0.03] border border-white/[0.08] rounded-lg px-3 py-2 text-sm text-white">
|
| 113 |
-
<option value="python">Python</option>
|
| 114 |
-
<option value="javascript">JavaScript</option>
|
| 115 |
-
<option value="typescript">TypeScript</option>
|
| 116 |
-
<option value="go">Go</option>
|
| 117 |
-
</select>
|
| 118 |
-
<select value={framework} onChange={e => setFramework(e.target.value)}
|
| 119 |
-
className="bg-white/[0.03] border border-white/[0.08] rounded-lg px-3 py-2 text-sm text-white">
|
| 120 |
-
{(FRAMEWORKS[language as keyof typeof FRAMEWORKS] || []).map(f => (
|
| 121 |
-
<option key={f} value={f}>{f}</option>
|
| 122 |
-
))}
|
| 123 |
-
</select>
|
| 124 |
-
</div>
|
| 125 |
-
|
| 126 |
-
{/* Test Type Checkboxes */}
|
| 127 |
-
<div className="flex flex-wrap gap-2 mb-3">
|
| 128 |
{['unit', 'integration', 'edge_case', 'security', 'e2e'].map(t => (
|
| 129 |
-
<
|
| 130 |
-
|
|
|
|
| 131 |
{t.replace('_', ' ')}
|
| 132 |
-
</
|
| 133 |
))}
|
| 134 |
</div>
|
| 135 |
|
| 136 |
{/* Textarea */}
|
| 137 |
-
<textarea value={input} onChange={e => setInput(e.target.value)}
|
| 138 |
-
|
| 139 |
-
className="flex-1 bg-white/[0.02] border border-white/[0.06] rounded-xl p-4 text-sm text-gray-200 placeholder-gray-600 resize-none focus:outline-none focus:border-emerald-500/40 font-mono" />
|
| 140 |
|
| 141 |
{/* Generate Button */}
|
| 142 |
<button onClick={generate} disabled={loading || !input.trim()}
|
| 143 |
-
className={`mt-3 py-3 rounded-xl font-semibold text-
|
| 144 |
-
|
|
|
|
|
|
|
| 145 |
</button>
|
| 146 |
-
|
| 147 |
-
{error && <p className="mt-2 text-red-400 text-xs">{error}</p>}
|
| 148 |
</div>
|
| 149 |
|
| 150 |
-
{/* RIGHT: Output
|
| 151 |
-
<div className="flex flex-col bg-white/[0.01] border border-white/[0.
|
| 152 |
{result ? (
|
| 153 |
<>
|
| 154 |
-
{/*
|
| 155 |
-
<div className="flex items-center justify-between px-4 py-2 border-b border-white/[0.
|
| 156 |
-
<div className="flex items-center gap-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 160 |
</div>
|
| 161 |
-
<button onClick={() =>
|
| 162 |
-
className="px-3 py-1 bg-emerald-
|
| 163 |
-
|
| 164 |
</button>
|
| 165 |
</div>
|
| 166 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 167 |
{/* File Tabs */}
|
| 168 |
-
{
|
| 169 |
-
<div className="flex
|
| 170 |
-
{
|
| 171 |
-
<button key={i} onClick={() =>
|
| 172 |
-
className={`px-
|
| 173 |
-
|
|
|
|
| 174 |
</button>
|
| 175 |
))}
|
| 176 |
</div>
|
| 177 |
)}
|
| 178 |
|
| 179 |
-
{/* Code
|
| 180 |
-
<pre className="flex-1 overflow-auto p-4 text-
|
| 181 |
-
{
|
| 182 |
</pre>
|
| 183 |
</>
|
| 184 |
) : (
|
| 185 |
-
<div className="flex-1 flex items-center justify-center
|
| 186 |
-
<div>
|
| 187 |
-
<div className="text-5xl mb-
|
| 188 |
-
<h3 className="text-
|
| 189 |
-
<p className="text-
|
| 190 |
-
Paste your
|
|
|
|
| 191 |
</p>
|
| 192 |
</div>
|
| 193 |
</div>
|
|
|
|
| 1 |
import React, { useState } from 'react';
|
| 2 |
|
| 3 |
+
const API = import.meta.env.VITE_API_URL || 'http://localhost:8000';
|
| 4 |
|
| 5 |
const TABS = [
|
| 6 |
+
{ id: 'requirements', label: 'Requirements', icon: '📝', placeholder: 'Paste product requirements, user stories, acceptance criteria...\n\nExample:\n• User can register with email + password\n• Password: 8+ chars, uppercase, lowercase, number\n• Email must be unique in system\n• Send verification email on signup\n• Rate limit: max 5 signup attempts per IP per hour\n• Account locked after 5 failed login attempts' },
|
| 7 |
+
{ id: 'api', label: 'API Spec', icon: '🔌', placeholder: 'Paste OpenAPI/Swagger JSON specification...\n\n{\n "openapi": "3.0.0",\n "info": { "title": "User API" },\n "paths": {\n "/users": { "post": { "summary": "Create user" } }\n }\n}' },
|
| 8 |
+
{ id: 'code', label: 'Source Code', icon: '💻', placeholder: 'Paste Python/JS/TS/Go source code...\n\ndef calculate_discount(price, user_type, coupon=None):\n if price <= 0:\n raise ValueError("Price must be positive")\n discount = 0\n if user_type == "premium":\n discount = 0.2\n elif user_type == "member":\n discount = 0.1\n if coupon and coupon.is_valid():\n discount += coupon.value\n return min(discount, 0.5) * price' },
|
| 9 |
+
{ id: 'flow', label: 'User Flow', icon: '🖥️', placeholder: 'Describe the frontend user flow...\n\nCheckout Flow:\n1. User reviews cart items (quantity editable)\n2. Enters shipping address (with autocomplete)\n3. Selects shipping method (standard/express)\n4. Enters payment (card number, expiry, CVV)\n5. Reviews order summary\n6. Clicks "Place Order"\n7. Shows confirmation with order number\n8. Sends confirmation email' },
|
| 10 |
];
|
| 11 |
|
| 12 |
+
const FRAMEWORKS: Record<string, string[]> = {
|
| 13 |
python: ['pytest', 'unittest'],
|
| 14 |
javascript: ['jest', 'mocha', 'cypress', 'playwright'],
|
| 15 |
typescript: ['jest', 'vitest', 'playwright'],
|
|
|
|
| 17 |
};
|
| 18 |
|
| 19 |
export function GeneratePage() {
|
| 20 |
+
const [tab, setTab] = useState('requirements');
|
| 21 |
const [input, setInput] = useState('');
|
| 22 |
+
const [lang, setLang] = useState('python');
|
| 23 |
const [framework, setFramework] = useState('pytest');
|
| 24 |
+
const [testTypes, setTestTypes] = useState(['unit', 'integration', 'edge_case', 'security']);
|
| 25 |
+
const [useMultiAgent, setUseMultiAgent] = useState(true);
|
| 26 |
const [result, setResult] = useState<any>(null);
|
| 27 |
const [loading, setLoading] = useState(false);
|
| 28 |
const [error, setError] = useState('');
|
| 29 |
+
const [activeFile, setActiveFile] = useState(0);
|
| 30 |
+
const [stage, setStage] = useState('');
|
| 31 |
|
| 32 |
const generate = async () => {
|
| 33 |
if (!input.trim()) return;
|
| 34 |
+
setLoading(true); setError(''); setResult(null); setStage('Analyzing input...');
|
|
|
|
|
|
|
| 35 |
|
| 36 |
try {
|
| 37 |
+
const endpoint = useMultiAgent ? '/api/v1/generate/multi-agent' : `/api/v1/generate/from-${tab === 'api' ? 'api-spec' : tab === 'flow' ? 'flow' : tab}`;
|
| 38 |
+
|
| 39 |
+
let body: any = { framework, language: lang, test_types: testTypes };
|
| 40 |
+
if (useMultiAgent) {
|
| 41 |
+
body = { ...body, max_iterations: 2 };
|
| 42 |
+
if (tab === 'requirements') body.requirements = input;
|
| 43 |
+
else if (tab === 'api') body.openapi_spec = JSON.parse(input);
|
| 44 |
+
else if (tab === 'code') body.source_code = input;
|
| 45 |
+
else body.requirements = input; // flow as requirements for multi-agent
|
| 46 |
+
} else {
|
| 47 |
+
if (tab === 'requirements') body.requirements = input;
|
| 48 |
+
else if (tab === 'api') body.openapi_spec = JSON.parse(input);
|
| 49 |
+
else if (tab === 'code') { body.source_code = input; body.filename = `source.${lang === 'python' ? 'py' : 'ts'}`; }
|
| 50 |
+
else body.flow_description = input;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
}
|
| 52 |
|
| 53 |
+
setStage(useMultiAgent ? 'Running 5-agent pipeline...' : 'Generating tests...');
|
| 54 |
+
const res = await fetch(`${API}${endpoint}`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) });
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
+
if (!res.ok) throw new Error((await res.json()).detail || `Error ${res.status}`);
|
| 57 |
+
const data = await res.json();
|
| 58 |
+
setResult(data); setActiveFile(0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
|
| 60 |
+
// Save history
|
| 61 |
+
const h = JSON.parse(localStorage.getItem('tg_history') || '[]');
|
| 62 |
+
h.unshift({ ...data, _input: input.slice(0, 150), _tab: tab, _time: Date.now() });
|
| 63 |
+
localStorage.setItem('tg_history', JSON.stringify(h.slice(0, 30)));
|
| 64 |
+
} catch (e: any) { setError(e.message); } finally { setLoading(false); setStage(''); }
|
| 65 |
};
|
| 66 |
|
| 67 |
+
const currentTab = TABS.find(t => t.id === tab)!;
|
| 68 |
+
const testFiles = result?.test_files || [];
|
| 69 |
+
const quality = result?.quality;
|
| 70 |
+
const coverage = result?.behavior_coverage;
|
| 71 |
|
| 72 |
return (
|
| 73 |
+
<div className="max-w-[1400px] mx-auto px-6 py-6">
|
| 74 |
+
{/* Top Controls */}
|
| 75 |
+
<div className="flex items-center justify-between mb-5">
|
| 76 |
+
<div>
|
| 77 |
+
<h1 className="text-xl font-bold">Test Generation Studio</h1>
|
| 78 |
+
<p className="text-xs text-gray-500 mt-0.5">Multi-agent AI pipeline • Iterative refinement • Behavior coverage</p>
|
| 79 |
+
</div>
|
| 80 |
+
<div className="flex items-center gap-3">
|
| 81 |
+
{/* Multi-agent toggle */}
|
| 82 |
+
<label className="flex items-center gap-2 cursor-pointer">
|
| 83 |
+
<input type="checkbox" checked={useMultiAgent} onChange={e => setUseMultiAgent(e.target.checked)}
|
| 84 |
+
className="w-4 h-4 rounded bg-white/5 border-white/10 text-emerald-500 focus:ring-emerald-500/20" />
|
| 85 |
+
<span className="text-xs text-gray-400">🧠 Multi-Agent Mode</span>
|
| 86 |
+
</label>
|
| 87 |
+
{/* Language */}
|
| 88 |
+
<select value={lang} onChange={e => { setLang(e.target.value); setFramework(FRAMEWORKS[e.target.value][0]); }}
|
| 89 |
+
className="bg-white/[0.03] border border-white/[0.06] rounded-lg px-3 py-1.5 text-xs text-white focus:border-emerald-500/40 focus:outline-none">
|
| 90 |
+
{Object.keys(FRAMEWORKS).map(l => <option key={l} value={l}>{l}</option>)}
|
| 91 |
+
</select>
|
| 92 |
+
{/* Framework */}
|
| 93 |
+
<select value={framework} onChange={e => setFramework(e.target.value)}
|
| 94 |
+
className="bg-white/[0.03] border border-white/[0.06] rounded-lg px-3 py-1.5 text-xs text-white focus:border-emerald-500/40 focus:outline-none">
|
| 95 |
+
{(FRAMEWORKS[lang] || []).map(f => <option key={f} value={f}>{f}</option>)}
|
| 96 |
+
</select>
|
| 97 |
+
</div>
|
| 98 |
+
</div>
|
| 99 |
+
|
| 100 |
+
{/* Main Split */}
|
| 101 |
+
<div className="grid lg:grid-cols-[1fr_1.2fr] gap-4 h-[calc(100vh-160px)]">
|
| 102 |
+
{/* LEFT: Input */}
|
| 103 |
+
<div className="flex flex-col min-h-0">
|
| 104 |
+
{/* Input Tabs */}
|
| 105 |
+
<div className="flex gap-1 mb-3">
|
| 106 |
+
{TABS.map(t => (
|
| 107 |
+
<button key={t.id} onClick={() => { setTab(t.id); setInput(''); }}
|
| 108 |
+
className={`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[12px] font-medium transition-all ${
|
| 109 |
+
tab === t.id ? 'bg-emerald-500/10 text-emerald-300 border border-emerald-500/20 shadow-sm shadow-emerald-500/5' : 'text-gray-500 hover:text-gray-300 border border-transparent'}`}>
|
| 110 |
+
<span>{t.icon}</span>{t.label}
|
| 111 |
</button>
|
| 112 |
))}
|
| 113 |
</div>
|
| 114 |
|
| 115 |
+
{/* Test Type Pills */}
|
| 116 |
+
<div className="flex flex-wrap gap-1.5 mb-3">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
{['unit', 'integration', 'edge_case', 'security', 'e2e'].map(t => (
|
| 118 |
+
<button key={t} onClick={() => setTestTypes(testTypes.includes(t) ? testTypes.filter(x => x !== t) : [...testTypes, t])}
|
| 119 |
+
className={`px-2.5 py-1 rounded-full text-[11px] font-medium transition-all ${
|
| 120 |
+
testTypes.includes(t) ? 'bg-emerald-500/15 text-emerald-300 border border-emerald-500/20' : 'bg-white/[0.02] text-gray-600 border border-white/[0.04] hover:border-white/[0.08]'}`}>
|
| 121 |
{t.replace('_', ' ')}
|
| 122 |
+
</button>
|
| 123 |
))}
|
| 124 |
</div>
|
| 125 |
|
| 126 |
{/* Textarea */}
|
| 127 |
+
<textarea value={input} onChange={e => setInput(e.target.value)} placeholder={currentTab.placeholder}
|
| 128 |
+
className="flex-1 bg-white/[0.015] border border-white/[0.05] rounded-xl p-4 text-[13px] text-gray-200 placeholder-gray-600 resize-none focus:outline-none focus:border-emerald-500/30 font-mono leading-relaxed transition" />
|
|
|
|
| 129 |
|
| 130 |
{/* Generate Button */}
|
| 131 |
<button onClick={generate} disabled={loading || !input.trim()}
|
| 132 |
+
className={`mt-3 py-3 rounded-xl font-semibold text-[14px] transition-all ${
|
| 133 |
+
loading ? 'bg-white/[0.03] text-gray-500 border border-white/[0.05]' :
|
| 134 |
+
'bg-gradient-to-r from-emerald-600 to-cyan-600 text-white shadow-lg shadow-emerald-500/20 hover:shadow-emerald-500/30 hover:scale-[1.01]'}`}>
|
| 135 |
+
{loading ? `⏳ ${stage}` : useMultiAgent ? '🧠 Run Multi-Agent Pipeline' : '⚡ Generate Tests'}
|
| 136 |
</button>
|
| 137 |
+
{error && <p className="mt-2 text-red-400 text-xs bg-red-500/5 px-3 py-2 rounded-lg border border-red-500/10">{error}</p>}
|
|
|
|
| 138 |
</div>
|
| 139 |
|
| 140 |
+
{/* RIGHT: Output */}
|
| 141 |
+
<div className="flex flex-col min-h-0 bg-white/[0.01] border border-white/[0.04] rounded-xl overflow-hidden">
|
| 142 |
{result ? (
|
| 143 |
<>
|
| 144 |
+
{/* Quality + Coverage Bar */}
|
| 145 |
+
<div className="flex items-center justify-between px-4 py-2.5 border-b border-white/[0.04] bg-white/[0.02]">
|
| 146 |
+
<div className="flex items-center gap-4">
|
| 147 |
+
{quality && (
|
| 148 |
+
<div className="flex items-center gap-2">
|
| 149 |
+
<div className={`w-7 h-7 rounded-lg flex items-center justify-center text-xs font-bold ${
|
| 150 |
+
quality.grade === 'A' ? 'bg-emerald-500/20 text-emerald-300' :
|
| 151 |
+
quality.grade === 'B' ? 'bg-blue-500/20 text-blue-300' :
|
| 152 |
+
quality.grade === 'C' ? 'bg-amber-500/20 text-amber-300' : 'bg-red-500/20 text-red-300'}`}>
|
| 153 |
+
{quality.grade}
|
| 154 |
+
</div>
|
| 155 |
+
<span className="text-[11px] text-gray-500">Quality {quality.overall}%</span>
|
| 156 |
+
</div>
|
| 157 |
+
)}
|
| 158 |
+
{coverage && (
|
| 159 |
+
<div className="flex items-center gap-2">
|
| 160 |
+
<div className="w-16 h-1.5 rounded-full bg-white/[0.05] overflow-hidden">
|
| 161 |
+
<div className="h-full bg-gradient-to-r from-emerald-500 to-cyan-500 rounded-full" style={{ width: `${coverage.coverage_pct}%` }} />
|
| 162 |
+
</div>
|
| 163 |
+
<span className="text-[11px] text-gray-500">{coverage.coverage_pct}% behaviors</span>
|
| 164 |
+
</div>
|
| 165 |
+
)}
|
| 166 |
+
<span className="text-[11px] text-gray-600">{result.processing_time_ms?.toFixed(0)}ms</span>
|
| 167 |
</div>
|
| 168 |
+
<button onClick={() => navigator.clipboard.writeText(testFiles[activeFile]?.code || '')}
|
| 169 |
+
className="px-3 py-1 rounded-lg bg-emerald-500/10 text-emerald-400 text-[11px] font-medium hover:bg-emerald-500/20 transition">
|
| 170 |
+
Copy Code
|
| 171 |
</button>
|
| 172 |
</div>
|
| 173 |
|
| 174 |
+
{/* Iteration badge */}
|
| 175 |
+
{result.iterations_performed > 0 && (
|
| 176 |
+
<div className="px-4 py-1.5 border-b border-white/[0.03] flex items-center gap-2">
|
| 177 |
+
<span className="text-[10px] px-2 py-0.5 rounded-full bg-purple-500/10 text-purple-300 border border-purple-500/20">
|
| 178 |
+
🔄 {result.iterations_performed} refinement iterations
|
| 179 |
+
</span>
|
| 180 |
+
{coverage?.uncovered_behaviors?.length > 0 && (
|
| 181 |
+
<span className="text-[10px] px-2 py-0.5 rounded-full bg-amber-500/10 text-amber-300 border border-amber-500/20">
|
| 182 |
+
⚠️ {coverage.uncovered} untested behaviors
|
| 183 |
+
</span>
|
| 184 |
+
)}
|
| 185 |
+
</div>
|
| 186 |
+
)}
|
| 187 |
+
|
| 188 |
{/* File Tabs */}
|
| 189 |
+
{testFiles.length > 1 && (
|
| 190 |
+
<div className="flex px-3 py-1.5 border-b border-white/[0.03] gap-1 overflow-x-auto">
|
| 191 |
+
{testFiles.map((f: any, i: number) => (
|
| 192 |
+
<button key={i} onClick={() => setActiveFile(i)}
|
| 193 |
+
className={`px-2.5 py-1 rounded-md text-[11px] whitespace-nowrap transition ${
|
| 194 |
+
i === activeFile ? 'bg-emerald-500/10 text-emerald-300' : 'text-gray-600 hover:text-gray-400'}`}>
|
| 195 |
+
{f.filename} <span className="text-gray-600 ml-1">({f.num_tests})</span>
|
| 196 |
</button>
|
| 197 |
))}
|
| 198 |
</div>
|
| 199 |
)}
|
| 200 |
|
| 201 |
+
{/* Code */}
|
| 202 |
+
<pre className="flex-1 overflow-auto p-4 text-[12px] text-gray-300 font-mono leading-[1.7] selection:bg-emerald-500/20">
|
| 203 |
+
{testFiles[activeFile]?.code || result.test_code || 'No code generated'}
|
| 204 |
</pre>
|
| 205 |
</>
|
| 206 |
) : (
|
| 207 |
+
<div className="flex-1 flex items-center justify-center">
|
| 208 |
+
<div className="text-center px-8">
|
| 209 |
+
<div className="text-5xl mb-5 opacity-50">🧪</div>
|
| 210 |
+
<h3 className="text-base font-medium text-white/80 mb-2">Ready to Generate</h3>
|
| 211 |
+
<p className="text-[13px] text-gray-500 max-w-sm leading-relaxed">
|
| 212 |
+
Paste your input, select test types, and click generate.
|
| 213 |
+
{useMultiAgent && <span className="block mt-1 text-emerald-400/60">Multi-agent mode: tests will be iteratively refined for higher quality.</span>}
|
| 214 |
</p>
|
| 215 |
</div>
|
| 216 |
</div>
|