Skip to content

Commit

Permalink
fix: 'Frame not included' string showing on all lots (#10479)
Browse files Browse the repository at this point in the history
* use force frame string logic

* add test for unlisted logic
  • Loading branch information
brainbicycle committed Jul 12, 2024
1 parent 2036225 commit 6844e74
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,17 @@ describe("ArtworkDimensionsClassificationAndAuthenticity", () => {
expect(screen.getByText("Frame not included")).toBeTruthy()
})

it("does not render a frame string when artwork is not unlisted", () => {
renderWithRelay({
Artwork: () => ({
framed: { details: "not included" },
isUnlisted: false,
}),
})

expect(screen.queryByText("Frame not included")).toBeFalsy()
})

it("renders 'Frame included' when the frame is included", () => {
renderWithRelay({
Artwork: () => ({ framed: { details: "Included" } }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,18 @@ interface ArtworkDimensionsClassificationAndAuthenticityProps {
const ArtworkDimensionsClassificationAndAuthenticity: React.FC<
ArtworkDimensionsClassificationAndAuthenticityProps
> = ({ artwork }) => {
const { medium, dimensions, framed, editionOf, editionSets } = artwork
const { medium, dimensions, framed, editionOf, editionSets, isUnlisted } = artwork

const dimensionsPresent = (dimensions: any) =>
/\d/.test(dimensions?.in) || /\d/.test(dimensions?.cm)

const getFrameString = (frameDetails?: string | null) => {
const getFrameString = (frameDetails?: string | null, isUnlisted?: boolean) => {
if (frameDetails !== "Included") {
return "Frame not included"
if (isUnlisted) {
return "Frame not included"
} else {
return
}
}

return `Frame ${frameDetails.toLowerCase()}`
Expand All @@ -33,9 +37,9 @@ const ArtworkDimensionsClassificationAndAuthenticity: React.FC<
{!!dimensionsPresent(dimensions) && (editionSets?.length ?? 0) < 2 && (
<Text color="black60" variant="sm">{`${dimensions?.in} | ${dimensions?.cm}`}</Text>
)}
{!!getFrameString(framed?.details) && (
{!!getFrameString(framed?.details, isUnlisted) && (
<Text color="black60" variant="sm">
{getFrameString(framed?.details)}
{getFrameString(framed?.details, isUnlisted)}
</Text>
)}
{!!editionOf && (
Expand Down Expand Up @@ -68,6 +72,7 @@ export const ArtworkDimensionsClassificationAndAuthenticityFragmentContainer =
}
editionOf
isEdition
isUnlisted
editionSets {
internalID
}
Expand Down

0 comments on commit 6844e74

Please sign in to comment.