Skip to content

Commit

Permalink
Merge branch 'main' into qa
Browse files Browse the repository at this point in the history
  • Loading branch information
avertrees committed Oct 25, 2023
2 parents 375fb2a + 3aadbfd commit 186643e
Show file tree
Hide file tree
Showing 19 changed files with 450 additions and 159 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Update version of NYPL Reservoir to 2.0.1

### Added

- Added spider block script (DR-2518)
- Created Dockerfile and docker-compose.yml files. (DR-2446)
- Created Next.js 13 app using NYPL Reservoir and TS 4.9.5. (DR-2444)
- Set up travis script to build and deploy to QA (DR-2448)
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ The following endpoints are currently available at http://localhost:3000/api/lan
- [/photographs](http://localhost:3000/api/lanes/photographs)
- [/prints-and-drawings](http://localhost:3000/api/lanes/prints-and-drawings)
- [/recently-digitized-collections](http://localhost:3000/api/lanes/recently-digitized-collections)
- [/items](http://localhost:3000/api/lanes/items)

### Individual Lane - GET /api/lanes/[...slug]

Expand All @@ -79,7 +80,13 @@ Returns respective JSON for that lane.

---

Returns JSON containing all lanes' metadata.
Returns JSON containing all lanes.

### Featured Items - GET /api/featuredItems

---

Returns JSON containing all featured items' image data.

#### Note for future

Expand Down
57 changes: 0 additions & 57 deletions __tests__/[slug].test.tsx

This file was deleted.

43 changes: 43 additions & 0 deletions __tests__/api/lanes/[slug].test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import slugHandler from "@/pages/api/lanes/[slug]";
import { NextApiRequest } from "next";

it("should respond with 200 status and lanes data for a GET request", () => {
const request: NextApiRequest = {
method: "GET",
query: {
slug: "maps",
},
} as unknown as NextApiRequest;

const mockResponse: any = {
status: jest.fn(function () {
return this;
}),
json: jest.fn(),
};

slugHandler(request, mockResponse);

expect(mockResponse.status).toHaveBeenCalledWith(200);
});

it("should respond with an error for nonexistent slugs", () => {
const request: NextApiRequest = {
method: "GET",
query: {
slug: "not-a-slug",
},
} as unknown as NextApiRequest;

const mockResponse: any = {
status: jest.fn(function () {
return this;
}),
json: jest.fn(),
};

slugHandler(request, mockResponse);

expect(mockResponse.status).toHaveBeenCalledWith(404);
expect(mockResponse.json).toHaveBeenCalledWith({ error: "Lane not found" });
});
File renamed without changes.
39 changes: 39 additions & 0 deletions __tests__/featureditems.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { getItemsData } from "@/pages/api/featuredItems";
import itemsDataHandler from "@/pages/api/featuredItems";
import { NextApiRequest } from "next";

describe("Featured items API endpoint handler", () => {
it("should respond with 200 status and items data for a GET request", () => {
const request: NextApiRequest = {
method: "GET",
} as NextApiRequest;

const mockResponse: any = {
status: jest.fn(function () {
return this;
}),
json: jest.fn(),
};

itemsDataHandler(request, mockResponse);

expect(mockResponse.status).toHaveBeenCalledWith(200);
expect(mockResponse.json).toHaveBeenCalledWith(getItemsData());
});

it("should respond with an error for non-GET requests", () => {
const request: NextApiRequest = {
method: "POST",
} as NextApiRequest;

const mockResponse: any = {
status: jest.fn(function () {
return this;
}),
};

itemsDataHandler(request, mockResponse);

expect(mockResponse.status).not.toHaveBeenCalledWith(200);
});
});
File renamed without changes.
8 changes: 8 additions & 0 deletions public/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
User-agent: Bytedance
Disallow: /

User-agent: Bytespider
Disallow: /

User-agent: GPTBot
Disallow: /
95 changes: 95 additions & 0 deletions src/data/featureditems.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
{
"featuredItems": {
"images": [
"105180.jpg",
"105196.jpg",
"105224.jpg",
"105226.jpg",
"1108684.jpg",
"1161044.jpg",
"1161045.jpg",
"1221632.jpg",
"1260009.jpg",
"1269908.jpg",
"1536497.jpg",
"1536861.jpg",
"1549431.jpg",
"1557804.jpg",
"1558053.jpg",
"1657176.jpg",
"1693502.jpg",
"4000175.jpg",
"405476.jpg",
"417074.jpg",
"419720.jpg",
"433221.jpg",
"433223.jpg",
"434110.jpg",
"434408.jpg",
"464341.jpg",
"465012.jpg",
"482599.jpg",
"482603.jpg",
"482752.jpg",
"482815.jpg",
"483644.jpg",
"5013067.jpg",
"5082781.jpg",
"5086214.jpg",
"5104191.jpg",
"5131004.jpg",
"5150304.jpg",
"5164274.jpg",
"5164604.jpg",
"5164631.jpg",
"5179778.jpg",
"5179798.jpg",
"5180605.jpg",
"5273165.jpg",
"5339958.jpg",
"53926.jpg",
"54528.jpg",
"54795.jpg",
"700179F.jpg",
"79781.jpg",
"79849.jpg",
"836151.jpg",
"G91F075_038F.jpg",
"M_1260849.jpg",
"T000725.jpg",
"nypl_mss_901.jpg",
"ps_mss_831.jpg",
"ps_prn_cd31_456.jpg",
"ps_prn_cd32_461.jpg",
"psnypl_dan_1757.jpg",
"psnypl_mss_1228.jpg",
"psnypl_spn_610.jpg"
],
"noIndex": {
"images": [
"105069.jpg",
"1558052.jpg",
"1582228.jpg",
"435037.jpg",
"465016.jpg",
"482602.jpg",
"5002508.jpg",
"5013067.jpg",
"5086214.jpg",
"5164590.jpg",
"5164599.jpg",
"5164608.jpg",
"5316870.jpg",
"53901.jpg",
"87300.jpg",
"G91F380_080F.jpg",
"den_1409v.jpg",
"psnypl_the_4323.jpg",
"swope_246124.jpg",
"th-16090.jpg",
"trouvelot_003.jpg",
"trouvelot_010.jpg"
]
}
}
}
Loading

0 comments on commit 186643e

Please sign in to comment.