@thepalaceproject/circulation-admin 1.19.0 → 1.20.0
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/dist/circulation-admin.js.LICENSE.txt +30 -2
- package/jest.config.js +4 -0
- package/jest.polyfills.js +20 -0
- package/package.json +12 -4
- package/tests/jest/api/admin.test.ts +60 -0
- package/tests/jest/components/CustomLists.test.tsx +11 -12
- package/tests/jest/components/InventoryReportRequestModal.test.tsx +652 -0
- package/tests/jest/components/QuicksightDashboard.test.tsx +12 -12
- package/tests/jest/testUtils/withProviders.tsx +71 -0
|
@@ -43,12 +43,40 @@ object-assign
|
|
|
43
43
|
|
|
44
44
|
/*! http://mths.be/fromcodepoint v0.1.0 by @mathias */
|
|
45
45
|
|
|
46
|
-
/*! https://mths.be/punycode v1.
|
|
46
|
+
/*! https://mths.be/punycode v1.4.1 by @mathias */
|
|
47
47
|
|
|
48
48
|
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
49
49
|
|
|
50
50
|
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
51
51
|
|
|
52
|
+
/**
|
|
53
|
+
* match-sorter-utils
|
|
54
|
+
*
|
|
55
|
+
* Copyright (c) TanStack
|
|
56
|
+
*
|
|
57
|
+
* This source code is licensed under the MIT license found in the
|
|
58
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
59
|
+
*
|
|
60
|
+
* @license MIT
|
|
61
|
+
*/
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @license React
|
|
65
|
+
* use-sync-external-store-shim.production.min.js
|
|
66
|
+
*
|
|
67
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
68
|
+
*
|
|
69
|
+
* This source code is licensed under the MIT license found in the
|
|
70
|
+
* LICENSE file in the root directory of this source tree.
|
|
71
|
+
*/
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @name match-sorter
|
|
75
|
+
* @license MIT license.
|
|
76
|
+
* @copyright (c) 2099 Kent C. Dodds
|
|
77
|
+
* @author Kent C. Dodds <me@kentcdodds.com> (https://kentcdodds.com)
|
|
78
|
+
*/
|
|
79
|
+
|
|
52
80
|
/** @license React v0.19.1
|
|
53
81
|
* scheduler.production.min.js
|
|
54
82
|
*
|
|
@@ -122,4 +150,4 @@ object-assign
|
|
|
122
150
|
|
|
123
151
|
//! momentjs.com
|
|
124
152
|
|
|
125
|
-
//! version : 2.
|
|
153
|
+
//! version : 2.30.1
|
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,8 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@nypl/dgx-svg-icons": "0.3.4",
|
|
39
|
+
"@reduxjs/toolkit": "^2.2.5",
|
|
40
|
+
"@tanstack/react-query": "^4.36.1",
|
|
39
41
|
"@thepalaceproject/web-opds-client": "^1.0.1",
|
|
40
42
|
"bootstrap": "^3.3.6",
|
|
41
43
|
"classnames": "^2.3.1",
|
|
@@ -56,7 +58,7 @@
|
|
|
56
58
|
"react-dnd": "^14.0.5",
|
|
57
59
|
"react-dnd-html5-backend": "^14.0.5",
|
|
58
60
|
"react-dom": "^16.8.6",
|
|
59
|
-
"react-redux": "^7.
|
|
61
|
+
"react-redux": "^7.2.9",
|
|
60
62
|
"react-router": "^3.2.0",
|
|
61
63
|
"recharts": "^1.8.6",
|
|
62
64
|
"redux": "^4.0.1",
|
|
@@ -67,8 +69,10 @@
|
|
|
67
69
|
"url": "^0.11.0"
|
|
68
70
|
},
|
|
69
71
|
"devDependencies": {
|
|
72
|
+
"@tanstack/react-query-devtools": "^4.36.1",
|
|
70
73
|
"@testing-library/jest-dom": "^5.16.5",
|
|
71
74
|
"@testing-library/react": "^12.1.5",
|
|
75
|
+
"@testing-library/react-hooks": "^8.0.1",
|
|
72
76
|
"@testing-library/user-event": "^14.4.3",
|
|
73
77
|
"@types/jest": "^29.2.6",
|
|
74
78
|
"@types/mocha": "^10.0.1",
|
|
@@ -77,7 +81,8 @@
|
|
|
77
81
|
"@types/prop-types": "^15.7.3",
|
|
78
82
|
"@types/react": "^16.14.6",
|
|
79
83
|
"@types/react-dom": "^16.9.8",
|
|
80
|
-
"@types/react-redux": "^7.1.
|
|
84
|
+
"@types/react-redux": "^7.1.33",
|
|
85
|
+
"@types/react-router": "^3.0.28",
|
|
81
86
|
"@types/recharts": "^1.8.28",
|
|
82
87
|
"@types/redux-mock-store": "^1.0.3",
|
|
83
88
|
"@typescript-eslint/eslint-plugin": "^5.46.0",
|
|
@@ -96,6 +101,8 @@
|
|
|
96
101
|
"eslint-plugin-react": "^7.19.0",
|
|
97
102
|
"eslint-plugin-react-hooks": "^4.0.0",
|
|
98
103
|
"fetch-mock": "^7.3.1",
|
|
104
|
+
"fetch-mock-jest": "^1.5.1",
|
|
105
|
+
"fetch-ponyfill": "^7.1.0",
|
|
99
106
|
"file-loader": "^6.2.0",
|
|
100
107
|
"follow-redirects": "^1.15.6",
|
|
101
108
|
"husky": "^4.3.0",
|
|
@@ -106,10 +113,11 @@
|
|
|
106
113
|
"lint-staged": "^10.4.0",
|
|
107
114
|
"mini-css-extract-plugin": "1.6.0",
|
|
108
115
|
"mocha": "^10.2.0",
|
|
109
|
-
"msw": "^
|
|
116
|
+
"msw": "^2.3.0",
|
|
110
117
|
"nightwatch": "^3.2.0",
|
|
111
118
|
"prettier": "2.1.2",
|
|
112
119
|
"react-axe": "^3.3.0",
|
|
120
|
+
"react-test-renderer": "^16.14.0",
|
|
113
121
|
"redux-mock-store": "^1.5.4",
|
|
114
122
|
"sass": "^1.64.2",
|
|
115
123
|
"sass-lint": "^1.13.1",
|
|
@@ -141,5 +149,5 @@
|
|
|
141
149
|
"*.{js,jsx,ts,tsx,css,md}": "prettier --write",
|
|
142
150
|
"*.{js,css,md}": "prettier --write"
|
|
143
151
|
},
|
|
144
|
-
"version": "1.
|
|
152
|
+
"version": "1.20.0"
|
|
145
153
|
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_BASE_ENDPOINT_URL,
|
|
3
|
+
getInventoryReportInfo,
|
|
4
|
+
requestInventoryReport,
|
|
5
|
+
} from "../../../src/api/admin";
|
|
6
|
+
import * as fetchMock from "fetch-mock-jest";
|
|
7
|
+
|
|
8
|
+
const sampleInfoResponseData = { collections: [] };
|
|
9
|
+
const sampleGenerateResponseData = { message: "some message" };
|
|
10
|
+
|
|
11
|
+
const testAlternateBaseUrl = "/test/base/url";
|
|
12
|
+
const libraryKey = "short-name";
|
|
13
|
+
|
|
14
|
+
const testEndpoints = ({
|
|
15
|
+
title,
|
|
16
|
+
baseEndpointUrl: baseEndpointUrl = undefined,
|
|
17
|
+
expectedUrl = DEFAULT_BASE_ENDPOINT_URL,
|
|
18
|
+
}) => {
|
|
19
|
+
describe(title, () => {
|
|
20
|
+
beforeEach(() => {
|
|
21
|
+
fetchMock
|
|
22
|
+
.get("*", { body: sampleInfoResponseData, status: 200 })
|
|
23
|
+
.post("*", { body: sampleGenerateResponseData, status: 202 });
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
afterEach(() => {
|
|
27
|
+
fetchMock.mockReset();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("requests inventory report information", async () => {
|
|
31
|
+
const response = await getInventoryReportInfo({
|
|
32
|
+
library: libraryKey,
|
|
33
|
+
baseEndpointUrl,
|
|
34
|
+
});
|
|
35
|
+
expect(response).toStrictEqual(sampleInfoResponseData);
|
|
36
|
+
expect(fetchMock).toHaveBeenCalledWith(expectedUrl);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it("requests report generation via a post to the endpoint", async () => {
|
|
40
|
+
const response = await requestInventoryReport({
|
|
41
|
+
library: libraryKey,
|
|
42
|
+
baseEndpointUrl,
|
|
43
|
+
});
|
|
44
|
+
expect(response).toStrictEqual(sampleGenerateResponseData);
|
|
45
|
+
expect(fetchMock).toHaveBeenCalledWith(expectedUrl, { method: "POST" });
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
describe("Inventory report API", () => {
|
|
51
|
+
testEndpoints({
|
|
52
|
+
title: "default endpoints",
|
|
53
|
+
expectedUrl: `${DEFAULT_BASE_ENDPOINT_URL}/${libraryKey}`,
|
|
54
|
+
});
|
|
55
|
+
testEndpoints({
|
|
56
|
+
title: "alternative test endpoints",
|
|
57
|
+
baseEndpointUrl: testAlternateBaseUrl,
|
|
58
|
+
expectedUrl: `${testAlternateBaseUrl}/${libraryKey}`,
|
|
59
|
+
});
|
|
60
|
+
});
|
|
@@ -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
|
|