@thepalaceproject/circulation-admin 1.19.0-post.2 → 1.19.0-post.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/circulation-admin.js +1 -1
- package/jest.config.js +4 -0
- package/jest.polyfills.js +20 -0
- package/package.json +7 -4
- package/tests/jest/components/CustomLists.test.tsx +11 -12
- package/tests/jest/components/InventoryReportRequestModal.test.tsx +22 -18
- package/tests/jest/components/QuicksightDashboard.test.tsx +12 -12
package/jest.config.js
CHANGED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// jest.polyfills.js
|
|
2
|
+
|
|
3
|
+
const globalThis = window;
|
|
4
|
+
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
6
|
+
const { ReadableStream, TextDecoder, TextEncoder } = require("node:util");
|
|
7
|
+
Object.defineProperties(globalThis, {
|
|
8
|
+
ReadableStream: { value: ReadableStream },
|
|
9
|
+
TextDecoder: { value: TextDecoder },
|
|
10
|
+
TextEncoder: { value: TextEncoder },
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
14
|
+
const { fetch, Request, Response, Headers } = require("fetch-ponyfill")();
|
|
15
|
+
Object.defineProperties(globalThis, {
|
|
16
|
+
fetch: { value: fetch, writable: true },
|
|
17
|
+
Headers: { value: Headers },
|
|
18
|
+
Request: { value: Request },
|
|
19
|
+
Response: { value: Response, writable: true },
|
|
20
|
+
});
|
package/package.json
CHANGED
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@nypl/dgx-svg-icons": "0.3.4",
|
|
39
|
+
"@reduxjs/toolkit": "^2.2.5",
|
|
39
40
|
"@tanstack/react-query": "^4.36.1",
|
|
40
41
|
"@thepalaceproject/web-opds-client": "^1.0.1",
|
|
41
42
|
"bootstrap": "^3.3.6",
|
|
@@ -57,7 +58,7 @@
|
|
|
57
58
|
"react-dnd": "^14.0.5",
|
|
58
59
|
"react-dnd-html5-backend": "^14.0.5",
|
|
59
60
|
"react-dom": "^16.8.6",
|
|
60
|
-
"react-redux": "^7.
|
|
61
|
+
"react-redux": "^7.2.9",
|
|
61
62
|
"react-router": "^3.2.0",
|
|
62
63
|
"recharts": "^1.8.6",
|
|
63
64
|
"redux": "^4.0.1",
|
|
@@ -80,7 +81,8 @@
|
|
|
80
81
|
"@types/prop-types": "^15.7.3",
|
|
81
82
|
"@types/react": "^16.14.6",
|
|
82
83
|
"@types/react-dom": "^16.9.8",
|
|
83
|
-
"@types/react-redux": "^7.1.
|
|
84
|
+
"@types/react-redux": "^7.1.33",
|
|
85
|
+
"@types/react-router": "^3.0.28",
|
|
84
86
|
"@types/recharts": "^1.8.28",
|
|
85
87
|
"@types/redux-mock-store": "^1.0.3",
|
|
86
88
|
"@typescript-eslint/eslint-plugin": "^5.46.0",
|
|
@@ -100,6 +102,7 @@
|
|
|
100
102
|
"eslint-plugin-react-hooks": "^4.0.0",
|
|
101
103
|
"fetch-mock": "^7.3.1",
|
|
102
104
|
"fetch-mock-jest": "^1.5.1",
|
|
105
|
+
"fetch-ponyfill": "^7.1.0",
|
|
103
106
|
"file-loader": "^6.2.0",
|
|
104
107
|
"follow-redirects": "^1.15.6",
|
|
105
108
|
"husky": "^4.3.0",
|
|
@@ -110,7 +113,7 @@
|
|
|
110
113
|
"lint-staged": "^10.4.0",
|
|
111
114
|
"mini-css-extract-plugin": "1.6.0",
|
|
112
115
|
"mocha": "^10.2.0",
|
|
113
|
-
"msw": "^
|
|
116
|
+
"msw": "^2.3.0",
|
|
114
117
|
"nightwatch": "^3.2.0",
|
|
115
118
|
"prettier": "2.1.2",
|
|
116
119
|
"react-axe": "^3.3.0",
|
|
@@ -146,5 +149,5 @@
|
|
|
146
149
|
"*.{js,jsx,ts,tsx,css,md}": "prettier --write",
|
|
147
150
|
"*.{js,css,md}": "prettier --write"
|
|
148
151
|
},
|
|
149
|
-
"version": "1.19.0-post.
|
|
152
|
+
"version": "1.19.0-post.4"
|
|
150
153
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { screen, waitFor } from "@testing-library/react";
|
|
3
3
|
import userEvent from "@testing-library/user-event";
|
|
4
|
-
|
|
5
|
-
import { rest } from "msw";
|
|
6
4
|
import { setupServer } from "msw/node";
|
|
5
|
+
import { http, HttpResponse } from "msw";
|
|
7
6
|
import CustomLists from "../../../src/components/CustomLists";
|
|
8
7
|
import renderWithContext from "../testUtils/renderWithContext";
|
|
9
8
|
import buildStore from "../../../src/store";
|
|
@@ -15,8 +14,8 @@ describe("CustomLists", () => {
|
|
|
15
14
|
Element.prototype.scrollTo = () => {};
|
|
16
15
|
|
|
17
16
|
const server = setupServer(
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
http.get("*/search", () => HttpResponse.xml("<feed />")),
|
|
18
|
+
http.get("*", () => HttpResponse.json({}))
|
|
20
19
|
);
|
|
21
20
|
|
|
22
21
|
beforeAll(() => {
|
|
@@ -111,10 +110,10 @@ describe("CustomLists", () => {
|
|
|
111
110
|
let searchParams = null;
|
|
112
111
|
|
|
113
112
|
server.use(
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
113
|
+
http.get("*/search", ({ request }) => {
|
|
114
|
+
const url = new URL(request.url);
|
|
115
|
+
searchParams = url.searchParams;
|
|
116
|
+
return HttpResponse.xml("<feed />");
|
|
118
117
|
})
|
|
119
118
|
);
|
|
120
119
|
|
|
@@ -154,10 +153,10 @@ describe("CustomLists", () => {
|
|
|
154
153
|
let searchParams = null;
|
|
155
154
|
|
|
156
155
|
server.use(
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
156
|
+
http.get("*/search", ({ request }) => {
|
|
157
|
+
const url = new URL(request.url);
|
|
158
|
+
searchParams = url.searchParams;
|
|
159
|
+
return HttpResponse.xml("<feed />");
|
|
161
160
|
})
|
|
162
161
|
);
|
|
163
162
|
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "../testUtils/withProviders";
|
|
8
8
|
import { QueryClient } from "@tanstack/react-query";
|
|
9
9
|
import { setupServer } from "msw/node";
|
|
10
|
-
import {
|
|
10
|
+
import { http, HttpResponse } from "msw";
|
|
11
11
|
import {
|
|
12
12
|
ACK_RESPONSE_BUTTON_CONTENT,
|
|
13
13
|
ACK_RESPONSE_HEADING,
|
|
@@ -45,12 +45,12 @@ const API_ENDPOINT_PARAMS: AdminAPI.InventoryReportRequestParams = {
|
|
|
45
45
|
|
|
46
46
|
const setupMockServer = () => {
|
|
47
47
|
return setupServer(
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
48
|
+
http.get(MOCK_SERVER_API_ENDPOINT_PATH, () =>
|
|
49
|
+
HttpResponse.json(INFO_SUCCESS_SOME_COLLECTIONS, { status: 200 })
|
|
50
|
+
),
|
|
51
|
+
http.post(MOCK_SERVER_API_ENDPOINT_PATH, () =>
|
|
52
|
+
HttpResponse.json(GENERATE_REPORT_SUCCESS, { status: 202 })
|
|
53
|
+
)
|
|
54
54
|
);
|
|
55
55
|
};
|
|
56
56
|
|
|
@@ -252,8 +252,9 @@ describe("InventoryReportRequestModal", () => {
|
|
|
252
252
|
});
|
|
253
253
|
it("returns an error value for unsuccessful report info (get) requests", async () => {
|
|
254
254
|
server.use(
|
|
255
|
-
|
|
256
|
-
|
|
255
|
+
http.get(
|
|
256
|
+
MOCK_SERVER_API_ENDPOINT_PATH,
|
|
257
|
+
() => new HttpResponse(null, { status: 404 })
|
|
257
258
|
)
|
|
258
259
|
);
|
|
259
260
|
let error = undefined;
|
|
@@ -271,8 +272,9 @@ describe("InventoryReportRequestModal", () => {
|
|
|
271
272
|
});
|
|
272
273
|
it("returns an error value for unsuccessful generate report (post) requests", async () => {
|
|
273
274
|
server.use(
|
|
274
|
-
|
|
275
|
-
|
|
275
|
+
http.post(
|
|
276
|
+
MOCK_SERVER_API_ENDPOINT_PATH,
|
|
277
|
+
() => new HttpResponse(null, { status: 404 })
|
|
276
278
|
)
|
|
277
279
|
);
|
|
278
280
|
let error = undefined;
|
|
@@ -452,9 +454,9 @@ describe("InventoryReportRequestModal", () => {
|
|
|
452
454
|
|
|
453
455
|
it("disables report generation, if info indicates no collections", async () => {
|
|
454
456
|
server.use(
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
457
|
+
http.get(MOCK_SERVER_API_ENDPOINT_PATH, () =>
|
|
458
|
+
HttpResponse.json(INFO_SUCCESS_NO_COLLECTIONS, { status: 200 })
|
|
459
|
+
)
|
|
458
460
|
);
|
|
459
461
|
|
|
460
462
|
const {
|
|
@@ -499,8 +501,9 @@ describe("InventoryReportRequestModal", () => {
|
|
|
499
501
|
|
|
500
502
|
it("displays minimal confirmation message, if report info request unsuccessful", async () => {
|
|
501
503
|
server.use(
|
|
502
|
-
|
|
503
|
-
|
|
504
|
+
http.get(
|
|
505
|
+
MOCK_SERVER_API_ENDPOINT_PATH,
|
|
506
|
+
() => new HttpResponse(null, { status: 404 })
|
|
504
507
|
)
|
|
505
508
|
);
|
|
506
509
|
|
|
@@ -607,8 +610,9 @@ describe("InventoryReportRequestModal", () => {
|
|
|
607
610
|
|
|
608
611
|
it("displays error message, when request is unsuccessful", async () => {
|
|
609
612
|
server.use(
|
|
610
|
-
|
|
611
|
-
|
|
613
|
+
http.post(
|
|
614
|
+
MOCK_SERVER_API_ENDPOINT_PATH,
|
|
615
|
+
() => new HttpResponse(null, { status: 404 })
|
|
612
616
|
)
|
|
613
617
|
);
|
|
614
618
|
const user = userEvent.setup();
|
|
@@ -2,10 +2,10 @@ import * as React from "react";
|
|
|
2
2
|
import { screen, waitFor } from "@testing-library/react";
|
|
3
3
|
|
|
4
4
|
import QuicksightDashboard from "../../../src/components/QuicksightDashboard";
|
|
5
|
-
import { LibrariesData
|
|
6
|
-
import buildStore
|
|
5
|
+
import { LibrariesData } from "../../../src/interfaces";
|
|
6
|
+
import buildStore from "../../../src/store";
|
|
7
7
|
import { setupServer } from "msw/node";
|
|
8
|
-
import {
|
|
8
|
+
import { http, HttpResponse } from "msw";
|
|
9
9
|
import renderWithContext from "../testUtils/renderWithContext";
|
|
10
10
|
|
|
11
11
|
const libraries: LibrariesData = { libraries: [{ uuid: "my-uuid" }] };
|
|
@@ -15,15 +15,15 @@ const dashboardUrlData = { embedUrl: embedUrl };
|
|
|
15
15
|
|
|
16
16
|
describe("QuicksightDashboard", () => {
|
|
17
17
|
const server = setupServer(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
)
|
|
18
|
+
http.get("/admin/libraries", () => HttpResponse.json(libraries)),
|
|
19
|
+
http.get(`/admin/quicksight_embed/${dashboardId}`, ({ request }) => {
|
|
20
|
+
const url = new URL(request.url);
|
|
21
|
+
const libraryUuids = url.searchParams.get("libraryUuids");
|
|
22
|
+
|
|
23
|
+
if (libraryUuids === libraries["libraries"][0]["uuid"]) {
|
|
24
|
+
return HttpResponse.json(dashboardUrlData);
|
|
25
|
+
}
|
|
26
|
+
})
|
|
27
27
|
);
|
|
28
28
|
|
|
29
29
|
beforeAll(() => {
|