Aimobile / assets /AiUnitTestGenerator-B0mTatHg.js
admin08077's picture
Upload 395 files
634008a verified
import{r as o,j as e}from"./react-B-lWpQRQ.js";import{B as u,I as h,L as d,T as j,M as g}from"./index-DyMS-nC-.js";import"./@google-xfXoiafW.js";import{d as b}from"./fileUtils-DLahR3l0.js";import"./@braintree-DY5JYOZd.js";import"./react-dom-CU2yWD-Y.js";import"./scheduler-DYLXRpC5.js";import"./idb-Dob3nYDb.js";import"./axe-core-CA05Kxsw.js";import"./marked-CesSW9Du.js";import"./@mermaid-js-Ce0__7Tp.js";import"./langium-B_PGe6V2.js";import"./vscode-jsonrpc-2tvYB2ki.js";import"./chevrotain-D5DQZOif.js";import"./@chevrotain-DMYZVohV.js";import"./lodash-es-CKTcnrxn.js";import"./chevrotain-allstar-eFSt8-qu.js";import"./vscode-languageserver-types-NoPvPymt.js";import"./vscode-languageserver-textdocument-CKBVUiR3.js";import"./vscode-uri-CoxP0whD.js";const y=`import React from 'react';
export const Greeting = ({ name }) => {
if (!name) {
return <div>Hello, Guest!</div>;
}
return <div>Hello, {name}!</div>;
};`,z=()=>{const[a,x]=o.useState(y),[t,c]=o.useState(""),[r,m]=o.useState(!1),[l,i]=o.useState(""),p=o.useCallback(async()=>{if(!a.trim()){i("Please enter some code to generate tests for.");return}m(!0),i(""),c("");try{const s=u(a);let n="";for await(const f of s)n+=f,c(n)}catch(s){const n=s instanceof Error?s.message:"An unknown error occurred.";i(`Failed to generate tests: ${n}`)}finally{m(!1)}},[a]);return e.jsxs("div",{className:"h-full flex flex-col p-4 sm:p-6 lg:p-8 text-text-primary",children:[e.jsxs("header",{className:"mb-6",children:[e.jsxs("h1",{className:"text-3xl font-bold flex items-center",children:[e.jsx(h,{}),e.jsx("span",{className:"ml-3",children:"AI Unit Test Generator"})]}),e.jsx("p",{className:"text-text-secondary mt-1",children:"Generate Vitest/RTL unit tests from your component code."})]}),e.jsxs("div",{className:"flex-grow flex flex-col gap-4 min-h-0",children:[e.jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[e.jsx("label",{htmlFor:"code-input",className:"text-sm font-medium text-text-secondary mb-2",children:"Component Code"}),e.jsx("textarea",{id:"code-input",value:a,onChange:s=>x(s.target.value),placeholder:"Paste your component code here...",className:"flex-grow p-4 bg-surface border border-border rounded-md resize-none font-mono text-sm"})]}),e.jsx("div",{className:"flex-shrink-0",children:e.jsx("button",{onClick:p,disabled:r,className:"btn-primary w-full max-w-xs mx-auto flex items-center justify-center px-6 py-3",children:r?e.jsx(d,{}):"Generate Tests"})}),e.jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsx("label",{className:"text-sm font-medium text-text-secondary",children:"Generated Tests"}),t&&!r&&e.jsxs("button",{onClick:()=>b(t,"tests.test.tsx","text/typescript"),className:"flex items-center gap-1 px-3 py-1 bg-gray-100 text-xs rounded-md hover:bg-gray-200",children:[e.jsx(j,{className:"w-4 h-4"})," Download"]})]}),e.jsxs("div",{className:"relative flex-grow p-1 bg-background border border-border rounded-md overflow-y-auto",children:[r&&!t&&e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(d,{})}),l&&e.jsx("p",{className:"p-4 text-red-500",children:l}),t&&e.jsx(g,{content:t}),!r&&!t&&!l&&e.jsx("div",{className:"text-text-secondary h-full flex items-center justify-center",children:"Tests will appear here."})]})]})]})]})};export{z as AiUnitTestGenerator};
//# sourceMappingURL=AiUnitTestGenerator-B0mTatHg.js.map