-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add not-found page * fix border on header * move common tests out of view-data * rename not found page * update fetch data error handling * make back button customizable * add back button to 404 page * [pre-commit.ci] auto fixes from pre-commit hooks * change back button text * Increase padding to 24 px * Boban/why (#2881) Add not found on non-integrated viewer * fix home page tests --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
6f80942
commit 6239898
Showing
13 changed files
with
253 additions
and
150 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,47 @@ | ||
"use client"; | ||
import { Icon } from "@trussworks/react-uswds"; | ||
import Header from "./Header"; | ||
import { BackButton } from "./view-data/components/BackButton"; | ||
|
||
/** | ||
* 404 page | ||
* @returns 404 Page | ||
*/ | ||
const NotFound = () => ( | ||
<div className="height-viewport width-viewport display-flex flex-column"> | ||
<Header /> | ||
<main className="display-flex flex-justify-center height-full"> | ||
<div className="display-inline-block margin-y-auto"> | ||
<h2 className="font-family-serif font-serif-xl margin-bottom-0"> | ||
<Icon.Error | ||
size={5} | ||
className="margin-right-105 text-middle" | ||
aria-hidden | ||
/> | ||
Page not found | ||
</h2> | ||
<div className="text-semibold font-sans-md margin-top-1"> | ||
The requested page could not be found | ||
</div> | ||
<div className="bg-info-lighter border border-info-light radius-md font-sans-md line-height-sans-4 padding-3 margin-top-2"> | ||
Please try the following: | ||
<ul className="margin-0 padding-left-3"> | ||
<li> | ||
<b>Check the URL:</b> Make sure there are no typos in the address. | ||
</li> | ||
<li> | ||
<b>Return to NBS:</b> Return to NBS and try to reopen the eCR. | ||
</li> | ||
<li> | ||
<b>Contact support:</b> If the problem persists, please reach out | ||
to your eCR coordinator. | ||
</li> | ||
</ul> | ||
</div> | ||
<BackButton className="margin-top-3 font-sans-md text-primary" /> | ||
</div> | ||
</main> | ||
</div> | ||
); | ||
|
||
export default NotFound; |
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
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
38 changes: 38 additions & 0 deletions
38
containers/ecr-viewer/src/app/tests/components/BackButton.test.tsx
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,38 @@ | ||
import { BackButton } from "@/app/view-data/components/BackButton"; | ||
import { render, screen } from "@testing-library/react"; | ||
|
||
describe("Back button", () => { | ||
it("should not appear when non integrated = false", () => { | ||
process.env.NEXT_PUBLIC_NON_INTEGRATED_VIEWER = "false"; | ||
|
||
render(<BackButton />); | ||
|
||
expect(screen.queryByText("Back to eCR Library")).not.toBeInTheDocument(); | ||
}); | ||
|
||
it("should appear when non integrated = true", () => { | ||
process.env.NEXT_PUBLIC_NON_INTEGRATED_VIEWER = "true"; | ||
|
||
render(<BackButton />); | ||
|
||
expect(screen.getByText("Back to eCR Library")).toBeInTheDocument(); | ||
}); | ||
|
||
it("should apply class name to the a tag", () => { | ||
process.env.NEXT_PUBLIC_NON_INTEGRATED_VIEWER = "true"; | ||
|
||
render(<BackButton className="some-class" />); | ||
|
||
expect(screen.getByText("Back to eCR Library").className).toContain( | ||
"some-class", | ||
); | ||
}); | ||
|
||
it("should icon apply class name to the icon tag", () => { | ||
process.env.NEXT_PUBLIC_NON_INTEGRATED_VIEWER = "true"; | ||
|
||
render(<BackButton iconClassName="some-icon-class" />); | ||
|
||
expect(screen.getByRole("img").classList).toContain("some-icon-class"); | ||
}); | ||
}); |
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
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
60 changes: 60 additions & 0 deletions
60
containers/ecr-viewer/src/app/tests/components/common.test.tsx
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,60 @@ | ||
import { getMedicationDisplayName } from "@/app/view-data/components/common"; | ||
|
||
describe("getMedicationDisplayName", () => { | ||
it("handles undefined case", () => { | ||
expect(getMedicationDisplayName(undefined)).toBe(undefined); | ||
}); | ||
|
||
it("handles empty case", () => { | ||
expect(getMedicationDisplayName({ coding: [] })).toBe(undefined); | ||
}); | ||
|
||
it("handles single named case", () => { | ||
expect( | ||
getMedicationDisplayName({ | ||
coding: [{ code: "123", display: "medication", system: "ABC" }], | ||
}), | ||
).toBe("medication"); | ||
}); | ||
|
||
it("handles single un-named case", () => { | ||
expect( | ||
getMedicationDisplayName({ | ||
coding: [{ code: "123", system: "ABC" }], | ||
}), | ||
).toBe("Unknown medication name - ABC code 123"); | ||
}); | ||
|
||
it("handles multiple named case", () => { | ||
expect( | ||
getMedicationDisplayName({ | ||
coding: [ | ||
{ code: "123", display: "first", system: "ABC" }, | ||
{ code: "456", display: "second", system: "DEF" }, | ||
], | ||
}), | ||
).toBe("first"); | ||
}); | ||
|
||
it("handles multiple mixed named case", () => { | ||
expect( | ||
getMedicationDisplayName({ | ||
coding: [ | ||
{ code: "123", system: "ABC" }, | ||
{ code: "456", display: "second", system: "DEF" }, | ||
], | ||
}), | ||
).toBe("second"); | ||
}); | ||
|
||
it("handles multiple un-named case", () => { | ||
expect( | ||
getMedicationDisplayName({ | ||
coding: [ | ||
{ code: "123", system: "ABC" }, | ||
{ code: "456", system: "DEF" }, | ||
], | ||
}), | ||
).toBe("Unknown medication name - ABC code 123"); | ||
}); | ||
}); |
Oops, something went wrong.