@thepalaceproject/circulation-admin 1.19.0-post.2 → 1.19.0-post.3
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/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
|
@@ -100,6 +100,7 @@
|
|
|
100
100
|
"eslint-plugin-react-hooks": "^4.0.0",
|
|
101
101
|
"fetch-mock": "^7.3.1",
|
|
102
102
|
"fetch-mock-jest": "^1.5.1",
|
|
103
|
+
"fetch-ponyfill": "^7.1.0",
|
|
103
104
|
"file-loader": "^6.2.0",
|
|
104
105
|
"follow-redirects": "^1.15.6",
|
|
105
106
|
"husky": "^4.3.0",
|
|
@@ -110,7 +111,7 @@
|
|
|
110
111
|
"lint-staged": "^10.4.0",
|
|
111
112
|
"mini-css-extract-plugin": "1.6.0",
|
|
112
113
|
"mocha": "^10.2.0",
|
|
113
|
-
"msw": "^
|
|
114
|
+
"msw": "^2.3.0",
|
|
114
115
|
"nightwatch": "^3.2.0",
|
|
115
116
|
"prettier": "2.1.2",
|
|
116
117
|
"react-axe": "^3.3.0",
|
|
@@ -146,5 +147,5 @@
|
|
|
146
147
|
"*.{js,jsx,ts,tsx,css,md}": "prettier --write",
|
|
147
148
|
"*.{js,css,md}": "prettier --write"
|
|
148
149
|
},
|
|
149
|
-
"version": "1.19.0-post.
|
|
150
|
+
"version": "1.19.0-post.3"
|
|
150
151
|
}
|
|
@@ -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(() => {
|