@eohjsc/react-native-smart-city 0.3.58 → 0.3.60
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 +2 -2
- package/src/Images/Common/loading-circle.json +1 -1
- package/src/Images/DevMode/report.svg +3 -0
- package/src/commons/Header/HeaderCustom.js +5 -1
- package/src/commons/ModalPopupCT/__test__/ModalPopupCT.test.js +68 -0
- package/src/commons/ModalPopupCT/index.js +118 -0
- package/src/commons/ModalPopupCT/styles.js +95 -0
- package/src/configs/API.js +7 -3
- package/src/configs/AccessibilityLabel.js +2 -0
- package/src/configs/Colors.js +2 -0
- package/src/context/actionType.ts +1 -0
- package/src/context/reducer.ts +10 -0
- package/src/screens/AddNewGateway/ConnectingWifiDevice.js +2 -2
- package/src/screens/AddNewGateway/RenameNewDevices.js +32 -24
- package/src/screens/AddNewGateway/SelectDeviceSubUnit.js +3 -3
- package/src/screens/AddNewGateway/ShareWifiPassword.js +19 -23
- package/src/screens/AddNewGateway/__test__/RenameNewDevices.test.js +129 -3
- package/src/screens/AddNewGateway/__test__/SelectDeviceSubUnit.test.js +25 -1
- package/src/screens/AddNewGateway/__test__/ShareWifiPassword.test.js +80 -1
- package/src/screens/Device/components/EmergencyCountdown.js +21 -3
- package/src/screens/Device/components/SensorDisplayItem.js +1 -1
- package/src/screens/Device/detail.js +15 -2
- package/src/screens/Device/hooks/useCountUp.js +0 -1
- package/src/screens/Gateway/DetailConfigActionModbus/index.js +12 -5
- package/src/screens/Gateway/DetailConfigActionModbus/styles.js +3 -0
- package/src/screens/Gateway/DetailConfigActionZigbee/__test__/index.test.js +2 -1
- package/src/screens/Gateway/DetailConfigActionZigbee/index.js +7 -2
- package/src/screens/Gateway/DeviceGatewayInfo/__test__/index.test.js +2 -1
- package/src/screens/Gateway/DeviceGatewayInfo/index.js +3 -1
- package/src/screens/Gateway/DeviceGatewayInfo/styles.js +3 -0
- package/src/screens/Gateway/DeviceModbusDetail/__test__/index.test.js +21 -10
- package/src/screens/Gateway/DeviceModbusDetail/index.js +52 -19
- package/src/screens/Gateway/DeviceZigbeeDetail/__test__/index.test.js +9 -10
- package/src/screens/Gateway/DeviceZigbeeDetail/index.js +40 -18
- package/src/screens/Gateway/GatewayConnectionMethods/__test__/index.test.js +2 -1
- package/src/screens/Gateway/GatewayConnectionMethods/index.js +1 -0
- package/src/screens/Gateway/GatewayDetail/__test__/index.test.js +15 -18
- package/src/screens/Gateway/GatewayDetail/index.js +68 -14
- package/src/screens/Gateway/GatewayInfo/__test__/index.test.js +4 -6
- package/src/screens/Gateway/GatewayInfo/index.js +64 -27
- package/src/screens/Gateway/GatewayInfo/styles.js +3 -0
- package/src/screens/Gateway/__test__/index.test.js +3 -2
- package/src/screens/Gateway/components/Detail/__test__/index.test.js +1 -0
- package/src/screens/Gateway/components/Detail/index.js +16 -1
- package/src/screens/Gateway/components/DetailActionModbus/__test__/index.test.js +2 -1
- package/src/screens/Gateway/components/DetailActionModbus/index.js +6 -1
- package/src/screens/Gateway/components/DetailActionModbus/styles.js +1 -0
- package/src/screens/Gateway/components/GatewayItem/__test__/index.test.js +1 -0
- package/src/screens/Gateway/components/Information/__test__/index.test.js +2 -1
- package/src/screens/Gateway/components/Information/index.js +6 -1
- package/src/screens/Gateway/components/RowItem/__test__/index.test.js +2 -1
- package/src/screens/Gateway/hooks/useGateway.js +18 -1
- package/src/screens/HanetCamera/hooks/__test__/useHanetPlaceMembers.test.js +12 -0
- package/src/screens/HanetCamera/hooks/useHanetPlaceMembers.js +1 -0
- package/src/screens/Template/__test__/EditTemplate.test.js +1 -1
- package/src/screens/Template/__test__/detail.test.js +39 -11
- package/src/screens/Template/__test__/index.test.js +46 -1
- package/src/screens/Template/detail.js +52 -5
- package/src/screens/Template/index.js +16 -7
- package/src/utils/Apis/axios.js +0 -1
- package/src/utils/I18n/translations/en.json +7 -2
- package/src/utils/I18n/translations/vi.json +7 -2
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
import { Colors } from '../../configs';
|
|
3
|
+
|
|
4
|
+
export default StyleSheet.create({
|
|
5
|
+
wrap: {
|
|
6
|
+
flex: 1,
|
|
7
|
+
alignItems: 'center',
|
|
8
|
+
justifyContent: 'center',
|
|
9
|
+
},
|
|
10
|
+
paddingBottom16: {
|
|
11
|
+
paddingBottom: 16,
|
|
12
|
+
},
|
|
13
|
+
modalPopupCT: {
|
|
14
|
+
backgroundColor: Colors.White,
|
|
15
|
+
padding: 24,
|
|
16
|
+
width: 343,
|
|
17
|
+
height: 'auto',
|
|
18
|
+
borderRadius: 16,
|
|
19
|
+
},
|
|
20
|
+
header: {
|
|
21
|
+
alignItems: 'flex-start',
|
|
22
|
+
justifyContent: 'flex-start',
|
|
23
|
+
},
|
|
24
|
+
alert: {
|
|
25
|
+
padding: 16,
|
|
26
|
+
borderRadius: 8,
|
|
27
|
+
borderWidth: 2,
|
|
28
|
+
borderColor: Colors.Orange8,
|
|
29
|
+
backgroundColor: Colors.Orange9,
|
|
30
|
+
flexDirection: 'row',
|
|
31
|
+
alignItems: 'center',
|
|
32
|
+
justifyContent: 'space-between',
|
|
33
|
+
marginBottom: 16,
|
|
34
|
+
},
|
|
35
|
+
viewIconAlert: {
|
|
36
|
+
paddingRight: 16,
|
|
37
|
+
},
|
|
38
|
+
viewTextAlert: {
|
|
39
|
+
flex: 1,
|
|
40
|
+
justifyContent: 'flex-start',
|
|
41
|
+
},
|
|
42
|
+
understand: {
|
|
43
|
+
flexDirection: 'row',
|
|
44
|
+
alignItems: 'center',
|
|
45
|
+
justifyContent: 'space-between',
|
|
46
|
+
paddingBottom: 16,
|
|
47
|
+
},
|
|
48
|
+
viewCheckboxUnderstand: {
|
|
49
|
+
alignItems: 'flex-start',
|
|
50
|
+
paddingRight: 16,
|
|
51
|
+
},
|
|
52
|
+
viewTextUnderstand: {
|
|
53
|
+
flex: 1,
|
|
54
|
+
justifyContent: 'flex-start',
|
|
55
|
+
},
|
|
56
|
+
body: {},
|
|
57
|
+
footer: {
|
|
58
|
+
paddingTop: 16,
|
|
59
|
+
borderTopWidth: 1,
|
|
60
|
+
borderTopColor: Colors.Neutral.Neutral3,
|
|
61
|
+
},
|
|
62
|
+
buttonBottom: {
|
|
63
|
+
flexDirection: 'row',
|
|
64
|
+
alignItems: 'flex-end',
|
|
65
|
+
justifyContent: 'flex-end',
|
|
66
|
+
},
|
|
67
|
+
buttonCancel: {
|
|
68
|
+
alignItems: 'center',
|
|
69
|
+
borderRadius: 8,
|
|
70
|
+
paddingVertical: 8,
|
|
71
|
+
paddingHorizontal: 16,
|
|
72
|
+
paddingTop: 12,
|
|
73
|
+
borderColor: Colors.Neutral.Neutral3,
|
|
74
|
+
borderWidth: 1,
|
|
75
|
+
},
|
|
76
|
+
buttonConfirm: {
|
|
77
|
+
position: 'relative',
|
|
78
|
+
marginLeft: 8,
|
|
79
|
+
alignItems: 'center',
|
|
80
|
+
borderRadius: 8,
|
|
81
|
+
paddingVertical: 8,
|
|
82
|
+
paddingHorizontal: 16,
|
|
83
|
+
paddingTop: 12,
|
|
84
|
+
backgroundColor: Colors.Red,
|
|
85
|
+
},
|
|
86
|
+
disableButton: {
|
|
87
|
+
position: 'absolute',
|
|
88
|
+
top: 0,
|
|
89
|
+
left: 0,
|
|
90
|
+
right: 0,
|
|
91
|
+
bottom: 0,
|
|
92
|
+
backgroundColor: Colors.White,
|
|
93
|
+
opacity: 0.7,
|
|
94
|
+
},
|
|
95
|
+
});
|
package/src/configs/API.js
CHANGED
|
@@ -208,12 +208,16 @@ const API = {
|
|
|
208
208
|
},
|
|
209
209
|
// NOTE: DEV MODE
|
|
210
210
|
DEV_MODE: {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
211
|
+
DASHBOARD: {
|
|
212
|
+
DETAIL: (id) => `/property_manager/iot_dashboard/dev_mode/units/${id}/`,
|
|
213
|
+
GET_TEMPLATES: '/property_manager/iot_dashboard/dev_mode/units/',
|
|
214
|
+
GET_WIDGETS: (templateId) =>
|
|
215
|
+
`/property_manager/iot_dashboard/dev_mode/units/${templateId}/widgets/`,
|
|
216
|
+
},
|
|
214
217
|
GATEWAY: {
|
|
215
218
|
LIST: () => '/chip_manager/developer_mode_chips/',
|
|
216
219
|
DETAIL: (id) => `/chip_manager/developer_mode_chips/${id}/`,
|
|
220
|
+
REBOOT: (id) => `/chip_manager/developer_mode_chips/${id}/reboot_chip/`,
|
|
217
221
|
},
|
|
218
222
|
ZIGBEE: {
|
|
219
223
|
SEARCH_DEVICE: (id) => `/iot/modules/zigbee/chips/${id}/search_device/`,
|
package/src/configs/Colors.js
CHANGED
|
@@ -32,6 +32,7 @@ export const Action = {
|
|
|
32
32
|
PERCENT_LOADED: 'PERCENT_LOADED',
|
|
33
33
|
REFRESH_PERCENT: 'REFRESH_PERCENT',
|
|
34
34
|
PROCESS_DONE: 'PROCESS_DONE',
|
|
35
|
+
IS_EMERGENCY_POPUP: 'IS_EMERGENCY_POPUP',
|
|
35
36
|
// NOTE: DEV MODE
|
|
36
37
|
SET_WIDGET_DRAGGING: 'SET_WIDGET_DRAGGING',
|
|
37
38
|
SET_IS_EDITING_TEMPLATE: 'SET_IS_EDITING_TEMPLATE',
|
package/src/context/reducer.ts
CHANGED
|
@@ -67,6 +67,7 @@ export const initialState = {
|
|
|
67
67
|
notificationData: null,
|
|
68
68
|
popoverAnimating: false,
|
|
69
69
|
isLockWhenPickColor: false,
|
|
70
|
+
isEmergencyPopupScreen: false,
|
|
70
71
|
},
|
|
71
72
|
iot: {
|
|
72
73
|
bluetooth: {
|
|
@@ -427,6 +428,15 @@ export const reducer = (currentState: ContextData, action: Action) => {
|
|
|
427
428
|
},
|
|
428
429
|
};
|
|
429
430
|
|
|
431
|
+
case Action.IS_EMERGENCY_POPUP:
|
|
432
|
+
return {
|
|
433
|
+
...currentState,
|
|
434
|
+
app: {
|
|
435
|
+
...currentState.app,
|
|
436
|
+
isEmergencyPopupScreen: payload,
|
|
437
|
+
},
|
|
438
|
+
};
|
|
439
|
+
|
|
430
440
|
case Action.SET_POPOVER_ANIMATING:
|
|
431
441
|
return {
|
|
432
442
|
...currentState,
|
|
@@ -73,8 +73,8 @@ const ConnectingWifiDevice = ({ route }) => {
|
|
|
73
73
|
|
|
74
74
|
useEffect(() => {
|
|
75
75
|
const unsubscribe = NetInfo.addEventListener((state) => {
|
|
76
|
-
if (state.isConnected
|
|
77
|
-
onReady(channelName);
|
|
76
|
+
if (state.isConnected) {
|
|
77
|
+
channelName && onReady(channelName);
|
|
78
78
|
}
|
|
79
79
|
});
|
|
80
80
|
return () => unsubscribe && unsubscribe();
|
|
@@ -2,6 +2,7 @@ import React, { memo, useCallback, useEffect, useState, useMemo } from 'react';
|
|
|
2
2
|
import { ScrollView, TouchableOpacity, View } from 'react-native';
|
|
3
3
|
import { IconOutline } from '@ant-design/icons-react-native';
|
|
4
4
|
import { CommonActions, useNavigation } from '@react-navigation/native';
|
|
5
|
+
import debounce from 'lodash.debounce';
|
|
5
6
|
|
|
6
7
|
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
7
8
|
import { Colors } from '../../configs';
|
|
@@ -49,37 +50,41 @@ const RenameNewDevices = memo(({ route }) => {
|
|
|
49
50
|
return baseHeight + contentItems * 25;
|
|
50
51
|
}, [addDeviceType, info.sensors]);
|
|
51
52
|
|
|
52
|
-
const
|
|
53
|
-
await axiosPost(API.CHIP.RENAME_DEVICES(info.id), info);
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
screen: Routes.DashboardStack,
|
|
53
|
+
const callApiRenameDevices = useCallback(async () => {
|
|
54
|
+
const { success } = await axiosPost(API.CHIP.RENAME_DEVICES(info.id), info);
|
|
55
|
+
if (success) {
|
|
56
|
+
const resetAction = CommonActions.reset({
|
|
57
|
+
index: 0,
|
|
58
|
+
routes: [
|
|
59
|
+
{
|
|
60
|
+
name: Routes.Main,
|
|
61
61
|
params: {
|
|
62
|
-
screen: Routes.
|
|
62
|
+
screen: Routes.DashboardStack,
|
|
63
|
+
params: {
|
|
64
|
+
screen: Routes.Dashboard,
|
|
65
|
+
},
|
|
63
66
|
},
|
|
64
67
|
},
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
name: Routes.UnitStack,
|
|
68
|
-
params: {
|
|
69
|
-
screen: Routes.UnitDetail,
|
|
68
|
+
{
|
|
69
|
+
name: Routes.UnitStack,
|
|
70
70
|
params: {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
screen: Routes.UnitDetail,
|
|
72
|
+
params: {
|
|
73
|
+
unitId: unit?.id,
|
|
74
|
+
stationId: subUnit?.id,
|
|
75
|
+
isSuccessfullyConnected: true,
|
|
76
|
+
routeName: Routes.DashboardStack,
|
|
77
|
+
},
|
|
75
78
|
},
|
|
76
79
|
},
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
80
|
+
],
|
|
81
|
+
});
|
|
82
|
+
dispatch(resetAction);
|
|
83
|
+
}
|
|
81
84
|
}, [dispatch, info, subUnit?.id, unit?.id]);
|
|
82
85
|
|
|
86
|
+
const onPressDone = debounce(() => callApiRenameDevices(), 2000);
|
|
87
|
+
|
|
83
88
|
useEffect(() => {
|
|
84
89
|
(async () => {
|
|
85
90
|
let params = new URLSearchParams();
|
|
@@ -193,7 +198,10 @@ const RenameNewDevices = memo(({ route }) => {
|
|
|
193
198
|
);
|
|
194
199
|
}
|
|
195
200
|
return (
|
|
196
|
-
<View
|
|
201
|
+
<View
|
|
202
|
+
style={[styles.devicesWrapper, { height: scrollViewHeight }]}
|
|
203
|
+
accessibilityLabel={`${renameLabel}_LIST_ITEM_RENAME`}
|
|
204
|
+
>
|
|
197
205
|
<ScrollView>
|
|
198
206
|
{(info?.sensors || []).map((sensor, sensor_index) =>
|
|
199
207
|
(sensor?.end_devices || []).map((end_device, end_device_index) => (
|
|
@@ -16,19 +16,19 @@ const SelectDeviceSubUnit = ({ route }) => {
|
|
|
16
16
|
case DEVICE_TYPE.WIFI_DEVICE:
|
|
17
17
|
navigation.navigate(Routes.ScanWifiDeviceQR, {
|
|
18
18
|
unit,
|
|
19
|
-
chosenSubUnit,
|
|
19
|
+
subUnit: chosenSubUnit,
|
|
20
20
|
});
|
|
21
21
|
break;
|
|
22
22
|
case DEVICE_TYPE.MODBUS:
|
|
23
23
|
navigation.navigate(Routes.ScanModbusQR, {
|
|
24
24
|
unit,
|
|
25
|
-
chosenSubUnit,
|
|
25
|
+
subUnit: chosenSubUnit,
|
|
26
26
|
});
|
|
27
27
|
break;
|
|
28
28
|
case DEVICE_TYPE.ZIGBEE:
|
|
29
29
|
navigation.navigate(Routes.ConnectRouterGuide, {
|
|
30
30
|
unit,
|
|
31
|
-
chosenSubUnit,
|
|
31
|
+
subUnit: chosenSubUnit,
|
|
32
32
|
});
|
|
33
33
|
break;
|
|
34
34
|
}
|
|
@@ -180,30 +180,26 @@ const ShareWifiPassword = ({ route }) => {
|
|
|
180
180
|
if (dataGateway?.gateway.length > 0) {
|
|
181
181
|
let currentSSID;
|
|
182
182
|
checkWifiInterval = setInterval(async () => {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
} catch (e) {
|
|
204
|
-
return;
|
|
183
|
+
currentSSID = await getCurrentWifiSSID();
|
|
184
|
+
if (currentSSID !== wifiOrGatewaySSID) {
|
|
185
|
+
clearInterval(checkWifiInterval);
|
|
186
|
+
setIsShowPopupPassword(false);
|
|
187
|
+
setIsDisabled(false);
|
|
188
|
+
socket?.close();
|
|
189
|
+
socket = null;
|
|
190
|
+
navigate(Routes.ConnectingWifiDevice, {
|
|
191
|
+
unit,
|
|
192
|
+
subUnit: subUnit ? subUnit : { id: stationId },
|
|
193
|
+
gateway: dataGateway.gateway[0],
|
|
194
|
+
qrData: qrData,
|
|
195
|
+
selectedWifi: {
|
|
196
|
+
ssid: selectedWifi,
|
|
197
|
+
password: selectedWifiPassword,
|
|
198
|
+
},
|
|
199
|
+
addDeviceType,
|
|
200
|
+
});
|
|
205
201
|
}
|
|
206
|
-
},
|
|
202
|
+
}, 800);
|
|
207
203
|
}
|
|
208
204
|
}
|
|
209
205
|
return () => {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { TouchableOpacity } from 'react-native';
|
|
2
3
|
import { act, create } from 'react-test-renderer';
|
|
3
4
|
import MockAdapter from 'axios-mock-adapter';
|
|
5
|
+
|
|
4
6
|
import RenameNewDevices from '../RenameNewDevices';
|
|
5
7
|
import { SCProvider } from '../../../context';
|
|
6
8
|
import { mockSCStore } from '../../../context/mockStore';
|
|
@@ -8,7 +10,7 @@ import api from '../../../utils/Apis/axios';
|
|
|
8
10
|
import AccessibilityLabel from '../../../configs/AccessibilityLabel';
|
|
9
11
|
import Text from '../../../commons/Text';
|
|
10
12
|
import _TextInput from '../../../commons/Form/TextInput';
|
|
11
|
-
import
|
|
13
|
+
import API from '../../../configs/API';
|
|
12
14
|
|
|
13
15
|
const wrapComponent = (route) => (
|
|
14
16
|
<SCProvider initState={mockSCStore({})}>
|
|
@@ -20,6 +22,9 @@ const mock = new MockAdapter(api.axiosInstance);
|
|
|
20
22
|
|
|
21
23
|
const mockedNavigate = jest.fn();
|
|
22
24
|
const mockedGoBack = jest.fn();
|
|
25
|
+
const mockedDispatch = jest.fn();
|
|
26
|
+
|
|
27
|
+
jest.mock('lodash.debounce', () => jest.fn((fn) => fn));
|
|
23
28
|
|
|
24
29
|
jest.mock('@react-navigation/native', () => {
|
|
25
30
|
return {
|
|
@@ -27,6 +32,7 @@ jest.mock('@react-navigation/native', () => {
|
|
|
27
32
|
useNavigation: () => ({
|
|
28
33
|
navigate: mockedNavigate,
|
|
29
34
|
goBack: mockedGoBack,
|
|
35
|
+
dispatch: mockedDispatch,
|
|
30
36
|
}),
|
|
31
37
|
};
|
|
32
38
|
});
|
|
@@ -34,6 +40,13 @@ jest.mock('@react-navigation/native', () => {
|
|
|
34
40
|
describe('Test rename new devices', () => {
|
|
35
41
|
let tree;
|
|
36
42
|
let route;
|
|
43
|
+
const listItemComponent = (instance) => {
|
|
44
|
+
return instance.find(
|
|
45
|
+
(el) =>
|
|
46
|
+
el.props.accessibilityLabel ===
|
|
47
|
+
`${AccessibilityLabel.CONNECTED_DEVICE_RENAME_DEVICE}_LIST_ITEM_RENAME`
|
|
48
|
+
);
|
|
49
|
+
};
|
|
37
50
|
const onPressToRename = async (instance) => {
|
|
38
51
|
const button = instance.findAll(
|
|
39
52
|
(el) =>
|
|
@@ -112,10 +125,11 @@ describe('Test rename new devices', () => {
|
|
|
112
125
|
expect(mock.history.get).toHaveLength(1);
|
|
113
126
|
});
|
|
114
127
|
|
|
115
|
-
it('rendering end
|
|
128
|
+
it('rendering one end device', async () => {
|
|
116
129
|
route = {
|
|
117
130
|
params: {
|
|
118
131
|
unitId: 1,
|
|
132
|
+
sensorId: 1,
|
|
119
133
|
stationId: 2,
|
|
120
134
|
chipId: 3,
|
|
121
135
|
qrData: {},
|
|
@@ -144,7 +158,91 @@ describe('Test rename new devices', () => {
|
|
|
144
158
|
tree = await create(wrapComponent(route));
|
|
145
159
|
});
|
|
146
160
|
const instance = tree.root;
|
|
147
|
-
|
|
161
|
+
expect(listItemComponent(instance).props.style[1].height).toEqual(90);
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
it('rendering two end device', async () => {
|
|
165
|
+
route = {
|
|
166
|
+
params: {
|
|
167
|
+
unitId: 1,
|
|
168
|
+
sensorId: 1,
|
|
169
|
+
stationId: 2,
|
|
170
|
+
chipId: 3,
|
|
171
|
+
qrData: {},
|
|
172
|
+
addDeviceType: 'wifi',
|
|
173
|
+
},
|
|
174
|
+
};
|
|
175
|
+
mock.onGet().reply(200, {
|
|
176
|
+
id: 1,
|
|
177
|
+
name: 'chip',
|
|
178
|
+
can_rename: true,
|
|
179
|
+
sensors: [
|
|
180
|
+
{
|
|
181
|
+
id: 1,
|
|
182
|
+
name: 'sensor',
|
|
183
|
+
end_devices: [
|
|
184
|
+
{
|
|
185
|
+
id: 1,
|
|
186
|
+
name: 'end_device',
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
id: 2,
|
|
190
|
+
name: 'end_device',
|
|
191
|
+
},
|
|
192
|
+
],
|
|
193
|
+
},
|
|
194
|
+
],
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
await act(async () => {
|
|
198
|
+
tree = await create(wrapComponent(route));
|
|
199
|
+
});
|
|
200
|
+
const instance = tree.root;
|
|
201
|
+
expect(listItemComponent(instance).props.style[1].height).toEqual(180);
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
it('rendering three end device', async () => {
|
|
205
|
+
route = {
|
|
206
|
+
params: {
|
|
207
|
+
unitId: 1,
|
|
208
|
+
sensorId: 1,
|
|
209
|
+
stationId: 2,
|
|
210
|
+
chipId: 3,
|
|
211
|
+
qrData: {},
|
|
212
|
+
addDeviceType: 'wifi',
|
|
213
|
+
},
|
|
214
|
+
};
|
|
215
|
+
mock.onGet().reply(200, {
|
|
216
|
+
id: 1,
|
|
217
|
+
name: 'chip',
|
|
218
|
+
can_rename: true,
|
|
219
|
+
sensors: [
|
|
220
|
+
{
|
|
221
|
+
id: 1,
|
|
222
|
+
name: 'sensor',
|
|
223
|
+
end_devices: [
|
|
224
|
+
{
|
|
225
|
+
id: 1,
|
|
226
|
+
name: 'end_device',
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
id: 2,
|
|
230
|
+
name: 'end_device',
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
id: 3,
|
|
234
|
+
name: 'end_device',
|
|
235
|
+
},
|
|
236
|
+
],
|
|
237
|
+
},
|
|
238
|
+
],
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
await act(async () => {
|
|
242
|
+
tree = await create(wrapComponent(route));
|
|
243
|
+
});
|
|
244
|
+
const instance = tree.root;
|
|
245
|
+
expect(listItemComponent(instance).props.style[1].height).toEqual(270);
|
|
148
246
|
});
|
|
149
247
|
|
|
150
248
|
it('render rename chip', async () => {
|
|
@@ -273,6 +371,7 @@ describe('Test rename new devices', () => {
|
|
|
273
371
|
el.props.accessibilityLabel === AccessibilityLabel.BUTTON_DONE &&
|
|
274
372
|
el.type === TouchableOpacity
|
|
275
373
|
);
|
|
374
|
+
mock.onPost(API.CHIP.RENAME_DEVICES(1)).reply(200);
|
|
276
375
|
|
|
277
376
|
await act(async () => {
|
|
278
377
|
doneButton.props.onPress();
|
|
@@ -297,5 +396,32 @@ describe('Test rename new devices', () => {
|
|
|
297
396
|
],
|
|
298
397
|
})
|
|
299
398
|
);
|
|
399
|
+
expect(mockedDispatch).toBeCalledWith({
|
|
400
|
+
payload: {
|
|
401
|
+
index: 0,
|
|
402
|
+
routes: [
|
|
403
|
+
{
|
|
404
|
+
name: 'Main',
|
|
405
|
+
params: {
|
|
406
|
+
params: { screen: 'Dashboard' },
|
|
407
|
+
screen: 'DashboardStack',
|
|
408
|
+
},
|
|
409
|
+
},
|
|
410
|
+
{
|
|
411
|
+
name: 'UnitStack',
|
|
412
|
+
params: {
|
|
413
|
+
params: {
|
|
414
|
+
isSuccessfullyConnected: true,
|
|
415
|
+
routeName: 'DashboardStack',
|
|
416
|
+
stationId: undefined,
|
|
417
|
+
unitId: undefined,
|
|
418
|
+
},
|
|
419
|
+
screen: 'UnitDetail',
|
|
420
|
+
},
|
|
421
|
+
},
|
|
422
|
+
],
|
|
423
|
+
},
|
|
424
|
+
type: 'RESET',
|
|
425
|
+
});
|
|
300
426
|
});
|
|
301
427
|
});
|
|
@@ -33,7 +33,7 @@ describe('Test SelectSubUnit', () => {
|
|
|
33
33
|
});
|
|
34
34
|
let tree;
|
|
35
35
|
|
|
36
|
-
it('test ViewButtonBottom onRightClick', async () => {
|
|
36
|
+
it('test ViewButtonBottom onRightClick WIFI_DEVICE', async () => {
|
|
37
37
|
const route = { params: { deviceType: DEVICE_TYPE.WIFI_DEVICE } };
|
|
38
38
|
await act(async () => {
|
|
39
39
|
tree = renderer.create(wrapComponent(route));
|
|
@@ -45,4 +45,28 @@ describe('Test SelectSubUnit', () => {
|
|
|
45
45
|
});
|
|
46
46
|
expect(mockedNavigate).toHaveBeenCalled();
|
|
47
47
|
});
|
|
48
|
+
it('test ViewButtonBottom onRightClick MODBUS', async () => {
|
|
49
|
+
const route = { params: { deviceType: DEVICE_TYPE.MODBUS } };
|
|
50
|
+
await act(async () => {
|
|
51
|
+
tree = renderer.create(wrapComponent(route));
|
|
52
|
+
});
|
|
53
|
+
const instance = tree.root;
|
|
54
|
+
const viewButtonBottom = instance.findByType(ViewButtonBottom);
|
|
55
|
+
await act(async () => {
|
|
56
|
+
viewButtonBottom.props.onRightClick();
|
|
57
|
+
});
|
|
58
|
+
expect(mockedNavigate).toHaveBeenCalled();
|
|
59
|
+
});
|
|
60
|
+
it('test ViewButtonBottom onRightClick ZIGBEE', async () => {
|
|
61
|
+
const route = { params: { deviceType: DEVICE_TYPE.ZIGBEE } };
|
|
62
|
+
await act(async () => {
|
|
63
|
+
tree = renderer.create(wrapComponent(route));
|
|
64
|
+
});
|
|
65
|
+
const instance = tree.root;
|
|
66
|
+
const viewButtonBottom = instance.findByType(ViewButtonBottom);
|
|
67
|
+
await act(async () => {
|
|
68
|
+
viewButtonBottom.props.onRightClick();
|
|
69
|
+
});
|
|
70
|
+
expect(mockedNavigate).toHaveBeenCalled();
|
|
71
|
+
});
|
|
48
72
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import renderer, { act } from 'react-test-renderer';
|
|
3
|
-
import { Platform } from 'react-native';
|
|
3
|
+
import { Platform, TouchableOpacity } from 'react-native';
|
|
4
4
|
import dgram from 'react-native-udp';
|
|
5
5
|
import Toast from 'react-native-toast-message';
|
|
6
6
|
import WifiManager from 'react-native-wifi-reborn';
|
|
@@ -11,6 +11,8 @@ import { mockSCStore } from '../../../context/mockStore';
|
|
|
11
11
|
import ButtonPopup from '../../../commons/ButtonPopup';
|
|
12
12
|
import TextInputPassword from '../../../commons/Form/TextInputPassword';
|
|
13
13
|
import Routes from '../../../utils/Route';
|
|
14
|
+
import { AccessibilityLabel } from '../../../configs/Constants';
|
|
15
|
+
import { HeaderCustom } from '../../../commons/Header';
|
|
14
16
|
|
|
15
17
|
const mockedGoBack = jest.fn();
|
|
16
18
|
const mockedNavigate = jest.fn();
|
|
@@ -152,4 +154,81 @@ describe('test share wifi password', () => {
|
|
|
152
154
|
Routes.ConnectingWifiDevice
|
|
153
155
|
);
|
|
154
156
|
});
|
|
157
|
+
it('render list wifi onPress item and cancel popup item', async () => {
|
|
158
|
+
jest.runOnlyPendingTimers();
|
|
159
|
+
jest.useFakeTimers();
|
|
160
|
+
Platform.OS = 'android';
|
|
161
|
+
const route = {
|
|
162
|
+
params: {
|
|
163
|
+
prefix: 'robot',
|
|
164
|
+
wifiList: [{ id: 1, ssid: 'wifi1' }],
|
|
165
|
+
stationId: 1,
|
|
166
|
+
subUnit: { id: 1, name: 'subUnit' },
|
|
167
|
+
unitId: 1,
|
|
168
|
+
},
|
|
169
|
+
};
|
|
170
|
+
await act(async () => {
|
|
171
|
+
tree = await renderer.create(wrapComponent(route));
|
|
172
|
+
});
|
|
173
|
+
const itemWifi = tree.root.find(
|
|
174
|
+
(el) =>
|
|
175
|
+
el.type === TouchableOpacity &&
|
|
176
|
+
el.props.accessibilityLabel === AccessibilityLabel.SELECT_WIFI + 'wifi1'
|
|
177
|
+
);
|
|
178
|
+
const buttonPopup = tree.root.find(
|
|
179
|
+
(el) =>
|
|
180
|
+
el.props.accessibilityLabel ===
|
|
181
|
+
AccessibilityLabel.GATEWAY_WIFI_LIST.BUTTON_POPUP
|
|
182
|
+
);
|
|
183
|
+
expect(buttonPopup.props.visible).toEqual(false);
|
|
184
|
+
await act(async () => {
|
|
185
|
+
await itemWifi.props.onPress();
|
|
186
|
+
});
|
|
187
|
+
expect(buttonPopup.props.visible).toEqual(true);
|
|
188
|
+
expect(
|
|
189
|
+
itemWifi.props.children.props.children[0].props.children.props.children
|
|
190
|
+
).toEqual('wifi1');
|
|
191
|
+
await act(async () => {
|
|
192
|
+
await buttonPopup.props.onPressSecondary();
|
|
193
|
+
});
|
|
194
|
+
expect(buttonPopup.props.visible).toEqual(false);
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
it('render headerCustom handle goback', async () => {
|
|
198
|
+
jest.useFakeTimers();
|
|
199
|
+
Platform.OS = 'android';
|
|
200
|
+
const route = {
|
|
201
|
+
params: { prefix: 'robot', wifiList: [{ id: 1, ssid: 'wifi1' }] },
|
|
202
|
+
};
|
|
203
|
+
await act(async () => {
|
|
204
|
+
tree = await renderer.create(wrapComponent(route));
|
|
205
|
+
});
|
|
206
|
+
const headerCustom = tree.root.find((el) => el.type === HeaderCustom);
|
|
207
|
+
const buttonPopup = tree.root.find(
|
|
208
|
+
(el) =>
|
|
209
|
+
el.props.accessibilityLabel ===
|
|
210
|
+
AccessibilityLabel.GATEWAY_WIFI_LIST.BUTTON_POPUP
|
|
211
|
+
);
|
|
212
|
+
const socket = dgram.createSocket({});
|
|
213
|
+
socket.on.mockClear();
|
|
214
|
+
socket.close.mockClear();
|
|
215
|
+
socket.send.mockClear();
|
|
216
|
+
|
|
217
|
+
await act(async () => {
|
|
218
|
+
await buttonPopup.props.onPressMain();
|
|
219
|
+
});
|
|
220
|
+
jest.runOnlyPendingTimers();
|
|
221
|
+
await act(async () => {
|
|
222
|
+
await headerCustom.props.onGoBack();
|
|
223
|
+
});
|
|
224
|
+
expect(socket.close).toBeCalled();
|
|
225
|
+
expect(mockedNavigate).toBeCalledWith('ConnectingWifiGuide', {
|
|
226
|
+
addDeviceType: undefined,
|
|
227
|
+
isBackFromOtherScreen: true,
|
|
228
|
+
qrData: undefined,
|
|
229
|
+
stationId: undefined,
|
|
230
|
+
subUnit: undefined,
|
|
231
|
+
unitId: undefined,
|
|
232
|
+
});
|
|
233
|
+
});
|
|
155
234
|
});
|