@thepalaceproject/circulation-admin 1.24.0 → 1.25.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/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
@@ -135,7 +135,7 @@
135
135
  "typedoc": "0.23.21",
136
136
  "typescript": "4.9.4",
137
137
  "url-loader": "^4.1.1",
138
- "webpack": "^5.76.0",
138
+ "webpack": "^5.94.0",
139
139
  "webpack-cli": "^5.0.1",
140
140
  "webpack-dev-server": "^4.11.1",
141
141
  "webpack-merge": "^5.8.0"
@@ -150,5 +150,5 @@
150
150
  "*.{js,jsx,ts,tsx,css,md}": "prettier --write",
151
151
  "*.{js,css,md}": "prettier --write"
152
152
  },
153
- "version": "1.24.0"
153
+ "version": "1.25.0-post.2"
154
154
  }
@@ -0,0 +1 @@
1
+ module.exports = "test-file-stub";
@@ -0,0 +1 @@
1
+ module.exports = {};
@@ -0,0 +1,38 @@
1
+ import * as React from "react";
2
+ import { render, screen } from "@testing-library/react";
3
+ import userEvent from "@testing-library/user-event";
4
+ import ProtocolFormField from "../../../src/components/ProtocolFormField";
5
+
6
+ // NB: This file adds / duplicates existing tests from:
7
+ // - `src/components/__tests__/ProtocolFormField-test.tsx`.
8
+ //
9
+ // Those tests should eventually be migrated here and
10
+ // adapted to the Jest/React Testing Library paradigm.
11
+
12
+ describe("ProtocolFormField", () => {
13
+ it("renders date-picker setting", async () => {
14
+ const user = userEvent.setup();
15
+ const emptyValue = "";
16
+ const testDate = "2022-01-01";
17
+ const datePickerLabel = "A date setting field";
18
+ const fieldDescription = "Description of the setting";
19
+ const setting = {
20
+ key: "setting",
21
+ label: datePickerLabel,
22
+ description: `<p>${fieldDescription}</p>`,
23
+ type: "date-picker",
24
+ };
25
+
26
+ render(<ProtocolFormField setting={setting} disabled={false} />);
27
+ const input = screen.getByLabelText(datePickerLabel) as HTMLInputElement;
28
+
29
+ expect(input.value).toBe(emptyValue);
30
+
31
+ // Enter a date.
32
+ await user.click(input);
33
+ await user.keyboard(`${testDate}{enter}`);
34
+
35
+ expect(input.value).toBe(testDate);
36
+ screen.debug();
37
+ });
38
+ });
@@ -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
- const contextProviderProps = {
39
- csrfToken: "",
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
- <QueryClientProvider client={queryClient}>
60
- {children}
61
- </QueryClientProvider>
73
+ <TOSContextProvider value={tosContextProviderProps}>
74
+ <QueryClientProvider client={queryClient}>
75
+ {children}
76
+ </QueryClientProvider>
77
+ </TOSContextProvider>
62
78
  </ContextProvider>
63
79
  </Provider>
64
80
  );
@@ -192,11 +192,11 @@ module.exports = (env) => {
192
192
  return responseBuffer;
193
193
  }
194
194
  ),
195
- proxyTimeout: 5000,
195
+ proxyTimeout: 120000,
196
196
  secure: false,
197
197
  selfHandleResponse: true,
198
198
  target: backend,
199
- timeout: 5000,
199
+ timeout: 120000,
200
200
  });
201
201
 
202
202
  const config = merge(dev, {