@thepalaceproject/circulation-admin 1.46.0-post.1 → 1.46.0-post.2
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/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { render, screen, waitFor } from "@testing-library/react";
|
|
2
|
+
import { render, screen, waitFor, within } from "@testing-library/react";
|
|
3
3
|
import userEvent from "@testing-library/user-event";
|
|
4
4
|
import * as fetchMock from "fetch-mock-jest";
|
|
5
5
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
@@ -217,8 +217,11 @@ describe("PatronAuthServiceEditForm – serialization", () => {
|
|
|
217
217
|
|
|
218
218
|
await user.click(saveButton);
|
|
219
219
|
|
|
220
|
-
//
|
|
220
|
+
// Saving collapses the library. Reopening it shows the rule was stored in
|
|
221
|
+
// library state, not just read from the editor.
|
|
221
222
|
expect(screen.queryByRole("button", { name: /Add Rule/i })).toBeNull();
|
|
223
|
+
await user.click(screen.getByRole("button", { name: /Edit/i }));
|
|
224
|
+
expect(screen.getByLabelText(/Rule Name/i)).toHaveValue("Test Rule");
|
|
222
225
|
});
|
|
223
226
|
|
|
224
227
|
it("includes patron_blocking_rules in payload when adding a new library", async () => {
|
|
@@ -253,8 +256,11 @@ describe("PatronAuthServiceEditForm – serialization", () => {
|
|
|
253
256
|
|
|
254
257
|
await user.click(addButton);
|
|
255
258
|
|
|
256
|
-
//
|
|
259
|
+
// The new-library editor is gone. Opening the added library shows the rule
|
|
260
|
+
// was stored in library state.
|
|
257
261
|
expect(screen.queryByLabelText(/Rule Name/i)).toBeNull();
|
|
262
|
+
await user.click(screen.getByRole("button", { name: /Edit/i }));
|
|
263
|
+
expect(screen.getByLabelText(/Rule Name/i)).toHaveValue("New Rule");
|
|
258
264
|
});
|
|
259
265
|
});
|
|
260
266
|
|
|
@@ -268,8 +274,10 @@ describe("PatronAuthServiceEditForm – per-library settings", () => {
|
|
|
268
274
|
...servicesData,
|
|
269
275
|
protocols: [protocolWithLibrarySettings, OTHER_PROTOCOL_DATA],
|
|
270
276
|
};
|
|
271
|
-
const settingInput = (root:
|
|
272
|
-
root.
|
|
277
|
+
const settingInput = (root: HTMLElement) =>
|
|
278
|
+
within(root).getByRole("textbox", {
|
|
279
|
+
name: /Library setting/i,
|
|
280
|
+
}) as HTMLInputElement;
|
|
273
281
|
|
|
274
282
|
it("keeps a library setting entered when adding a new library", async () => {
|
|
275
283
|
const user = userEvent.setup();
|
|
@@ -4,6 +4,7 @@ import { render, within } from "@testing-library/react";
|
|
|
4
4
|
import userEvent from "@testing-library/user-event";
|
|
5
5
|
|
|
6
6
|
import ServiceEditForm, {
|
|
7
|
+
libraryRefKey,
|
|
7
8
|
ServiceEditFormProps,
|
|
8
9
|
ServiceEditFormState,
|
|
9
10
|
} from "../../../src/components/ServiceEditForm";
|
|
@@ -999,6 +1000,15 @@ describe("ServiceEditForm", () => {
|
|
|
999
1000
|
).toBe("option3");
|
|
1000
1001
|
});
|
|
1001
1002
|
|
|
1003
|
+
it("builds library ref keys for add and edit mode", () => {
|
|
1004
|
+
expect(libraryRefKey("key", "add")).toBe("key");
|
|
1005
|
+
expect(libraryRefKey("key", "edit", "nypl")).toBe("nypl_key");
|
|
1006
|
+
// Compile-time guard: ts-jest fails this file if the overloads stop
|
|
1007
|
+
// rejecting an edit-mode call with no short name.
|
|
1008
|
+
// @ts-expect-error edit mode must pass the library short name
|
|
1009
|
+
libraryRefKey("key", "edit");
|
|
1010
|
+
});
|
|
1011
|
+
|
|
1002
1012
|
it("calls save when the form is submitted", async () => {
|
|
1003
1013
|
// The reusable Form wires submission solely through its submit button's
|
|
1004
1014
|
// onClick, so clicking it is the only way to submit; assert the resulting
|