@eohjsc/react-native-smart-city 0.4.46 → 0.4.48
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/README.md +1 -5
- package/android/build.gradle +24 -19
- package/package.json +11 -14
- package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +7 -4
- package/src/commons/ActionGroup/__test__/ColorPickerTemplate.test.js +3 -6
- package/src/commons/ActionGroup/__test__/NumberUpDownTemplate.test.js +1 -4
- package/src/commons/ActionGroup/__test__/TwoButtonTemplate.test.js +11 -1
- package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +5 -0
- package/src/commons/Dashboard/MyPinnedSharedUnit/index.js +6 -1
- package/src/commons/Dashboard/MyUnit/index.js +6 -8
- package/src/commons/DateTimeRangeChange/index.js +3 -3
- package/src/commons/Device/Hanet/ItemHanetDevice.js +1 -5
- package/src/commons/Device/ItemAddNew/index.js +2 -6
- package/src/commons/Device/ItemDevice.js +1 -5
- package/src/commons/FlatListDnD/__test__/index.test.js +25 -27
- package/src/commons/GroupCheckBox/__test__/GroupCheckBox.test.js +22 -1
- package/src/commons/HeaderAni/index.js +2 -12
- package/src/commons/MediaPlayerDetail/__test__/MediaPlayerFull.test.js +23 -1
- package/src/commons/Modal/ModalCustom.js +2 -2
- package/src/commons/SubUnit/OneTap/ItemOneTap.js +2 -10
- package/src/commons/Unit/HeaderUnit/index.js +7 -18
- package/src/commons/Unit/SharedUnit.js +43 -58
- package/src/commons/Unit/__test__/SharedUnit.test.js +100 -60
- package/src/commons/UnitSummary/ConfigHistoryChart/__test__/ConfigHistoryChart.test.js +289 -0
- package/src/commons/UnitSummary/ConfigHistoryChart/index.js +59 -1
- package/src/commons/WrapParallaxScrollView/index.js +0 -4
- package/src/configs/AccessibilityLabel.js +0 -3
- package/src/hooks/IoT/__test__/useRemoteControl.test.js +51 -52
- package/src/hooks/IoT/__test__/useWatchConfigs.test.js +2 -3
- package/src/navigations/AutomateStack.js +2 -5
- package/src/navigations/NotificationStack.js +2 -28
- package/src/navigations/SharedStack.js +2 -8
- package/src/navigations/UnitStack.js +2 -2
- package/src/screens/AllGateway/DeviceModbusDetail/__test__/index.test.js +32 -31
- package/src/screens/Automate/EditActionsList/__tests__/index.test.js +68 -69
- package/src/screens/Automate/ScriptDetail/Styles/indexStyles.js +0 -1
- package/src/screens/Automate/ScriptDetail/index.js +7 -4
- package/src/screens/ChangePosition/__test__/index.test.js +32 -34
- package/src/screens/ConfirmUnitDeletion/__test__/ConfirmUnitDeletion.test.js +11 -1
- package/src/screens/Device/__test__/detail.test.js +1 -61
- package/src/screens/Device/components/ChartWrapper.js +12 -14
- package/src/screens/Device/components/VisualChart.js +1 -7
- package/src/screens/Device/components/__test__/VisualChart.test.js +3 -0
- package/src/screens/Device/detail.js +31 -28
- package/src/screens/Device/hooks/__test__/useEvaluateValue.test.js +18 -20
- package/src/screens/Device/styles.js +0 -3
- package/src/screens/Notification/__test__/Notification.test.js +8 -14
- package/src/screens/Notification/components/NotificationItem.js +0 -1
- package/src/screens/Notification/index.js +48 -42
- package/src/screens/Notification/styles/indexStyles.js +3 -6
- package/src/screens/SharedUnit/index.js +4 -1
- package/src/screens/Sharing/InfoMemberUnit.js +1 -3
- package/src/screens/Sharing/MemberList.js +3 -16
- package/src/screens/Sharing/__test__/InfoMemberUnit.test.js +0 -2
- package/src/screens/Sharing/__test__/SelectPermission.test.js +137 -96
- package/src/screens/Template/__test__/EditTemplate.test.js +45 -48
- package/src/screens/Unit/__test__/SelectAddress.test.js +11 -4
- package/src/screens/Unit/components/SharedUnit/index.js +9 -6
- package/src/screens/Unit/components/__test__/SharedUnit.test.js +15 -19
- package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js +11 -1
- package/src/utils/Monitor.js +2 -2
- package/src/Images/Common/pushpin-full.svg +0 -3
- package/src/Images/Common/pushpin-outline.svg +0 -3
- package/src/Images/Common/star-full.svg +0 -3
- package/src/Images/Common/star-outline.svg +0 -3
|
@@ -17,7 +17,7 @@ import api from '../../../../utils/Apis/axios';
|
|
|
17
17
|
import { API } from '../../../../configs';
|
|
18
18
|
import { PERMISSION_TYPE } from '../../../../configs/Constants';
|
|
19
19
|
import Detail from '../../components/Detail';
|
|
20
|
-
|
|
20
|
+
import ModalPopupCT from '../../../../commons/ModalPopupCT';
|
|
21
21
|
import { fetchGatewayCT, flushPromises } from '../../test-utils';
|
|
22
22
|
|
|
23
23
|
const mock = new MockAdapter(api.axiosInstance);
|
|
@@ -133,6 +133,8 @@ describe('Test DeviceModbusDetail', () => {
|
|
|
133
133
|
const menuActionMore = detail?.findAllByType(MenuActionMore);
|
|
134
134
|
expect(menuActionMore[0].props.isVisible).toEqual(true);
|
|
135
135
|
|
|
136
|
+
await flushPromises();
|
|
137
|
+
|
|
136
138
|
await act(async () => {
|
|
137
139
|
await menuActionMore[0].props.listMenuItem[0].doAction();
|
|
138
140
|
});
|
|
@@ -143,39 +145,38 @@ describe('Test DeviceModbusDetail', () => {
|
|
|
143
145
|
});
|
|
144
146
|
});
|
|
145
147
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
// expect(menuActionMore.props.isVisible).toEqual(true);
|
|
148
|
+
it('test render DeviceModbusDetail onPress more and onPress Delete modbus', async () => {
|
|
149
|
+
await act(async () => {
|
|
150
|
+
tree = await create(wrapComponent());
|
|
151
|
+
});
|
|
152
|
+
await flushPromises();
|
|
153
|
+
const instance = tree.root;
|
|
154
|
+
const detail = instance?.findByType(Detail);
|
|
155
|
+
await headerCustomOnPressMore(detail);
|
|
156
|
+
const menuActionMore = detail?.findByType(MenuActionMore);
|
|
157
|
+
expect(menuActionMore.props.isVisible).toEqual(true);
|
|
157
158
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
159
|
+
await act(async () => {
|
|
160
|
+
menuActionMore.props.listMenuItem[1].doAction();
|
|
161
|
+
});
|
|
162
|
+
await flushPromises();
|
|
162
163
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
164
|
+
const modal = instance.findByType(ModalPopupCT);
|
|
165
|
+
mock.onDelete(API.DEV_MODE.ZIGBEE.DEVICE_DETAIL(1, 1)).reply(200);
|
|
166
|
+
await act(async () => {
|
|
167
|
+
await modal.props.onPressConfirm();
|
|
168
|
+
});
|
|
169
|
+
await flushPromises();
|
|
169
170
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
171
|
+
expect(mockPop).toBeCalledWith(1);
|
|
172
|
+
expect(Toast.show).toBeCalledWith({
|
|
173
|
+
position: 'bottom',
|
|
174
|
+
text1: 'Delete successfully!',
|
|
175
|
+
text2: undefined,
|
|
176
|
+
type: 'success',
|
|
177
|
+
visibilityTime: 1000,
|
|
178
|
+
});
|
|
179
|
+
});
|
|
179
180
|
|
|
180
181
|
it('test render DeviceZigbeeDetail onPress TabPanel config write', async () => {
|
|
181
182
|
mock.onGet(API.DEV_MODE.MODBUS.REGISTER(1, 1)).reply(200, [
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable no-unused-vars */
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import DraggableFlatList from 'react-native-draggable-flatlist';
|
|
4
3
|
import { create, act } from 'react-test-renderer';
|
|
@@ -38,78 +37,78 @@ describe('EditActionsList', () => {
|
|
|
38
37
|
mockedNavigate.mockClear();
|
|
39
38
|
});
|
|
40
39
|
it('render EditActionsList', async () => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
40
|
+
await act(async () => {
|
|
41
|
+
tree = await create(wrapComponent());
|
|
42
|
+
});
|
|
43
|
+
const instance = tree.root;
|
|
44
|
+
const draggableFlatList = instance.findAllByType(DraggableFlatList);
|
|
45
|
+
const modalBottom = instance.findAllByType(ModalBottom);
|
|
46
|
+
expect(draggableFlatList).toHaveLength(1);
|
|
47
|
+
expect(modalBottom).toHaveLength(1);
|
|
48
|
+
});
|
|
49
|
+
it('EditActionsList onPress cancel', async () => {
|
|
50
|
+
await act(async () => {
|
|
51
|
+
tree = await create(wrapComponent());
|
|
52
|
+
});
|
|
53
|
+
const instance = tree.root;
|
|
54
|
+
const buttonCancel = instance.find(
|
|
55
|
+
(el) =>
|
|
56
|
+
el.props.accessibilityLabel ===
|
|
57
|
+
AccessibilityLabel.BUTTON_CANCEL_EDIT_ACTION_LIST &&
|
|
58
|
+
el.type === TouchableOpacity
|
|
59
|
+
);
|
|
60
|
+
expect(buttonCancel).toBeDefined();
|
|
61
|
+
await act(async () => {
|
|
62
|
+
buttonCancel.props.onPress();
|
|
63
|
+
});
|
|
64
|
+
expect(mockedNavigate).toHaveBeenCalled();
|
|
49
65
|
});
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
// buttonCancel.props.onPress();
|
|
64
|
-
// });
|
|
65
|
-
// expect(mockedNavigate).toHaveBeenCalled();
|
|
66
|
-
// });
|
|
67
|
-
// it('EditActionsList onPress save', async () => {
|
|
68
|
-
// mock.onPut(API.AUTOMATE.ORDER_SCRIPT_ACTION(1)).reply(200);
|
|
69
|
-
// await act(async () => {
|
|
70
|
-
// tree = await create(wrapComponent());
|
|
71
|
-
// });
|
|
72
|
-
// const instance = tree.root;
|
|
73
|
-
// const buttonSave = instance.find(
|
|
74
|
-
// (el) =>
|
|
75
|
-
// el.props.accessibilityLabel ===
|
|
76
|
-
// AccessibilityLabel.BUTTON_SAVE_EDIT_ACTION_LIST &&
|
|
77
|
-
// el.type === TouchableOpacity
|
|
78
|
-
// );
|
|
79
|
-
// expect(buttonSave).toBeDefined();
|
|
66
|
+
it('EditActionsList onPress save', async () => {
|
|
67
|
+
mock.onPut(API.AUTOMATE.ORDER_SCRIPT_ACTION(1)).reply(200);
|
|
68
|
+
await act(async () => {
|
|
69
|
+
tree = await create(wrapComponent());
|
|
70
|
+
});
|
|
71
|
+
const instance = tree.root;
|
|
72
|
+
const buttonSave = instance.find(
|
|
73
|
+
(el) =>
|
|
74
|
+
el.props.accessibilityLabel ===
|
|
75
|
+
AccessibilityLabel.BUTTON_SAVE_EDIT_ACTION_LIST &&
|
|
76
|
+
el.type === TouchableOpacity
|
|
77
|
+
);
|
|
78
|
+
expect(buttonSave).toBeDefined();
|
|
80
79
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
80
|
+
await act(async () => {
|
|
81
|
+
buttonSave.props.onPress();
|
|
82
|
+
});
|
|
84
83
|
|
|
85
|
-
|
|
86
|
-
|
|
84
|
+
expect(mock.history.put).toHaveLength(1);
|
|
85
|
+
});
|
|
87
86
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
87
|
+
it('EditActionsList has remove button', async () => {
|
|
88
|
+
await act(async () => {
|
|
89
|
+
tree = await create(wrapComponent());
|
|
90
|
+
});
|
|
91
|
+
const instance = tree.root;
|
|
92
|
+
const buttonRemove = instance.find(
|
|
93
|
+
(el) =>
|
|
94
|
+
el.props.accessibilityLabel ===
|
|
95
|
+
AccessibilityLabel.BUTTON_REMOVE_EDIT_ACTION_LIST &&
|
|
96
|
+
el.type === TouchableOpacity
|
|
97
|
+
);
|
|
98
|
+
expect(buttonRemove).toBeDefined();
|
|
99
|
+
});
|
|
101
100
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
101
|
+
it('EditActionsList modal onPress remove', async () => {
|
|
102
|
+
await act(async () => {
|
|
103
|
+
tree = await create(wrapComponent());
|
|
104
|
+
});
|
|
105
|
+
const instance = tree.root;
|
|
106
|
+
const modalBottom = instance.findAllByType(ModalBottom);
|
|
107
|
+
await act(async () => {
|
|
108
|
+
modalBottom[0].props.onRemove();
|
|
109
|
+
});
|
|
111
110
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
111
|
+
mock.onDelete(API.AUTOMATE.DELETE_SCRIPT_ACTION(1, 1)).reply(200);
|
|
112
|
+
expect(mock.history.delete).toHaveLength(1);
|
|
113
|
+
});
|
|
115
114
|
});
|
|
@@ -7,6 +7,7 @@ import React, {
|
|
|
7
7
|
} from 'react';
|
|
8
8
|
import { Image, Platform, TouchableOpacity, View } from 'react-native';
|
|
9
9
|
import { PopoverMode } from 'react-native-popover-view';
|
|
10
|
+
import { IconFill, IconOutline } from '@ant-design/icons-react-native';
|
|
10
11
|
import { Icon } from '@ant-design/react-native';
|
|
11
12
|
|
|
12
13
|
import { useTranslations } from '../../../hooks/Common/useTranslations';
|
|
@@ -30,8 +31,6 @@ import RenameScript from './Components/RenameScript';
|
|
|
30
31
|
import DeleteScript from './Components/DeleteScript';
|
|
31
32
|
import Images from '../../../configs/Images';
|
|
32
33
|
import { useBackendPermission } from '../../../utils/Permission/backend';
|
|
33
|
-
import StarFull from '../../../Images/Common/star-full.svg';
|
|
34
|
-
import StarOutline from '../../../Images/Common/star-outline.svg';
|
|
35
34
|
|
|
36
35
|
const PreventDoubleTouch = withPreventDoubleClick(TouchableOpacity);
|
|
37
36
|
|
|
@@ -161,7 +160,7 @@ const ScriptDetail = ({ route }) => {
|
|
|
161
160
|
style={[styles.headerButton, styles.moreButton]}
|
|
162
161
|
accessibilityLabel={AccessibilityLabel.ICON_MORE}
|
|
163
162
|
>
|
|
164
|
-
<Icon name={'
|
|
163
|
+
<Icon name={'more'} size={27} color={Colors.Black} />
|
|
165
164
|
</TouchableOpacity>
|
|
166
165
|
</View>
|
|
167
166
|
),
|
|
@@ -377,7 +376,11 @@ const ButtonStar = ({ automate }) => {
|
|
|
377
376
|
onPress={onPressStar}
|
|
378
377
|
accessibilityLabel={AccessibilityLabel.HEADER_SCRIPT_DETAIL_BUTTON_STAR}
|
|
379
378
|
>
|
|
380
|
-
{isStarred ?
|
|
379
|
+
{isStarred ? (
|
|
380
|
+
<IconFill name="star" size={25} color={Colors.Yellow6} />
|
|
381
|
+
) : (
|
|
382
|
+
<IconOutline name="star" size={25} />
|
|
383
|
+
)}
|
|
381
384
|
</PreventDoubleTouch>
|
|
382
385
|
);
|
|
383
386
|
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable no-unused-vars */
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import { act, create } from 'react-test-renderer';
|
|
4
3
|
import MockAdapter from 'axios-mock-adapter';
|
|
@@ -34,8 +33,6 @@ const wrapComponent = ({ ...rest }) => (
|
|
|
34
33
|
</SCProvider>
|
|
35
34
|
);
|
|
36
35
|
|
|
37
|
-
// NOTE: Hinh will fix it later
|
|
38
|
-
|
|
39
36
|
describe('Test ChangePosition', () => {
|
|
40
37
|
let tree;
|
|
41
38
|
|
|
@@ -45,36 +42,37 @@ describe('Test ChangePosition', () => {
|
|
|
45
42
|
});
|
|
46
43
|
|
|
47
44
|
it('render ChangePosition', async () => {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
45
|
+
const mockFetchData = jest.fn();
|
|
46
|
+
const spyToastSuccess = jest.spyOn(ToastBottomHelper, 'success');
|
|
47
|
+
useRoute.mockReturnValue({
|
|
48
|
+
params: {
|
|
49
|
+
sensor: { id: 1, name: 'device' },
|
|
50
|
+
display: { items: [{ id: 1 }, { id: 2 }] },
|
|
51
|
+
setDisplay: mockSetDisplay,
|
|
52
|
+
station: { id: 1, name: 'station' },
|
|
53
|
+
evaluate: {},
|
|
54
|
+
fetchDataDeviceDetail: mockFetchData,
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
mock.onPut(API.DEVICE.ORDER_DISPLAY_ITEMS(1)).reply(200);
|
|
58
|
+
await act(async () => {
|
|
59
|
+
tree = await create(wrapComponent({}));
|
|
60
|
+
});
|
|
61
|
+
const instance = tree.root;
|
|
62
|
+
const flatListDnD = instance.findAllByType(DraggableFlatList);
|
|
63
|
+
expect(flatListDnD).toHaveLength(1);
|
|
64
|
+
|
|
65
|
+
const bottomButtonView = instance.findAllByType(BottomButtonView);
|
|
66
|
+
expect(bottomButtonView).toHaveLength(1);
|
|
67
|
+
await act(async () => {
|
|
68
|
+
flatListDnD[0].props.onDragEnd({ data: [{ id: 2 }, { id: 1 }] });
|
|
69
|
+
});
|
|
70
|
+
await act(async () => {
|
|
71
|
+
bottomButtonView[0].props.onPressMain();
|
|
72
|
+
});
|
|
73
|
+
expect(mockGoBack).toHaveBeenCalled();
|
|
74
|
+
expect(mockFetchData).toHaveBeenCalled();
|
|
75
|
+
expect(mockSetDisplay).toHaveBeenCalled();
|
|
76
|
+
expect(spyToastSuccess).toBeCalledWith('Updated widget successfully');
|
|
79
77
|
});
|
|
80
78
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
2
|
import renderer, { act } from 'react-test-renderer';
|
|
3
3
|
|
|
4
4
|
import { SCProvider } from '../../../context';
|
|
@@ -30,6 +30,14 @@ jest.mock('@react-navigation/native', () => {
|
|
|
30
30
|
};
|
|
31
31
|
});
|
|
32
32
|
|
|
33
|
+
const mockSetState = jest.fn();
|
|
34
|
+
jest.mock('react', () => {
|
|
35
|
+
return {
|
|
36
|
+
...jest.requireActual('react'),
|
|
37
|
+
useState: jest.fn((init) => [init, mockSetState]),
|
|
38
|
+
};
|
|
39
|
+
});
|
|
40
|
+
|
|
33
41
|
describe('Test ConfirmUnitDeletion', () => {
|
|
34
42
|
let tree;
|
|
35
43
|
let route;
|
|
@@ -45,6 +53,7 @@ describe('Test ConfirmUnitDeletion', () => {
|
|
|
45
53
|
});
|
|
46
54
|
|
|
47
55
|
it('test render ConfirmUnitDeletion', async () => {
|
|
56
|
+
useState.mockImplementationOnce((init) => ['new_name', mockSetState]);
|
|
48
57
|
await act(async () => {
|
|
49
58
|
tree = await renderer.create(wrapComponent(route));
|
|
50
59
|
});
|
|
@@ -56,6 +65,7 @@ describe('Test ConfirmUnitDeletion', () => {
|
|
|
56
65
|
});
|
|
57
66
|
});
|
|
58
67
|
it('Onpress button ConfirmUnitDeletion ', async () => {
|
|
68
|
+
useState.mockImplementationOnce((init) => ['YES', mockSetState]);
|
|
59
69
|
await act(async () => {
|
|
60
70
|
tree = await renderer.create(wrapComponent(route));
|
|
61
71
|
});
|
|
@@ -194,7 +194,6 @@ describe('test DeviceDetail', () => {
|
|
|
194
194
|
useLayoutEffectSpy.mockImplementation(() => setState);
|
|
195
195
|
mock.reset();
|
|
196
196
|
mockedNavigate.mockClear();
|
|
197
|
-
watchMultiConfigs.mockReset();
|
|
198
197
|
});
|
|
199
198
|
|
|
200
199
|
it('render DeviceDetail render SensorDisplayItem', async () => {
|
|
@@ -814,65 +813,6 @@ describe('test DeviceDetail', () => {
|
|
|
814
813
|
el.props.accessibilityLabel === AccessibilityLabel.SENSOR_DISPLAY_ITEM
|
|
815
814
|
);
|
|
816
815
|
expect(sensorDisplayItem.length).toEqual(1);
|
|
817
|
-
expect(watchMultiConfigs).
|
|
818
|
-
});
|
|
819
|
-
|
|
820
|
-
it('watch action config', async () => {
|
|
821
|
-
mock.onGet(API.CHIP.JSON_CONFIGURATION).reply(200, []);
|
|
822
|
-
const responseDisplay = {
|
|
823
|
-
items: [
|
|
824
|
-
{
|
|
825
|
-
id: 1,
|
|
826
|
-
order: 0,
|
|
827
|
-
template: 'on_off_button_action_template',
|
|
828
|
-
type: 'on_off_button_action_template',
|
|
829
|
-
configuration: {
|
|
830
|
-
config: 2,
|
|
831
|
-
},
|
|
832
|
-
},
|
|
833
|
-
],
|
|
834
|
-
};
|
|
835
|
-
const responseDisplayValueV2 = {
|
|
836
|
-
configs: [{ id: 2 }],
|
|
837
|
-
is_connected: true,
|
|
838
|
-
last_updated: '2021-01-24T12:00:00.000Z',
|
|
839
|
-
};
|
|
840
|
-
mockAxios(responseDisplay, responseDisplayValueV2);
|
|
841
|
-
await act(async () => {
|
|
842
|
-
tree = await create(wrapComponent(store, account, route));
|
|
843
|
-
});
|
|
844
|
-
|
|
845
|
-
expect(watchMultiConfigs).toHaveBeenCalledWith([2]);
|
|
846
|
-
});
|
|
847
|
-
|
|
848
|
-
it('watch stages grid action config', async () => {
|
|
849
|
-
mock.onGet(API.CHIP.JSON_CONFIGURATION).reply(200, []);
|
|
850
|
-
const responseDisplay = {
|
|
851
|
-
items: [
|
|
852
|
-
{
|
|
853
|
-
id: 1,
|
|
854
|
-
order: 0,
|
|
855
|
-
template: 'StatesGridActionTemplate',
|
|
856
|
-
configuration: {
|
|
857
|
-
options: [
|
|
858
|
-
{
|
|
859
|
-
config: 3,
|
|
860
|
-
},
|
|
861
|
-
],
|
|
862
|
-
},
|
|
863
|
-
},
|
|
864
|
-
],
|
|
865
|
-
};
|
|
866
|
-
const responseDisplayValueV2 = {
|
|
867
|
-
configs: [{ id: 2 }],
|
|
868
|
-
is_connected: true,
|
|
869
|
-
last_updated: '2021-01-24T12:00:00.000Z',
|
|
870
|
-
};
|
|
871
|
-
mockAxios(responseDisplay, responseDisplayValueV2);
|
|
872
|
-
await act(async () => {
|
|
873
|
-
tree = await create(wrapComponent(store, account, route));
|
|
874
|
-
});
|
|
875
|
-
|
|
876
|
-
expect(watchMultiConfigs).toHaveBeenCalledWith([3]);
|
|
816
|
+
expect(watchMultiConfigs).toHaveBeenCalled();
|
|
877
817
|
});
|
|
878
818
|
});
|
|
@@ -5,7 +5,7 @@ import DateTimeRangeChange from '../../../commons/DateTimeRangeChange';
|
|
|
5
5
|
import moment from 'moment';
|
|
6
6
|
|
|
7
7
|
const ChartWrapper = memo(
|
|
8
|
-
({ children, onChangeDate, showTime, isWidgetOrder
|
|
8
|
+
({ children, onChangeDate, showTime, isWidgetOrder }) => {
|
|
9
9
|
const [value, setValue] = useState([
|
|
10
10
|
moment().subtract(6, 'days'),
|
|
11
11
|
moment(),
|
|
@@ -24,20 +24,18 @@ const ChartWrapper = memo(
|
|
|
24
24
|
|
|
25
25
|
return (
|
|
26
26
|
<View>
|
|
27
|
-
{
|
|
28
|
-
<View
|
|
29
|
-
<
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
/>
|
|
38
|
-
</View>
|
|
27
|
+
<View style={styles.headerContainer}>
|
|
28
|
+
<View>
|
|
29
|
+
<DateTimeRangeChange
|
|
30
|
+
startTime={value[0]}
|
|
31
|
+
endTime={value[1]}
|
|
32
|
+
showTime={showTime}
|
|
33
|
+
selectStart={selectStart}
|
|
34
|
+
selectEnd={selectEnd}
|
|
35
|
+
isWidgetOrder={isWidgetOrder}
|
|
36
|
+
/>
|
|
39
37
|
</View>
|
|
40
|
-
|
|
38
|
+
</View>
|
|
41
39
|
{children}
|
|
42
40
|
</View>
|
|
43
41
|
);
|
|
@@ -163,12 +163,7 @@ const groupByOptions = [
|
|
|
163
163
|
{ title: 'Y', data: CHART_GROUP_TYPE.YEAR },
|
|
164
164
|
];
|
|
165
165
|
|
|
166
|
-
const VisualChart = ({
|
|
167
|
-
item,
|
|
168
|
-
isDemo = false,
|
|
169
|
-
isWidgetOrder,
|
|
170
|
-
shouldRenderDate,
|
|
171
|
-
}) => {
|
|
166
|
+
const VisualChart = ({ item, isDemo = false, isWidgetOrder }) => {
|
|
172
167
|
const { configuration = {} } = item;
|
|
173
168
|
const {
|
|
174
169
|
configs = [],
|
|
@@ -307,7 +302,6 @@ const VisualChart = ({
|
|
|
307
302
|
dateFormat={date_format}
|
|
308
303
|
showTime={show_time}
|
|
309
304
|
isWidgetOrder={isWidgetOrder}
|
|
310
|
-
shouldRenderDate
|
|
311
305
|
>
|
|
312
306
|
<Highcharts
|
|
313
307
|
options={options}
|
|
@@ -6,6 +6,7 @@ import { act, create } from 'react-test-renderer';
|
|
|
6
6
|
import VisualChart from '../VisualChart';
|
|
7
7
|
import { API } from '../../../../configs';
|
|
8
8
|
import { getPusher } from '../../../../utils/Pusher';
|
|
9
|
+
import { flushPromises } from '../../../AllGateway/test-utils';
|
|
9
10
|
import api from '../../../../utils/Apis/axios';
|
|
10
11
|
import ChartAggregationOption from '../../../../commons/ChartAggregationOption';
|
|
11
12
|
import DateTimeRangeChange from '../../../../commons/DateTimeRangeChange';
|
|
@@ -135,6 +136,8 @@ describe('Test LinearChartWidget', () => {
|
|
|
135
136
|
});
|
|
136
137
|
});
|
|
137
138
|
|
|
139
|
+
await flushPromises();
|
|
140
|
+
|
|
138
141
|
assertChartData(chart.props.options.series[0].data, [
|
|
139
142
|
[moment(1), 2],
|
|
140
143
|
[moment(3), 4],
|