Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: E2E tests maintenance #1966

Merged
merged 12 commits into from
Jan 13, 2025
22 changes: 22 additions & 0 deletions e2e/chart-actions.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { promises } from "fs";

import { setup } from "./common";

const { test, expect } = setup();
Expand All @@ -18,3 +20,23 @@ test("it should be possible to duplicate a chart", async ({
expect(await chartTabs.count()).toBe(2);
});

test("it should be possible to make a screenshot of a chart", async ({
page,
actions,
selectors,
}) => {
await actions.chart.createFrom({
iri: "https://energy.ld.admin.ch/sfoe/bfe_ogd84_einmalverguetung_fuer_photovoltaikanlagen/10",
dataSource: "Prod",
});
await selectors.chart.loaded();
const chartMoreButton = await selectors.chart.moreButton();
await chartMoreButton.click();
const downloadPromise = page.waitForEvent("download");
await (await selectors.mui.popover().findByText("Export PNG")).click();
const download = await downloadPromise;
expect((await promises.stat(await download.path())).size).toBeGreaterThan(
// Assuring the file is not empty.
4000
bprusinowski marked this conversation as resolved.
Show resolved Hide resolved
);
});
5 changes: 5 additions & 0 deletions e2e/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ export const createSelectors = ({ screen, page, within }: Ctx) => {
// Let the map tiles fade in and enter animations finish
await sleep(1_000);
},
screenshot: {
png: async () => {
return await screen.findByTestId("screenshot-png");
},
},
tablePreviewSwitch: async () => {
return await screen.findByText("Table view");
},
Expand Down
Loading