also iterate through stacks

This commit is contained in:
Abi Raja 2024-05-17 16:52:01 -04:00
parent 7396160833
commit 610400bc49

View File

@ -1,5 +1,6 @@
import puppeteer, { Browser, Page, ElementHandle } from "puppeteer"; import puppeteer, { Browser, Page, ElementHandle } from "puppeteer";
import { Stack } from "../lib/stacks"; import { Stack } from "../lib/stacks";
import { CodeGenerationModel } from "../lib/models";
const REPO_PATH = "/Users/abi/Documents/GitHub/screenshot-to-code/frontend"; const REPO_PATH = "/Users/abi/Documents/GitHub/screenshot-to-code/frontend";
const DOWNLOAD_PATH = `${REPO_PATH}/qa`; const DOWNLOAD_PATH = `${REPO_PATH}/qa`;
@ -32,17 +33,17 @@ describe("Simple Puppeteer Test", () => {
await browser.close(); await browser.close();
}); });
const stacks = Object.values(Stack); const stacks = Object.values(Stack).slice(0, 1);
const models = Object.values(CodeGenerationModel);
// For debugging // For debugging
//.slice(0, 1); //.slice(0, 1);
models.forEach((model) => {
stacks.forEach((stack) => { stacks.forEach((stack) => {
it(`should load the homepage and check the title for stack: ${stack}`, async () => { it(`should load the homepage and check the title for stack: ${stack}`, async () => {
const codeGenerationModel = "claude_3_sonnet"; const testId = `${model}_${stack}`;
const testId = `${codeGenerationModel}_${stack}`;
await setupLocalStorage(page, stack, codeGenerationModel); await setupLocalStorage(page, stack, model);
// Upload file // Upload file
const fileInput = (await page.$( const fileInput = (await page.$(
@ -62,15 +63,19 @@ describe("Simple Puppeteer Test", () => {
// Click the generate button and wait for the code to be generated // Click the generate button and wait for the code to be generated
await page.waitForNetworkIdle(); await page.waitForNetworkIdle();
await page.waitForFunction(() => document.body.innerText.includes("v1"), { await page.waitForFunction(
() => document.body.innerText.includes("v1"),
{
timeout: 30000, timeout: 30000,
}); }
);
await page.screenshot({ await page.screenshot({
path: `${SCREENSHOTS_PATH}/${testId}_image_results.png`, path: `${SCREENSHOTS_PATH}/${testId}_image_results.png`,
}); });
}); });
}); });
});
}); });
async function setupLocalStorage(page: Page, stack: string, model: string) { async function setupLocalStorage(page: Page, stack: string, model: string) {