-
Notifications
You must be signed in to change notification settings - Fork 2
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 #321 from nulib/4576-pdf-download
Support Alternative Items download in Work Download and Share modal
- Loading branch information
Showing
12 changed files
with
1,568 additions
and
801 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
56 changes: 56 additions & 0 deletions
56
components/Work/ActionsDialog/DownloadAndShare/EmbedResources.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,56 @@ | ||
import { render, screen } from "@testing-library/react"; | ||
|
||
import EmbedResources from "./EmbedResources"; | ||
import React from "react"; | ||
import { manifest } from "@/mocks/work-page/download-and-share"; | ||
import { work1 } from "@/mocks/work-page/work1"; | ||
|
||
const alternateFormatItems = manifest.rendering ? [...manifest.rendering] : []; | ||
|
||
describe("EmbedResources", () => { | ||
it("should render the Download and Embed section with standard images ", () => { | ||
render( | ||
<EmbedResources | ||
manifest={manifest} | ||
alternateFormatItems={[]} | ||
showEmbedWarning={false} | ||
work={work1} | ||
/> | ||
); | ||
expect( | ||
screen.getByRole("heading", { name: "Download and Embed" }) | ||
).toBeInTheDocument(); | ||
expect(screen.getByRole("heading", { name: "Images" })).toBeInTheDocument(); | ||
|
||
const downloadEmbedItems = screen.getByTestId("download-embed-items"); | ||
|
||
expect(downloadEmbedItems).toHaveTextContent( | ||
"BFMF_B06_F12_006_022n_am.tif" | ||
); | ||
expect(downloadEmbedItems).toHaveTextContent("Download JPG"); | ||
expect(downloadEmbedItems).toHaveTextContent("Embed HTML"); | ||
expect(downloadEmbedItems).toHaveTextContent("Copy IIIF"); | ||
|
||
// Alternate Formats should not be rendered | ||
expect( | ||
screen.queryByRole("heading", { name: "Alternate Formats" }) | ||
).toBeNull(); | ||
}); | ||
|
||
it("should render the Download and Embed section with alternate formats. It should also include 'pdf' in the link if it's a PDF mime/type", () => { | ||
render( | ||
<EmbedResources | ||
manifest={manifest} | ||
alternateFormatItems={alternateFormatItems} | ||
showEmbedWarning={false} | ||
work={work1} | ||
/> | ||
); | ||
|
||
expect( | ||
screen.getByRole("heading", { name: "Alternate Formats" }) | ||
).toBeInTheDocument(); | ||
expect(screen.getByRole("link", { name: "Test PDF (pdf)" })).toBeVisible(); | ||
expect(screen.getByRole("link", { name: "Transcript XYZ" })).toBeVisible(); | ||
}); | ||
}); |
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,23 @@ | ||
import { LabeledContentResource } from "@/types/components/works"; | ||
import { workManifest1 } from "./work-manifest1"; | ||
|
||
const rendering: LabeledContentResource[] = [ | ||
{ | ||
format: "application/pdf", | ||
id: "https://clickdimensions.com/links/TestPDFfile.pdf", | ||
label: { en: ["Test PDF"] }, | ||
type: "Text", | ||
}, | ||
|
||
{ | ||
format: "text/plain", | ||
id: "https://clickdimensions.com/links/TestPDFfile2.pdf", | ||
label: { en: ["Transcript XYZ"] }, | ||
type: "Text", | ||
}, | ||
]; | ||
|
||
export const manifest = { | ||
...workManifest1, | ||
rendering, | ||
}; |
Oops, something went wrong.