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

Experience/15823/fix link checker #15919

Merged
merged 23 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
1f138bb
add logic to evaluate non http 400 responses
etanb Sep 13, 2024
610e0ae
update link checker logic to read page content
etanb Sep 18, 2024
f16b64b
completely redo link checker logic
etanb Sep 20, 2024
57ca606
revert capitalization
etanb Sep 23, 2024
a0fdba0
Merge branch 'master' into experience/15823/fix-link-checker
etanb Sep 23, 2024
6a12f8d
double test timeout
etanb Sep 23, 2024
aa700b7
Merge branch 'master' into experience/15823/fix-link-checker
etanb Sep 24, 2024
9eb9f55
make sure expect does not block
etanb Sep 24, 2024
5a622c9
Merge branch 'master' into experience/15823/fix-link-checker
etanb Sep 25, 2024
c0b05a4
Merge branch 'master' into experience/15823/fix-link-checker
etanb Sep 25, 2024
91b8e56
Merge branch 'master' into experience/15823/fix-link-checker
etanb Sep 26, 2024
2f28d73
remove so many console.error
etanb Sep 26, 2024
66606cf
formal expect statement
etanb Sep 26, 2024
aa2726b
Merge branch 'master' into experience/15823/fix-link-checker
etanb Sep 26, 2024
d307198
Merge branch 'master' into experience/15823/fix-link-checker
etanb Sep 26, 2024
aa21731
change uppercase
etanb Sep 26, 2024
61f347c
Merge branch 'experience/15823/fix-link-checker' of github.com:CDCgov…
etanb Sep 26, 2024
c973ad3
try p limit
etanb Sep 27, 2024
fb23c1e
replace page not found with variable
etanb Sep 27, 2024
81f5e7c
DO NOT MERGE THIS: testing core issue
etanb Sep 27, 2024
64a8bbe
remove async logic, single thread link checker
etanb Sep 27, 2024
e0907a2
Merge branch 'master' into experience/15823/fix-link-checker
etanb Sep 27, 2024
23a7fcf
increase timeout
etanb Sep 30, 2024
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
12 changes: 8 additions & 4 deletions frontend-react/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<title>%VITE_TITLE%</title>
<meta name="description" content="%VITE_DESCRIPTION%" />
<meta property="og:image" content="%VITE_OPENGRAPH_DEFAULT_IMAGE_SRC%" />
<meta property="og:image:alt" content="%VITE_OPENGRAPH_DEFAULT_IMAGE_ALTTEXT%" />
<title>Page not found</title>
<meta
name="description"
content="This page could not be found on our website. Please check the URL or return to the homepage."
/>
<meta property="og:title" content="404 - Page Not Found" />
<meta property="og:description" content="The page you are looking for is not available." />

<!-- 404 -->
<link rel="apple-touch-icon" href="/logo192.png" />
<link rel="manifest" href="/manifest.json" />
Expand Down
11 changes: 11 additions & 0 deletions frontend-react/e2e/helpers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,14 @@ export function removeDateTime(filename: string) {

return filename;
}

export function isAbsoluteURL(url: string): boolean {
return /^(https?|ftp|file|mailto):/.test(url);
}

export function isAssetURL(url: string): boolean {
// Regular expression to match common asset file extensions at the end of a URL
const assetExtensions = /\.(pdf|png|jpg|jpeg|gif|bmp|svg|webp|mp4|mp3|wav|ogg|avi|mov|mkv|zip|rar|tar|gz|iso)$/i;

return assetExtensions.test(url);
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { pageNotFound } from "../../../../../src/content/error/ErrorMessages";
import { tableRows } from "../../../../helpers/utils";
import { LastMileFailuresPage } from "../../../../pages/authenticated/admin/last-mile-failures";
import { test as baseTest, expect } from "../../../../test";
Expand Down Expand Up @@ -95,15 +96,15 @@ test.describe("Last Mile Failure page", () => {
test.use({ storageState: "e2e/.auth/receiver.json" });

test("returns Page Not Found", async ({ lastMileFailuresPage }) => {
await expect(lastMileFailuresPage.page).toHaveTitle(/Page Not Found/);
await expect(lastMileFailuresPage.page).toHaveTitle(new RegExp(pageNotFound));
});
});

test.describe("sender user", () => {
test.use({ storageState: "e2e/.auth/sender.json" });

test("returns Page Not Found", async ({ lastMileFailuresPage }) => {
await expect(lastMileFailuresPage.page).toHaveTitle(/Page Not Found/);
await expect(lastMileFailuresPage.page).toHaveTitle(new RegExp(pageNotFound));
});
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { pageNotFound } from "../../../../../src/content/error/ErrorMessages";
import { noData, tableRows } from "../../../../helpers/utils";
import { MOCK_GET_MESSAGES } from "../../../../mocks/messages";
import { MessageIDSearchPage } from "../../../../pages/authenticated/admin/message-id-search";
Expand Down Expand Up @@ -160,7 +161,7 @@ test.describe("Message ID Search Page", () => {
messageIDSearchPage.mockError = true;
await messageIDSearchPage.reload();

await expect(messageIDSearchPage.page).toHaveTitle(/Page Not Found/);
await expect(messageIDSearchPage.page).toHaveTitle(new RegExp(pageNotFound));
});
});

Expand All @@ -171,7 +172,7 @@ test.describe("Message ID Search Page", () => {
messageIDSearchPage.mockError = true;
await messageIDSearchPage.reload();

await expect(messageIDSearchPage.page).toHaveTitle(/Page Not Found/);
await expect(messageIDSearchPage.page).toHaveTitle(new RegExp(pageNotFound));
});
});
});
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { expect } from "@playwright/test";
import { pageNotFound } from "../../../../../src/content/error/ErrorMessages";
import { tableDataCellValue } from "../../../../helpers/utils";
import { MOCK_GET_ORGANIZATION_IGNORE } from "../../../../mocks/organizations";
import { OrganizationEditPage } from "../../../../pages/authenticated/admin/organization-edit";
Expand Down Expand Up @@ -47,14 +48,14 @@ test.describe("Organization Edit Page", () => {
test.describe("receiver user", () => {
test.use({ storageState: "e2e/.auth/receiver.json" });
test("returns Page Not Found", async ({ organizationEditPage }) => {
await expect(organizationEditPage.page).toHaveTitle(/Page Not Found/);
await expect(organizationEditPage.page).toHaveTitle(new RegExp(pageNotFound));
});
});

test.describe("sender user", () => {
test.use({ storageState: "e2e/.auth/sender.json" });
test("returns Page Not Found", async ({ organizationEditPage }) => {
await expect(organizationEditPage.page).toHaveTitle(/Page Not Found/);
await expect(organizationEditPage.page).toHaveTitle(new RegExp(pageNotFound));
});
});

Expand Down Expand Up @@ -84,18 +85,24 @@ test.describe("Organization Edit Page", () => {
test("has expected 'Meta'", async ({ organizationEditPage }) => {
const meta = organizationEditPage.page.getByTestId("gridContainer").getByTestId("grid").nth(2);
await expect(meta).toHaveText(organizationEditPage.getOrgMeta(MOCK_GET_ORGANIZATION_IGNORE));
});
});

test("has expected 'Description'", async ({ organizationEditPage }) => {
await expect(organizationEditPage.page.getByTestId("description")).toHaveValue(MOCK_GET_ORGANIZATION_IGNORE.description);
await expect(organizationEditPage.page.getByTestId("description")).toHaveValue(
MOCK_GET_ORGANIZATION_IGNORE.description,
);
});

test("has expected 'Jurisdiction'", async ({ organizationEditPage }) => {
await expect(organizationEditPage.page.getByTestId("jurisdiction")).toHaveValue(MOCK_GET_ORGANIZATION_IGNORE.jurisdiction);
await expect(organizationEditPage.page.getByTestId("jurisdiction")).toHaveValue(
MOCK_GET_ORGANIZATION_IGNORE.jurisdiction,
);
});

test("has expected 'Filters'", async ({ organizationEditPage }) => {
await expect(organizationEditPage.page.getByTestId("filters")).toHaveValue(JSON.stringify(MOCK_GET_ORGANIZATION_IGNORE.filters, null, 2));
await expect(organizationEditPage.page.getByTestId("filters")).toHaveValue(
JSON.stringify(MOCK_GET_ORGANIZATION_IGNORE.filters, null, 2),
);
});
});

Expand Down Expand Up @@ -129,9 +136,12 @@ test.describe("Organization Edit Page", () => {
test.describe("'Organization Sender Settings' section", () => {
test("can create a new organization sender", async ({ organizationEditPage }) => {
await organizationEditPage.page
.locator('#orgsendersettings').getByRole('link', { name: 'New' })
.locator("#orgsendersettings")
.getByRole("link", { name: "New" })
.click();
await expect(organizationEditPage.page).toHaveURL(`/admin/orgnewsetting/org/ignore/settingtype/sender`);
await expect(organizationEditPage.page).toHaveURL(
`/admin/orgnewsetting/org/ignore/settingtype/sender`,
);
await expect(organizationEditPage.page.getByText(/Org name: ignore/)).toBeVisible();
await expect(organizationEditPage.page.getByText(/Setting Type: sender/)).toBeVisible();

Expand All @@ -141,9 +151,20 @@ test.describe("Organization Edit Page", () => {
});

test("can edit an organization sender", async ({ organizationEditPage }) => {
const firstOrgSender = await organizationEditPage.page.locator("#orgsendersettings").nth(0).locator("td").nth(0).innerText();
await organizationEditPage.page.locator('#orgsendersettings').getByRole('link', { name: 'Edit' }).nth(0).click();
await expect(organizationEditPage.page).toHaveURL(`/admin/orgsendersettings/org/ignore/sender/${firstOrgSender}/action/edit`);
const firstOrgSender = await organizationEditPage.page
.locator("#orgsendersettings")
.nth(0)
.locator("td")
.nth(0)
.innerText();
await organizationEditPage.page
.locator("#orgsendersettings")
.getByRole("link", { name: "Edit" })
.nth(0)
.click();
await expect(organizationEditPage.page).toHaveURL(
`/admin/orgsendersettings/org/ignore/sender/${firstOrgSender}/action/edit`,
);
await expect(organizationEditPage.page.getByText(`Org name: ignore`)).toBeVisible();
await expect(organizationEditPage.page.getByText(`Sender name: ${firstOrgSender}`)).toBeVisible();

Expand All @@ -162,15 +183,24 @@ test.describe("Organization Edit Page", () => {

const orgSenderLocator = firstOrgSender.replace("-", "_");

await expect(organizationEditPage.page.locator(`#id_Item__${orgSenderLocator}__has_been_saved`).getByTestId("alerttoast")).toHaveText(`Item '${firstOrgSender}' has been saved`);
await expect(
organizationEditPage.page
.locator(`#id_Item__${orgSenderLocator}__has_been_saved`)
.getByTestId("alerttoast"),
).toHaveText(`Item '${firstOrgSender}' has been saved`);
await expect(organizationEditPage.page).toHaveURL(organizationEditPage.url);
});

test("can cancel when editing an organization sender", async ({ organizationEditPage }) => {
const firstOrgSender = await tableDataCellValue(organizationEditPage.page, 0, 0);
await organizationEditPage.page.
locator('#orgsendersettings').getByRole('link', { name: 'Edit' }).nth(0).click();
await expect(organizationEditPage.page).toHaveURL(`/admin/orgsendersettings/org/ignore/sender/${firstOrgSender}/action/edit`);
await organizationEditPage.page
.locator("#orgsendersettings")
.getByRole("link", { name: "Edit" })
.nth(0)
.click();
await expect(organizationEditPage.page).toHaveURL(
`/admin/orgsendersettings/org/ignore/sender/${firstOrgSender}/action/edit`,
);
await expect(organizationEditPage.page.getByText(`Org name: ignore`)).toBeVisible();
await expect(organizationEditPage.page.getByText(`Sender name: ${firstOrgSender}`)).toBeVisible();

Expand All @@ -182,9 +212,12 @@ test.describe("Organization Edit Page", () => {
test.describe("'Organization Receiver Settings' section", () => {
test("can create a new organization receiver", async ({ organizationEditPage }) => {
await organizationEditPage.page
.locator('#orgreceiversettings').getByRole('link', { name: 'New' })
.locator("#orgreceiversettings")
.getByRole("link", { name: "New" })
.click();
await expect(organizationEditPage.page).toHaveURL(`/admin/orgnewsetting/org/ignore/settingtype/receiver`);
await expect(organizationEditPage.page).toHaveURL(
`/admin/orgnewsetting/org/ignore/settingtype/receiver`,
);
await expect(organizationEditPage.page.getByText(/Org name: ignore/)).toBeVisible();
await expect(organizationEditPage.page.getByText(/Setting Type: receiver/)).toBeVisible();

Expand All @@ -194,11 +227,24 @@ test.describe("Organization Edit Page", () => {
});

test("can edit an organization receiver", async ({ organizationEditPage }) => {
const firstOrgReceiver = await organizationEditPage.page.locator("#orgreceiversettings").nth(0).locator("td").nth(0).innerText();
await organizationEditPage.page.locator('#orgreceiversettings').getByRole('link', { name: 'Edit' }).nth(0).click();
await expect(organizationEditPage.page).toHaveURL(`/admin/orgreceiversettings/org/ignore/receiver/${firstOrgReceiver}/action/edit`);
const firstOrgReceiver = await organizationEditPage.page
.locator("#orgreceiversettings")
.nth(0)
.locator("td")
.nth(0)
.innerText();
await organizationEditPage.page
.locator("#orgreceiversettings")
.getByRole("link", { name: "Edit" })
.nth(0)
.click();
await expect(organizationEditPage.page).toHaveURL(
`/admin/orgreceiversettings/org/ignore/receiver/${firstOrgReceiver}/action/edit`,
);
await expect(organizationEditPage.page.getByText(`Org name: ignore`)).toBeVisible();
await expect(organizationEditPage.page.getByText(`Receiver name: ${firstOrgReceiver}`)).toBeVisible();
await expect(
organizationEditPage.page.getByText(`Receiver name: ${firstOrgReceiver}`),
).toBeVisible();

await organizationEditPage.orgReceiverEdit.editJsonButton.click();
const modal = organizationEditPage.page.getByTestId("modalWindow").nth(0);
Expand All @@ -208,23 +254,42 @@ test.describe("Organization Edit Page", () => {
await expect(organizationEditPage.orgReceiverEdit.editJsonModal.save).toHaveAttribute("disabled");

await organizationEditPage.orgReceiverEdit.editJsonModal.checkSyntax.click();
await expect(organizationEditPage.orgReceiverEdit.editJsonModal.save).not.toHaveAttribute("disabled");
await expect(organizationEditPage.orgReceiverEdit.editJsonModal.save).not.toHaveAttribute(
"disabled",
);

await organizationEditPage.orgReceiverEdit.editJsonModal.save.click();
await expect(modal).toBeHidden();

const orgReceiverLocator = firstOrgReceiver.replace("-", "_");

await expect(organizationEditPage.page.locator(`#id_Item__${orgReceiverLocator}__has_been_updated`).getByTestId("alerttoast")).toHaveText(`Item '${firstOrgReceiver}' has been updated`);
await expect(
organizationEditPage.page
.locator(`#id_Item__${orgReceiverLocator}__has_been_updated`)
.getByTestId("alerttoast"),
).toHaveText(`Item '${firstOrgReceiver}' has been updated`);
await expect(organizationEditPage.page).toHaveURL(organizationEditPage.url);
});

test("can cancel when editing an organization receiver", async ({ organizationEditPage }) => {
const firstOrgReceiver = await organizationEditPage.page.locator("#orgreceiversettings").nth(0).locator("td").nth(0).innerText();
await organizationEditPage.page.locator('#orgreceiversettings').getByRole('link', { name: 'Edit' }).nth(0).click();
await expect(organizationEditPage.page).toHaveURL(`/admin/orgreceiversettings/org/ignore/receiver/${firstOrgReceiver}/action/edit`);
const firstOrgReceiver = await organizationEditPage.page
.locator("#orgreceiversettings")
.nth(0)
.locator("td")
.nth(0)
.innerText();
await organizationEditPage.page
.locator("#orgreceiversettings")
.getByRole("link", { name: "Edit" })
.nth(0)
.click();
await expect(organizationEditPage.page).toHaveURL(
`/admin/orgreceiversettings/org/ignore/receiver/${firstOrgReceiver}/action/edit`,
);
await expect(organizationEditPage.page.getByText(`Org name: ignore`)).toBeVisible();
await expect(organizationEditPage.page.getByText(`Receiver name: ${firstOrgReceiver}`)).toBeVisible();
await expect(
organizationEditPage.page.getByText(`Receiver name: ${firstOrgReceiver}`),
).toBeVisible();

await organizationEditPage.orgReceiverEdit.cancelButton.click();
await expect(organizationEditPage.page).toHaveURL(organizationEditPage.url);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { expect } from "@playwright/test";
import { readFileSync } from "node:fs";
import { join } from "node:path";
import { fileURLToPath } from "node:url";
import { pageNotFound } from "../../../../../src/content/error/ErrorMessages";
import { MOCK_GET_ORGANIZATION_SETTINGS_LIST } from "../../../../mocks/organizations";
import { OrganizationPage } from "../../../../pages/authenticated/admin/organization";
import { test as baseTest } from "../../../../test";
Expand Down Expand Up @@ -51,14 +52,14 @@ test.describe("Admin Organization Settings Page", () => {
test.describe("receiver user", () => {
test.use({ storageState: "e2e/.auth/receiver.json" });
test("returns Page Not Found", async ({ organizationPage }) => {
await expect(organizationPage.page).toHaveTitle(/Page Not Found/);
await expect(organizationPage.page).toHaveTitle(new RegExp(pageNotFound));
});
});

test.describe("sender user", () => {
test.use({ storageState: "e2e/.auth/sender.json" });
test("returns Page Not Found", async ({ organizationPage }) => {
await expect(organizationPage.page).toHaveTitle(/Page Not Found/);
await expect(organizationPage.page).toHaveTitle(new RegExp(pageNotFound));
});
});

Expand All @@ -79,8 +80,8 @@ test.describe("Admin Organization Settings Page", () => {

test.describe("when there is no error", () => {
test("nav contains the 'Admin tools' dropdown with 'Organization Settings' option", async ({
organizationPage,
}) => {
organizationPage,
}) => {
const navItems = organizationPage.page.locator(".usa-nav li");
await expect(navItems).toContainText(["Admin tools"]);

Expand Down Expand Up @@ -126,8 +127,8 @@ test.describe("Admin Organization Settings Page", () => {
i === 0
? MOCK_GET_ORGANIZATION_SETTINGS_LIST[0]
: (MOCK_GET_ORGANIZATION_SETTINGS_LIST.find((i) => i.name === cols[0]) ?? {
name: "INVALID",
});
name: "INVALID",
});
// if first row, we expect column headers. else, the data row matching id (name)
// SetEdit is text of buttons in button column
const expectedColContents =
Expand Down
Loading
Loading