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

Commit

Permalink
Add test updates
Browse files Browse the repository at this point in the history
  • Loading branch information
acouch committed May 20, 2024
1 parent ffcd8c9 commit cdc461b
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 21 deletions.
1 change: 1 addition & 0 deletions frontend/src/app/[locale]/newsletter/confirmation/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import PageSEO from "src/components/PageSEO";
import BetaAlert from "src/components/BetaAlert";
import { useTranslations } from "next-intl";
import { Metadata } from "next";

export function generateMetadata() {
// TODO: Enable once [locale] folder created, see: https://next-intl-docs.vercel.app/docs/getting-started/app-router/with-i18n-routing
// const t = await getTranslations({ locale: "en" });
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/app/[locale]/newsletter/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ export default function Newsletter() {
})}
</Grid>
<Grid tabletLg={{ col: 6 }}>
<NextIntlClientProvider messages={pick(messages, "Newsletter")}>
<NextIntlClientProvider
locale="en"
messages={pick(messages, "Newsletter")}
>
<NewsletterForm />
</NextIntlClientProvider>
</Grid>
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/app/[locale]/not-found.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ 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";

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

return (
<>
<BetaAlert />
Expand Down
3 changes: 0 additions & 3 deletions frontend/src/app/[locale]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import IndexGoalContent from "src/components/content/IndexGoalContent";
import ProcessAndResearchContent from "src/components/content/ProcessAndResearchContent";
import { Metadata } from "next";
import { useTranslations } from "next-intl";
import { unstable_setRequestLocale } from "next-intl/server";

export function generateMetadata() {
// TODO: Enable once [locale] folder created, see: https://next-intl-docs.vercel.app/docs/getting-started/app-router/with-i18n-routing
Expand All @@ -20,8 +19,6 @@ export function generateMetadata() {
return meta;
}
export default function Home() {
// TODO: Remove when https://github.com/amannn/next-intl/issues/663 lands.
unstable_setRequestLocale("en");
const t = useTranslations("Index");

return (
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/i18n/messages/en/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,9 @@ export const messages = {
invalid_email:
"Enter an email address in the correct format, like [email protected].",
already_subscribed:
"{{email_address}} is already subscribed. If you’re not seeing our emails, check your spam folder and add [email protected] to your contacts, address book, or safe senders list. If you continue to not receive our emails, contact <email>[email protected]</email>.",
"<email_address/> is already subscribed. If you’re not seeing our emails, check your spam folder and add [email protected] to your contacts, address book, or safe senders list. If you continue to not receive our emails, contact <email>[email protected]</email>.",
sendy:
"Sorry, an unexpected error in our system occured when trying to save your subscription. If this continues to happen, you may email <email>[email protected]</email>. Error: {{sendy_error}}",
"Sorry, an unexpected error in our system occured when trying to save your subscription. If this continues to happen, you may email <email>[email protected]</email>. Error: <sendy_error/>",
},
},
Newsletter_confirmation: {
Expand Down
2 changes: 1 addition & 1 deletion frontend/tests/pages/newsletter/confirmation.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { render, waitFor } from "@testing-library/react";
import { render, waitFor } from "tests/react-utils";
import { axe } from "jest-axe";
import NewsletterConfirmation from "src/app/[locale]/newsletter/confirmation/page";

Expand Down
18 changes: 9 additions & 9 deletions frontend/tests/pages/newsletter/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { fireEvent, render, screen, waitFor } from "@testing-library/react";
import { fireEvent, render, screen, waitFor } from "tests/react-utils";

import userEvent from "@testing-library/user-event";
import { axe } from "jest-axe";
import Newsletter from "src/app/[locale]/newsletter/page";

import { useRouter } from "next/router";
import { useRouter } from "next/navigation";

jest.mock("next/router", () => ({
useRouter: jest.fn(),
}));
jest.mock("next/navigation");

describe("Newsletter", () => {
it("renders signup form with a submit button", () => {
Expand Down Expand Up @@ -44,10 +43,11 @@ describe("Newsletter", () => {

// Wait for the form submission
await waitFor(() => {
expect(mockRouter.push).toHaveBeenCalledWith({
pathname: "/newsletter/confirmation/",
query: { sendy: "Success" },
});
console.log(mockRouter.push);

expect(mockRouter.push).toHaveBeenCalledWith(
"/newsletter/confirmation?sendy=User+subscribed+successfully.",
);
});
});

Expand Down
2 changes: 1 addition & 1 deletion frontend/tests/pages/newsletter/unsubscribe.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { render, waitFor } from "@testing-library/react";
import { render, waitFor } from "tests/react-utils";
import { axe } from "jest-axe";
import NewsletterUnsubscribe from "src/app/[locale]/newsletter/unsubsrcibe/page";

Expand Down
3 changes: 1 addition & 2 deletions frontend/tests/pages/process.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { screen, waitFor } from "tests/react-utils";
import { render } from "@testing-library/react";
import { render, screen, waitFor } from "tests/react-utils";

import { axe } from "jest-axe";
import Process from "src/app/[locale]/process/page";
Expand Down

0 comments on commit cdc461b

Please sign in to comment.