@eohjsc/react-native-smart-city 0.3.41 → 0.3.42
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/src/commons/AlertAction/index.js +22 -5
- package/src/commons/Device/FlatListItems.js +1 -1
- package/src/commons/Device/PMSensor/PMSensorIndicatior.js +1 -1
- package/src/commons/Device/WindSpeed/Anemometer/index.js +21 -17
- package/src/commons/OneTapTemplate/__test__/OptionsDropdownActionTemplate.test.js +1 -1
- package/src/commons/Processing/__test__/Connecting.test.js +1 -1
- package/src/commons/Processing/index.js +60 -6
- package/src/commons/Processing/styles.js +19 -0
- package/src/commons/SubUnit/ShortDetail.js +3 -4
- package/src/commons/SubUnit/__test__/ShortDetail.test.js +1 -2
- package/src/commons/UnitSummary/ConfigHistoryChart/index.js +5 -2
- package/src/configs/AccessibilityLabel.js +1 -0
- package/src/hooks/Explore/useKeyboardAnimated.js +13 -22
- package/src/hooks/IoT/__test__/useRemoteControl.test.js +1 -1
- package/src/hooks/IoT/useRemoteControl.js +9 -2
- package/src/iot/RemoteControl/HomeAssistant.js +1 -1
- package/src/screens/AddNewGateway/ConnectingDevice.js +24 -7
- package/src/screens/AddNewGateway/ConnectingModbusDevice.js +42 -20
- package/src/screens/AddNewGateway/ConnectingWifiDevice.js +24 -30
- package/src/screens/AddNewGateway/ConnectingWifiGuide.js +3 -3
- package/src/screens/AddNewGateway/ConnectingZigbeeDevice.js +4 -5
- package/src/screens/AddNewGateway/PlugAndPlay/ConnectRouterGuide.js +7 -7
- package/src/screens/AddNewGateway/PlugAndPlay/__test__/ConnectRouterGuide.test.js +69 -0
- package/src/screens/AddNewGateway/PlugAndPlay/__test__/ZigbeeDeviceConnectGuide.test.js +71 -0
- package/src/screens/AddNewGateway/RenameNewDevices.js +6 -12
- package/src/screens/AddNewGateway/ScanModbusQR.js +9 -5
- package/src/screens/AddNewGateway/ScanWifiDeviceQR.js +3 -3
- package/src/screens/AddNewGateway/SelectDeviceSubUnit.js +4 -7
- package/src/screens/AddNewGateway/SelectDeviceType.js +18 -19
- package/src/screens/AddNewGateway/SelectModbusGateway.js +5 -8
- package/src/screens/AddNewGateway/SelectZigbeeGateway.js +3 -4
- package/src/screens/AddNewGateway/ShareWifiPassword.js +13 -4
- package/src/screens/AddNewGateway/__test__/ConnectingWifiDevice.test.js +5 -1
- package/src/screens/AddNewGateway/__test__/ConnectingWifiGuide.test.js +6 -2
- package/src/screens/AddNewGateway/__test__/ConnectingZigbeeDevice.test.js +8 -4
- package/src/screens/AddNewGateway/__test__/RenameNewDevices.test.js +64 -0
- package/src/screens/AddNewGateway/__test__/SelectDeviceType.test.js +3 -1
- package/src/screens/AddNewGateway/__test__/SelectModbusGateway.test.js +6 -2
- package/src/screens/AddNewGateway/__test__/SelectZigbeeGateway.test.js +6 -2
- package/src/screens/Device/EditDevice/index.js +4 -8
- package/src/screens/Explore/index.js +22 -7
- package/src/screens/HanetCamera/MemberInfo.js +4 -8
- package/src/screens/ScriptDetail/index.js +3 -8
- package/src/screens/SubUnit/EditSubUnit.js +22 -41
- package/src/screens/SubUnit/__test__/EditSubUnit.test.js +51 -59
- package/src/screens/Unit/ManageUnit.js +25 -47
- package/src/screens/Unit/ManageUnitStyles.js +0 -4
- package/src/screens/Unit/__test__/ManageUnit.test.js +6 -14
- package/src/utils/I18n/translations/en.json +8 -2
- package/src/utils/I18n/translations/vi.json +8 -2
- package/src/hooks/Common/useKeyboardShowTranslation.js +0 -120
- package/src/utils/runTiming.js +0 -52
|
@@ -41,10 +41,13 @@ describe('Test connecting wifi device', () => {
|
|
|
41
41
|
});
|
|
42
42
|
|
|
43
43
|
beforeEach(() => {
|
|
44
|
+
jest.useFakeTimers();
|
|
44
45
|
route = {
|
|
45
46
|
params: {
|
|
46
47
|
unitId: 1,
|
|
47
|
-
|
|
48
|
+
subUnit: {
|
|
49
|
+
id: 2,
|
|
50
|
+
},
|
|
48
51
|
gateway: {},
|
|
49
52
|
qrData: {},
|
|
50
53
|
selectedWifi: {},
|
|
@@ -58,6 +61,7 @@ describe('Test connecting wifi device', () => {
|
|
|
58
61
|
});
|
|
59
62
|
const instance = tree.root;
|
|
60
63
|
expect(instance.findAllByType(Processing)).toHaveLength(1);
|
|
64
|
+
jest.runAllTimers();
|
|
61
65
|
expect(mock.history.post).toHaveLength(1);
|
|
62
66
|
});
|
|
63
67
|
});
|
|
@@ -177,7 +177,9 @@ describe('test share wifi password', () => {
|
|
|
177
177
|
params: {
|
|
178
178
|
qrData: { org_slug: 'eoh', prefix: 'robot' },
|
|
179
179
|
unitId: 1,
|
|
180
|
-
|
|
180
|
+
subUnit: {
|
|
181
|
+
id: 1,
|
|
182
|
+
},
|
|
181
183
|
},
|
|
182
184
|
};
|
|
183
185
|
await act(async () => {
|
|
@@ -201,7 +203,9 @@ describe('test share wifi password', () => {
|
|
|
201
203
|
|
|
202
204
|
expect(mockedNavigate).toBeCalledWith('ShareWifiPassword', {
|
|
203
205
|
unitId: 1,
|
|
204
|
-
|
|
206
|
+
subUnit: {
|
|
207
|
+
id: 1,
|
|
208
|
+
},
|
|
205
209
|
wifiList: [{ ssid: 'wifi 1' }, { ssid: 'wifi.2' }],
|
|
206
210
|
qrData: { org_slug: 'eoh', prefix: 'robot' },
|
|
207
211
|
});
|
|
@@ -47,8 +47,10 @@ describe('Test connecting modbus device', () => {
|
|
|
47
47
|
route = {
|
|
48
48
|
params: {
|
|
49
49
|
unitId: 1,
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
subUnit: {
|
|
51
|
+
id: 2,
|
|
52
|
+
station: 'Station 2',
|
|
53
|
+
},
|
|
52
54
|
chipId: 3,
|
|
53
55
|
qrData: {},
|
|
54
56
|
},
|
|
@@ -84,8 +86,10 @@ describe('Test connecting modbus device', () => {
|
|
|
84
86
|
expect(mockedNavigate).toHaveBeenCalledWith(Routes.RenameNewDevices, {
|
|
85
87
|
addDeviceType: undefined,
|
|
86
88
|
unitId: 1,
|
|
87
|
-
|
|
88
|
-
|
|
89
|
+
subUnit: {
|
|
90
|
+
id: 2,
|
|
91
|
+
station: 'Station 2',
|
|
92
|
+
},
|
|
89
93
|
chipId: 3,
|
|
90
94
|
sensorId: 1,
|
|
91
95
|
});
|
|
@@ -207,4 +207,68 @@ describe('Test rename new devices', () => {
|
|
|
207
207
|
})
|
|
208
208
|
);
|
|
209
209
|
});
|
|
210
|
+
|
|
211
|
+
it('update end device name', async () => {
|
|
212
|
+
mock.onGet().reply(200, {
|
|
213
|
+
id: 1,
|
|
214
|
+
can_rename: true,
|
|
215
|
+
sensors: [
|
|
216
|
+
{
|
|
217
|
+
id: 1,
|
|
218
|
+
name: 'sensor',
|
|
219
|
+
end_devices: [
|
|
220
|
+
{
|
|
221
|
+
id: 1,
|
|
222
|
+
name: 'end_device',
|
|
223
|
+
},
|
|
224
|
+
],
|
|
225
|
+
},
|
|
226
|
+
],
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
await act(async () => {
|
|
230
|
+
tree = await create(wrapComponent(route));
|
|
231
|
+
});
|
|
232
|
+
const instance = tree.root;
|
|
233
|
+
|
|
234
|
+
const chipNameField = instance.find(
|
|
235
|
+
(el) =>
|
|
236
|
+
el.props.accessibilityLabel ===
|
|
237
|
+
`${AccessibilityLabel.CONNECTED_DEVICE_RENAME_DEVICE}-end_device-1` &&
|
|
238
|
+
el.type === _TextInput
|
|
239
|
+
);
|
|
240
|
+
await act(async () => {
|
|
241
|
+
chipNameField.props.onChange('new name');
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
const doneButton = instance.find(
|
|
245
|
+
(el) =>
|
|
246
|
+
el.props.accessibilityLabel === AccessibilityLabel.BUTTON_DONE &&
|
|
247
|
+
el.type === TouchableOpacity
|
|
248
|
+
);
|
|
249
|
+
|
|
250
|
+
await act(async () => {
|
|
251
|
+
doneButton.props.onPress();
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
expect(mock.history.post).toHaveLength(1);
|
|
255
|
+
expect(mock.history.post[0].data).toEqual(
|
|
256
|
+
JSON.stringify({
|
|
257
|
+
id: 1,
|
|
258
|
+
can_rename: true,
|
|
259
|
+
sensors: [
|
|
260
|
+
{
|
|
261
|
+
id: 1,
|
|
262
|
+
name: 'sensor',
|
|
263
|
+
end_devices: [
|
|
264
|
+
{
|
|
265
|
+
id: 1,
|
|
266
|
+
name: 'new name',
|
|
267
|
+
},
|
|
268
|
+
],
|
|
269
|
+
},
|
|
270
|
+
],
|
|
271
|
+
})
|
|
272
|
+
);
|
|
273
|
+
});
|
|
210
274
|
});
|
|
@@ -43,7 +43,9 @@ describe('Test select modbus gateway', () => {
|
|
|
43
43
|
route = {
|
|
44
44
|
params: {
|
|
45
45
|
unitId: 1,
|
|
46
|
-
|
|
46
|
+
subUnit: {
|
|
47
|
+
id: 2,
|
|
48
|
+
},
|
|
47
49
|
},
|
|
48
50
|
};
|
|
49
51
|
});
|
|
@@ -70,7 +72,9 @@ describe('Test select modbus gateway', () => {
|
|
|
70
72
|
|
|
71
73
|
expect(mockedNavigate).toBeCalledWith(Routes.ConnectingModbusDevice, {
|
|
72
74
|
unitId: 1,
|
|
73
|
-
|
|
75
|
+
subUnit: {
|
|
76
|
+
id: 2,
|
|
77
|
+
},
|
|
74
78
|
chipId: 3,
|
|
75
79
|
});
|
|
76
80
|
});
|
|
@@ -43,7 +43,9 @@ describe('Test select zigbee gateway', () => {
|
|
|
43
43
|
route = {
|
|
44
44
|
params: {
|
|
45
45
|
unitId: 1,
|
|
46
|
-
|
|
46
|
+
subUnit: {
|
|
47
|
+
id: 2,
|
|
48
|
+
},
|
|
47
49
|
},
|
|
48
50
|
};
|
|
49
51
|
});
|
|
@@ -70,7 +72,9 @@ describe('Test select zigbee gateway', () => {
|
|
|
70
72
|
|
|
71
73
|
expect(mockedNavigate).toBeCalledWith(Routes.ZigbeeDeviceConnectGuide, {
|
|
72
74
|
unitId: 1,
|
|
73
|
-
|
|
75
|
+
subUnit: {
|
|
76
|
+
id: 2,
|
|
77
|
+
},
|
|
74
78
|
chipId: 3,
|
|
75
79
|
});
|
|
76
80
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { memo, useState, useCallback } from 'react';
|
|
2
|
-
import { View, TouchableOpacity
|
|
2
|
+
import { View, TouchableOpacity } from 'react-native';
|
|
3
3
|
import { useTranslations } from '../../../hooks/Common/useTranslations';
|
|
4
4
|
import { HeaderCustom } from '../../../commons/Header';
|
|
5
5
|
import { IconOutline } from '@ant-design/icons-react-native';
|
|
@@ -72,12 +72,8 @@ const EditDevice = memo(() => {
|
|
|
72
72
|
}
|
|
73
73
|
}, [stateAlertAction.isDelete, deleteSensor, renameSensor]);
|
|
74
74
|
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
ios: {
|
|
78
|
-
marginBottom: transY,
|
|
79
|
-
},
|
|
80
|
-
});
|
|
75
|
+
const transY = useKeyboardAnimated();
|
|
76
|
+
|
|
81
77
|
return (
|
|
82
78
|
<View style={styles.wrap}>
|
|
83
79
|
<HeaderCustom title={t('edit_device')} isShowSeparator />
|
|
@@ -130,7 +126,7 @@ const EditDevice = memo(() => {
|
|
|
130
126
|
leftButtonClick={hideAlertAction}
|
|
131
127
|
rightButtonTitle={stateAlertAction.rightButton}
|
|
132
128
|
rightButtonClick={handleRenameOrDelete}
|
|
133
|
-
|
|
129
|
+
transY={transY}
|
|
134
130
|
>
|
|
135
131
|
{!stateAlertAction.isDelete && (
|
|
136
132
|
<_TextInput
|
|
@@ -5,8 +5,10 @@ import {
|
|
|
5
5
|
StyleSheet,
|
|
6
6
|
ScrollView,
|
|
7
7
|
FlatList,
|
|
8
|
+
Animated,
|
|
9
|
+
Platform,
|
|
10
|
+
Easing,
|
|
8
11
|
} from 'react-native';
|
|
9
|
-
import Animated from 'react-native-reanimated';
|
|
10
12
|
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
11
13
|
|
|
12
14
|
import { API, Colors } from '../../configs';
|
|
@@ -27,11 +29,8 @@ let page = 1;
|
|
|
27
29
|
const Explore = ({ navigation }) => {
|
|
28
30
|
const t = useTranslations();
|
|
29
31
|
useBlockBackAndroid();
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
const animatedStyle = {
|
|
33
|
-
marginBottom: transY,
|
|
34
|
-
};
|
|
32
|
+
const transY = useKeyboard(80);
|
|
33
|
+
const [keyboardAnim] = useState(new Animated.Value(transY));
|
|
35
34
|
|
|
36
35
|
useSCContextSelector((state) => state.language);
|
|
37
36
|
|
|
@@ -122,9 +121,25 @@ const Explore = ({ navigation }) => {
|
|
|
122
121
|
}
|
|
123
122
|
};
|
|
124
123
|
|
|
124
|
+
useEffect(() => {
|
|
125
|
+
Animated.timing(keyboardAnim, {
|
|
126
|
+
toValue: transY,
|
|
127
|
+
duration: 220,
|
|
128
|
+
useNativeDriver: false,
|
|
129
|
+
easing: Easing.linear,
|
|
130
|
+
});
|
|
131
|
+
}, [keyboardAnim, transY]);
|
|
132
|
+
|
|
125
133
|
return (
|
|
126
134
|
<SafeAreaView style={styles.container}>
|
|
127
|
-
<Animated.View
|
|
135
|
+
<Animated.View
|
|
136
|
+
style={[
|
|
137
|
+
{ backgroundColor: Colors.White },
|
|
138
|
+
Platform.OS === 'ios' && {
|
|
139
|
+
marginBottom: keyboardAnim,
|
|
140
|
+
},
|
|
141
|
+
]}
|
|
142
|
+
>
|
|
128
143
|
<FlatList
|
|
129
144
|
data={unitsPublic}
|
|
130
145
|
ListHeaderComponent={listHeader}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React, { useEffect, useState } from 'react';
|
|
2
|
-
import { View, TouchableOpacity, Image
|
|
2
|
+
import { View, TouchableOpacity, Image } from 'react-native';
|
|
3
3
|
import { useNavigation } from '@react-navigation/native';
|
|
4
4
|
import { IconFill } from '@ant-design/icons-react-native';
|
|
5
|
+
|
|
5
6
|
import { HeaderCustom } from '../../commons/Header';
|
|
6
7
|
import { AlertAction, FullLoading } from '../../commons';
|
|
7
8
|
import BottomButtonView from '../../commons/BottomButtonView';
|
|
@@ -160,12 +161,7 @@ const HanetMemberInfo = ({ route }) => {
|
|
|
160
161
|
}
|
|
161
162
|
};
|
|
162
163
|
|
|
163
|
-
const
|
|
164
|
-
const animatedStyle = Platform.select({
|
|
165
|
-
ios: {
|
|
166
|
-
marginBottom: transY,
|
|
167
|
-
},
|
|
168
|
-
});
|
|
164
|
+
const transY = useKeyboardAnimated();
|
|
169
165
|
|
|
170
166
|
return (
|
|
171
167
|
<View style={styles.container}>
|
|
@@ -229,7 +225,7 @@ const HanetMemberInfo = ({ route }) => {
|
|
|
229
225
|
rightButtonTitle={stateAlertAction.rightButton}
|
|
230
226
|
rightButtonClick={handleRenameOrDelete}
|
|
231
227
|
rightButtonStyle={{ color: stateAlertAction.rightColor }}
|
|
232
|
-
|
|
228
|
+
transY={transY}
|
|
233
229
|
>
|
|
234
230
|
{!stateAlertAction.isDelete && (
|
|
235
231
|
<TextInput
|
|
@@ -6,7 +6,7 @@ import React, {
|
|
|
6
6
|
useEffect,
|
|
7
7
|
memo,
|
|
8
8
|
} from 'react';
|
|
9
|
-
import { View, TouchableOpacity, Image
|
|
9
|
+
import { View, TouchableOpacity, Image } from 'react-native';
|
|
10
10
|
import { IconFill, IconOutline } from '@ant-design/icons-react-native';
|
|
11
11
|
import { Icon } from '@ant-design/react-native';
|
|
12
12
|
|
|
@@ -83,12 +83,7 @@ const ScriptDetail = ({ route }) => {
|
|
|
83
83
|
(state) => state.app.popoverAnimating
|
|
84
84
|
);
|
|
85
85
|
|
|
86
|
-
const
|
|
87
|
-
const animatedStyle = Platform.select({
|
|
88
|
-
ios: {
|
|
89
|
-
marginBottom: transY,
|
|
90
|
-
},
|
|
91
|
-
});
|
|
86
|
+
const transY = useKeyboardAnimated();
|
|
92
87
|
|
|
93
88
|
const renameScript = useCallback(async () => {
|
|
94
89
|
const { success, data: script } = await axiosPatch(
|
|
@@ -508,7 +503,7 @@ const ScriptDetail = ({ route }) => {
|
|
|
508
503
|
rightButtonTitle={stateAlertAction.rightButton}
|
|
509
504
|
rightButtonClick={handleRenameOrDelete}
|
|
510
505
|
rightButtonStyle={{ color: stateAlertAction.rightColor }}
|
|
511
|
-
|
|
506
|
+
transY={transY}
|
|
512
507
|
>
|
|
513
508
|
{!stateAlertAction.isDelete && havePermission && (
|
|
514
509
|
<_TextInput
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useState, useCallback, useEffect } from 'react';
|
|
2
|
-
import { View, TouchableOpacity, Image
|
|
2
|
+
import { View, TouchableOpacity, Image } from 'react-native';
|
|
3
3
|
import { connect } from 'react-redux';
|
|
4
4
|
import { useIsFocused, useNavigation } from '@react-navigation/native';
|
|
5
5
|
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
@@ -17,15 +17,12 @@ import useBoolean from '../../hooks/Common/useBoolean';
|
|
|
17
17
|
import { ImagePicker, Section } from '../../commons';
|
|
18
18
|
import AlertAction from '../../commons/AlertAction';
|
|
19
19
|
import _TextInput from '../../commons/Form/TextInput';
|
|
20
|
-
import ViewButtonBottom from '../../commons/ViewButtonBottom';
|
|
21
20
|
import Text from '../../commons/Text';
|
|
22
21
|
import { AccessibilityLabel } from '../../configs/Constants';
|
|
23
22
|
import { IconOutline } from '@ant-design/icons-react-native';
|
|
24
23
|
import { useEmeragencyContacts } from './hooks/useEmergencyContacts';
|
|
25
|
-
import Animated from 'react-native-reanimated';
|
|
26
24
|
import useKeyboardAnimated from '../../hooks/Explore/useKeyboardAnimated';
|
|
27
25
|
import styles from './EditSubUnitStyles';
|
|
28
|
-
import { ModalCustom } from '../../commons/Modal';
|
|
29
26
|
|
|
30
27
|
const EditSubUnit = ({ route }) => {
|
|
31
28
|
const { unit, station } = route?.params || {};
|
|
@@ -164,12 +161,7 @@ const EditSubUnit = ({ route }) => {
|
|
|
164
161
|
});
|
|
165
162
|
}, [group, navigation, unit.id]);
|
|
166
163
|
|
|
167
|
-
const
|
|
168
|
-
const animatedStyle = Platform.select({
|
|
169
|
-
ios: {
|
|
170
|
-
marginBottom: transY,
|
|
171
|
-
},
|
|
172
|
-
});
|
|
164
|
+
const transY = useKeyboardAnimated();
|
|
173
165
|
|
|
174
166
|
return (
|
|
175
167
|
<View style={styles.container}>
|
|
@@ -220,6 +212,7 @@ const EditSubUnit = ({ route }) => {
|
|
|
220
212
|
<Text
|
|
221
213
|
type={'Body'}
|
|
222
214
|
color={contactsName.length > 0 ? Colors.Primary : Colors.Gray6}
|
|
215
|
+
accessibilityLabel={AccessibilityLabel.CONTACT_NAME}
|
|
223
216
|
>
|
|
224
217
|
{contactsName.length > 0
|
|
225
218
|
? contactsName.join(', ')
|
|
@@ -253,37 +246,25 @@ const EditSubUnit = ({ route }) => {
|
|
|
253
246
|
)}
|
|
254
247
|
</View>
|
|
255
248
|
</View>
|
|
256
|
-
<
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
249
|
+
<AlertAction
|
|
250
|
+
visible={showEdit}
|
|
251
|
+
hideModal={setHideEdit}
|
|
252
|
+
title={t('rename_sub_unit')}
|
|
253
|
+
leftButtonTitle={t('cancel')}
|
|
254
|
+
leftButtonClick={setHideEdit}
|
|
255
|
+
rightButtonTitle={t('rename')}
|
|
256
|
+
rightButtonClick={goRename}
|
|
257
|
+
transY={transY}
|
|
258
|
+
accessibilityLabel={AccessibilityLabel.MANAGE_UNIT_MODAL_RENAME}
|
|
262
259
|
>
|
|
263
|
-
<
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
defaultValue={station.name}
|
|
272
|
-
onChange={onChangeName}
|
|
273
|
-
textInputStyle={styles.textInputStyle}
|
|
274
|
-
wrapStyle={styles.textInputWrapStyle}
|
|
275
|
-
selectionColor={Colors.Primary}
|
|
276
|
-
/>
|
|
277
|
-
|
|
278
|
-
<ViewButtonBottom
|
|
279
|
-
leftTitle={t('cancel')}
|
|
280
|
-
onLeftClick={setHideEdit}
|
|
281
|
-
rightTitle={t('rename')}
|
|
282
|
-
onRightClick={goRename}
|
|
283
|
-
/>
|
|
284
|
-
</View>
|
|
285
|
-
</Animated.View>
|
|
286
|
-
</ModalCustom>
|
|
260
|
+
<_TextInput
|
|
261
|
+
defaultValue={station.name}
|
|
262
|
+
onChange={onChangeName}
|
|
263
|
+
textInputStyle={styles.textInputStyle}
|
|
264
|
+
wrapStyle={styles.textInputWrapStyle}
|
|
265
|
+
selectionColor={Colors.Primary}
|
|
266
|
+
/>
|
|
267
|
+
</AlertAction>
|
|
287
268
|
<AlertAction
|
|
288
269
|
visible={showModalRemoveSubUnit}
|
|
289
270
|
hideModal={hideRemoveSubUnitModal}
|
|
@@ -293,7 +274,7 @@ const EditSubUnit = ({ route }) => {
|
|
|
293
274
|
rightButtonTitle={t('remove')}
|
|
294
275
|
leftButtonClick={hideRemoveSubUnitModal}
|
|
295
276
|
rightButtonClick={onRemoveSubUnit}
|
|
296
|
-
|
|
277
|
+
transY={transY}
|
|
297
278
|
/>
|
|
298
279
|
</View>
|
|
299
280
|
);
|
|
@@ -38,6 +38,8 @@ jest.mock('react-redux', () => {
|
|
|
38
38
|
};
|
|
39
39
|
});
|
|
40
40
|
|
|
41
|
+
const mockUseIsFocused = jest.fn();
|
|
42
|
+
|
|
41
43
|
jest.mock('@react-navigation/native', () => {
|
|
42
44
|
return {
|
|
43
45
|
...jest.requireActual('@react-navigation/native'),
|
|
@@ -46,7 +48,7 @@ jest.mock('@react-navigation/native', () => {
|
|
|
46
48
|
dangerouslyGetState: mockedDangerouslyGetState,
|
|
47
49
|
pop: mockedPop,
|
|
48
50
|
}),
|
|
49
|
-
useIsFocused:
|
|
51
|
+
useIsFocused: () => mockUseIsFocused,
|
|
50
52
|
};
|
|
51
53
|
});
|
|
52
54
|
|
|
@@ -91,6 +93,7 @@ describe('Test EditSubUnit', () => {
|
|
|
91
93
|
|
|
92
94
|
afterEach(() => {
|
|
93
95
|
mockedDispatch.mockClear();
|
|
96
|
+
mock.reset();
|
|
94
97
|
Toast.show.mockClear();
|
|
95
98
|
});
|
|
96
99
|
let tree;
|
|
@@ -100,19 +103,17 @@ describe('Test EditSubUnit', () => {
|
|
|
100
103
|
tree = await create(wrapComponent(route));
|
|
101
104
|
});
|
|
102
105
|
const instance = tree.root;
|
|
103
|
-
const alertAction = instance.
|
|
104
|
-
expect(alertAction.props.leftButtonTitle).toEqual(
|
|
106
|
+
const alertAction = instance.findAllByType(AlertAction);
|
|
107
|
+
expect(alertAction[1].props.leftButtonTitle).toEqual(
|
|
105
108
|
getTranslate('en', 'cancel')
|
|
106
109
|
);
|
|
107
|
-
expect(alertAction.props.rightButtonTitle).toEqual(
|
|
110
|
+
expect(alertAction[1].props.rightButtonTitle).toEqual(
|
|
108
111
|
getTranslate('en', 'remove')
|
|
109
112
|
);
|
|
110
113
|
});
|
|
111
114
|
|
|
112
115
|
it('alertAction rightButtonClick success, previous screen Routes.UnitDetail', async () => {
|
|
113
|
-
mock
|
|
114
|
-
.onDelete('https://backend.eoh.io/api/property_manager/1/sub_units/2/')
|
|
115
|
-
.reply(200);
|
|
116
|
+
mock.onDelete(API.SUB_UNIT.REMOVE_SUB_UNIT(1, 2)).reply(200);
|
|
116
117
|
|
|
117
118
|
mockedDangerouslyGetState.mockImplementation(() => ({
|
|
118
119
|
routes: [
|
|
@@ -127,11 +128,17 @@ describe('Test EditSubUnit', () => {
|
|
|
127
128
|
});
|
|
128
129
|
|
|
129
130
|
const instance = tree.root;
|
|
130
|
-
const alertAction = instance.
|
|
131
|
+
const alertAction = instance.findAllByType(AlertAction);
|
|
131
132
|
await act(async () => {
|
|
132
|
-
await alertAction.props.rightButtonClick();
|
|
133
|
+
await alertAction[1].props.rightButtonClick();
|
|
134
|
+
});
|
|
135
|
+
expect(alertAction[1].props.visible).toEqual(false);
|
|
136
|
+
expect(Toast.show).toBeCalledWith({
|
|
137
|
+
type: 'success',
|
|
138
|
+
position: 'bottom',
|
|
139
|
+
text1: getTranslate('en', 'text_remove_sub_unit_success'),
|
|
140
|
+
visibilityTime: 1000,
|
|
133
141
|
});
|
|
134
|
-
expect(alertAction.props.visible).toEqual(false);
|
|
135
142
|
});
|
|
136
143
|
|
|
137
144
|
it('alertAction rightButtonClick success', async () => {
|
|
@@ -146,11 +153,11 @@ describe('Test EditSubUnit', () => {
|
|
|
146
153
|
tree = await create(wrapComponent(route));
|
|
147
154
|
});
|
|
148
155
|
const instance = tree.root;
|
|
149
|
-
const alertAction = instance.
|
|
156
|
+
const alertAction = instance.findAllByType(AlertAction);
|
|
150
157
|
await act(async () => {
|
|
151
|
-
await alertAction.props.rightButtonClick();
|
|
158
|
+
await alertAction[1].props.rightButtonClick();
|
|
152
159
|
});
|
|
153
|
-
expect(mockedPop).
|
|
160
|
+
expect(mockedPop).toBeCalled();
|
|
154
161
|
});
|
|
155
162
|
|
|
156
163
|
it('alertAction rightButtonClick fail', async () => {
|
|
@@ -166,9 +173,9 @@ describe('Test EditSubUnit', () => {
|
|
|
166
173
|
tree = await create(wrapComponent(route));
|
|
167
174
|
});
|
|
168
175
|
const instance = tree.root;
|
|
169
|
-
const alertAction = instance.
|
|
176
|
+
const alertAction = instance.findAllByType(AlertAction);
|
|
170
177
|
await act(async () => {
|
|
171
|
-
await alertAction.props.rightButtonClick();
|
|
178
|
+
await alertAction[1].props.rightButtonClick();
|
|
172
179
|
});
|
|
173
180
|
|
|
174
181
|
expect(Toast.show).toHaveBeenCalledWith({
|
|
@@ -184,49 +191,11 @@ describe('Test EditSubUnit', () => {
|
|
|
184
191
|
tree = await create(wrapComponent(route));
|
|
185
192
|
});
|
|
186
193
|
const instance = tree.root;
|
|
187
|
-
const alertAction = instance.
|
|
188
|
-
await act(async () => {
|
|
189
|
-
await alertAction.props.leftButtonClick();
|
|
190
|
-
});
|
|
191
|
-
expect(alertAction.props.visible).toEqual(false);
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
it('alertAction hideModal', async () => {
|
|
195
|
-
await act(async () => {
|
|
196
|
-
tree = await create(wrapComponent(route));
|
|
197
|
-
});
|
|
198
|
-
const instance = tree.root;
|
|
199
|
-
const alertAction = instance.findByType(AlertAction);
|
|
200
|
-
await act(async () => {
|
|
201
|
-
await alertAction.props.hideModal();
|
|
202
|
-
});
|
|
203
|
-
expect(alertAction.props.visible).toEqual(false);
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
it('viewBottomButton onLeftClick', async () => {
|
|
207
|
-
await act(async () => {
|
|
208
|
-
tree = await create(wrapComponent(route));
|
|
209
|
-
});
|
|
210
|
-
const instance = tree.root;
|
|
211
|
-
const modal = instance.find(
|
|
212
|
-
(el) =>
|
|
213
|
-
el.props.accessibilityLabel === AccessibilityLabel.MANAGE_SUB_UNIT_MODAL
|
|
214
|
-
);
|
|
215
|
-
const viewBottomButtons = instance.findAllByType(ViewButtonBottom);
|
|
216
|
-
const viewBottomButton = viewBottomButtons[0];
|
|
217
|
-
|
|
218
|
-
expect(viewBottomButton.props.leftTitle).toEqual(
|
|
219
|
-
getTranslate('en', 'cancel')
|
|
220
|
-
);
|
|
221
|
-
expect(viewBottomButton.props.rightTitle).toEqual(
|
|
222
|
-
getTranslate('en', 'rename')
|
|
223
|
-
);
|
|
224
|
-
|
|
194
|
+
const alertAction = instance.findAllByType(AlertAction);
|
|
225
195
|
await act(async () => {
|
|
226
|
-
await
|
|
196
|
+
await alertAction[1].props.leftButtonClick();
|
|
227
197
|
});
|
|
228
|
-
|
|
229
|
-
expect(modal.props.isVisible).toEqual(false);
|
|
198
|
+
expect(alertAction[1].props.visible).toEqual(false);
|
|
230
199
|
});
|
|
231
200
|
|
|
232
201
|
it('viewBottomButton onRightClick success', async () => {
|
|
@@ -279,14 +248,14 @@ describe('Test EditSubUnit', () => {
|
|
|
279
248
|
AccessibilityLabel.MANAGE_SUB_UNIT_REMOVE_BUTTON &&
|
|
280
249
|
el.type === TouchableOpacity
|
|
281
250
|
);
|
|
282
|
-
const alertAction = instance.
|
|
283
|
-
expect(alertAction.props.visible).toEqual(false);
|
|
251
|
+
const alertAction = instance.findAllByType(AlertAction);
|
|
252
|
+
expect(alertAction[1].props.visible).toEqual(false);
|
|
284
253
|
|
|
285
254
|
await act(async () => {
|
|
286
255
|
button.props.onPress();
|
|
287
256
|
});
|
|
288
257
|
|
|
289
|
-
expect(alertAction.props.visible).toEqual(true);
|
|
258
|
+
expect(alertAction[1].props.visible).toEqual(true);
|
|
290
259
|
});
|
|
291
260
|
|
|
292
261
|
it('onChangeName', async () => {
|
|
@@ -360,4 +329,27 @@ describe('Test EditSubUnit', () => {
|
|
|
360
329
|
uri: 'path',
|
|
361
330
|
});
|
|
362
331
|
});
|
|
332
|
+
|
|
333
|
+
it('Test getContact success', async () => {
|
|
334
|
+
route = {
|
|
335
|
+
...route,
|
|
336
|
+
params: {
|
|
337
|
+
...route.params,
|
|
338
|
+
station: { ...route.params.station, emergency_group: { id: 1 } },
|
|
339
|
+
},
|
|
340
|
+
};
|
|
341
|
+
mock
|
|
342
|
+
.onGet(API.EMERGENCY_BUTTON.CONTACTS())
|
|
343
|
+
.reply(200, [{ id: 1, name: 'name' }]);
|
|
344
|
+
mockUseIsFocused.mockImplementationOnce(() => true);
|
|
345
|
+
await act(async () => {
|
|
346
|
+
tree = await create(wrapComponent(route));
|
|
347
|
+
});
|
|
348
|
+
const contactNameTexts = tree.root.findAll(
|
|
349
|
+
(el) =>
|
|
350
|
+
el.props.accessibilityLabel === AccessibilityLabel.CONTACT_NAME &&
|
|
351
|
+
el.type === Text
|
|
352
|
+
);
|
|
353
|
+
expect(contactNameTexts[0].props.children).toBe('name');
|
|
354
|
+
});
|
|
363
355
|
});
|