Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions src/e2e/app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import puppeteer, { Page } from "puppeteer";
import "pptr-testing-library/extend";

export class App {
private page: Promise<Page>;

constructor() {
this.page = (async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
const client = await page.target().createCDPSession();
await client.send("Page.setDownloadBehavior", {
behavior: "allow",
downloadPath: "/tmp",
});
return page;
})();
}

async download() {
const page = await this.page;
const document = await page.getDocument();
const downloadButton = await document.getByText("Download");
await downloadButton.click();
}

async reload() {
const page = await this.page;
await page.goto("http://localhost:3000");
}

async dispose() {
return (await this.page).browser().close();
}
}
23 changes: 6 additions & 17 deletions src/e2e/basic.test.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,12 @@
import puppeteer from "puppeteer";
import "pptr-testing-library/extend";
import { App } from "./app";

describe("Toolbar actions", () => {
it("Download - downloads a HEX file", async () => {
const browser = await puppeteer.launch();
const app = new App();

const page = await browser.newPage();
await page.goto("http://localhost:3000");
const client = await page.target().createCDPSession();
await client.send("Page.setDownloadBehavior", {
behavior: "allow",
downloadPath: "/tmp",
});
beforeAll(app.reload.bind(app));
afterAll(app.dispose.bind(app));

const document = await page.getDocument();
const downloadButton = await document.getByText("Download");
await downloadButton.click();
// TODO: wait for download, check file

browser.close();
it("Download - download the default HEX file", async () => {
await app.download();
});
});