PageSourceSearch

https://gen-lang-client-0290275991.firebaseapp.com/assets/AIFunctionTestHarness-Cyy6cL8-.js

js gen-lang-client-0290275991.firebaseapp.com collected 2026-10-03 14:06:57 UTC 12,503 bytes, 54 lines download raw bytes

1import{r as i,b_ as t}from"./vendor-C8YG_F64.js";import{s as A,q as b}from"./refineLogService-Cvxwj8-9.js";import"./vendor-ai-BjAxNs1s.js";import"./firebaseConfig-BtMNHh3y.js";import"./vendor-firebase-DuIfxB6K.js";import"./index-BkOCZzzJ.js";import"./circuitBreaker-Ciky9SaW.js";import{r as q}from"./project-Cl9ZuAUa.js";import{r as W}from"./prompts-C1FbkFBO.js";import"./core-v8lkC0dE.js";import"./sentryConfig-BLpyzu5-.js";import"./defaultPrompts-B1oQnVlX.js";import"./usageService-C5EM3gYk.js";import"./subPrompts-fd85q-p3.js";const $={simpleWebApp:{label:"🌐 Simple Web App",summary:"A todo list application with user authentication and real-time sync",features:["User login/signup","Create/edit/delete todos","Real-time sync","Mobile responsive"]},enterpriseSaaS:{label:"🏢 Enterprise SaaS",summary:"Multi-tenant project management platform with billing, RBAC, and audit logs",features:["Multi-tenant architecture","Role-based access control","Stripe billing integration","Audit logging","API rate limiting","SSO integration"]},mobilePlatform:{label:"📱 Mobile Platform",summary:"Cross-platform fitness tracking app with social features and AI coaching",features:["Workout tracking","Nutrition logging","AI coaching engine","Social feed","Push notifications","Wearable sync"]}},Z=()=>{const[h,D]=i.useState("simpleWebApp"),[g,m]=i.useState(!1),[f,w]=i.useState([]),[k,S]=i.useState([]),[P,p]=i.useState(null),T=i.useRef(null),x=i.useRef(!1),s=i.useCallback((e,n,r,c)=>{w(o=>[...o,{id:crypto.randomUUID(),timestamp:new Date,level:e,function:n,message:r,data:c}]),setTimeout(()=>T.current?.scrollIntoView({behavior:"smooth"}),50)},[]),u=i.useCallback(e=>{S(n=>[...n,e])},[]),v=i.useCallback(async()=>{p("scoreGeneration"),s("info","scoreGeneration","🔍 Starting heuristic scorer test...");const e=Date.now(),r=A(`# Hello World
2This is a basic document.`,{documentDepth:"standard"});s("score","scoreGeneration",`Minimal content scored: ${r.overallScore}/100`,{dimensions:r.dimensions,stats:r.stats});const o=A(`# Architecture Overview
3
4## Executive Summary
5This document outlines the complete system architecture for a modern web application.
6
7## System Architecture
8The application uses a microservices architecture with the following components:
9
10### Backend Services
11- **API Gateway**: Handles routing, rate limiting, and authentication
12- **User Service**: Manages user accounts and profiles
13- **Data Service**: Handles CRUD operations on core entities
14
15### Frontend
16Built with React 18, TypeScript, and TailwindCSS.
17
18\`\`\`typescript
19interface UserService {
20    getUser(id: string): Promise<User>;
21    createUser(data: CreateUserDTO): Promise<User>;
22    updateUser(id: string, data: Partial<User>): Promise<User>;
23}
24\`\`\`
25
26## Database Design
27
28\`\`\`mermaid
29erDiagram
30    USER ||--o{ PROJECT : owns
31    PROJECT ||--o{ TASK : contains
32    TASK ||--o{ COMMENT : has
33\`\`\`
34
35## Testing Strategy
36- Unit tests with Vitest (>80% coverage target)
37- Integration tests for API endpoints
38- E2E tests with Playwright
39
40## Deployment
41CI/CD pipeline using GitHub Actions deploying to AWS.
42
43| Environment | URL | Branch |
44|------------|-----|--------|
45| Dev | dev.app.com | develop |
46| Staging | staging.app.com | main |
47| Production | app.com | release/* |
48`,{documentDepth:"comprehensive"});s("score","scoreGeneration",`Rich content scored: ${o.overallScore}/100`,{dimensions:o.dimensions,stats:o.stats,issues:o.issues,strengths:o.strengths});const d=Date.now()-e,a=r.overallScore<o.overallScore&&o.overallScore>=50;u({function:"scoreGeneration",status:a?"pass":"warning",score:o.overallScore,duration:d,details:`Min: ${r.overallScore}, Rich: ${o.overallScore}. ${a?"Correctly ranked rich > minimal.":"Ranking may be incorrect."}`}),s(a?"success":"warning","scoreGeneration",a?`✅ Scorer correctly ranked rich (${o.overallScore}) > minimal (${r.overallScore})`:`⚠️ Scorer ranking may be off: rich=${o.overallScore}, minimal=${r.overallScore}`)},[s,u]),y=i.useCallback(async()=>{p("quickScore"),s("info","quickScore","🔍 Testing quickScore helper...");const e=Date.now(),n=b(`# Test Document
49
50Some content here with a few paragraphs of text to score.`),r=Date.now()-e;s("score","quickScore",`Score: ${n.score}/100, Words: ${n.wordCount}`,{...n}),u({function:"quickScore",status:n.score>=0?"pass":"fail",score:n.score,duration:r,details:`Returned score ${n.score} with ${n.wordCount} words in ${r}ms`}),s("success","quickScore",`✅ quickScore completed in ${r}ms`)},[s,u]),C=i.useCallback(async()=>{p("refineGeneratedPrompt"),s("info","refineGeneratedPrompt","🔄 Testing refine function (requires API key)...");const e=`# My App
51
52A basic app description that needs improvement.`,n="Add more detail about the scalability approach and include a section on monitoring.",r=b(e);s("info","refineGeneratedPrompt",`Before refine: score=${r.score}, words=${r.wordCount}`);const c=Date.now();try{const o=await W(e,n,"gemini-2.0-flash"),d=Date.now()-c,a=b(o);s("score","refineGeneratedPrompt",`After refine: score=${a.score}, words=${a.wordCount}`,{scoreDelta:a.score-r.score,wordDelta:a.wordCount-r.wordCount});const l=a.score>
52=r.score;u({function:"refineGeneratedPrompt",status:l?"pass":"warning",score:a.score,duration:d,details:`Score: ${r.score} → ${a.score} (${l?"+":""}${a.score-r.score}). Words: ${r.wordCount} → ${a.wordCount}`}),s(l?"success":"warning","refineGeneratedPrompt",l?`✅ Refine improved quality by +${a.score-r.score} points`:`⚠️ Refine did not improve score (${a.score-r.score})`)}catch(o){const d=Date.now()-c;s("error","refineGeneratedPrompt",`❌ Refine failed: ${o.message}`),u({function:"refineGeneratedPrompt",status:"fail",duration:d,details:o.message})}},[s,u]),j=i.useCallback(async()=>{p("regenerateSection"),s("info","regenerateSection","🔧 Testing section regeneration...");const e="Testing Strategy",n=`## Testing Strategy
53
54We will write some tests.`,r="A modern web application with microservices",c=b(n);s("info","regenerateSection",`Before regen: score=${c.score}, words=${c.wordCount}`);const o=Date.now();try{const d=await q(e,n,r),a=Date.now()-o,l=b(d);s("score","regenerateSection",`After regen: score=${l.score}, words=${l.wordCount}`,{scoreDelta:l.score-c.score,outputPreview:d.substring(0,200)+"..."});const N=l.wordCount>c.wordCount;u({function:"regenerateSection",status:N?"pass":"warning",score:l.score,duration:a,details:`Words: ${c.wordCount} → ${l.wordCount}. Score: ${c.score} → ${l.score}`}),s(N?"success":"warning","regenerateSection",N?`✅ Regenerated section expanded from ${c.wordCount} to ${l.wordCount} words`:"⚠️ Section did not expand appreciably")}catch(d){const a=Date.now()-o;s("error","regenerateSection",`❌ Section regen failed: ${d.message}`),u({function:"regenerateSection",status:"fail",duration:a,details:d.message})}},[s,u]),G=i.useCallback(async()=>{if(m(!0),w([]),S([]),x.current=!1,s("info","harness",`🚀 Starting AI Function Test Suite with "${$[h].label}" test data...`),s("info","harness",`Features: ${$[h].features.join(", ")}`),await v(),x.current){m(!1);return}if(await y(),x.current){m(!1);return}if(await C(),x.current){m(!1);return}await j(),s("info","harness","🏁 All tests complete!"),p(null),m(!1)},[h,s,v,y,C,j]),I=i.useCallback(()=>{x.current=!0,s("warning","harness","⏹️ Tests aborted by user"),m(!1),p(null)},[s]),U=i.useCallback(()=>{w([]),S([])},[]),R={info:"text-slate-400",success:"text-emerald-400",warning:"text-amber-400",error:"text-red-400",score:"text-violet-400"},E={pass:"bg-emerald-500/20 border-emerald-500/40 text-emerald-400",fail:"bg-red-500/20 border-red-500/40 text-red-400",warning:"bg-amber-500/20 border-amber-500/40 text-amber-400"};return t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"text-lg font-bold text-white flex items-center gap-2",children:"🧪 AI Function Test Harness"}),t.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Test AI functions with sample data and view process logs with scoring"})]}),t.jsxs("div",{className:"flex gap-2 items-center",children:[t.jsx("select",{value:h,onChange:e=>D(e.target.value),disabled:g,className:"bg-slate-900 border border-slate-700 rounded-lg px-3 py-2 text-xs text-white focus:outline-none focus:border-blue-500",children:Object.entries($).map(([e,n])=>t.jsx("option",{value:e,children:n.label},e))}),g?t.jsx("button",{onClick:I,className:"bg-red-600 hover:bg-red-500 text-white text-xs font-bold px-4 py-2 rounded-lg transition-colors",children:"⏹️ Stop"}):t.jsx("button",{onClick:G,className:"bg-blue-600 hover:bg-blue-500 text-white text-xs font-bold px-4 py-2 rounded-lg transition-colors",children:"▶️ Run All Tests"}),t.jsx("button",{onClick:U,disabled:g,className:"bg-slate-800 hover:bg-slate-700 disabled:opacity-50 text-slate-300 text-xs px-3 py-2 rounded-lg transition-colors border border-slate-700",children:"Clear"})]})]}),t.jsx("div",{className:"flex flex-wrap gap-2",children:[{id:"scorer",label:"📊 Score Test",fn:v},{id:"quick",label:"⚡ Quick Score",fn:y},{id:"refine",label:"🔄 Refine Test",fn:C},{id:"regen",label:"🔧 Section Regen",fn:j}].map(e=>t.jsx("button",{onClick:async()=>{m(!0),await e.fn(),m(!1),p(null)},disabled:g,className:`text-xs px-3 py-1.5 rounded-lg border transition-all ${g&&P?.includes(e.id)?"bg-blue-600/30 border-blue-500 text-blue-300 animate-pulse":"bg-slate-800 border-slate-700 text-slate-400 hover:text-white hover:border-slate-600 disabled:opacity-50"}`,children:e.label},e.id))}),k.length>0&&t.jsxs("div",{className:"bg-slate-900/80 border border-slate-700/50 rounded-xl p-4",children:[t.jsx("h4",{className:"text-xs font-bold text-slate-400 uppercase tracking-wider mb-3",children:"Test Results"}),t.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-2",children:k.map((e,n)=>t.jsxs("div",{className:`p-3 rounded-lg border ${E[e.status]}`,children:[t.jsxs("div",{className:"flex justify-between items-center mb-1",children:[t.jsx("span",{className:"text-xs font-bold font-mono",children:e.function}),t.jsx("span",{className:"text-[10px] uppercase font-bold",children:e.status})]}),e.score!==void 0&&t.jsxs("div",{className:"text-lg font-black",children:[e.score,t.jsx("span",{className:"text-xs font-normal opacity-60",children:"/100"})]}),t.jsx("div",{className:"text-[10px] opacity-60 mt-1 line-clamp-2",children:e.details}),t.jsxs("div",{className:"text-[10px] opacity-40 mt-1",children:[e.duration,"ms"]})]},n))})]}),t.jsxs("div",{className:"bg-slate-950 border border-slate-800 rounded-xl overflow-hidden",children:[t.jsxs("div",{className:"px-4 py-2 bg-slate-900/50 border-b border-slate-800 flex items-center justify-between",children:[t.jsxs("h4",{className:"text-xs font-bold text-slate-400 uppercase tracking-wider flex items-center gap-2",children:["📋 Process Log",g&&t.jsx("span",{className:"inline-block w-2 h-2 bg-green-400 rounded-full animate-pulse"})]}),t.jsxs("span",{className:"text-[10px] text-slate-600",children:[f.length," entries"]})]}),t.jsxs("div",{className:"max-h-80 overflow-y-auto p-3 font-mono text-xs space-y-0.5 custom-scrollbar",children:[f.length===0?t.jsx("div",{className:"text-center text-slate-600 py-8",children:"No logs yet — run a test to see output here"}):f.map(e=>t.jsxs("div",{className:"flex gap-2 hover:bg-slate-900/30 px-1 rounded",children:[t.jsx("span",{className:"text-slate-700 flex-shrink-0",children:e.timestamp.toLocaleTimeString("en-GB",{hour12:!1})}),t.jsxs("span",{className:`flex-shrink-0 w-32 truncate ${R[e.level]}`,children:["[",e.function,"]"]}),t.jsx("span",{className:R[e.level],children:e.message})]},e.id)),t.jsx("div",{ref:T})]})]}),f.filter(e=>e.level==="score"&&e.data).length>0&&t.jsxs("div",{className:"bg-slate-900/50 border border-slate-700/50 rounded-xl p-4",children:[t.jsx("h4",{className:"text-xs font-bold text-slate-400 uppercase tracking-wider mb-3",children:"📊 Score Breakdowns"}),t.jsx("div",{className:"space-y-3",children:f.filter(e=>e.level==="score"&&e.data).map(e=>t.jsxs("details",{className:"bg-slate-950 rounded-lg border border-slate-800",children:[t.jsxs("summary",{className:"px-3 py-2 text-xs text-violet-400 cursor-pointer hover:text-violet-300 font-mono",children:["[",e.function,"] ",e.message]}),t.jsx("pre",{className:"px-3 pb-3 text-[10px] text-slate-500 overflow-x-auto",children:JSON.stringify(e.data,null,2)})]},e.id))})]})]})};export{Z as AIFunctionTestHarness};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.