@openmrs/esm-react-utils 4.0.0-pre.1 → 4.0.1-pre.204
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/.turbo/turbo-build.log +16 -13
- package/__mocks__/openmrs-esm-state.mock.ts +1 -0
- package/dist/openmrs-esm-react-utils.js +1 -1
- package/dist/openmrs-esm-react-utils.js.LICENSE.txt +0 -9
- package/dist/openmrs-esm-react-utils.js.map +1 -1
- package/jest.config.js +3 -2
- package/package.json +7 -7
- package/src/ConfigurableLink.test.tsx +8 -4
- package/src/Extension.tsx +30 -6
- package/src/ExtensionSlot.tsx +108 -68
- package/src/UserHasAccess.tsx +1 -1
- package/src/extensions.test.tsx +276 -0
- package/src/public.ts +1 -2
- package/src/setup-tests.js +2 -0
- package/src/useAssignedExtensionIds.ts +1 -1
- package/src/useAssignedExtensions.ts +1 -1
- package/src/useConfig.test.tsx +8 -7
- package/src/useConfig.ts +1 -1
- package/.turbo/turbo-lint.log +0 -2
- package/.turbo/turbo-test.log +0 -45
package/src/useConfig.test.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { render, cleanup, screen, waitFor } from "@testing-library/react";
|
|
2
|
+
import { render, cleanup, screen, waitFor, act } from "@testing-library/react";
|
|
3
3
|
import {
|
|
4
4
|
defineConfigSchema,
|
|
5
5
|
temporaryConfigStore,
|
|
@@ -26,7 +26,6 @@ function clearConfig() {
|
|
|
26
26
|
|
|
27
27
|
describe(`useConfig in root context`, () => {
|
|
28
28
|
afterEach(clearConfig);
|
|
29
|
-
afterEach(cleanup);
|
|
30
29
|
|
|
31
30
|
it(`can return config as a react hook`, async () => {
|
|
32
31
|
defineConfigSchema("foo-module", {
|
|
@@ -103,9 +102,11 @@ describe(`useConfig in root context`, () => {
|
|
|
103
102
|
expect(screen.findByText("The first thing")).toBeTruthy()
|
|
104
103
|
);
|
|
105
104
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
105
|
+
act(() =>
|
|
106
|
+
temporaryConfigStore.setState({
|
|
107
|
+
config: { "foo-module": { thing: "A new thing" } },
|
|
108
|
+
})
|
|
109
|
+
);
|
|
109
110
|
|
|
110
111
|
await waitFor(() => expect(screen.findByText("A new thing")).toBeTruthy());
|
|
111
112
|
});
|
|
@@ -273,7 +274,7 @@ describe(`useConfig in an extension`, () => {
|
|
|
273
274
|
);
|
|
274
275
|
|
|
275
276
|
const newConfig = { "ext-module": { thing: "A new thing" } };
|
|
276
|
-
temporaryConfigStore.setState({ config: newConfig });
|
|
277
|
+
act(() => temporaryConfigStore.setState({ config: newConfig }));
|
|
277
278
|
|
|
278
279
|
await waitFor(() => expect(screen.findByText("A new thing")).toBeTruthy());
|
|
279
280
|
|
|
@@ -290,7 +291,7 @@ describe(`useConfig in an extension`, () => {
|
|
|
290
291
|
},
|
|
291
292
|
},
|
|
292
293
|
};
|
|
293
|
-
temporaryConfigStore.setState({ config: newConfig2 });
|
|
294
|
+
act(() => temporaryConfigStore.setState({ config: newConfig2 }));
|
|
294
295
|
|
|
295
296
|
await waitFor(() =>
|
|
296
297
|
expect(screen.findByText("Yet another thing")).toBeTruthy()
|
package/src/useConfig.ts
CHANGED
|
@@ -4,11 +4,11 @@ import {
|
|
|
4
4
|
getConfigStore,
|
|
5
5
|
getExtensionsConfigStore,
|
|
6
6
|
ConfigStore,
|
|
7
|
+
ConfigObject,
|
|
7
8
|
ExtensionsConfigStore,
|
|
8
9
|
getExtensionConfigFromStore,
|
|
9
10
|
} from "@openmrs/esm-config";
|
|
10
11
|
import { ComponentContext, ExtensionData } from "./ComponentContext";
|
|
11
|
-
import { ConfigObject } from "@openmrs/esm-config";
|
|
12
12
|
import { Store } from "unistore";
|
|
13
13
|
import isEqual from "lodash-es/isEqual";
|
|
14
14
|
|
package/.turbo/turbo-lint.log
DELETED
package/.turbo/turbo-test.log
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
[33m@openmrs/esm-react-utils:test: [0mcache hit, replaying output [2m5c98fc05f32d4ded[0m
|
|
2
|
-
[33m@openmrs/esm-react-utils:test: [0m$ jest --passWithNoTests
|
|
3
|
-
[33m@openmrs/esm-react-utils:test: [0mPASS src/openmrsComponentDecorator.test.tsx (12.76 s)
|
|
4
|
-
[33m@openmrs/esm-react-utils:test: [0mPASS src/useSession.test.tsx (14.355 s)
|
|
5
|
-
[33m@openmrs/esm-react-utils:test: [0mPASS src/useOnClickOutside.test.tsx (14.227 s)
|
|
6
|
-
[33m@openmrs/esm-react-utils:test: [0mPASS src/useConfig.test.tsx (16.25 s)
|
|
7
|
-
[33m@openmrs/esm-react-utils:test: [0m ● Console
|
|
8
|
-
[33m@openmrs/esm-react-utils:test: [0m
|
|
9
|
-
[33m@openmrs/esm-react-utils:test: [0m console.error
|
|
10
|
-
[33m@openmrs/esm-react-utils:test: [0m Warning: An update to RenderConfig inside a test was not wrapped in act(...).
|
|
11
|
-
[33m@openmrs/esm-react-utils:test: [0m
|
|
12
|
-
[33m@openmrs/esm-react-utils:test: [0m When testing, code that causes React state updates should be wrapped into act(...):
|
|
13
|
-
[33m@openmrs/esm-react-utils:test: [0m
|
|
14
|
-
[33m@openmrs/esm-react-utils:test: [0m act(() => {
|
|
15
|
-
[33m@openmrs/esm-react-utils:test: [0m /* fire events that update state */
|
|
16
|
-
[33m@openmrs/esm-react-utils:test: [0m });
|
|
17
|
-
[33m@openmrs/esm-react-utils:test: [0m /* assert on the output */
|
|
18
|
-
[33m@openmrs/esm-react-utils:test: [0m
|
|
19
|
-
[33m@openmrs/esm-react-utils:test: [0m This ensures that you're testing the behavior the user would see in the browser. Learn more at https://reactjs.org/link/wrap-tests-with-act
|
|
20
|
-
[33m@openmrs/esm-react-utils:test: [0m at RenderConfig (/home/brandon/Code/pih/mf/openmrs-esm-core/packages/framework/esm-react-utils/src/useConfig.test.tsx:18:29)
|
|
21
|
-
[33m@openmrs/esm-react-utils:test: [0m at Suspense
|
|
22
|
-
[33m@openmrs/esm-react-utils:test: [0m
|
|
23
|
-
[33m@openmrs/esm-react-utils:test: [0m 85 | return store?.subscribe((state) => {
|
|
24
|
-
[33m@openmrs/esm-react-utils:test: [0m 86 | if (state.loaded && state.config) {
|
|
25
|
-
[33m@openmrs/esm-react-utils:test: [0m > 87 | setState(state.config);
|
|
26
|
-
[33m@openmrs/esm-react-utils:test: [0m | ^
|
|
27
|
-
[33m@openmrs/esm-react-utils:test: [0m 88 | }
|
|
28
|
-
[33m@openmrs/esm-react-utils:test: [0m 89 | });
|
|
29
|
-
[33m@openmrs/esm-react-utils:test: [0m 90 | }, [store]);
|
|
30
|
-
[33m@openmrs/esm-react-utils:test: [0m
|
|
31
|
-
[33m@openmrs/esm-react-utils:test: [0m at printWarning (../../../node_modules/react-dom/cjs/react-dom.development.js:86:30)
|
|
32
|
-
[33m@openmrs/esm-react-utils:test: [0m at error (../../../node_modules/react-dom/cjs/react-dom.development.js:60:7)
|
|
33
|
-
[33m@openmrs/esm-react-utils:test: [0m at warnIfUpdatesNotWrappedWithActDEV (../../../node_modules/react-dom/cjs/react-dom.development.js:27543:9)
|
|
34
|
-
[33m@openmrs/esm-react-utils:test: [0m at scheduleUpdateOnFiber (../../../node_modules/react-dom/cjs/react-dom.development.js:25404:5)
|
|
35
|
-
[33m@openmrs/esm-react-utils:test: [0m at dispatchSetState (../../../node_modules/react-dom/cjs/react-dom.development.js:17389:16)
|
|
36
|
-
[33m@openmrs/esm-react-utils:test: [0m at Array.setState (src/useConfig.ts:87:9)
|
|
37
|
-
[33m@openmrs/esm-react-utils:test: [0m at Object.e (../../../node_modules/unistore/src/index.js:16:19)
|
|
38
|
-
[33m@openmrs/esm-react-utils:test: [0m
|
|
39
|
-
[33m@openmrs/esm-react-utils:test: [0mPASS src/ConfigurableLink.test.tsx (17.386 s)
|
|
40
|
-
[33m@openmrs/esm-react-utils:test: [0m
|
|
41
|
-
[33m@openmrs/esm-react-utils:test: [0mTest Suites: 5 passed, 5 total
|
|
42
|
-
[33m@openmrs/esm-react-utils:test: [0mTests: 19 passed, 19 total
|
|
43
|
-
[33m@openmrs/esm-react-utils:test: [0mSnapshots: 0 total
|
|
44
|
-
[33m@openmrs/esm-react-utils:test: [0mTime: 27.609 s
|
|
45
|
-
[33m@openmrs/esm-react-utils:test: [0mRan all test suites.
|