Skip to content

Commit

Permalink
Merge branch 'main' into DR-3271/api-test-coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
7emansell committed Nov 21, 2024
2 parents 54dfc8e + 610e1f4 commit e9c275a
Show file tree
Hide file tree
Showing 18 changed files with 320 additions and 399 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy_production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ jobs:
- name: Update ECS service
run: |
aws ecs update-service --cluster new-digitalcollections --service new-digitalcollections --force-new-deployment
aws ecs update-service --cluster new-digitalcollections-prod --service new-digitalcollections-prod --force-new-deployment
44 changes: 44 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,50 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

## [0.2.3] 2024-11-21

### Updated

- Update timeout on API request to 14 seconds

## [0.2.2] 2024-11-20

### Updated

- Update production DC_URL in appConfig.ts file

## [0.2.1] 2024-11-20

### Updated

- Update collection links to be relative

## [0.2.0] 2024-11-20

### Removed

- Remove banner that links to OG Digital Collections (DR-3263)

### Updated

- Update links on /divisions page to point to /divisions/:slug pages (DR-3142)
- Updating pagination text on division landing page
- Updating Next Image quality

## [0.1.19] 2024-11-18

### Updated

- Moved `/divisions` and `/divisions/[slug]` from behind middleware, now accessible (DR-3132, DR-3133)
- Updated collection card urls to use uuid
- Updated item card urls to use uuid
- Updated collection card urls to use legacy url
- Updated prod ECS cluster name to `new-digitalcollections-prod`

## [0.1.18] 2024-11-18

- merged into 0.1.19

## [0.1.17] 2024-11-14

### Updated
Expand Down
1 change: 1 addition & 0 deletions app/src/components/card/cardImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export const CardImage = ({ record, imageHeight }: CardImageProps) => {
minHeight: "100%",
height: "auto",
}}
quality={100}
placeholder="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mN8WQ8AAlcBas53/MIAAAAASUVORK5CYII="
width={initialImageHeight * 2}
height={initialImageHeight}
Expand Down
2 changes: 0 additions & 2 deletions app/src/components/pageLayout/pageLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
import React, { useEffect } from "react";
import { type PropsWithChildren } from "react";
import Header from "../header/header";
import NotificationBanner from "../notificationBanner/notificationBanner";
import Script from "next/script";
import { BreadcrumbsDataProps } from "@nypl/design-system-react-components/dist/src/components/Breadcrumbs/Breadcrumbs";
import { ADOBE_EMBED_URL } from "../../config/constants";
Expand Down Expand Up @@ -52,7 +51,6 @@ const PageLayout = ({
<DSProvider>
<FeedbackProvider>
<SkipNavigation />
<NotificationBanner />
<Header />
{activePage === "home" ||
activePage === "about" ||
Expand Down
5 changes: 3 additions & 2 deletions app/src/components/pages/divisionPage/divisionPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,14 @@ export default function DivisionPage({ data }: any) {

<Heading
size="heading5"
sx={{ marginBottom: "m" }}
sx={{ marginBottom: "l" }}
ref={headingRef}
tabIndex={-1}
id={slug}
width="max-content"
>
{displayResults(data.numFound, data.perPage, data.page)}
{`Displaying ${displayResults(data.numFound, data.perPage, data.page)}
results`}
</Heading>

<Heading level="h2" size="heading3" style={{ width: "fit-content" }}>
Expand Down
2 changes: 1 addition & 1 deletion app/src/components/pages/divisionsPage/divisionsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default function DivisionsPage({ summary, divisions }: DivisionsProps) {
<DCLane
key={key}
records={division.collections}
seeMoreLink={`${DC_URL}/divisions`}
seeMoreLink={`/divisions`}
laneName={division.name}
laneSlug={division.slug}
/>
Expand Down
2 changes: 1 addition & 1 deletion app/src/data/dcNavLinks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const dcNavLinks = [
text: "Collections",
},
{
href: `${DC_URL}/divisions`,
href: `/divisions`,
text: "Divisions",
},
{
Expand Down
6 changes: 1 addition & 5 deletions app/src/models/collectionCard.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// import { CollectionCardData } from "app/types/Collection";
import { imageURL } from "../utils/utils";
import { stringToSlug } from "../utils/utils";
import { parseBoolean } from "../utils/utils";

// TODO: Connect to typescript interface for CollectionCardData
Expand All @@ -16,10 +15,7 @@ export class CollectionCardModel {
constructor(data: any) {
this.uuid = data.uuid;
this.title = data.title;
this.url =
process.env.APP_ENV === "development" || process.env.APP_ENV === "qa"
? `/collections/${stringToSlug(data.title)}`
: data.url;
this.url = `/collections/${data.uuid}`;
this.imageID = data.image_id || data.imageID;
this.imageURL = imageURL(data.imageID, "full", "288,", "0");
this.numberOfDigitizedItems =
Expand Down
5 changes: 1 addition & 4 deletions app/src/models/itemCard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ export class ItemCardModel {
constructor(data: any) {
this.uuid = data.uuid;
this.title = data.title;
this.url =
process.env.APP_ENV === "development" || process.env.APP_ENV === "qa"
? `/items/${data.uuid}`
: data.href || data.url;
this.url = `/items/${data.uuid}`;
this.imageID = data.imageID;
this.imageURL = imageURL(data.imageID, "full", "288,", "0");
}
Expand Down
4 changes: 2 additions & 2 deletions app/src/utils/api.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,12 @@ describe("apiResponse", () => {

const apiCall = apiResponse(mockApiUrl);

jest.advanceTimersByTime(7000);
jest.advanceTimersByTime(14000);

await expect(apiCall).rejects.toEqual(
new Error("apiResponse: Request timed out")
);

jest.useRealTimers();
}, 10000);
}, 20000);
});
2 changes: 1 addition & 1 deletion app/src/utils/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export const apiResponse = async (
apiUrl += queryString;
}

const timeout = 7000;
const timeout = 14000;

const fetchWithTimeout = (url: string, opts: RequestInit) => {
return Promise.race([
Expand Down
12 changes: 6 additions & 6 deletions app/src/utils/utils.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,26 +180,26 @@ describe("createAdobeAnalyticsPageName generates the correct Adobe Analytics pag

describe("displayResults", () => {
test("displays correct result range for first page with enough results", () => {
expect(displayResults(100, 10, 1)).toBe("Results: 1-10 of 100");
expect(displayResults(100, 10, 1)).toBe("1-10 of 100");
});

test("displays correct result range for middle page", () => {
expect(displayResults(100, 10, 5)).toBe("Results: 41-50 of 100");
expect(displayResults(100, 10, 5)).toBe("41-50 of 100");
});

test("displays correct result range for last page when there are fewer results than perPage", () => {
expect(displayResults(45, 10, 5)).toBe("Results: 41-45 of 45");
expect(displayResults(45, 10, 5)).toBe("41-45 of 45");
});

test("displays correct result range when numFound is less than perPage", () => {
expect(displayResults(8, 10, 1)).toBe("Results: 1-8 of 8");
expect(displayResults(8, 10, 1)).toBe("1-8 of 8");
});

test("displays correct result range for the last page when it's the same as perPage", () => {
expect(displayResults(50, 10, 5)).toBe("Results: 41-50 of 50");
expect(displayResults(50, 10, 5)).toBe("41-50 of 50");
});

test("displays correct range when perPage is greater than numFound", () => {
expect(displayResults(5, 10, 1)).toBe("Results: 1-5 of 5");
expect(displayResults(5, 10, 1)).toBe("1-5 of 5");
});
});
2 changes: 1 addition & 1 deletion app/src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,5 @@ export function displayResults(
) {
const start = (page - 1) * perPage + 1;
const end = Math.min(page * perPage, numFound);
return `Results: ${start}-${end} of ${numFound}`;
return `${start}-${end} of ${numFound}`;
}
2 changes: 1 addition & 1 deletion appConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const appConfig = {
DC_URL: {
development: "",
qa: "",
production: "https://digitalcollections.nypl.org",
production: "",
},
IIIF_URL: {
development: "https://iiif.nypl.org",
Expand Down
2 changes: 0 additions & 2 deletions middleware.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ export const config = {
matcher: [
"/collections",
"/collections/:path*",
"/divisions",
"/divisions/:path*",
"/items/:path*",
"/search/:path*",
],
Expand Down
Loading

0 comments on commit e9c275a

Please sign in to comment.