Skip to content

Drop in a screenshot and convert it to clean code (HTML/Tailwind/React/Vue)

Python

also iterate through stacks

Abi Raja610400bc49ae
diff --git a/frontend/src/tests/qa.test.ts b/frontend/src/tests/qa.test.ts
index 0c6de478..a86a0d06 100644
--- a/frontend/src/tests/qa.test.ts
+++ b/frontend/src/tests/qa.test.ts
@@ -1,5 +1,6 @@
import puppeteer, { Browser, Page, ElementHandle } from "puppeteer";
import { Stack } from "../lib/stacks";
+import { CodeGenerationModel } from "../lib/models";
const REPO_PATH = "/Users/abi/Documents/GitHub/screenshot-to-code/frontend";
const DOWNLOAD_PATH = `${REPO_PATH}/qa`;
@@ -32,42 +33,46 @@ describe("Simple Puppeteer Test", () => {
await browser.close();
});
- const stacks = Object.values(Stack);
-
+ const stacks = Object.values(Stack).slice(0, 1);
+ const models = Object.values(CodeGenerationModel);
// For debugging
//.slice(0, 1);
- stacks.forEach((stack) => {
- it(`should load the homepage and check the title for stack: ${stack}`, async () => {
- const codeGenerationModel = "claude_3_sonnet";
- const testId = `${codeGenerationModel}_${stack}`;
-
- await setupLocalStorage(page, stack, codeGenerationModel);
-
- // Upload file
- const fileInput = (await page.$(
- ".file-input"
- )) as ElementHandle<HTMLInputElement>;
-
- if (!fileInput) {
- throw new Error("File input element not found");
- }
-
- await fileInput.uploadFile(IMAGE_PATH);
-
- // Screenshot the first step
- await page.screenshot({
- path: `${SCREENSHOTS_PATH}/${testId}_image_uploaded.png`,
- });
-
- // Click the generate button and wait for the code to be generated
- await page.waitForNetworkIdle();
- await page.waitForFunction(() => document.body.innerText.includes("v1"), {
- timeout: 30000,
- });
-
- await page.screenshot({
- path: `${SCREENSHOTS_PATH}/${testId}_image_results.png`,
+ models.forEach((model) => {
+ stacks.forEach((stack) => {
+ it(`should load the homepage and check the title for stack: ${stack}`, async () => {
+ const testId = `${model}_${stack}`;
+
+ await setupLocalStorage(page, stack, model);
+
+ // Upload file
+ const fileInput = (await page.$(
+ ".file-input"
+ )) as ElementHandle<HTMLInputElement>;
+
+ if (!fileInput) {
+ throw new Error("File input element not found");
+ }
+
+ await fileInput.uploadFile(IMAGE_PATH);
+
+ // Screenshot the first step
+ await page.screenshot({
+ path: `${SCREENSHOTS_PATH}/${testId}_image_uploaded.png`,
+ });
+
+ // Click the generate button and wait for the code to be generated
+ await page.waitForNetworkIdle();
+ await page.waitForFunction(
+ () => document.body.innerText.includes("v1"),
+ {
+ timeout: 30000,
+ }
+ );
+
+ await page.screenshot({
+ path: `${SCREENSHOTS_PATH}/${testId}_image_results.png`,
+ });
});
});
});