agora-appbuilder-core 4.1.23-beta.2 → 4.1.23-beta.3
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 +1 -1
- package/template/customization-implementation/__tests__/useCustomizationUndefined.test.tsx +64 -0
- package/template/customization-implementation/useCustomization.tsx +7 -2
- package/template/defaultConfig.js +2 -2
- package/template/src/auth/AuthProvider.tsx +1 -1
- package/template/src/components/RTMConfigure.tsx +1 -1
package/package.json
CHANGED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import TestRenderer, {act} from 'react-test-renderer';
|
|
3
|
+
import {describe, expect, it, jest} from '@jest/globals';
|
|
4
|
+
|
|
5
|
+
jest.mock('customization', () => ({
|
|
6
|
+
__esModule: true,
|
|
7
|
+
default: undefined,
|
|
8
|
+
}));
|
|
9
|
+
|
|
10
|
+
jest.mock('../../src/components/SdkApiContext', () => {
|
|
11
|
+
const ReactModule = require('react');
|
|
12
|
+
|
|
13
|
+
return {
|
|
14
|
+
SdkApiContext: ReactModule.createContext({customize: {}}),
|
|
15
|
+
};
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
import {CustomizationProvider, useCustomization} from '../useCustomization';
|
|
19
|
+
|
|
20
|
+
const LifecycleConsumer = ({
|
|
21
|
+
onRender,
|
|
22
|
+
}: {
|
|
23
|
+
onRender: (value: unknown) => void;
|
|
24
|
+
}) => {
|
|
25
|
+
const {lifecycle} = useCustomization();
|
|
26
|
+
onRender(lifecycle);
|
|
27
|
+
return null;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
describe('undefined customization fallback', () => {
|
|
31
|
+
it('provides a safe default in the regular web application', () => {
|
|
32
|
+
const onRender = jest.fn();
|
|
33
|
+
let renderer!: TestRenderer.ReactTestRenderer;
|
|
34
|
+
|
|
35
|
+
expect(() => {
|
|
36
|
+
act(() => {
|
|
37
|
+
renderer = TestRenderer.create(
|
|
38
|
+
<LifecycleConsumer onRender={onRender} />,
|
|
39
|
+
);
|
|
40
|
+
});
|
|
41
|
+
}).not.toThrow();
|
|
42
|
+
|
|
43
|
+
expect(onRender).toHaveBeenLastCalledWith(undefined);
|
|
44
|
+
renderer.unmount();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('provides a safe default through CustomizationProvider', () => {
|
|
48
|
+
const onRender = jest.fn();
|
|
49
|
+
let renderer!: TestRenderer.ReactTestRenderer;
|
|
50
|
+
|
|
51
|
+
expect(() => {
|
|
52
|
+
act(() => {
|
|
53
|
+
renderer = TestRenderer.create(
|
|
54
|
+
<CustomizationProvider>
|
|
55
|
+
<LifecycleConsumer onRender={onRender} />
|
|
56
|
+
</CustomizationProvider>,
|
|
57
|
+
);
|
|
58
|
+
});
|
|
59
|
+
}).not.toThrow();
|
|
60
|
+
|
|
61
|
+
expect(onRender).toHaveBeenLastCalledWith(undefined);
|
|
62
|
+
renderer.unmount();
|
|
63
|
+
});
|
|
64
|
+
});
|
|
@@ -15,15 +15,20 @@ import customizationConfig from 'customization';
|
|
|
15
15
|
import createHook from './createHook';
|
|
16
16
|
import {SdkApiContext} from '../src/components/SdkApiContext';
|
|
17
17
|
|
|
18
|
+
const defaultCustomizationConfig: CustomizationApiInterface =
|
|
19
|
+
customizationConfig ?? {};
|
|
20
|
+
|
|
18
21
|
const CustomizationContext: React.Context<CustomizationApiInterface> =
|
|
19
|
-
React.createContext(
|
|
22
|
+
React.createContext(defaultCustomizationConfig);
|
|
20
23
|
|
|
21
24
|
const CustomizationProvider: React.FC = (props) => {
|
|
22
25
|
const {customize: userCustomization} = useContext(SdkApiContext);
|
|
23
26
|
|
|
24
27
|
return (
|
|
25
28
|
<CustomizationContext.Provider
|
|
26
|
-
value={
|
|
29
|
+
value={
|
|
30
|
+
userCustomization?.customization ?? defaultCustomizationConfig
|
|
31
|
+
}>
|
|
27
32
|
{props.children}
|
|
28
33
|
</CustomizationContext.Provider>
|
|
29
34
|
);
|
|
@@ -77,8 +77,8 @@ const DefaultConfig = {
|
|
|
77
77
|
CHAT_ORG_NAME: "",
|
|
78
78
|
CHAT_APP_NAME: "",
|
|
79
79
|
CHAT_URL: "",
|
|
80
|
-
CLI_VERSION: "3.1.23-beta.
|
|
81
|
-
CORE_VERSION: "4.1.23-beta.
|
|
80
|
+
CLI_VERSION: "3.1.23-beta.3",
|
|
81
|
+
CORE_VERSION: "4.1.23-beta.3",
|
|
82
82
|
DISABLE_LANDSCAPE_MODE: false,
|
|
83
83
|
STT_AUTO_START: false,
|
|
84
84
|
CLOUD_RECORDING_AUTO_START: false,
|
|
@@ -65,7 +65,7 @@ const AuthContext = createContext<AuthContextInterface | null>(null);
|
|
|
65
65
|
const AuthProvider = (props: AuthProviderProps) => {
|
|
66
66
|
const loadingLabel = useString(loadingText)();
|
|
67
67
|
const timeoutHeading = useString(authSessionTimeoutToastHeading)();
|
|
68
|
-
const
|
|
68
|
+
const lifecycle = useCustomization(data => data?.lifecycle);
|
|
69
69
|
const regEvent = useRef(true);
|
|
70
70
|
const refreshTimeoutWeb = useRef(null);
|
|
71
71
|
const [showNativePopup, setShowNativePopup] = useState(false);
|
|
@@ -82,7 +82,7 @@ const RtmConfigure = (props: any) => {
|
|
|
82
82
|
const {rtcProps} = useContext(PropsContext);
|
|
83
83
|
const {dispatch} = useContext(DispatchContext);
|
|
84
84
|
const {defaultContent, activeUids} = useContent();
|
|
85
|
-
const
|
|
85
|
+
const lifecycle = useCustomization(data => data?.lifecycle);
|
|
86
86
|
const {
|
|
87
87
|
waitingRoomStatus,
|
|
88
88
|
data: {isHost},
|