Skip to content

Commit

Permalink
Merge branch 'development' into SFR-2236/edition-license-link
Browse files Browse the repository at this point in the history
  • Loading branch information
jackiequach committed Oct 9, 2024
2 parents d16abac + ed7dd65 commit 0630135
Show file tree
Hide file tree
Showing 23 changed files with 155 additions and 56 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## [Prerelease]

- Update license link for editions, works, and collections to copyright
- Update License page to Copyright and add section for "In Copyright" explanation

## [0.18.3]

Expand Down
6 changes: 3 additions & 3 deletions playwright/support/mappings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export const pages: { [name: string]: Pages } = {
about: {
route: "/about",
},
license: {
route: "/license",
copyright: {
route: "/copyright",
},
"read online": {
route: "/read/4440666",
Expand Down Expand Up @@ -117,7 +117,7 @@ export const elements = {
"item featured edition year": "a:has-text('Edition') >> nth=0",
"item featured edition publisher": "div:text('Published by') >> nth=0",
"item featured edition language": "div:text('Languages') >> nth=0",
"item featured edition license": "[href='/license'] >> nth=0",
"item featured edition license": "[href='/copyright'] >> nth=0",
"item details heading": "#details-list-heading",
"item details authors heading": "dt:text('Authors')",
"item details authors": "dd > a[href*='display=author'] >> nth=0",
Expand Down
6 changes: 3 additions & 3 deletions src/__tests__/Search.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ describe("Renders Search Results Page", () => {
test("Shows license with links", () => {
expect(
screen.getByText("Copyright: Public Domain").closest("a").href
).toContain("/license");
).toContain("/copyright");
});
test("Shows cover", () => {
expect(
Expand Down Expand Up @@ -416,7 +416,7 @@ describe("Renders Search Results Page", () => {
test("Shows Unknown license with links", () => {
expect(
screen.getByText("Copyright: Unknown").closest("a").href
).toContain("/license");
).toContain("/copyright");
});
test("Shows Placeholder cover", () => {
expect(
Expand Down Expand Up @@ -486,7 +486,7 @@ describe("Renders Search Results Page", () => {
"Copyright: Public Domain Public Domain Public Domain Public Domain Public Domain Public Domain Public Domain Public Domain Public Domain"
)
.closest("a").href
).toContain("/license");
).toContain("/copyright");
});
test("Shows cover", () => {
expect(
Expand Down
6 changes: 3 additions & 3 deletions src/components/About/About.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ const About: React.FC = () => {
All the materials in Digital Research Books Beta are completely free to
read and most of them you can download and keep, with no library card
required. The books are either in the{" "}
<Link to="/license">public domain</Link>, with no restrictions on your
<Link to="/copyright">public domain</Link>, with no restrictions on your
use of them, or under{" "}
<Link to="/license">Creative Commons licences</Link> that may have some
conditions, but only on redistribution or adaptation.
<Link to="/copyright">Creative Commons licences</Link> that may have
some conditions, but only on redistribution or adaptation.
</p>

<p>
Expand Down
4 changes: 2 additions & 2 deletions src/components/About/__snapshots__/About.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,15 @@ exports[`renders about unchanged 1`] = `
<a
class="chakra-link css-qsaw8"
href="/license"
href="/copyright"
>
public domain
</a>
, with no restrictions on your use of them, or under
<a
class="chakra-link css-qsaw8"
href="/license"
href="/copyright"
>
Creative Commons licences
</a>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Collection/Collection.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ describe("Renders Collection Page", () => {
test("Shows license with links", () => {
expect(
screen.getByText("Copyright: Public Domain").closest("a").href
).toContain("/license");
).toContain("/copyright");
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe("Collection Item Card", () => {
});
test("shows license", () => {
expect(screen.getByText("Copyright: Unknown").closest("a").href).toContain(
"/license"
"/copyright"
);
});
});
2 changes: 1 addition & 1 deletion src/components/CollectionItemCard/CopyrightLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Link from "~/src/components/Link/Link";

const CopyrightLink: React.FC<{ rights: Rights }> = ({ rights }) => {
return (
<Link to="/license">
<Link to="/copyright">
{rights ? `Copyright: ${rights.rightsStatement}` : "Copyright: Unknown"}
</Link>
);
Expand Down
77 changes: 77 additions & 0 deletions src/components/Copyright/Copyright.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import React from "react";
import { render } from "~/src/__tests__/testUtils/render";
import { screen } from "@testing-library/react";
import Copyright from "./Copyright";

it("renders Copyright page unchanged", async () => {
const tree = render(<Copyright />);
expect(tree.container.firstChild).toMatchSnapshot();
});

describe("Copyright Page", () => {
beforeEach(() => {
render(<Copyright />);
});

it("renders the Copyright Explanations heading", () => {
expect(
screen.getByRole("heading", { name: "Copyright Explanations" })
).toBeInTheDocument();
});

it("renders the Public Domain headings", () => {
expect(
screen.getByRole("heading", { name: "Public Domain" })
).toBeInTheDocument();
expect(
screen.getByRole("heading", { name: "Public Domain (US Only)" })
).toBeInTheDocument();
});

it("renders the Creative Commons section", () => {
expect(
screen.getByRole("heading", { name: "Creative Commons Licenses" })
).toBeInTheDocument();

expect(
screen.getByRole("link", { name: "Creative Commons licenses" })
).toHaveAttribute("href", "https://creativecommons.org/");

expect(
screen.getByRole("link", { name: "Attribution 3.0 Unported (CC BY 3.0)" })
).toHaveAttribute("href", "https://creativecommons.org/licenses/by/3.0/");
});

it("renders the CC0 section", () => {
expect(
screen.getByRole("heading", { name: "CC0 Public Domain Dedication" })
).toBeInTheDocument();

expect(
screen.getByRole("link", {
name: "CC0 1.0 Universal (CC0 1.0) Public Domain Dedication",
})
).toHaveAttribute(
"href",
"https://creativecommons.org/publicdomain/zero/1.0/"
);
});

it("renders the GNU section", () => {
expect(
screen.getByRole("heading", { name: "GNU General Public License" })
).toBeInTheDocument();

expect(
screen.getByRole("link", {
name: "GNU General Public License",
})
).toHaveAttribute("href", "http://www.gnu.org/licenses/gpl.html");
});

it("renders the In Copyright heading", () => {
expect(
screen.getByRole("heading", { name: "In Copyright" })
).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import {
import Link from "../Link/Link";
import DrbBreakout from "../DrbBreakout/DrbBreakout";

const License: React.FC = () => {
const Copyright: React.FC = () => {
const breakoutElement = (
<DrbBreakout breadcrumbsData={[{ url: "/license", text: "License" }]} />
<DrbBreakout breadcrumbsData={[{ url: "/copyright", text: "Copyright" }]} />
);
const contentPrimaryElement = (
<>
<Heading level="h1">License Explanations</Heading>
<Heading level="h1">Copyright Explanations</Heading>
<Heading level="h2">Public Domain</Heading>
<p>
Works in the public domain have no copyright (in most cases because the
Expand Down Expand Up @@ -159,6 +159,13 @@ const License: React.FC = () => {
, you may copy, distribute and modify the work as long as any
modifications are also made available under the GPL.
</p>
<Heading level="h2">In Copyright</Heading>
<p>
Works that are In Copyright are protected by copyright and/or related
rights. You are free to use this Item in any way that is permitted by
the copyright and related rights legislation that applies to your use.
For other uses you need to obtain permission from the rights-holder(s).
</p>
</>
);
return (
Expand All @@ -169,4 +176,4 @@ const License: React.FC = () => {
);
};

export default License;
export default Copyright;
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`renders License page unchanged 1`] = `
exports[`renders Copyright page unchanged 1`] = `
<div
class="css-1u8qly9"
>
Expand Down Expand Up @@ -101,12 +101,12 @@ exports[`renders License page unchanged 1`] = `
<a
aria-current="page"
class="chakra-breadcrumb__link css-0"
href="/license"
href="/copyright"
>
<span
class="breadcrumb-label"
>
License
Copyright
</span>
</a>
</li>
Expand All @@ -124,7 +124,7 @@ exports[`renders License page unchanged 1`] = `
<h1
class="chakra-heading css-1xdhyk6"
>
License Explanations
Copyright Explanations
</h1>
<h2
class="chakra-heading css-1xdhyk6"
Expand Down Expand Up @@ -316,6 +316,14 @@ exports[`renders License page unchanged 1`] = `
</a>
, you may copy, distribute and modify the work as long as any modifications are also made available under the GPL.
</p>
<h2
class="chakra-heading css-1xdhyk6"
>
In Copyright
</h2>
<p>
Works that are In Copyright are protected by copyright and/or related rights. You are free to use this Item in any way that is permitted by the copyright and related rights legislation that applies to your use. For other uses you need to obtain permission from the rights-holder(s).
</p>
</div>
</main>
</div>
Expand Down
15 changes: 15 additions & 0 deletions src/components/EditionCard/CopyrightLink.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from "react";
import { Rights } from "~/src/types/DataModel";
import Link from "~/src/components/Link/Link";

const CopyrightLink: React.FC<{ rights: Rights[] }> = ({ rights }) => {
return (
<Link to="/copyright">
{rights && rights.length > 0
? `Copyright: ${rights[0].rightsStatement}`
: "Copyright: Unknown"}
</Link>
);
};

export default CopyrightLink;
4 changes: 2 additions & 2 deletions src/components/EditionCard/EditionCard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe("Edition Card with Valid Data", () => {
test("Shows license with links", () => {
expect(
screen.getByText("Copyright: test rights statement").closest("a").href
).toContain("/license");
).toContain("/copyright");
});
test("Shows cover", () => {
expect(
Expand Down Expand Up @@ -80,7 +80,7 @@ describe("Edition Year with Minimal Data", () => {
});
test("Shows Unknown license with links", () => {
expect(screen.getByText("Copyright: Unknown").closest("a").href).toContain(
"/license"
"/copyright"
);
});
test("Shows Placeholder cover", () => {
Expand Down
5 changes: 2 additions & 3 deletions src/components/EditionCard/EditionCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import FeaturedEditionBadge from "./FeaturedEditionBadge";
import PhysicalEditionBadge from "./PhysicalEditionBadge";
import ScanAndDeliverBlurb from "./ScanAndDeliverBlurb";
import UpBlurb from "./UpBlurb";
import CopyrightLink from "./CopyrightLink";

export const EditionCard: React.FC<{
edition: WorkEdition;
Expand Down Expand Up @@ -114,9 +115,7 @@ export const EditionCard: React.FC<{
publishers={edition.publishers}
/>
<LanguageDisplayText edition={edition} />
<Link to="/license">
{EditionCardUtils.getLicense(previewItem)}
</Link>
<CopyrightLink rights={previewItem?.rights} />
</Box>
{isPhysicalEdition && <ScanAndDeliverBlurb />}
{isUniversityPress && <UpBlurb publishers={edition.publishers} />}
Expand Down
2 changes: 1 addition & 1 deletion src/components/EditionDetail/Edition.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ describe("Renders edition component when given valid edition", () => {
screen
.getAllByText("Copyright: Public Domain when viewed in the US")[0]
.closest("a").href
).toContain("/license");
).toContain("/copyright");
});

test("Featured Card, which has publisher 'Miller', shows up once", () => {
Expand Down
4 changes: 2 additions & 2 deletions src/components/InstanceCard/InstanceCard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe("Instance Card with Valid Data", () => {
test("shows license", () => {
expect(
screen.getByText("Copyright: test rights statement").closest("a").href
).toContain("/license");
).toContain("/copyright");
});
});

Expand Down Expand Up @@ -75,7 +75,7 @@ describe("Instance Card with Minmal Data", () => {
});
test("shows license", () => {
expect(screen.getByText("Copyright: Unknown").closest("a").href).toContain(
"/license"
"/copyright"
);
});
});
Expand Down
4 changes: 2 additions & 2 deletions src/components/InstanceCard/InstanceCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
Flex,
} from "@nypl/design-system-react-components";
import EditionCardUtils from "~/src/util/EditionCardUtils";
import Link from "../Link/Link";
import Ctas from "../EditionCard/Ctas";
import PublisherAndLocation from "../EditionCard/PublisherAndLocation";
import WorldCat from "./WorldCat";
Expand All @@ -19,6 +18,7 @@ import FeaturedEditionBadge from "../EditionCard/FeaturedEditionBadge";
import PhysicalEditionBadge from "../EditionCard/PhysicalEditionBadge";
import ScanAndDeliverBlurb from "../EditionCard/ScanAndDeliverBlurb";
import UpBlurb from "../EditionCard/UpBlurb";
import CopyrightLink from "../EditionCard/CopyrightLink";

// Creates an Instance card out of the Edition Year and Instance object
// Note: Edition Year only needs to be passed because `instance.publication_date`
Expand Down Expand Up @@ -94,7 +94,7 @@ export const InstanceCard: React.FC<{
/>
</div>
<WorldCat instance={instance} />
<Link to="/license">{EditionCardUtils.getLicense(previewItem)}</Link>
<CopyrightLink rights={previewItem?.rights} />
{isPhysicalEdition && <ScanAndDeliverBlurb />}
{isUniversityPress && <UpBlurb publishers={edition.publishers} />}
</CardContent>
Expand Down
8 changes: 0 additions & 8 deletions src/components/License/License.test.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion src/components/Work/Work.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ describe("Renders Work component when given valid work", () => {
expect(screen.getAllByText("Languages: English, German").length).toBe(1);
expect(
screen.getAllByText("Copyright: Unknown")[0].closest("a").href
).toContain("/license");
).toContain("/copyright");
});
test("Shows Details Table", () => {
expect(
Expand Down
Loading

0 comments on commit 0630135

Please sign in to comment.