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/public/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,
);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BasePage, BasePageTestArgs } from "../BasePage";
import { BasePage, BasePageTestArgs } from "../../BasePage";

export class DeveloperResourcesPage extends BasePage {
constructor(testArgs: BasePageTestArgs) {
Expand Down
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/public/developer-resources/api/api";
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 { DeveloperResourcesPage } from "../../../pages/public/resources";
import { test as baseTest } from "../../../test";
import { DeveloperResourcesPage } from "../../../../pages/public/developer-resources/resources";
import { test as baseTest } from "../../../../test";

export interface DeveloperResourcesPageFixtures {
developerResourcesPage: DeveloperResourcesPage;
Expand Down
Loading