@thepalaceproject/circulation-admin 1.13.0 → 1.14.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/package.json
CHANGED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { screen, waitFor } from "@testing-library/react";
|
|
3
|
+
|
|
4
|
+
import QuicksightDashboard from "../../../src/components/QuicksightDashboard";
|
|
5
|
+
import { LibrariesData, LibraryData } from "../../../src/interfaces";
|
|
6
|
+
import buildStore, { RootState } from "../../../src/store";
|
|
7
|
+
import { setupServer } from "msw/node";
|
|
8
|
+
import { rest } from "msw";
|
|
9
|
+
import renderWithContext from "../testUtils/renderWithContext";
|
|
10
|
+
|
|
11
|
+
const libraries: LibrariesData = { libraries: [{ uuid: "my-uuid" }] };
|
|
12
|
+
const dashboardId = "test";
|
|
13
|
+
const embedUrl = "http://embedUrl";
|
|
14
|
+
const dashboardUrlData = { embedUrl: embedUrl };
|
|
15
|
+
|
|
16
|
+
describe("QuicksightDashboard", () => {
|
|
17
|
+
const server = setupServer(
|
|
18
|
+
rest.get("*/admin/libraries", (req, res, ctx) => res(ctx.json(libraries))),
|
|
19
|
+
|
|
20
|
+
rest.get(
|
|
21
|
+
"*/admin/quicksight_embed/" +
|
|
22
|
+
dashboardId +
|
|
23
|
+
"?libraryUuids=" +
|
|
24
|
+
libraries["libraries"][0]["uuid"],
|
|
25
|
+
(req, res, ctx) => res(ctx.json(dashboardUrlData))
|
|
26
|
+
)
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
beforeAll(() => {
|
|
30
|
+
server.listen();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
afterAll(() => {
|
|
34
|
+
server.close();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("embed url is retrieved and set in iframe", async () => {
|
|
38
|
+
const contextProviderProps = {
|
|
39
|
+
csrfToken: "",
|
|
40
|
+
roles: [{ role: "system" }],
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
renderWithContext(
|
|
44
|
+
<QuicksightDashboard dashboardId={dashboardId} store={buildStore()} />,
|
|
45
|
+
contextProviderProps
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
await waitFor(() => {
|
|
49
|
+
expect(screen.getAllByTitle("Library Dashboard")[0]).toHaveAttribute(
|
|
50
|
+
"src",
|
|
51
|
+
embedUrl
|
|
52
|
+
);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
});
|