@thepalaceproject/circulation-admin 1.38.0-post.1 → 1.38.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/package.json
CHANGED
|
@@ -79,7 +79,56 @@ describe("CollectionImportButton", () => {
|
|
|
79
79
|
screen.getByRole("button", { name: "Queue Import" })
|
|
80
80
|
).toBeInTheDocument();
|
|
81
81
|
expect(screen.getByRole("checkbox")).toBeInTheDocument();
|
|
82
|
-
expect(screen.
|
|
82
|
+
expect(screen.getByLabelText("Force full re-import")).toBeInTheDocument();
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it("shows compact summary by default; detailed docs are hidden", async () => {
|
|
86
|
+
const user = userEvent.setup();
|
|
87
|
+
renderButton();
|
|
88
|
+
await expandPanel(user);
|
|
89
|
+
expect(
|
|
90
|
+
screen.getByText(/queue import picks up new and changed items/i)
|
|
91
|
+
).toBeInTheDocument();
|
|
92
|
+
expect(
|
|
93
|
+
screen.getByText(/schedules a background import job/i)
|
|
94
|
+
).not.toBeVisible();
|
|
95
|
+
expect(
|
|
96
|
+
screen.getByText(/the import job re-processes every item/i)
|
|
97
|
+
).not.toBeVisible();
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it("clicking 'More details' reveals the detailed docs", async () => {
|
|
101
|
+
const user = userEvent.setup();
|
|
102
|
+
renderButton();
|
|
103
|
+
await expandPanel(user);
|
|
104
|
+
|
|
105
|
+
const details = screen.getByText("More details").closest("details");
|
|
106
|
+
expect(details).not.toHaveAttribute("open");
|
|
107
|
+
|
|
108
|
+
await user.click(screen.getByText("More details"));
|
|
109
|
+
|
|
110
|
+
expect(details).toHaveAttribute("open");
|
|
111
|
+
expect(
|
|
112
|
+
screen.getByText(/schedules a background import job/i)
|
|
113
|
+
).toBeVisible();
|
|
114
|
+
expect(
|
|
115
|
+
screen.getByText(/the import job re-processes every item/i)
|
|
116
|
+
).toBeVisible();
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it("clicking 'More details' again hides the detailed docs", async () => {
|
|
120
|
+
const user = userEvent.setup();
|
|
121
|
+
renderButton();
|
|
122
|
+
await expandPanel(user);
|
|
123
|
+
|
|
124
|
+
await user.click(screen.getByText("More details"));
|
|
125
|
+
expect(
|
|
126
|
+
screen.getByText(/schedules a background import job/i)
|
|
127
|
+
).toBeVisible();
|
|
128
|
+
|
|
129
|
+
await user.click(screen.getByText("More details"));
|
|
130
|
+
const details = screen.getByText("More details").closest("details");
|
|
131
|
+
expect(details).not.toHaveAttribute("open");
|
|
83
132
|
});
|
|
84
133
|
|
|
85
134
|
it("checkbox toggles force state", async () => {
|
|
@@ -94,6 +143,41 @@ describe("CollectionImportButton", () => {
|
|
|
94
143
|
expect(checkbox).not.toBeChecked();
|
|
95
144
|
});
|
|
96
145
|
|
|
146
|
+
it("button text changes to 'Queue Full Re-import' when force is checked", async () => {
|
|
147
|
+
const user = userEvent.setup();
|
|
148
|
+
renderButton();
|
|
149
|
+
await expandPanel(user);
|
|
150
|
+
|
|
151
|
+
expect(
|
|
152
|
+
screen.getByRole("button", { name: "Queue Import" })
|
|
153
|
+
).toBeInTheDocument();
|
|
154
|
+
|
|
155
|
+
await user.click(screen.getByRole("checkbox"));
|
|
156
|
+
|
|
157
|
+
expect(
|
|
158
|
+
screen.getByRole("button", { name: "Queue Full Re-import" })
|
|
159
|
+
).toBeInTheDocument();
|
|
160
|
+
expect(
|
|
161
|
+
screen.queryByRole("button", { name: "Queue Import" })
|
|
162
|
+
).not.toBeInTheDocument();
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it("button uses force class when force is checked", async () => {
|
|
166
|
+
const user = userEvent.setup();
|
|
167
|
+
renderButton();
|
|
168
|
+
await expandPanel(user);
|
|
169
|
+
|
|
170
|
+
const button = screen.getByRole("button", { name: "Queue Import" });
|
|
171
|
+
expect(button).not.toHaveClass("force");
|
|
172
|
+
|
|
173
|
+
await user.click(screen.getByRole("checkbox"));
|
|
174
|
+
|
|
175
|
+
const forceButton = screen.getByRole("button", {
|
|
176
|
+
name: "Queue Full Re-import",
|
|
177
|
+
});
|
|
178
|
+
expect(forceButton).toHaveClass("force");
|
|
179
|
+
});
|
|
180
|
+
|
|
97
181
|
it("button triggers import with correct args (force=false)", async () => {
|
|
98
182
|
const user = userEvent.setup();
|
|
99
183
|
const { importCollection } = renderButton();
|
|
@@ -109,18 +193,39 @@ describe("CollectionImportButton", () => {
|
|
|
109
193
|
await expandPanel(user);
|
|
110
194
|
const checkbox = screen.getByRole("checkbox");
|
|
111
195
|
await user.click(checkbox);
|
|
112
|
-
const button = screen.getByRole("button", {
|
|
196
|
+
const button = screen.getByRole("button", {
|
|
197
|
+
name: "Queue Full Re-import",
|
|
198
|
+
});
|
|
113
199
|
await user.click(button);
|
|
114
200
|
expect(importCollection).toHaveBeenCalledWith(42, true);
|
|
115
201
|
});
|
|
116
202
|
|
|
117
|
-
it("shows success feedback
|
|
203
|
+
it("shows success feedback for regular import", async () => {
|
|
118
204
|
const user = userEvent.setup();
|
|
119
205
|
renderButton();
|
|
120
206
|
await expandPanel(user);
|
|
121
207
|
await user.click(screen.getByRole("button", { name: "Queue Import" }));
|
|
122
208
|
await waitFor(() => {
|
|
123
|
-
const feedback = screen.getByText(
|
|
209
|
+
const feedback = screen.getByText(
|
|
210
|
+
/import task queued\. new and updated items will appear/i
|
|
211
|
+
);
|
|
212
|
+
expect(feedback).toBeInTheDocument();
|
|
213
|
+
expect(feedback).toHaveClass("alert", "alert-success");
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
it("shows success feedback for force re-import", async () => {
|
|
218
|
+
const user = userEvent.setup();
|
|
219
|
+
renderButton();
|
|
220
|
+
await expandPanel(user);
|
|
221
|
+
await user.click(screen.getByRole("checkbox"));
|
|
222
|
+
await user.click(
|
|
223
|
+
screen.getByRole("button", { name: "Queue Full Re-import" })
|
|
224
|
+
);
|
|
225
|
+
await waitFor(() => {
|
|
226
|
+
const feedback = screen.getByText(
|
|
227
|
+
/full re-import task queued\. all items will be re-processed/i
|
|
228
|
+
);
|
|
124
229
|
expect(feedback).toBeInTheDocument();
|
|
125
230
|
expect(feedback).toHaveClass("alert", "alert-success");
|
|
126
231
|
});
|
|
@@ -150,9 +255,13 @@ describe("CollectionImportButton", () => {
|
|
|
150
255
|
await user.click(checkbox);
|
|
151
256
|
expect(checkbox).toBeChecked();
|
|
152
257
|
|
|
153
|
-
await user.click(
|
|
258
|
+
await user.click(
|
|
259
|
+
screen.getByRole("button", { name: "Queue Full Re-import" })
|
|
260
|
+
);
|
|
154
261
|
await waitFor(() => {
|
|
155
|
-
expect(
|
|
262
|
+
expect(
|
|
263
|
+
screen.getByText(/full re-import task queued/i)
|
|
264
|
+
).toBeInTheDocument();
|
|
156
265
|
});
|
|
157
266
|
|
|
158
267
|
const nextCollection: CollectionData = {
|
|
@@ -171,7 +280,9 @@ describe("CollectionImportButton", () => {
|
|
|
171
280
|
|
|
172
281
|
await waitFor(() => {
|
|
173
282
|
expect(screen.getByRole("checkbox")).not.toBeChecked();
|
|
174
|
-
expect(
|
|
283
|
+
expect(
|
|
284
|
+
screen.queryByText(/full re-import task queued/i)
|
|
285
|
+
).not.toBeInTheDocument();
|
|
175
286
|
});
|
|
176
287
|
});
|
|
177
288
|
|
|
@@ -204,4 +315,31 @@ describe("CollectionImportButton", () => {
|
|
|
204
315
|
).toBeEnabled();
|
|
205
316
|
});
|
|
206
317
|
});
|
|
318
|
+
|
|
319
|
+
it("shows 'Queuing Full Re-import...' while importing with force", async () => {
|
|
320
|
+
const user = userEvent.setup();
|
|
321
|
+
let resolveImport: () => void;
|
|
322
|
+
const pendingImport = new Promise<void>((resolve) => {
|
|
323
|
+
resolveImport = resolve;
|
|
324
|
+
});
|
|
325
|
+
const mockImport = jest.fn().mockReturnValue(pendingImport);
|
|
326
|
+
renderButton({ importCollection: mockImport });
|
|
327
|
+
await expandPanel(user);
|
|
328
|
+
|
|
329
|
+
await user.click(screen.getByRole("checkbox"));
|
|
330
|
+
await user.click(
|
|
331
|
+
screen.getByRole("button", { name: "Queue Full Re-import" })
|
|
332
|
+
);
|
|
333
|
+
|
|
334
|
+
expect(
|
|
335
|
+
screen.getByRole("button", { name: "Queuing Full Re-import..." })
|
|
336
|
+
).toBeDisabled();
|
|
337
|
+
|
|
338
|
+
resolveImport();
|
|
339
|
+
await waitFor(() => {
|
|
340
|
+
expect(
|
|
341
|
+
screen.getByRole("button", { name: "Queue Full Re-import" })
|
|
342
|
+
).toBeEnabled();
|
|
343
|
+
});
|
|
344
|
+
});
|
|
207
345
|
});
|