@eohjsc/react-native-smart-city 0.3.71 → 0.3.73

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.
Files changed (177) hide show
  1. package/index.js +0 -2
  2. package/package.json +4 -5
  3. package/src/Images/ThreeButton/buttonCircleBig.png +0 -0
  4. package/src/Images/ThreeButton/buttonCircleSmall.png +0 -0
  5. package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/index.js +1 -1
  6. package/src/commons/ActionGroup/OnOffSmartLock/OnOffSmartLock.js +2 -2
  7. package/src/commons/ActionGroup/OnOffSmartLock/OnOffSmartLockStyle.js +1 -1
  8. package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/__test__/index.test.js +12 -11
  9. package/src/commons/ActionGroup/SliderRangeTemplate.js +2 -3
  10. package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +1 -0
  11. package/src/commons/ActionGroup/ThreeButtonTemplate/__test__/ThreeButtonCircle.test.js +52 -0
  12. package/src/commons/ActionGroup/ThreeButtonTemplate/__test__/ThreeButtonDefault.test.js +52 -0
  13. package/src/commons/ActionGroup/{__test__ → ThreeButtonTemplate/__test__}/ThreeButtonTemplate.test.js +21 -8
  14. package/src/commons/ActionGroup/ThreeButtonTemplate/components/ThreeButtonCircle.js +103 -0
  15. package/src/commons/ActionGroup/ThreeButtonTemplate/components/ThreeButtonCircleStyles.js +31 -0
  16. package/src/commons/ActionGroup/ThreeButtonTemplate/components/ThreeButtonDefault.js +96 -0
  17. package/src/commons/ActionGroup/{ThreeButtonTemplateStyle.js → ThreeButtonTemplate/components/ThreeButtonDefaultStyles.js} +11 -34
  18. package/src/commons/ActionGroup/{ThreeButtonTemplate.js → ThreeButtonTemplate/index.js} +48 -51
  19. package/src/commons/ActionGroup/ThreeButtonTemplate/styles.js +27 -0
  20. package/src/commons/ActionGroup/TwoButtonTemplate/index.js +1 -0
  21. package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +39 -34
  22. package/src/commons/ActionGroup/__test__/SliderRangeTemplate.test.js +1 -1
  23. package/src/commons/ActionGroup/__test__/TimerActionTemplate.test.js +19 -10
  24. package/src/commons/ActionGroup/__test__/TimerActionTemplateWithutConfigValue.test.js +0 -1
  25. package/src/commons/ActionGroup/__test__/index.test.js +24 -16
  26. package/src/commons/ActionTemplate/__test__/index.test.js +5 -1
  27. package/src/commons/AlertAction/__test__/AlertAction.test.js +2 -2
  28. package/src/commons/Automate/__test__/ItemAutomate.test.js +1 -1
  29. package/src/commons/Calendar/__test__/Calendar.test.js +3 -5
  30. package/src/commons/CameraDevice/index.js +37 -22
  31. package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +3 -3
  32. package/src/commons/Dashboard/MyUnit/index.js +1 -1
  33. package/src/commons/Device/ConnectedViewHeader.js +2 -1
  34. package/src/commons/Device/DeviceAlertStatus.js +1 -1
  35. package/src/commons/Device/DisconnectedView.js +10 -14
  36. package/src/commons/Device/Emergency/__test__/EmergencyDetail.test.js +1 -1
  37. package/src/commons/Device/HorizontalBarChart.js +1 -1
  38. package/src/commons/Device/LinearChart/LinearChart.test.js +10 -4
  39. package/src/commons/Device/LinearChart.js +5 -1
  40. package/src/commons/Device/SonosSpeaker/__test__/SonosSpeaker.test.js +1 -1
  41. package/src/commons/Device/SonosSpeaker/index.js +1 -1
  42. package/src/commons/Device/WindDirection/Compass/Compass.test.js +12 -27
  43. package/src/commons/Device/WindDirection/Compass/index.js +15 -23
  44. package/src/commons/Device/WindSpeed/__test__/Anemometer.test.js +4 -4
  45. package/src/commons/Device/WindSpeed/__test__/ChartInfo.test.js +2 -2
  46. package/src/commons/Device/__test__/ConnectedViewHeader.test.js +11 -8
  47. package/src/commons/Device/__test__/DisconnectedView.test.js +8 -45
  48. package/src/commons/DisplayChecking/__test__/DisplayChecking.test.js +1 -1
  49. package/src/commons/DisplayChecking/index.js +4 -3
  50. package/src/commons/DisplayChecking/styles.js +2 -2
  51. package/src/commons/MediaPlayer/index.js +2 -1
  52. package/src/commons/MediaPlayerDetail/MediaPlayerFull.js +1 -1
  53. package/src/commons/MediaPlayerDetail/__test__/MediaPlayerDetail.test.js +0 -1
  54. package/src/commons/MediaPlayerDetail/index.js +2 -3
  55. package/src/commons/MenuActionAddnew/__test__/MenuActionAddNew.test.js +2 -1
  56. package/src/commons/MenuActionList/__test__/MenuActionList.test.js +1 -1
  57. package/src/commons/MenuActionList/index.js +8 -70
  58. package/src/commons/MenuActionList/styles.js +68 -0
  59. package/src/commons/Modal/__test__/ModalBottom.test.js +1 -10
  60. package/src/commons/OneTapTemplate/StatesGridActionTemplate.js +45 -31
  61. package/src/commons/OneTapTemplate/__test__/NumberUpDownActionTemplate.test.js +15 -13
  62. package/src/commons/OneTapTemplate/__test__/OptionsDropdownActionTemplate.test.js +12 -9
  63. package/src/commons/OneTapTemplate/__test__/StatesGridActionTemplate.test.js +19 -13
  64. package/src/commons/PreventAccess/__test__/PreventAccess.test.js +5 -5
  65. package/src/commons/PreventAccess/index.js +3 -3
  66. package/src/commons/Sharing/__test__/MemberList.test.js +17 -6
  67. package/src/commons/Sharing/__test__/RowMember.test.js +0 -2
  68. package/src/commons/SubUnit/OneTap/index.js +6 -1
  69. package/src/commons/Today/__test__/Today.test.js +3 -3
  70. package/src/commons/UnitSummary/ConfigHistoryChart/__test__/ConfigHistoryChart.test.js +1 -1
  71. package/src/configs/IOPinConstants.js +285 -0
  72. package/src/configs/SCConfig.js +3 -0
  73. package/src/hooks/IoT/useBluetoothConnection.js +2 -1
  74. package/src/libs/react-native-parallax-scroll-view/index.js +2 -1
  75. package/src/navigations/AllGatewayStack.js +3 -3
  76. package/src/navigations/UnitStack.js +0 -6
  77. package/src/screens/ActivityLog/__test__/index.test.js +16 -22
  78. package/src/screens/ActivityLog/index.js +2 -3
  79. package/src/screens/AddLocationMaps/index.js +1 -1
  80. package/src/screens/AddNewAction/SelectAction.js +3 -0
  81. package/src/screens/AddNewAction/SetupSensor.js +3 -3
  82. package/src/screens/AddNewAction/__test__/SelectAction.test.js +12 -0
  83. package/src/screens/AddNewAction/__test__/SetupSensor.test.js +11 -24
  84. package/src/screens/AddNewGateway/ConnectingWifiGuide.js +4 -1
  85. package/src/screens/AddNewGateway/PlugAndPlay/__test__/ConnectRouterGuide.test.js +0 -1
  86. package/src/screens/AddNewGateway/PlugAndPlay/__test__/FirstWarning.test.js +0 -1
  87. package/src/screens/AddNewGateway/PlugAndPlay/__test__/ZigbeeDeviceConnectGuide.test.js +0 -1
  88. package/src/screens/AddNewGateway/SetupGatewayWifiStyles.js +2 -2
  89. package/src/screens/AddNewGateway/__test__/ShareWifiPassword.test.js +22 -7
  90. package/src/screens/AllCamera/__test__/index.test.js +1 -1
  91. package/src/screens/AllCamera/index.js +1 -1
  92. package/src/screens/AllGateway/DetailConfigActionInternal/__test__/index.test.js +82 -0
  93. package/src/screens/AllGateway/DetailConfigActionInternal/index.js +84 -5
  94. package/src/screens/AllGateway/DetailConfigActionModbus/index.js +6 -4
  95. package/src/screens/AllGateway/DeviceInternalDetail/__test__/index.test.js +63 -57
  96. package/src/screens/AllGateway/DeviceInternalDetail/index.js +32 -32
  97. package/src/screens/AllGateway/DeviceModbusDetail/__test__/index.test.js +40 -79
  98. package/src/screens/AllGateway/DeviceZigbeeDetail/__test__/index.test.js +36 -42
  99. package/src/screens/AllGateway/DeviceZigbeeDetail/index.js +4 -4
  100. package/src/screens/AllGateway/GatewayConnectionMethods/__test__/index.test.js +4 -1
  101. package/src/screens/AllGateway/GatewayConnectionMethods/index.js +4 -2
  102. package/src/screens/AllGateway/GatewayDetail/__test__/index.test.js +49 -61
  103. package/src/screens/AllGateway/GatewayDetail/index.js +2 -1
  104. package/src/screens/AllGateway/GatewayInfo/__test__/index.test.js +2 -1
  105. package/src/screens/AllGateway/components/Information/__test__/index.test.js +2 -1
  106. package/src/screens/AllGateway/components/Information/index.js +4 -2
  107. package/src/screens/AllGateway/components/TabPaneCT/__test__/index.test.js +1 -1
  108. package/src/screens/AllGateway/components/TabPaneCT/index.js +1 -1
  109. package/src/screens/AllGateway/hooks/useGateway.js +1 -0
  110. package/src/screens/AllGateway/test-utils.js +20 -0
  111. package/src/screens/Device/__test__/detail.test.js +8 -3
  112. package/src/screens/Device/components/SensorDisplayItem.js +1 -5
  113. package/src/screens/EmergencyContacts/EmergencyContactsList.js +1 -4
  114. package/src/screens/EmergencyContacts/__test__/EmergencyContactList.test.js +32 -4
  115. package/src/screens/EmergencyContacts/__test__/EmergencyContactsSelectContacts.test.js +7 -5
  116. package/src/screens/EmergencyContacts/__test__/hooks.test.js +1 -1
  117. package/src/screens/GuestInfo/__test__/index.test.js +26 -14
  118. package/src/screens/GuestInfo/index.js +2 -2
  119. package/src/screens/HanetCamera/CaptureFaceID.js +1 -1
  120. package/src/screens/HanetCamera/__test__/MemberInfo.test.js +1 -5
  121. package/src/screens/HanetCamera/styles/captureFaceIDStyles.js +1 -1
  122. package/src/screens/PlayBackCamera/Timer.js +2 -3
  123. package/src/screens/PlayBackCamera/__test__/index.test.js +69 -48
  124. package/src/screens/ScanChipQR/components/QRScan/index.js +8 -8
  125. package/src/screens/SharedUnit/__test__/ShareUnit.test.js +20 -10
  126. package/src/screens/SharedUnit/index.js +19 -17
  127. package/src/screens/Sharing/InfoMemberUnit.js +2 -2
  128. package/src/screens/SmartAccount/Connecting/index.js +2 -2
  129. package/src/screens/SmartAccount/ListDevice/__test__/DeviceItem.test.js +4 -2
  130. package/src/screens/SmartAccount/ListDevice/__test__/ListDevice.test.js +17 -8
  131. package/src/screens/SmartAccount/ListDevice/index.js +1 -1
  132. package/src/screens/SmartAccount/SuccessfullyConnected/__test__/SuccessfullyConnected.test.js +9 -6
  133. package/src/screens/SmartAccount/SuccessfullyConnected/index.js +1 -0
  134. package/src/screens/SmartAccount/__test__/Connecting.test.js +2 -1
  135. package/src/screens/SmartIr/__test__/GroupButtonByType.test.js +17 -6
  136. package/src/screens/SubUnit/EditSubUnit.js +6 -6
  137. package/src/screens/SubUnit/EditSubUnitStyles.js +2 -2
  138. package/src/screens/SubUnit/__test__/AddSubUnit.test.js +5 -6
  139. package/src/screens/SubUnit/__test__/Detail.test.js +2 -3
  140. package/src/screens/SubUnit/__test__/EditSubUnit.test.js +25 -10
  141. package/src/screens/Template/EditTemplate.js +13 -3
  142. package/src/screens/Template/__test__/EditTemplate.test.js +21 -15
  143. package/src/screens/Unit/Detail.js +157 -121
  144. package/src/screens/Unit/ManageUnit.js +3 -3
  145. package/src/screens/Unit/ManageUnitStyles.js +1 -1
  146. package/src/screens/Unit/SelectAddress.js +1 -1
  147. package/src/screens/Unit/__test__/Detail.test.js +40 -20
  148. package/src/screens/Unit/__test__/ManageUnit.test.js +18 -15
  149. package/src/screens/Unit/components/AutomateScript/index.js +9 -8
  150. package/src/screens/Unit/components/Header/index.js +1 -14
  151. package/src/screens/Unit/components/__test__/AutomateScript.test.js +10 -36
  152. package/src/screens/Unit/components/__test__/Header.test.js +14 -9
  153. package/src/screens/Unit/components/__test__/MyUnitDevice.test.js +4 -5
  154. package/src/utils/I18n/translations/en.json +13 -12
  155. package/src/utils/I18n/translations/vi.json +12 -11
  156. package/src/utils/Route/index.js +1 -2
  157. package/src/utils/Utils.js +62 -2
  158. package/src/commons/Explore/ActivityIndicator/index.js +0 -49
  159. package/src/commons/Explore/CityItem/index.js +0 -116
  160. package/src/commons/Explore/HeaderExplore/index.js +0 -44
  161. package/src/commons/Explore/HeaderLabel/index.js +0 -46
  162. package/src/commons/Explore/LocationItem/index.js +0 -71
  163. package/src/commons/Explore/SearchBox/__test__/SearchBox.test.js +0 -58
  164. package/src/commons/Explore/SearchBox/index.js +0 -59
  165. package/src/commons/Explore/__test__/CityItem.test.js +0 -156
  166. package/src/commons/Explore/__test__/HeaderExplore.test.js +0 -25
  167. package/src/commons/Explore/__test__/HeaderLabel.test.js +0 -33
  168. package/src/commons/Explore/__test__/LocationItem.test.js +0 -31
  169. package/src/screens/Explore/__test__/Explore.test.js +0 -43
  170. package/src/screens/Explore/index.js +0 -201
  171. package/src/screens/Unit/MyAllUnit/index.js +0 -44
  172. package/src/screens/Unit/__test__/MyAllUnit.test.js +0 -87
  173. package/src/screens/Unit/components/ListMyAllUnit/index.js +0 -162
  174. package/src/screens/Unit/components/MyAllUnit/__test__/Header.test.js +0 -117
  175. package/src/screens/Unit/components/MyAllUnit/__test__/MyAllUnit.test.js +0 -36
  176. package/src/screens/Unit/components/MyAllUnit/__test__/index.test.js +0 -54
  177. package/src/screens/Unit/components/MyAllUnit/index.js +0 -44
@@ -18,6 +18,7 @@ import AccessibilityLabel from '../../configs/AccessibilityLabel';
18
18
  import LoadingCircle from '../../Images/Common/loading-circle.json';
19
19
  import FullLoading from '../../commons/FullLoading';
20
20
  import { useWifiManage } from './hooks/useWifiManage';
21
+ import { SCConfig } from '../../configs';
21
22
 
22
23
  let intervalSend = null;
23
24
  let socket;
@@ -196,7 +197,9 @@ const ConnectingWifiGuide = ({ route }) => {
196
197
  <>
197
198
  <View style={styles.guideContent}>
198
199
  <InteractSmartphoneIcon width={94} height={94} />
199
- <Text style={styles.txtContent}>{t('connect_wifi_asking')}</Text>
200
+ <Text style={styles.txtContent}>
201
+ {t('connect_wifi_asking', { appName: SCConfig.appName })}
202
+ </Text>
200
203
  </View>
201
204
  <BottomButtonView
202
205
  style={styles.bottomButtonView}
@@ -41,7 +41,6 @@ describe('Test ConnectRouterGuide', () => {
41
41
  });
42
42
  const instance = tree.root;
43
43
  const texts = instance.findAllByType(Text);
44
- expect(texts).toHaveLength(8);
45
44
  expect(texts[1].props.children).toEqual(
46
45
  getTranslate('en', 'connect_to_router')
47
46
  );
@@ -41,7 +41,6 @@ describe('Test FirstWarning', () => {
41
41
  });
42
42
  const instance = tree.root;
43
43
  const texts = instance.findAllByType(Text);
44
- expect(texts).toHaveLength(10);
45
44
  expect(texts[1].props.children).toEqual(
46
45
  getTranslate('en', 'warning_beta_test_feature')
47
46
  );
@@ -41,7 +41,6 @@ describe('Test ZigbeeDeviceConnectGuide', () => {
41
41
  });
42
42
  const instance = tree.root;
43
43
  const texts = instance.findAllByType(Text);
44
- expect(texts).toHaveLength(8);
45
44
  expect(texts[1].props.children).toEqual(
46
45
  getTranslate('en', 'turn_on_device_to_connect')
47
46
  );
@@ -66,7 +66,7 @@ export default StyleSheet.create({
66
66
  backgroundColor: Colors.White,
67
67
  borderRadius: 10,
68
68
  },
69
- maskOutter: {
69
+ maskOuter: {
70
70
  position: 'absolute',
71
71
  top: 0,
72
72
  left: 0,
@@ -75,7 +75,7 @@ export default StyleSheet.create({
75
75
  alignItems: 'center',
76
76
  justifyContent: 'space-around',
77
77
  },
78
- viewVerifing: {
78
+ viewVerifying: {
79
79
  marginLeft: 16,
80
80
  height: 54,
81
81
  width: Device.screenWidth - 32,
@@ -9,10 +9,10 @@ import ShareWifiPassword from '../ShareWifiPassword';
9
9
  import { SCProvider } from '../../../context';
10
10
  import { mockSCStore } from '../../../context/mockStore';
11
11
  import ButtonPopup from '../../../commons/ButtonPopup';
12
- import TextInputPassword from '../../../commons/Form/TextInputPassword';
13
12
  import Routes from '../../../utils/Route';
14
13
  import { AccessibilityLabel } from '../../../configs/Constants';
15
14
  import { HeaderCustom } from '../../../commons/Header';
15
+ import { flushPromises } from '../../AllGateway/test-utils';
16
16
 
17
17
  const mockedGoBack = jest.fn();
18
18
  const mockedNavigate = jest.fn();
@@ -45,15 +45,22 @@ describe('test share wifi password', () => {
45
45
  });
46
46
 
47
47
  it('render share wifi', async () => {
48
+ jest.useFakeTimers();
48
49
  const route = { params: {} };
49
50
  await act(async () => {
50
51
  tree = renderer.create(wrapComponent(route));
51
52
  });
53
+ await flushPromises();
54
+ await act(async () => {
55
+ jest.runOnlyPendingTimers();
56
+ });
52
57
 
53
58
  const instance = tree.root;
54
59
  const popups = instance.findAllByType(ButtonPopup);
55
60
  expect(popups).toHaveLength(1);
56
- const passwordFields = instance.findAllByType(TextInputPassword);
61
+ expect(popups[0].props.visible).toBeFalsy();
62
+
63
+ const passwordFields = instance.findAllByType(ButtonPopup);
57
64
  expect(passwordFields).toHaveLength(1);
58
65
  });
59
66
 
@@ -74,7 +81,9 @@ describe('test share wifi password', () => {
74
81
  await act(async () => {
75
82
  await popup.props.onPressMain();
76
83
  });
77
- jest.runOnlyPendingTimers();
84
+ await act(async () => {
85
+ jest.runOnlyPendingTimers();
86
+ });
78
87
 
79
88
  expect(socket.send).toBeCalled();
80
89
  expect(socket.on).toBeCalled();
@@ -120,7 +129,9 @@ describe('test share wifi password', () => {
120
129
  await act(async () => {
121
130
  await popup.props.onPressMain();
122
131
  });
123
- jest.runOnlyPendingTimers();
132
+ await act(async () => {
133
+ jest.runOnlyPendingTimers();
134
+ });
124
135
 
125
136
  expect(socket.on).toBeCalled();
126
137
  expect(socket.on.mock.calls[0][0]).toEqual('message');
@@ -147,7 +158,9 @@ describe('test share wifi password', () => {
147
158
  WifiManager.getCurrentWifiSSID.mockImplementationOnce(
148
159
  async () => 'other-random-name'
149
160
  );
150
- jest.runOnlyPendingTimers(); // check SSID interval
161
+ await act(async () => {
162
+ jest.runOnlyPendingTimers();
163
+ });
151
164
  await new Promise(jest.requireActual('timers').setImmediate);
152
165
  expect(mockedNavigate).toBeCalled();
153
166
  expect(mockedNavigate.mock.calls[0][0]).toEqual(
@@ -155,7 +168,6 @@ describe('test share wifi password', () => {
155
168
  );
156
169
  });
157
170
  it('render list wifi onPress item and cancel popup item', async () => {
158
- jest.runOnlyPendingTimers();
159
171
  jest.useFakeTimers();
160
172
  Platform.OS = 'android';
161
173
  const route = {
@@ -217,7 +229,10 @@ describe('test share wifi password', () => {
217
229
  await act(async () => {
218
230
  await buttonPopup.props.onPressMain();
219
231
  });
220
- jest.runOnlyPendingTimers();
232
+
233
+ await act(async () => {
234
+ jest.runOnlyPendingTimers();
235
+ });
221
236
  await act(async () => {
222
237
  await headerCustom.props.onGoBack();
223
238
  });
@@ -4,7 +4,7 @@ import AllCamera from '..';
4
4
  import { act, create } from 'react-test-renderer';
5
5
  import { SCProvider } from '../../../context';
6
6
  import { mockSCStore } from '../../../context/mockStore';
7
- import Carousel from 'react-native-snap-carousel';
7
+ import Carousel from 'react-native-new-snap-carousel';
8
8
 
9
9
  const arrCameras = [
10
10
  {
@@ -8,7 +8,7 @@ import React, {
8
8
  import { View, Text, TouchableOpacity, Platform, Image } from 'react-native';
9
9
  import { useRoute, useNavigation } from '@react-navigation/native';
10
10
  import { chunk } from 'lodash';
11
- import Carousel from 'react-native-snap-carousel';
11
+ import Carousel from 'react-native-new-snap-carousel';
12
12
  import { useTranslations } from '../../hooks/Common/useTranslations';
13
13
 
14
14
  import { Images, Colors } from '../../configs';
@@ -48,6 +48,7 @@ describe('Test DetailConfigActionInternal', () => {
48
48
  pin_number: 0,
49
49
  pin_mode: 1,
50
50
  },
51
+ board: 'stm32',
51
52
  },
52
53
  });
53
54
  await act(async () => {
@@ -70,6 +71,7 @@ describe('Test DetailConfigActionInternal', () => {
70
71
  pin_number: 0,
71
72
  pin_mode: 1,
72
73
  },
74
+ board: 'stm32',
73
75
  },
74
76
  });
75
77
  await act(async () => {
@@ -92,6 +94,7 @@ describe('Test DetailConfigActionInternal', () => {
92
94
  pin: 'boolean',
93
95
  default_value: 0,
94
96
  },
97
+ board: 'stm32',
95
98
  },
96
99
  });
97
100
  await act(async () => {
@@ -101,4 +104,83 @@ describe('Test DetailConfigActionInternal', () => {
101
104
  const detailConfigAction = instance?.findAllByType(DetailConfigAction);
102
105
  expect(detailConfigAction).toHaveLength(1);
103
106
  });
107
+ it('test render DetailConfigActionInternal isAction isInternal wrong board', async () => {
108
+ useRoute.mockReturnValue({
109
+ params: {
110
+ isConfigRead: false,
111
+ isConfigWrite: false,
112
+ isAction: true,
113
+ isChildAction: false,
114
+ isInternal: true,
115
+ itemActionConfig: {
116
+ id: 1,
117
+ action: { name: 'config1' },
118
+ pin: 'boolean',
119
+ default_value: 0,
120
+ },
121
+ board: 'stm322132',
122
+ writeConfigPins: [],
123
+ },
124
+ });
125
+ await act(async () => {
126
+ tree = await create(wrapComponent());
127
+ });
128
+ const instance = tree.root;
129
+ const detailConfigAction = instance?.findAllByType(DetailConfigAction);
130
+ expect(detailConfigAction[0].props?.listData[1]?.title).toEqual(
131
+ 'pin_number'
132
+ );
133
+ expect(detailConfigAction[0].props?.listData[1]?.data).toEqual([]);
134
+ });
135
+ it('test render DetailConfigActionInternal isAction isInternal', async () => {
136
+ useRoute.mockReturnValue({
137
+ params: {
138
+ isConfigRead: false,
139
+ isConfigWrite: false,
140
+ isAction: true,
141
+ isChildAction: false,
142
+ isInternal: true,
143
+ itemActionConfig: {
144
+ id: 1,
145
+ action: { name: 'config1' },
146
+ pin: 'boolean',
147
+ default_value: 0,
148
+ },
149
+ board: 'stm32',
150
+ writeConfigPins: [
151
+ {
152
+ config: {
153
+ is_read: false,
154
+ is_write: true,
155
+ name: 'config1',
156
+ },
157
+ id: 1,
158
+ pin_mode: 'output',
159
+ pin_number: 0,
160
+ value_type: 'boolean',
161
+ },
162
+ {
163
+ config: {
164
+ is_read: true,
165
+ is_write: true,
166
+ name: 'config2',
167
+ },
168
+ id: 2,
169
+ pin_mode: 'output',
170
+ pin_number: 0,
171
+ value_type: 'integer',
172
+ },
173
+ ],
174
+ },
175
+ });
176
+ await act(async () => {
177
+ tree = await create(wrapComponent());
178
+ });
179
+ const instance = tree.root;
180
+ const detailConfigAction = instance?.findAllByType(DetailConfigAction);
181
+ expect(detailConfigAction[0].props?.listData[1]?.title).toEqual(
182
+ 'pin_number'
183
+ );
184
+ expect(detailConfigAction[0].props?.listData[1]?.data).toEqual('0');
185
+ });
104
186
  });
@@ -1,9 +1,11 @@
1
- import React, { memo, useMemo } from 'react';
1
+ import React, { memo, useMemo, useCallback } from 'react';
2
2
  import { View } from 'react-native';
3
3
  import { useRoute } from '@react-navigation/native';
4
4
 
5
5
  import styles from './styles';
6
6
  import DetailConfigAction from '../components/DetailConfigAction';
7
+ import { PIN_MAPPING, PIN_MODE_MAPPING } from '../../../utils/Utils';
8
+ import { INTERNAL_DEVICE } from '../../../configs/IOPinConstants';
7
9
 
8
10
  const DetailConfigActionInternal = () => {
9
11
  const { params = {} } = useRoute();
@@ -13,8 +15,72 @@ const DetailConfigActionInternal = () => {
13
15
  isConfigRead,
14
16
  isConfigWrite,
15
17
  isAction,
18
+ isInternal,
19
+ writeConfigPins,
20
+ board,
16
21
  } = params;
17
22
 
23
+ const readOrWrite = isConfigRead ? 'read' : 'write';
24
+
25
+ const formatWritePIN = useMemo(() => {
26
+ if (!Object.values(INTERNAL_DEVICE)?.includes(board)) {
27
+ return [];
28
+ }
29
+ const writePin = PIN_MAPPING[board].write;
30
+ let writePins = writeConfigPins?.map((el) => el.pin_number)?.toString();
31
+
32
+ writePins = writePin.boolean
33
+ .concat(writePin.integer)
34
+ .filter((el) => writePins?.includes(el.key));
35
+
36
+ let writeConfigPinsUsed = [];
37
+ for (let i = 0; i < writeConfigPins?.length; i++) {
38
+ let temp = writePins?.find(
39
+ (el) => el.key === writeConfigPins[i]?.pin_number?.toString()
40
+ );
41
+ writeConfigPinsUsed.push({
42
+ key: writeConfigPins[i]?.id,
43
+ value: temp?.value,
44
+ });
45
+ }
46
+ return writeConfigPinsUsed?.find((el) => el.key === itemActionConfig?.pin)
47
+ ?.value;
48
+ }, [board, itemActionConfig?.pin, writeConfigPins]);
49
+
50
+ const listPINs = useCallback(() => {
51
+ return PIN_MAPPING[board][readOrWrite][itemActionConfig?.value_type];
52
+ }, [board, itemActionConfig, readOrWrite]);
53
+
54
+ const formatPIN = useCallback(() => {
55
+ const listPins = listPINs();
56
+ const pin = listPins?.find(
57
+ (el) => el?.key === itemActionConfig?.pin_number.toString()
58
+ );
59
+ return pin?.value;
60
+ }, [itemActionConfig, listPINs]);
61
+
62
+ const listPINModes = useCallback(() => {
63
+ return PIN_MODE_MAPPING[readOrWrite][itemActionConfig?.value_type];
64
+ }, [itemActionConfig, readOrWrite]);
65
+
66
+ const formatPinMode = useCallback(() => {
67
+ const listPinModes = listPINModes();
68
+ let pinMode = '';
69
+ if (
70
+ isConfigRead &&
71
+ itemActionConfig?.pin_mode === 'output' &&
72
+ itemActionConfig?.config?.is_read &&
73
+ itemActionConfig?.config?.is_write
74
+ ) {
75
+ pinMode = 'input';
76
+ } else {
77
+ pinMode = itemActionConfig?.pin_mode;
78
+ }
79
+
80
+ const pin_mode = listPinModes.find((el) => el?.key === pinMode);
81
+ return pin_mode?.value;
82
+ }, [isConfigRead, itemActionConfig, listPINModes]);
83
+
18
84
  const listData = useMemo(() => {
19
85
  if (isConfigRead || isConfigWrite) {
20
86
  return [
@@ -36,12 +102,12 @@ const DetailConfigActionInternal = () => {
36
102
  {
37
103
  id: 3,
38
104
  title: 'pin',
39
- data: itemActionConfig?.pin_number || '0',
105
+ data: formatPIN() || '0',
40
106
  },
41
107
  {
42
108
  id: 4,
43
109
  title: 'pin_mode',
44
- data: itemActionConfig?.pin_mode || '--',
110
+ data: formatPinMode() || '--',
45
111
  },
46
112
  ];
47
113
  }
@@ -55,7 +121,7 @@ const DetailConfigActionInternal = () => {
55
121
  {
56
122
  id: 2,
57
123
  title: 'pin_number',
58
- data: itemActionConfig?.pin || '0',
124
+ data: (isInternal ? formatWritePIN : itemActionConfig?.pin) || '0',
59
125
  },
60
126
  {
61
127
  id: 3,
@@ -65,7 +131,20 @@ const DetailConfigActionInternal = () => {
65
131
  ];
66
132
  }
67
133
  return [];
68
- }, [isAction, isConfigRead, isConfigWrite, itemActionConfig]);
134
+ }, [
135
+ formatPIN,
136
+ formatPinMode,
137
+ formatWritePIN,
138
+ isAction,
139
+ isConfigRead,
140
+ isConfigWrite,
141
+ isInternal,
142
+ itemActionConfig?.action?.name,
143
+ itemActionConfig?.config?.name,
144
+ itemActionConfig?.pin,
145
+ itemActionConfig?.value,
146
+ itemActionConfig?.value_type,
147
+ ]);
69
148
 
70
149
  const title = useMemo(
71
150
  () =>
@@ -4,11 +4,13 @@ import { useRoute, useNavigation } from '@react-navigation/native';
4
4
 
5
5
  import DetailConfigAction from '../components/DetailConfigAction';
6
6
  import DetailActionModbus from '../components/DetailActionModbus';
7
+ import { useTranslations } from '../../../hooks/Common/useTranslations';
7
8
  import { calculateLength, calculateStartAddress } from '../utils';
8
9
  import Routes from '../../../utils/Route';
9
10
  import styles from './styles';
10
11
 
11
12
  const DetailConfigActionModbus = () => {
13
+ const t = useTranslations();
12
14
  const { params = {} } = useRoute();
13
15
  const { navigate } = useNavigation();
14
16
  const {
@@ -46,7 +48,7 @@ const DetailConfigActionModbus = () => {
46
48
  },
47
49
  {
48
50
  id: 2,
49
- title: 'Sa',
51
+ title: t('data_address'),
50
52
  data: sa,
51
53
  },
52
54
  {
@@ -55,7 +57,7 @@ const DetailConfigActionModbus = () => {
55
57
  data: len,
56
58
  },
57
59
  ],
58
- [itemActionConfig?.func, len, sa]
60
+ [itemActionConfig?.func, len, sa, t]
59
61
  );
60
62
 
61
63
  const listConfigWrite = useMemo(
@@ -67,7 +69,7 @@ const DetailConfigActionModbus = () => {
67
69
  },
68
70
  {
69
71
  id: 2,
70
- title: 'Sa',
72
+ title: t('data_address'),
71
73
  data: sa,
72
74
  },
73
75
  {
@@ -81,7 +83,7 @@ const DetailConfigActionModbus = () => {
81
83
  data: itemActionConfig?.ex || '--',
82
84
  },
83
85
  ],
84
- [itemActionConfig?.ex, itemActionConfig?.func, len, sa]
86
+ [itemActionConfig?.ex, itemActionConfig?.func, len, sa, t]
85
87
  );
86
88
 
87
89
  const listAction = useMemo(
@@ -18,6 +18,7 @@ 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
+ import { fetchGatewayCT, flushPromises } from '../../test-utils';
21
22
 
22
23
  const mock = new MockAdapter(api.axiosInstance);
23
24
 
@@ -64,6 +65,25 @@ const headerCustomOnPressMore = async (instance) => {
64
65
  });
65
66
  };
66
67
 
68
+ const renderDetail = async (listActions) => {
69
+ let tree;
70
+ mock.onGet(API.DEV_MODE.ARDUINO.ACTION(1, 1)).reply(200, listActions);
71
+ await act(async () => {
72
+ tree = await create(wrapComponent());
73
+ });
74
+ const instance = tree.root;
75
+ const detail = instance?.findByType(Detail);
76
+ const tabPaneCT = detail.findByType(TabPaneCT);
77
+ const segmentedControl = tabPaneCT.findByType(SegmentedControl);
78
+ await act(async () => {
79
+ await segmentedControl.props.onChange({
80
+ nativeEvent: { selectedSegmentIndex: 2 },
81
+ });
82
+ });
83
+ await flushPromises();
84
+ return { detail, tabPaneCT };
85
+ };
86
+
67
87
  describe('Test DeviceInternalDetail', () => {
68
88
  let tree;
69
89
  const listConfigReads = [
@@ -114,8 +134,6 @@ describe('Test DeviceInternalDetail', () => {
114
134
  isInternal: true,
115
135
  },
116
136
  });
117
- });
118
- afterEach(() => {
119
137
  mock.reset();
120
138
  mock.resetHistory();
121
139
  mockNavigate.mockClear();
@@ -143,7 +161,7 @@ describe('Test DeviceInternalDetail', () => {
143
161
  });
144
162
  const instance = tree.root;
145
163
  const detail = instance?.findByType(Detail);
146
- headerCustomOnPressMore(detail);
164
+ await headerCustomOnPressMore(detail);
147
165
  const menuActionMore = detail?.findAllByType(MenuActionMore);
148
166
  expect(menuActionMore[0].props.isVisible).toEqual(true);
149
167
  await act(async () => {
@@ -162,17 +180,18 @@ describe('Test DeviceInternalDetail', () => {
162
180
  });
163
181
  const instance = tree.root;
164
182
  const detail = instance?.findByType(Detail);
165
- headerCustomOnPressMore(detail);
183
+ await headerCustomOnPressMore(detail);
166
184
  const menuActionMore = detail?.findByType(MenuActionMore);
167
185
  expect(menuActionMore.props.isVisible).toEqual(true);
168
186
  await act(async () => {
169
187
  menuActionMore.props.listMenuItem[1].doAction();
170
188
  });
171
189
  const modal = instance.findByType(ModalPopupCT);
190
+
191
+ mock.onDelete(API.DEV_MODE.ARDUINO.DEVICE_DETAIL(1, 1)).reply(200);
172
192
  await act(async () => {
173
193
  await modal.props.onPressConfirm();
174
194
  });
175
- mock.onDelete(API.DEV_MODE.ARDUINO.DEVICE_DETAIL(1, 1)).reply(200);
176
195
  expect(mockPop).toBeCalledWith(1);
177
196
  expect(Toast.show).toBeCalledWith({
178
197
  position: 'bottom',
@@ -228,19 +247,7 @@ describe('Test DeviceInternalDetail', () => {
228
247
  });
229
248
 
230
249
  it('test render DeviceInternalDetail onPress TabPanel action', async () => {
231
- mock.onGet(API.DEV_MODE.ARDUINO.ACTION(1, 1)).reply(200, listActions);
232
- await act(async () => {
233
- tree = await create(wrapComponent());
234
- });
235
- const instance = tree.root;
236
- const detail = instance?.findByType(Detail);
237
- const tabPaneCT = detail.findByType(TabPaneCT);
238
- const segmentedControl = tabPaneCT.findByType(SegmentedControl);
239
- await act(async () => {
240
- await segmentedControl.props.onChange({
241
- nativeEvent: { selectedSegmentIndex: 2 },
242
- });
243
- });
250
+ const { tabPaneCT } = await renderDetail(listActions);
244
251
  expect(tabPaneCT.props.listTabs[2].data).toEqual([
245
252
  {
246
253
  id: 1,
@@ -271,7 +278,7 @@ describe('Test DeviceInternalDetail', () => {
271
278
  await act(async () => {
272
279
  await detail.props.onPressRow(1);
273
280
  });
274
- expect(mockNavigate).toBeCalledWith(Routes.DetailConfigActionInterval, {
281
+ expect(mockNavigate).toBeCalledWith(Routes.DetailConfigActionInternal, {
275
282
  device: {
276
283
  id: 1,
277
284
  name: 'abc',
@@ -280,6 +287,32 @@ describe('Test DeviceInternalDetail', () => {
280
287
  isConfigRead: false,
281
288
  isConfigWrite: true,
282
289
  itemActionConfig: 1,
290
+ isInternal: true,
291
+ board: undefined,
292
+ writeConfigPins: [
293
+ {
294
+ config: {
295
+ is_read: false,
296
+ is_write: true,
297
+ name: 'config1',
298
+ },
299
+ id: 1,
300
+ pin_mode: 'output',
301
+ pin_number: 0,
302
+ value_type: 'boolean',
303
+ },
304
+ {
305
+ config: {
306
+ is_read: true,
307
+ is_write: true,
308
+ name: 'config2',
309
+ },
310
+ id: 2,
311
+ pin_mode: 'output',
312
+ pin_number: 0,
313
+ value_type: 'integer',
314
+ },
315
+ ],
283
316
  });
284
317
  });
285
318
 
@@ -290,19 +323,11 @@ describe('Test DeviceInternalDetail', () => {
290
323
  await act(async () => {
291
324
  tree = await create(wrapComponent());
292
325
  });
293
- const instance = tree.root;
294
- const detail = instance?.findByType(Detail);
295
- const tabPaneCT = detail.findByType(TabPaneCT);
296
- const segmentedControl = tabPaneCT.findByType(SegmentedControl);
297
- await act(async () => {
298
- await segmentedControl.props.onChange({
299
- nativeEvent: { selectedSegmentIndex: 1 },
300
- });
301
- });
326
+ const { detail } = await fetchGatewayCT(tree);
302
327
  await act(async () => {
303
328
  await detail.props.onPressRow(1);
304
329
  });
305
- expect(mockNavigate).toBeCalledWith(Routes.DetailConfigActionInterval, {
330
+ expect(mockNavigate).toBeCalledWith(Routes.DetailConfigActionInternal, {
306
331
  device: {
307
332
  id: 1,
308
333
  name: 'abc',
@@ -311,27 +336,18 @@ describe('Test DeviceInternalDetail', () => {
311
336
  isConfigRead: true,
312
337
  isConfigWrite: false,
313
338
  itemActionConfig: 1,
339
+ board: undefined,
340
+ isInternal: true,
341
+ writeConfigPins: [],
314
342
  });
315
343
  });
316
344
 
317
345
  it('test render DeviceInternalDetail onPress TabPanel action onPressRow', async () => {
318
- mock.onGet(API.DEV_MODE.ARDUINO.ACTION(1, 1)).reply(200, listActions);
319
- await act(async () => {
320
- tree = await create(wrapComponent());
321
- });
322
- const instance = tree.root;
323
- const detail = instance?.findByType(Detail);
324
- const tabPaneCT = detail.findByType(TabPaneCT);
325
- const segmentedControl = tabPaneCT.findByType(SegmentedControl);
326
- await act(async () => {
327
- await segmentedControl.props.onChange({
328
- nativeEvent: { selectedSegmentIndex: 2 },
329
- });
330
- });
346
+ const { detail } = await renderDetail(listActions);
331
347
  await act(async () => {
332
348
  await detail.props.onPressRow(1);
333
349
  });
334
- expect(mockNavigate).toBeCalledWith(Routes.DetailConfigActionInterval, {
350
+ expect(mockNavigate).toBeCalledWith(Routes.DetailConfigActionInternal, {
335
351
  device: {
336
352
  id: 1,
337
353
  name: 'abc',
@@ -340,6 +356,9 @@ describe('Test DeviceInternalDetail', () => {
340
356
  isConfigRead: false,
341
357
  isConfigWrite: false,
342
358
  itemActionConfig: 1,
359
+ board: undefined,
360
+ isInternal: true,
361
+ writeConfigPins: undefined,
343
362
  });
344
363
  });
345
364
 
@@ -364,20 +383,7 @@ describe('Test DeviceInternalDetail', () => {
364
383
  });
365
384
 
366
385
  it('test render DeviceInternalDetail onPress TabPanel action onRefresh', async () => {
367
- mock.onGet(API.DEV_MODE.ARDUINO.ACTION(1, 1)).reply(200, listActions);
368
-
369
- await act(async () => {
370
- tree = await create(wrapComponent());
371
- });
372
- const instance = tree.root;
373
- const detail = instance?.findByType(Detail);
374
- const tabPaneCT = detail.findByType(TabPaneCT);
375
- const segmentedControl = tabPaneCT.findByType(SegmentedControl);
376
- await act(async () => {
377
- await segmentedControl.props.onChange({
378
- nativeEvent: { selectedSegmentIndex: 2 },
379
- });
380
- });
386
+ const { detail, tabPaneCT } = await renderDetail(listActions);
381
387
  await act(async () => {
382
388
  await detail.props.onRefresh();
383
389
  });