Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Commit

Permalink
Move 404 page to app router
Browse files Browse the repository at this point in the history
  • Loading branch information
acouch committed May 22, 2024
1 parent 0120c7b commit ccbc956
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 69 deletions.
15 changes: 13 additions & 2 deletions frontend/src/app/not-found.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
import BetaAlert from "src/components/AppBetaAlert";
import BetaAlert from "src/components/BetaAlert";
import { GridContainer } from "@trussworks/react-uswds";
import Link from "next/link";
import { useTranslations } from "next-intl";
import { unstable_setRequestLocale } from "next-intl/server";
import { getTranslations, unstable_setRequestLocale } from "next-intl/server";
import { Metadata } from "next";

export async function generateMetadata() {
const t = await getTranslations({ locale: "en" });
const meta: Metadata = {
title: t("ErrorPages.page_not_found.title"),
description: t("Index.meta_description"),
};
return meta;
}

export default function NotFound() {
unstable_setRequestLocale("en");
const t = useTranslations("ErrorPages.page_not_found");

return (
<>
<BetaAlert />
Expand Down
39 changes: 0 additions & 39 deletions frontend/src/pages/404.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion frontend/stories/pages/404.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Meta } from "@storybook/react";
import PageNotFound from "src/pages/404";
import PageNotFound from "src/app/not-found";

const meta: Meta<typeof PageNotFound> = {
title: "Pages/404",
Expand Down
20 changes: 20 additions & 0 deletions frontend/tests/e2e/404.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/* eslint-disable testing-library/prefer-screen-queries */
import { test, expect } from "@playwright/test";

test.beforeEach(async ({ page }) => {
await page.goto("/imnothere");
});

test.afterEach(async ({ context }) => {
await context.close();
});

test("has title", async ({ page }) => {
await expect(page).toHaveTitle("Oops! Page Not Found");
});

test("can view the home button", async ({ page }) => {
await expect(page.getByRole("link", { name: "Return Home" })).toHaveText(
"Return Home",
);
});
27 changes: 0 additions & 27 deletions frontend/tests/pages/404.test.tsx

This file was deleted.

0 comments on commit ccbc956

Please sign in to comment.