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

Create E2E tests for api page #15709

Merged
17 changes: 17 additions & 0 deletions frontend-react/e2e/pages/developer-resources/api/api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { BasePage, BasePageTestArgs } from "../../BasePage";

export class DeveloperResourcesApiPage extends BasePage {
constructor(testArgs: BasePageTestArgs) {
super(
{
url: "/developer-resources/api",
title: "Guide to connecting with ReportStream's API",
heading: testArgs.page.getByRole("heading", {
name: "ReportStream API",
exact: true,
}),
},
testArgs,
);
}
}
78 changes: 78 additions & 0 deletions frontend-react/e2e/spec/all/developer-resources/api/api.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import { scrollToFooter, scrollToTop } from "../../../../helpers/utils.js";
import { DeveloperResourcesApiPage } from "../../../../pages/developer-resources/api/api.js";
import { test as baseTest, expect } from "../../../../test.js";

export interface Fixtures {
developerResourcesApiPage: DeveloperResourcesApiPage;
}

const test = baseTest.extend<Fixtures>({
developerResourcesApiPage: async (
{
page: _page,
isMockDisabled,
adminLogin,
senderLogin,
receiverLogin,
storageState,
isFrontendWarningsLog,
frontendWarningsLogPath,
},
use,
) => {
const page = new DeveloperResourcesApiPage({
page: _page,
isMockDisabled,
adminLogin,
senderLogin,
receiverLogin,
storageState,
isFrontendWarningsLog,
frontendWarningsLogPath,
});
await page.goto();
await use(page);
},
});

test.describe(
"Developer Resources / API page",
{
tag: "@smoke",
},
() => {
test("has correct title", async ({ developerResourcesApiPage }) => {
await expect(developerResourcesApiPage.page).toHaveTitle(developerResourcesApiPage.title);
await expect(developerResourcesApiPage.heading).toBeVisible();
});

test("has side nav", async ({ developerResourcesApiPage }) => {
await expect(
developerResourcesApiPage.page.getByRole("navigation", { name: "side-navigation " }),
).toBeVisible();
});

test("pdf file download works", async ({ developerResourcesApiPage }) => {
const downloadPromise = developerResourcesApiPage.page.waitForEvent("download");
await developerResourcesApiPage.page.getByRole("link", { name: "downloadable PDF" }).click();
const download = await downloadPromise;
expect(download.suggestedFilename()).toMatch(/^.+\.pdf$/);
await download.cancel();
});

test.describe("Footer", () => {
test("has footer", async ({ developerResourcesApiPage }) => {
await expect(developerResourcesApiPage.footer).toBeAttached();
});

test("explicit scroll to footer and then scroll to top", async ({ developerResourcesApiPage }) => {
await expect(developerResourcesApiPage.footer).not.toBeInViewport();
await scrollToFooter(developerResourcesApiPage.page);
await expect(developerResourcesApiPage.footer).toBeInViewport();
await expect(developerResourcesApiPage.page.getByTestId("govBanner")).not.toBeInViewport();
await scrollToTop(developerResourcesApiPage.page);
await expect(developerResourcesApiPage.page.getByTestId("govBanner")).toBeInViewport();
});
});
},
);
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect, test } from "@playwright/test";
import * as resources from "../../pages/resources";
import * as resources from "../../../pages/developer-resources/resources";

// eslint-disable-next-line playwright/no-skipped-test
test.describe.skip("Developer Resources page", () => {
Expand Down Expand Up @@ -61,9 +61,7 @@ test.describe.skip("Developer Resources page", () => {
});
}

test("should redirect unauthenticated users to login page on managing public key", async ({
page,
}) => {
test("should redirect unauthenticated users to login page on managing public key", async ({ page }) => {
await page
.getByRole("link", {
name: "Manage your public key",
Expand Down
Loading