@thepalaceproject/circulation-admin 1.23.0-post.1 → 1.24.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/dist/circulation-admin.js +1 -1
- package/jest.config.js +5 -0
- package/package.json +1 -1
- package/tests/__mocks__/fileMock.js +1 -0
- package/tests/__mocks__/styleMock.js +1 -0
- package/tests/jest/components/QuicksightDashboard.test.tsx +20 -9
- package/tests/jest/testUtils/withProviders.tsx +19 -3
package/jest.config.js
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
/** @type {import('ts-jest').JestConfigWithTsJest} */
|
|
2
2
|
module.exports = {
|
|
3
|
+
moduleNameMapper: {
|
|
4
|
+
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$":
|
|
5
|
+
"<rootDir>/tests/__mocks__/fileMock.js",
|
|
6
|
+
"\\.(css|less)$": "<rootDir>/tests/__mocks__/styleMock.js",
|
|
7
|
+
},
|
|
3
8
|
preset: "ts-jest",
|
|
4
9
|
testEnvironment: "jsdom",
|
|
5
10
|
testEnvironmentOptions: {
|
package/package.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = "test-file-stub";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = {};
|
|
@@ -7,6 +7,8 @@ import buildStore from "../../../src/store";
|
|
|
7
7
|
import { setupServer } from "msw/node";
|
|
8
8
|
import { http, HttpResponse } from "msw";
|
|
9
9
|
import renderWithContext from "../testUtils/renderWithContext";
|
|
10
|
+
import { renderWithProviders } from "../testUtils/withProviders";
|
|
11
|
+
import QuicksightDashboardPage from "../../../src/components/QuicksightDashboardPage";
|
|
10
12
|
|
|
11
13
|
const libraries: LibrariesData = { libraries: [{ uuid: "my-uuid" }] };
|
|
12
14
|
const dashboardId = "test";
|
|
@@ -35,15 +37,8 @@ describe("QuicksightDashboard", () => {
|
|
|
35
37
|
});
|
|
36
38
|
|
|
37
39
|
it("embed url is retrieved and set in iframe", async () => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
featureFlags: {},
|
|
41
|
-
roles: [{ role: "system" }],
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
renderWithContext(
|
|
45
|
-
<QuicksightDashboard dashboardId={dashboardId} store={buildStore()} />,
|
|
46
|
-
contextProviderProps
|
|
40
|
+
renderWithProviders(
|
|
41
|
+
<QuicksightDashboard dashboardId={dashboardId} store={buildStore()} />
|
|
47
42
|
);
|
|
48
43
|
|
|
49
44
|
await waitFor(() => {
|
|
@@ -53,4 +48,20 @@ describe("QuicksightDashboard", () => {
|
|
|
53
48
|
);
|
|
54
49
|
});
|
|
55
50
|
});
|
|
51
|
+
|
|
52
|
+
it("header renders without navigation links ", () => {
|
|
53
|
+
renderWithProviders(<QuicksightDashboardPage params={{ library: null }} />);
|
|
54
|
+
|
|
55
|
+
// Make sure we see the QuicksSight iFrame.
|
|
56
|
+
expect(screen.getByTitle("Library Dashboard")).toBeInTheDocument();
|
|
57
|
+
// Make sure we have the branding image.
|
|
58
|
+
expect(
|
|
59
|
+
screen.getByAltText("Palace Collection Manager")
|
|
60
|
+
).toBeInTheDocument();
|
|
61
|
+
|
|
62
|
+
// Make sure we do not see other navigation links.
|
|
63
|
+
["Dashboard", "System Configuration"].forEach((name) => {
|
|
64
|
+
expect(screen.queryByText(name)).not.toBeInTheDocument();
|
|
65
|
+
});
|
|
66
|
+
});
|
|
56
67
|
});
|
|
@@ -7,10 +7,15 @@ import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
|
7
7
|
import { render, RenderOptions, RenderResult } from "@testing-library/react";
|
|
8
8
|
import { defaultFeatureFlags } from "../../../src/utils/featureFlags";
|
|
9
9
|
import { store } from "../../../src/store";
|
|
10
|
+
import {
|
|
11
|
+
TOSContextProvider,
|
|
12
|
+
TOSContextProviderProps,
|
|
13
|
+
} from "../../../src/components/TOSContext";
|
|
10
14
|
|
|
11
15
|
export type TestProviderWrapperOptions = {
|
|
12
16
|
reduxProviderProps?: ProviderProps;
|
|
13
17
|
contextProviderProps?: Partial<ContextProviderProps>;
|
|
18
|
+
tosContextProviderProps?: TOSContextProviderProps;
|
|
14
19
|
queryClient?: QueryClient;
|
|
15
20
|
};
|
|
16
21
|
export type TestRenderWrapperOptions = TestProviderWrapperOptions & {
|
|
@@ -21,6 +26,13 @@ export type TestRenderWrapperOptions = TestProviderWrapperOptions & {
|
|
|
21
26
|
// be the same for both the Redux Provider and the ContextProvider.
|
|
22
27
|
const defaultReduxStore = store;
|
|
23
28
|
|
|
29
|
+
// Setup default TOSContext provider props.
|
|
30
|
+
const tosText = "Sample terms of service.";
|
|
31
|
+
const tosHref = "http://example.com/terms-of-service";
|
|
32
|
+
const requiredTOSContextProviderProps: TOSContextProviderProps = {
|
|
33
|
+
...[tosText, tosHref],
|
|
34
|
+
};
|
|
35
|
+
|
|
24
36
|
// The `csrfToken` context provider prop is required, so we provide
|
|
25
37
|
// a default value here, so it can be easily merged with other props.
|
|
26
38
|
const requiredContextProviderProps: ContextProviderProps = {
|
|
@@ -35,6 +47,7 @@ const requiredContextProviderProps: ContextProviderProps = {
|
|
|
35
47
|
* @param {TestProviderWrapperOptions} options
|
|
36
48
|
* @param options.reduxProviderProps Props to pass to the Redux `Provider` wrapper
|
|
37
49
|
* @param {ContextProviderProps} options.contextProviderProps Props to pass to the ContextProvider wrapper
|
|
50
|
+
* @param {TOSContextProviderProps} options.tosContextProviderProps Props to pass to the TOSContextProvider wrapper
|
|
38
51
|
* @param {QueryClient} options.queryClient A `tanstack/react-query` QueryClient
|
|
39
52
|
* @returns {React.FunctionComponent} A React component that wraps children with our providers
|
|
40
53
|
*/
|
|
@@ -46,6 +59,7 @@ export const componentWithProviders = ({
|
|
|
46
59
|
csrfToken: "",
|
|
47
60
|
featureFlags: defaultFeatureFlags,
|
|
48
61
|
},
|
|
62
|
+
tosContextProviderProps = requiredTOSContextProviderProps,
|
|
49
63
|
queryClient = new QueryClient(),
|
|
50
64
|
}: TestProviderWrapperOptions = {}): React.FunctionComponent => {
|
|
51
65
|
const effectiveContextProviderProps = {
|
|
@@ -56,9 +70,11 @@ export const componentWithProviders = ({
|
|
|
56
70
|
const wrapper = ({ children }) => (
|
|
57
71
|
<Provider {...reduxProviderProps}>
|
|
58
72
|
<ContextProvider {...effectiveContextProviderProps}>
|
|
59
|
-
<
|
|
60
|
-
{
|
|
61
|
-
|
|
73
|
+
<TOSContextProvider value={tosContextProviderProps}>
|
|
74
|
+
<QueryClientProvider client={queryClient}>
|
|
75
|
+
{children}
|
|
76
|
+
</QueryClientProvider>
|
|
77
|
+
</TOSContextProvider>
|
|
62
78
|
</ContextProvider>
|
|
63
79
|
</Provider>
|
|
64
80
|
);
|