-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Issue 1179] Search Page Boilerplate (#1197)
- Loading branch information
1 parent
5e0beb9
commit 24b8295
Showing
3 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import type { GetStaticProps, NextPage } from "next"; | ||
|
||
import { serverSideTranslations } from "next-i18next/serverSideTranslations"; | ||
|
||
const Search: NextPage = () => { | ||
return <>Search Boilerplate</>; | ||
}; | ||
|
||
// Change this to GetServerSideProps if you're using server-side rendering | ||
export const getStaticProps: GetStaticProps = async ({ locale }) => { | ||
const translations = await serverSideTranslations(locale ?? "en"); | ||
|
||
// TODO: update the statement below with a feature flag check | ||
const hideSearchPage = true; | ||
// redirects to default 404 page | ||
if (hideSearchPage) return { notFound: true }; | ||
|
||
return { props: { ...translations } }; | ||
}; | ||
|
||
export default Search; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Meta } from "@storybook/react"; | ||
import Search from "src/pages/search"; | ||
|
||
const meta: Meta<typeof Search> = { | ||
title: "Pages/Search", | ||
component: Search, | ||
}; | ||
export default meta; | ||
|
||
export const Preview = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { render, waitFor } from "@testing-library/react"; | ||
import { axe } from "jest-axe"; | ||
import Search from "src/pages/search"; | ||
|
||
describe("Search", () => { | ||
it("passes accessibility scan", async () => { | ||
const { container } = render(<Search />); | ||
const results = await waitFor(() => axe(container)); | ||
|
||
expect(results).toHaveNoViolations(); | ||
}); | ||
}); |