clean up the code
This commit is contained in:
parent
72d412fa52
commit
7396160833
@ -32,13 +32,48 @@ describe("Simple Puppeteer Test", () => {
|
||||
await browser.close();
|
||||
});
|
||||
|
||||
const stacks = Object.values(Stack).slice(0, 1);
|
||||
const stacks = Object.values(Stack);
|
||||
|
||||
// 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}`;
|
||||
|
||||
// Set up local storage
|
||||
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`,
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
async function setupLocalStorage(page: Page, stack: string, model: string) {
|
||||
const setting = {
|
||||
openAiApiKey: null,
|
||||
openAiBaseURL: null,
|
||||
@ -46,7 +81,7 @@ describe("Simple Puppeteer Test", () => {
|
||||
isImageGenerationEnabled: false,
|
||||
editorTheme: "cobalt",
|
||||
generatedCodeConfig: stack,
|
||||
codeGenerationModel: codeGenerationModel,
|
||||
codeGenerationModel: model,
|
||||
isTermOfServiceAccepted: false,
|
||||
accessCode: null,
|
||||
};
|
||||
@ -57,39 +92,4 @@ describe("Simple Puppeteer Test", () => {
|
||||
|
||||
// Reload the page to apply the local storage
|
||||
await page.reload();
|
||||
|
||||
// Generate from image
|
||||
|
||||
const fileInput = (await page.$(
|
||||
".file-input"
|
||||
)) as ElementHandle<HTMLInputElement>;
|
||||
// Replace with the path to your image
|
||||
const imagePath = IMAGE_PATH;
|
||||
if (!fileInput) {
|
||||
throw new Error("File input element not found");
|
||||
}
|
||||
|
||||
// Upload file
|
||||
await fileInput.uploadFile(imagePath);
|
||||
|
||||
// Screenshot of the uploaded image
|
||||
await page.screenshot({
|
||||
path: `${SCREENSHOTS_PATH}/${codeGenerationModel}_${stack}_image_uploaded.png`,
|
||||
});
|
||||
|
||||
console.log("starting image code generation for stack: ", stack);
|
||||
|
||||
// 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}/${codeGenerationModel}_${stack}_image_generation_results.png`,
|
||||
});
|
||||
|
||||
console.log(`done with image code generation for stack: ${stack}`);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user