-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #218 from NYPL/release/0.1.16
Release/0.1.16
- Loading branch information
Showing
40 changed files
with
1,403 additions
and
1,363 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
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
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
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 @@ | ||
import PageLayout from "@/src/components/pageLayout/pageLayout"; | ||
import ErrorPage from "@/src/components/pages/errorPage/errorPage"; | ||
import { fireEvent, render, screen } from "@testing-library/react"; | ||
import { useRouter } from "next/navigation"; | ||
import React from "react"; | ||
|
||
jest.mock("next/navigation", () => ({ | ||
useRouter: jest.fn(), | ||
})); | ||
|
||
describe("Error Page", () => { | ||
it("renders an error message", () => { | ||
(useRouter as jest.Mock).mockImplementation(() => ({ | ||
pathname: "/test-error", | ||
})); | ||
|
||
render( | ||
<PageLayout activePage={"serverError"}> | ||
<ErrorPage /> | ||
</PageLayout> | ||
); | ||
|
||
const heading = screen.getByRole("heading", { | ||
name: /Something went wrong on our end./i, | ||
}); | ||
expect(heading).toBeInTheDocument(); | ||
}); | ||
|
||
it("has a link that can open the feedback box", async () => { | ||
(useRouter as jest.Mock).mockImplementation(() => ({ | ||
pathname: "/test-error", | ||
})); | ||
|
||
render( | ||
<PageLayout activePage={"serverError"}> | ||
<ErrorPage /> | ||
</PageLayout> | ||
); | ||
|
||
const button = screen.getByText(/contact us/); | ||
fireEvent.click(button); | ||
|
||
expect( | ||
screen.getByText(/What is your feedback about?/) | ||
).toBeInTheDocument(); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,26 @@ | ||
"use client"; | ||
import { Box, Heading } from "@nypl/design-system-react-components"; | ||
import Link from "next/link"; | ||
import PageLayout from "./src/components/pageLayout/pageLayout"; | ||
import { useEffect } from "react"; | ||
|
||
import PageLayout from "./src/components/pageLayout/pageLayout"; | ||
import ErrorPage from "./src/components/pages/errorPage/errorPage"; | ||
|
||
export default function Error({ | ||
error, | ||
}: { | ||
error: Error & { digest?: string }; | ||
}) { | ||
useEffect(() => { | ||
console.error(error); | ||
|
||
// Send error to New Relic | ||
if ((window as any).newrelic) { | ||
(window as any).newrelic.noticeError(error); | ||
} | ||
}, [error]); | ||
|
||
return ( | ||
<PageLayout activePage="serverError"> | ||
<Box | ||
sx={{ | ||
display: "flex", | ||
flexDirection: "column", | ||
justifyContent: "center", | ||
alignItems: "center", | ||
margin: "xl", | ||
textAlign: "center", | ||
}} | ||
> | ||
<Heading level="h1">Error</Heading> | ||
<p>We're sorry...</p> | ||
<p>Something went wrong.</p> | ||
<p> | ||
Return to <Link href={"/"}>Digital Collections</Link>. | ||
</p> | ||
</Box> | ||
<ErrorPage /> | ||
</PageLayout> | ||
); | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import Image from "next/image"; | ||
import React from "react"; | ||
import { useState } from "react"; | ||
import { DCCardProps } from "./card"; | ||
|
||
interface CardImageProps extends Pick<DCCardProps, "record"> { | ||
imageHeight: number; | ||
} | ||
|
||
export const CardImage = ({ record, imageHeight }: CardImageProps) => { | ||
const [imageSrc, setImageSrc] = useState( | ||
record.imageID ? record.imageURL : "/noImage.png" | ||
); | ||
const initialImageHeight = 144; | ||
return ( | ||
<div | ||
style={{ | ||
overflow: "hidden", | ||
height: imageHeight, | ||
}} | ||
> | ||
<Image | ||
src={imageSrc} | ||
alt="" | ||
id={ | ||
record.imageID | ||
? `image-${record.imageID}` | ||
: `no-image-${record.imageID}` | ||
} | ||
sizes="(max-width: 480px) 100vw, (max-width: 1024px) 50vw, 25vw" | ||
style={{ | ||
width: "100%", | ||
minHeight: "100%", | ||
height: "auto", | ||
}} | ||
width={initialImageHeight * 2} | ||
height={initialImageHeight} | ||
onError={(_event) => { | ||
console.warn( | ||
`CardImage: Card image failed to load, fallback image loaded instead. ImageURL: ${record.imageURL}` | ||
); | ||
setImageSrc("/noImage.png"); | ||
}} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export default CardImage; |
Oops, something went wrong.