read fixtures path from env var
This commit is contained in:
parent
a3104fab1a
commit
ce82fc87c4
4
frontend/.gitignore
vendored
4
frontend/.gitignore
vendored
@ -26,5 +26,5 @@ dist-ssr
|
|||||||
# Env files
|
# Env files
|
||||||
.env*
|
.env*
|
||||||
|
|
||||||
# QA files
|
# Test files
|
||||||
qa/**/*
|
src/tests/results/
|
||||||
|
|||||||
BIN
frontend/src/tests/fixtures/simple_button.png
vendored
Normal file
BIN
frontend/src/tests/fixtures/simple_button.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
BIN
frontend/src/tests/fixtures/simple_ui_with_image.png
vendored
Normal file
BIN
frontend/src/tests/fixtures/simple_ui_with_image.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 35 KiB |
@ -2,11 +2,11 @@ import puppeteer, { Browser, Page, ElementHandle } from "puppeteer";
|
|||||||
import { Stack } from "../lib/stacks";
|
import { Stack } from "../lib/stacks";
|
||||||
import { CodeGenerationModel } from "../lib/models";
|
import { CodeGenerationModel } from "../lib/models";
|
||||||
|
|
||||||
const REPO_PATH = "/Users/abi/Documents/GitHub/screenshot-to-code/frontend";
|
const TESTS_ROOT_PATH = process.env.TEST_ROOT_PATH;
|
||||||
const DOWNLOAD_PATH = `${REPO_PATH}/qa`;
|
const RESULTS_DIR = `${TESTS_ROOT_PATH}/results`;
|
||||||
const SCREENSHOTS_PATH = `${REPO_PATH}/qa/results`;
|
const FIXTURES_PATH = `${TESTS_ROOT_PATH}/fixtures`;
|
||||||
const IMAGE_PATH = DOWNLOAD_PATH + "/simple_button.png";
|
const SIMPLE_SCREENSHOT = FIXTURES_PATH + "/simple_button.png";
|
||||||
const SCREENSHOT_WITH_IMAGES = `${DOWNLOAD_PATH}/simple_ui_with_image.png`;
|
const SCREENSHOT_WITH_IMAGES = `${FIXTURES_PATH}/simple_ui_with_image.png`;
|
||||||
|
|
||||||
describe("e2e tests", () => {
|
describe("e2e tests", () => {
|
||||||
let browser: Browser;
|
let browser: Browser;
|
||||||
@ -30,13 +30,12 @@ describe("e2e tests", () => {
|
|||||||
await page.setViewport({ width: 1080, height: 1024 });
|
await page.setViewport({ width: 1080, height: 1024 });
|
||||||
|
|
||||||
// TODO: Does this need to be moved?
|
// TODO: Does this need to be moved?
|
||||||
const client = await page.createCDPSession();
|
// const client = await page.createCDPSession();
|
||||||
|
|
||||||
// Set download behavior path
|
// Set download behavior path
|
||||||
await client.send("Page.setDownloadBehavior", {
|
// await client.send("Page.setDownloadBehavior", {
|
||||||
behavior: "allow",
|
// behavior: "allow",
|
||||||
downloadPath: DOWNLOAD_PATH,
|
// downloadPath: DOWNLOAD_PATH,
|
||||||
});
|
// });
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(async () => {
|
afterAll(async () => {
|
||||||
@ -83,14 +82,14 @@ describe("e2e tests", () => {
|
|||||||
// Update tests - for every model (doesn’t need to be repeated for each stack - fix to HTML Tailwind only)
|
// Update tests - for every model (doesn’t need to be repeated for each stack - fix to HTML Tailwind only)
|
||||||
models.forEach((model) => {
|
models.forEach((model) => {
|
||||||
["html_tailwind"].forEach((stack) => {
|
["html_tailwind"].forEach((stack) => {
|
||||||
it(
|
it.only(
|
||||||
`Update for : ${model}`,
|
`Update for : ${model}`,
|
||||||
async () => {
|
async () => {
|
||||||
const app = new App(page, stack, model, `update_${model}_${stack}`);
|
const app = new App(page, stack, model, `update_${model}_${stack}`);
|
||||||
await app.init();
|
await app.init();
|
||||||
|
|
||||||
// Generate from screenshot
|
// Generate from screenshot
|
||||||
await app.uploadImage(IMAGE_PATH);
|
await app.uploadImage(SIMPLE_SCREENSHOT);
|
||||||
// Regenerate works for v1
|
// Regenerate works for v1
|
||||||
await app.regenerate();
|
await app.regenerate();
|
||||||
// Make an update
|
// Make an update
|
||||||
@ -116,7 +115,7 @@ describe("e2e tests", () => {
|
|||||||
await app.init();
|
await app.init();
|
||||||
|
|
||||||
// Generate from screenshot
|
// Generate from screenshot
|
||||||
await app.uploadImage(IMAGE_PATH);
|
await app.uploadImage(SIMPLE_SCREENSHOT);
|
||||||
// Regenerate works for v1
|
// Regenerate works for v1
|
||||||
await app.regenerate();
|
await app.regenerate();
|
||||||
// Make an update
|
// Make an update
|
||||||
@ -147,7 +146,7 @@ class App {
|
|||||||
this.page = page;
|
this.page = page;
|
||||||
this.stack = stack;
|
this.stack = stack;
|
||||||
this.model = model;
|
this.model = model;
|
||||||
this.screenshotPathPrefix = `${SCREENSHOTS_PATH}/${testId}`;
|
this.screenshotPathPrefix = `${RESULTS_DIR}/${testId}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
async init() {
|
async init() {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user