Skip to content

Commit

Permalink
Create E2E tests for api page (#15709)
Browse files Browse the repository at this point in the history
* Create E2E tests for developer resources index and api pages
Fixes #14782 #14781
  • Loading branch information
jpandersen87 authored Aug 29, 2024
1 parent 1ba9021 commit eee3ae9
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 3 deletions.
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,64 @@
import { developerResourcesApiSideNav } from "../../../../../helpers/internal-links";
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 side nav", async ({ developerResourcesApiPage }) => {
await developerResourcesApiPage.testSidenav(developerResourcesApiSideNav);
});

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("has correct title + heading", async ({ developerResourcesApiPage }) => {
await developerResourcesApiPage.testHeader();
});

test("footer", async ({ developerResourcesApiPage }) => {
await developerResourcesApiPage.testFooter();
});
},
);
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

0 comments on commit eee3ae9

Please sign in to comment.