From 3a0f0bb42cc6c5b4abf72e75c5d223f560ae2fa0 Mon Sep 17 00:00:00 2001 From: Sammy Steiner Date: Thu, 24 Aug 2023 10:19:26 -0400 Subject: [PATCH 1/9] title and head in index --- frontend/public/locales/en/common.json | 5 ++--- frontend/src/pages/index.tsx | 5 +++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/frontend/public/locales/en/common.json b/frontend/public/locales/en/common.json index 9e8f77ae2..b10f0a7ce 100644 --- a/frontend/public/locales/en/common.json +++ b/frontend/public/locales/en/common.json @@ -1,8 +1,7 @@ { "Index": { - "title": "Home", - "intro": "This is a template for a React web application using the Next.js framework.", - "body": "This is template includes:", + "page_title": "Home | Beta.grants.gov", + "meta_description": "The beta version of a government website where federal agencies post discretionary funding opportunities and grantees find and apply for them", "alert": "This website is a work in progress. To search for funding opportunities and apply, visit www.grants.gov.", "goal_title": "What's the goal?", "goal_paragraph_1": "We want Grants.gov to be the simplest, most inclusive, and most gratifying tool ever built for posting, finding, sharing, and applying for financial assistance. Our mission is to increase access to grants and improve the grants experience for everyone.", diff --git a/frontend/src/pages/index.tsx b/frontend/src/pages/index.tsx index 16848dd7e..56ffa2182 100644 --- a/frontend/src/pages/index.tsx +++ b/frontend/src/pages/index.tsx @@ -9,12 +9,17 @@ import FullWidthAlert from "../components/FullWidthAlert"; import FundingContent from "../components/FundingContent"; import GoalContent from "../components/GoalContent"; import Hero from "../components/Hero"; +import Head from "next/head"; const Home: NextPage = () => { const { t } = useTranslation("common", { keyPrefix: "Index" }); return ( <> + + {t("page_title")} + + Date: Thu, 24 Aug 2023 13:05:43 -0400 Subject: [PATCH 2/9] lint --- frontend/src/pages/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/pages/index.tsx b/frontend/src/pages/index.tsx index 56ffa2182..9bd022ea0 100644 --- a/frontend/src/pages/index.tsx +++ b/frontend/src/pages/index.tsx @@ -3,13 +3,13 @@ import { ExternalRoutes } from "src/constants/routes"; import { Trans, useTranslation } from "next-i18next"; import { serverSideTranslations } from "next-i18next/serverSideTranslations"; +import Head from "next/head"; import WtGIContent from "src/components/WtGIContent"; import FullWidthAlert from "../components/FullWidthAlert"; import FundingContent from "../components/FundingContent"; import GoalContent from "../components/GoalContent"; import Hero from "../components/Hero"; -import Head from "next/head"; const Home: NextPage = () => { const { t } = useTranslation("common", { keyPrefix: "Index" }); @@ -18,7 +18,7 @@ const Home: NextPage = () => { <> {t("page_title")} - + From 8f78182b1f16ed6f237321d239978307ddbcba15 Mon Sep 17 00:00:00 2001 From: Sammy Steiner Date: Thu, 24 Aug 2023 14:06:53 -0400 Subject: [PATCH 3/9] page seo component and test --- frontend/src/components/PageSEO.tsx | 19 ++++++++++ frontend/src/pages/index.tsx | 7 +--- frontend/tests/components/PageSEO.test.tsx | 44 ++++++++++++++++++++++ 3 files changed, 65 insertions(+), 5 deletions(-) create mode 100644 frontend/src/components/PageSEO.tsx create mode 100644 frontend/tests/components/PageSEO.test.tsx diff --git a/frontend/src/components/PageSEO.tsx b/frontend/src/components/PageSEO.tsx new file mode 100644 index 000000000..c1e16ff0c --- /dev/null +++ b/frontend/src/components/PageSEO.tsx @@ -0,0 +1,19 @@ +import Head from "next/head"; + +type Props = { + title: string; + description: string; + titleKey: string; +}; + +const PageSEO = ({ title, description, titleKey }: Props) => { + return ( + + {title} + + + + ); +}; + +export default PageSEO; diff --git a/frontend/src/pages/index.tsx b/frontend/src/pages/index.tsx index 9bd022ea0..1bdb2a47b 100644 --- a/frontend/src/pages/index.tsx +++ b/frontend/src/pages/index.tsx @@ -3,8 +3,8 @@ import { ExternalRoutes } from "src/constants/routes"; import { Trans, useTranslation } from "next-i18next"; import { serverSideTranslations } from "next-i18next/serverSideTranslations"; -import Head from "next/head"; +import PageSEO from "src/components/PageSEO"; import WtGIContent from "src/components/WtGIContent"; import FullWidthAlert from "../components/FullWidthAlert"; import FundingContent from "../components/FundingContent"; @@ -16,10 +16,7 @@ const Home: NextPage = () => { return ( <> - - {t("page_title")} - - + { + return { + __esModule: true, + default: ({ children }: { children: Array }) => { + return <>{children}; + }, + }; +}); + +describe("PageSEO", () => { + it("Renders title without errors", () => { + const props = { title: "test title", description: "test description" }; + render(); + expect(document.title).toBe("test title"); + }); + + it("Renders meta description content without errors", () => { + const props = { title: "test title", description: "test description" }; + render(); + const description = document.querySelector( + "meta[name='description']" + ) as HTMLTemplateElement; + expect(description.content).toBe("test description"); + }); + + it("Renders the correct title after rerendering", async () => { + const initialProps = { + title: "test title", + description: "test description", + }; + const updatedProps = { + title: "updated test title", + description: "updated test description", + }; + const { rerender } = render(); + expect(document.title).toBe("test title"); + rerender(); + expect(document.title).toBe("updated test title"); + }); +}); From f35ea9b4b8abc02b59b9eabef9ba6d28cb8939c8 Mon Sep 17 00:00:00 2001 From: Sammy Steiner Date: Thu, 24 Aug 2023 14:09:29 -0400 Subject: [PATCH 4/9] didn't save properly --- frontend/src/components/PageSEO.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/PageSEO.tsx b/frontend/src/components/PageSEO.tsx index c1e16ff0c..ab384c1b7 100644 --- a/frontend/src/components/PageSEO.tsx +++ b/frontend/src/components/PageSEO.tsx @@ -3,15 +3,14 @@ import Head from "next/head"; type Props = { title: string; description: string; - titleKey: string; }; -const PageSEO = ({ title, description, titleKey }: Props) => { +const PageSEO = ({ title, description }: Props) => { return ( {title} - - + + ); }; From 08354f5b382a96e88842a5e8f0265229bb451c47 Mon Sep 17 00:00:00 2001 From: Sammy Steiner Date: Thu, 24 Aug 2023 14:10:37 -0400 Subject: [PATCH 5/9] removed unused imports --- frontend/tests/components/PageSEO.test.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/tests/components/PageSEO.test.tsx b/frontend/tests/components/PageSEO.test.tsx index cab3c3c17..163ed9f4f 100644 --- a/frontend/tests/components/PageSEO.test.tsx +++ b/frontend/tests/components/PageSEO.test.tsx @@ -1,4 +1,4 @@ -import { render, screen, waitFor } from "@testing-library/react"; +import { render } from "@testing-library/react"; import PageSEO from "src/components/PageSEO"; From e96d6db904d094be8c25733f30dfe023a686ffd1 Mon Sep 17 00:00:00 2001 From: Sammy Steiner Date: Thu, 24 Aug 2023 14:12:31 -0400 Subject: [PATCH 6/9] removed unnecessary async --- frontend/tests/components/PageSEO.test.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/tests/components/PageSEO.test.tsx b/frontend/tests/components/PageSEO.test.tsx index 163ed9f4f..9d7b646b0 100644 --- a/frontend/tests/components/PageSEO.test.tsx +++ b/frontend/tests/components/PageSEO.test.tsx @@ -27,7 +27,7 @@ describe("PageSEO", () => { expect(description.content).toBe("test description"); }); - it("Renders the correct title after rerendering", async () => { + it("Renders the correct title after rerendering", () => { const initialProps = { title: "test title", description: "test description", From 078c3825ffc0bcdfa638764ff5d2a42586d01c6e Mon Sep 17 00:00:00 2001 From: Sammy Steiner Date: Thu, 24 Aug 2023 15:44:07 -0400 Subject: [PATCH 7/9] no node access in test for eslint --- frontend/src/components/PageSEO.tsx | 7 ++++++- frontend/tests/components/PageSEO.test.tsx | 19 +++++++++++-------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/frontend/src/components/PageSEO.tsx b/frontend/src/components/PageSEO.tsx index ab384c1b7..adda7d368 100644 --- a/frontend/src/components/PageSEO.tsx +++ b/frontend/src/components/PageSEO.tsx @@ -10,7 +10,12 @@ const PageSEO = ({ title, description }: Props) => { {title} - + ); }; diff --git a/frontend/tests/components/PageSEO.test.tsx b/frontend/tests/components/PageSEO.test.tsx index 9d7b646b0..d9942706d 100644 --- a/frontend/tests/components/PageSEO.test.tsx +++ b/frontend/tests/components/PageSEO.test.tsx @@ -1,4 +1,4 @@ -import { render } from "@testing-library/react"; +import { render, screen } from "@testing-library/react"; import PageSEO from "src/components/PageSEO"; @@ -15,16 +15,15 @@ describe("PageSEO", () => { it("Renders title without errors", () => { const props = { title: "test title", description: "test description" }; render(); - expect(document.title).toBe("test title"); + const title = screen.getByText("test title"); + expect(title).toBeInTheDocument(); }); it("Renders meta description content without errors", () => { const props = { title: "test title", description: "test description" }; render(); - const description = document.querySelector( - "meta[name='description']" - ) as HTMLTemplateElement; - expect(description.content).toBe("test description"); + const description = screen.getByTestId("meta-description"); + expect(description).toBeInTheDocument(); }); it("Renders the correct title after rerendering", () => { @@ -37,8 +36,12 @@ describe("PageSEO", () => { description: "updated test description", }; const { rerender } = render(); - expect(document.title).toBe("test title"); + const title = screen.getByText("test title"); + expect(title).toBeInTheDocument(); rerender(); - expect(document.title).toBe("updated test title"); + const oldTitle = screen.queryByText("test title"); + const updatedtitle = screen.getByText("updated test title"); + expect(oldTitle).not.toBeInTheDocument(); + expect(updatedtitle).toBeInTheDocument(); }); }); From 41d62dcc3c78693dc0dad2ba9cd1611180350610 Mon Sep 17 00:00:00 2001 From: Sammy Steiner Date: Fri, 25 Aug 2023 11:21:37 -0400 Subject: [PATCH 8/9] content --- frontend/public/locales/en/common.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/public/locales/en/common.json b/frontend/public/locales/en/common.json index b10f0a7ce..f42b08207 100644 --- a/frontend/public/locales/en/common.json +++ b/frontend/public/locales/en/common.json @@ -1,7 +1,7 @@ { "Index": { "page_title": "Home | Beta.grants.gov", - "meta_description": "The beta version of a government website where federal agencies post discretionary funding opportunities and grantees find and apply for them", + "meta_description": "Our mission is to increase access to grants and improve the grants experience for everyone. A one-stop shop for all federal discretionary funding to make it easy for you to discover, understand, and apply for opportunities.", "alert": "This website is a work in progress. To search for funding opportunities and apply, visit www.grants.gov.", "goal_title": "What's the goal?", "goal_paragraph_1": "We want Grants.gov to be the simplest, most inclusive, and most gratifying tool ever built for posting, finding, sharing, and applying for financial assistance. Our mission is to increase access to grants and improve the grants experience for everyone.", From 1969963e60fec70d399081e4e2f8daf21871224f Mon Sep 17 00:00:00 2001 From: Sammy Steiner Date: Fri, 25 Aug 2023 14:17:35 -0400 Subject: [PATCH 9/9] content decision --- frontend/public/locales/en/common.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/public/locales/en/common.json b/frontend/public/locales/en/common.json index f42b08207..7d5c6cef7 100644 --- a/frontend/public/locales/en/common.json +++ b/frontend/public/locales/en/common.json @@ -1,7 +1,7 @@ { "Index": { "page_title": "Home | Beta.grants.gov", - "meta_description": "Our mission is to increase access to grants and improve the grants experience for everyone. A one-stop shop for all federal discretionary funding to make it easy for you to discover, understand, and apply for opportunities.", + "meta_description": "A one-stop shop for all federal discretionary funding to make it easy for you to discover, understand, and apply for opportunities.", "alert": "This website is a work in progress. To search for funding opportunities and apply, visit www.grants.gov.", "goal_title": "What's the goal?", "goal_paragraph_1": "We want Grants.gov to be the simplest, most inclusive, and most gratifying tool ever built for posting, finding, sharing, and applying for financial assistance. Our mission is to increase access to grants and improve the grants experience for everyone.",