@eohjsc/react-native-smart-city 0.4.39 → 0.4.41

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 (78) hide show
  1. package/android/build.gradle +1 -1
  2. package/package.json +2 -2
  3. package/src/commons/Action/ItemQuickAction.js +1 -0
  4. package/src/commons/ActionGroup/ColorPickerTemplate.js +3 -4
  5. package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +3 -3
  6. package/src/commons/ActionGroup/OnOffSmartLock/OnOffSmartLock.js +2 -2
  7. package/src/commons/ActionGroup/OnOffTemplate/OnOffButtonTemplate.js +4 -5
  8. package/src/commons/ActionGroup/OnOffTemplate/SwitchButtonTemplate.js +4 -4
  9. package/src/commons/ActionGroup/OnOffTemplate/index.js +6 -5
  10. package/src/commons/ActionGroup/OneBigButtonTemplate.js +4 -4
  11. package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +6 -17
  12. package/src/commons/ActionGroup/SliderRangeTemplate.js +5 -3
  13. package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +7 -7
  14. package/src/commons/ActionGroup/StatesGridActionTemplate.js +6 -20
  15. package/src/commons/ActionGroup/ThreeButtonTemplate/__test__/ThreeButtonTemplate.test.js +6 -6
  16. package/src/commons/ActionGroup/ThreeButtonTemplate/index.js +2 -2
  17. package/src/commons/ActionGroup/TimerActionTemplate.js +3 -2
  18. package/src/commons/ActionGroup/TwoButtonTemplate/index.js +133 -135
  19. package/src/commons/ActionGroup/__test__/ColorPickerTemplate.test.js +37 -14
  20. package/src/commons/ActionGroup/__test__/NumberUpDownTemplate.test.js +71 -31
  21. package/src/commons/ActionGroup/__test__/OnOffButtonTemplate.test.js +11 -11
  22. package/src/commons/ActionGroup/__test__/OnOffSmartLock.test.js +13 -17
  23. package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +44 -48
  24. package/src/commons/ActionGroup/__test__/OneBigButtonTemplate.test.js +56 -22
  25. package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +123 -21
  26. package/src/commons/ActionGroup/__test__/SliderRangeTemplate.test.js +12 -16
  27. package/src/commons/ActionGroup/__test__/StatesGridActionTemplate.test.js +73 -38
  28. package/src/commons/ActionGroup/__test__/SwitchButtonTemplate.test.js +11 -15
  29. package/src/commons/ActionGroup/__test__/TimerActionTemplate.test.js +11 -15
  30. package/src/commons/ActionGroup/__test__/TimerActionTemplateWithutConfigValue.test.js +9 -9
  31. package/src/commons/ActionGroup/__test__/TwoButtonTemplate.test.js +21 -31
  32. package/src/commons/ActionGroup/__test__/index.test.js +36 -21
  33. package/src/commons/ActionGroup/index.js +4 -7
  34. package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +0 -5
  35. package/src/commons/Dashboard/MyUnit/index.js +2 -2
  36. package/src/commons/FlatListDnD/__test__/index.test.js +27 -25
  37. package/src/commons/GroupCheckBox/__test__/GroupCheckBox.test.js +1 -22
  38. package/src/commons/HeaderAni/index.js +12 -2
  39. package/src/commons/MediaPlayerDetail/__test__/MediaPlayerFull.test.js +1 -23
  40. package/src/commons/OneTapTemplate/__test__/NumberUpDownActionTemplate.test.js +5 -3
  41. package/src/commons/Processing/index.js +1 -0
  42. package/src/commons/Processing/styles.js +3 -0
  43. package/src/commons/SubUnit/OneTap/ItemOneTap.js +1 -0
  44. package/src/commons/UnitSummary/ConfigHistoryChart/index.js +1 -58
  45. package/src/commons/icon/index.js +57 -0
  46. package/src/configs/AccessibilityLabel.js +1 -0
  47. package/src/hooks/IoT/__test__/useRemoteControl.test.js +52 -51
  48. package/src/hooks/IoT/__test__/useWatchConfigs.test.js +3 -2
  49. package/src/hooks/useMqtt.js +5 -2
  50. package/src/iot/mqtt.js +2 -0
  51. package/src/navigations/UnitStack.js +2 -2
  52. package/src/screens/AddNewGateway/ConnectingDevice.js +2 -2
  53. package/src/screens/AddNewGateway/ShareWifiPassword.js +2 -2
  54. package/src/screens/AllGateway/DeviceModbusDetail/__test__/index.test.js +31 -32
  55. package/src/screens/Automate/AddNewAction/SetupConfigCondition.js +19 -2
  56. package/src/screens/Automate/AddNewAction/__test__/{SetupSensor.test.js → SetupConfigCondition.test.js} +97 -0
  57. package/src/screens/Automate/EditActionsList/__tests__/index.test.js +69 -68
  58. package/src/screens/ChangePosition/__test__/index.test.js +34 -32
  59. package/src/screens/ConfirmUnitDeletion/__test__/ConfirmUnitDeletion.test.js +1 -11
  60. package/src/screens/Device/__test__/detail.test.js +40 -45
  61. package/src/screens/Device/__test__/sensorDisplayItem.test.js +14 -2
  62. package/src/screens/Device/components/ChartWrapper.js +14 -12
  63. package/src/screens/Device/components/SensorDisplayItem.js +18 -2
  64. package/src/screens/Device/components/VisualChart.js +7 -1
  65. package/src/screens/Device/components/__test__/VisualChart.test.js +0 -3
  66. package/src/screens/Device/detail.js +32 -14
  67. package/src/screens/Device/hooks/__test__/useEvaluateValue.test.js +20 -18
  68. package/src/screens/Device/styles.js +3 -0
  69. package/src/screens/Sharing/MemberList.js +16 -3
  70. package/src/screens/Sharing/__test__/SelectPermission.test.js +96 -137
  71. package/src/screens/Template/__test__/EditTemplate.test.js +48 -45
  72. package/src/screens/Unit/SelectAddToFavorites.js +1 -0
  73. package/src/screens/Unit/__test__/SelectAddress.test.js +4 -11
  74. package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js +1 -11
  75. package/src/utils/Apis/axios.js +1 -0
  76. package/src/utils/I18n/translations/en.js +2 -0
  77. package/src/utils/I18n/translations/vi.js +2 -0
  78. package/src/commons/UnitSummary/ConfigHistoryChart/__test__/ConfigHistoryChart.test.js +0 -289
@@ -62,6 +62,7 @@ const shouldHideError = async (message) => {
62
62
  const parseErrorResponse = async (error) => {
63
63
  let message;
64
64
  let data = {};
65
+
65
66
  if (error.data instanceof Array) {
66
67
  message = error.data[0];
67
68
  } else if (error.data instanceof Object) {
@@ -1425,4 +1425,6 @@ export default {
1425
1425
  actions: 'actions',
1426
1426
  value_must_be_less_than_8_character:
1427
1427
  'Value must be less than or equal to 8 characters',
1428
+ bellow_widget_is_not_configured: 'Bellow widget is not configured',
1429
+ bellow_widget_is_wrongly_configured: 'Bellow widget is wrongly configured',
1428
1430
  };
@@ -1436,4 +1436,6 @@ export default {
1436
1436
  you_can_only_add_more: 'Bạn chỉ có thể thêm {number}',
1437
1437
  actions: 'hành động',
1438
1438
  value_must_be_less_than_8_character: 'Giá trị phải ít hơn hoặc bằng 8 kí tự',
1439
+ bellow_widget_is_not_configured: 'Tiện ích bên dưới chưa được cấu hình',
1440
+ bellow_widget_is_wrongly_configured: 'Tiện ích bên dưới được cấu hình sai',
1439
1441
  };
@@ -1,289 +0,0 @@
1
- import React from 'react';
2
- import { act, create } from 'react-test-renderer';
3
- import MockAdapter from 'axios-mock-adapter';
4
-
5
- import ConfigHistoryChart from '../';
6
- import api from '../../../../utils/Apis/axios';
7
- import { mockSCStore } from '../../../../context/mockStore';
8
- import { SCProvider } from '../../../../context';
9
- import API from '../../../../configs/API';
10
- import { getPusher } from '../../../../utils/Pusher';
11
- import Highcharts from '../../../Highcharts';
12
-
13
- const mock = new MockAdapter(api.axiosInstance);
14
-
15
- const wrapComponent = (configs = []) => (
16
- <SCProvider initState={mockSCStore({})}>
17
- <ConfigHistoryChart configs={configs} />
18
- </SCProvider>
19
- );
20
-
21
- describe('Test HistoryChart', () => {
22
- let tree;
23
-
24
- beforeAll(() => {
25
- jest.useFakeTimers();
26
- });
27
-
28
- beforeEach(() => {
29
- getPusher().subscribe.mockClear();
30
- });
31
-
32
- const assertChartData = async (data) => {
33
- const chart = tree.root.findByType(Highcharts);
34
- expect(chart.props.options.series[0].data).toEqual(
35
- data.map((i) => [i.x, i.y])
36
- );
37
- };
38
-
39
- it('Test render null', async () => {
40
- await act(async () => {
41
- tree = create(wrapComponent());
42
- });
43
- const instance = tree.root;
44
- const HistoryCharts = instance.findAllByType(Highcharts);
45
- expect(HistoryCharts).toHaveLength(0);
46
- });
47
-
48
- it('Test render chart empty data', async () => {
49
- const response = {
50
- data: {
51
- configs: [
52
- {
53
- id: 1,
54
- head: [],
55
- tail: [],
56
- middle: {
57
- ready: [],
58
- not_ready: [],
59
- channel: '',
60
- },
61
- },
62
- ],
63
- },
64
- };
65
- mock.onGet(API.CONFIG.DISPLAY_HISTORY_V3()).reply(200, response.data);
66
- const configs = [{ id: 1 }];
67
- await act(async () => {
68
- tree = await create(wrapComponent(configs));
69
- jest.runAllTimers();
70
- });
71
- await assertChartData([]);
72
- });
73
-
74
- it('Test render chart empty head data', async () => {
75
- const response = {
76
- data: {
77
- configs: [
78
- {
79
- id: 1,
80
- head: [],
81
- tail: [{ x: 1, y: 2 }],
82
- middle: {
83
- ready: [],
84
- not_ready: [],
85
- channel: '',
86
- },
87
- },
88
- ],
89
- },
90
- };
91
- mock.onGet(API.CONFIG.DISPLAY_HISTORY_V3()).reply(200, response.data);
92
- const configs = [{ id: 1 }];
93
- await act(async () => {
94
- tree = await create(wrapComponent(configs));
95
- jest.runAllTimers();
96
- });
97
- await assertChartData([{ x: 1, y: 2 }]);
98
- });
99
-
100
- it('Test render chart empty tail data', async () => {
101
- const response = {
102
- data: {
103
- configs: [
104
- {
105
- id: 1,
106
- head: [{ x: 1, y: 2 }],
107
- tail: [],
108
- middle: {
109
- ready: [],
110
- not_ready: [],
111
- channel: '',
112
- },
113
- },
114
- ],
115
- },
116
- };
117
- mock.onGet(API.CONFIG.DISPLAY_HISTORY_V3()).reply(200, response.data);
118
- const configs = [{ id: 1 }];
119
- await act(async () => {
120
- tree = await create(wrapComponent(configs));
121
- jest.runAllTimers();
122
- });
123
- await assertChartData([{ x: 1, y: 2 }]);
124
- });
125
-
126
- it('Test render chart merge head and tail data', async () => {
127
- const response = {
128
- data: {
129
- configs: [
130
- {
131
- id: 1,
132
- head: [{ x: 1, y: 2 }],
133
- tail: [{ x: 2, y: 3 }],
134
- middle: {
135
- ready: [],
136
- not_ready: [],
137
- channel: '',
138
- },
139
- },
140
- ],
141
- },
142
- };
143
- mock.onGet(API.CONFIG.DISPLAY_HISTORY_V3()).reply(200, response.data);
144
- const configs = [{ id: 1 }];
145
- await act(async () => {
146
- tree = await create(wrapComponent(configs));
147
- jest.runAllTimers();
148
- });
149
- await assertChartData([
150
- { x: 1, y: 2 },
151
- { x: 2, y: 3 },
152
- ]);
153
- });
154
-
155
- it('Test render chart merge fetch ready data', async () => {
156
- const cacheUrl = 'https://s3.eoh.io/xxx.json';
157
- const response = {
158
- data: {
159
- configs: [
160
- {
161
- id: 1,
162
- head: [{ x: 1, y: 2 }],
163
- tail: [{ x: 2, y: 3 }],
164
- middle: {
165
- ready: [{ date: '2022-03-03', url: cacheUrl }],
166
- not_ready: [],
167
- channel: '',
168
- },
169
- },
170
- ],
171
- },
172
- };
173
- mock.onGet(API.CONFIG.DISPLAY_HISTORY_V3()).reply(200, response.data);
174
- mock.onGet(cacheUrl).reply(200, [{ x: 3, y: 4 }]);
175
- const configs = [{ id: 1 }];
176
- await act(async () => {
177
- tree = await create(wrapComponent(configs));
178
- jest.runAllTimers();
179
- });
180
- await assertChartData([
181
- { x: 1, y: 2 },
182
- { x: 3, y: 4 },
183
- { x: 2, y: 3 },
184
- ]);
185
- });
186
-
187
- it('Test render chart merge fetch not-ready data', async () => {
188
- const cacheUrl = 'https://s3.eoh.io/xxx.json';
189
- const response = {
190
- data: {
191
- configs: [
192
- {
193
- id: 1,
194
- head: [{ x: 1, y: 2 }],
195
- tail: [{ x: 2, y: 3 }],
196
- middle: {
197
- ready: [],
198
- not_ready: [{ date: '2022-03-03', url: cacheUrl }],
199
- channel: 'cache-xxx',
200
- },
201
- },
202
- ],
203
- },
204
- };
205
- mock.onGet(API.CONFIG.DISPLAY_HISTORY_V3()).reply(200, response.data);
206
- mock.onGet(cacheUrl).reply(200, [{ x: 3, y: 4 }]);
207
- const configs = [{ id: 1 }];
208
- await act(async () => {
209
- tree = await create(wrapComponent(configs));
210
- jest.runAllTimers();
211
- });
212
- await assertChartData([
213
- { x: 1, y: 2 },
214
- { x: 2, y: 3 },
215
- ]);
216
- await act(async () => {
217
- await getPusher()
218
- .subscribe('cache-xxx')
219
- .trigger('caching-value-log-process', {
220
- success: true,
221
- });
222
- });
223
- await assertChartData([
224
- { x: 1, y: 2 },
225
- { x: 3, y: 4 },
226
- { x: 2, y: 3 },
227
- ]);
228
- });
229
-
230
- it('Test render chart merge fetch both ready and not-ready data', async () => {
231
- const cacheUrl1 = 'https://s3.eoh.io/xxx1.json';
232
- const cacheUrl2 = 'https://s3.eoh.io/xxx2.json';
233
- const cacheUrl3 = 'https://s3.eoh.io/xxx3.json';
234
- const cacheUrl4 = 'https://s3.eoh.io/xxx4.json';
235
- const response = {
236
- data: {
237
- configs: [
238
- {
239
- id: 1,
240
- head: [{ x: 1, y: 2 }],
241
- tail: [{ x: 2, y: 3 }],
242
- middle: {
243
- ready: [
244
- { date: '2022-03-02', url: cacheUrl1 },
245
- { date: '2022-03-04', url: cacheUrl3 },
246
- ],
247
- not_ready: [
248
- { date: '2022-03-03', url: cacheUrl2 },
249
- { date: '2022-03-05', url: cacheUrl4 },
250
- ],
251
- channel: 'cache-xxx',
252
- },
253
- },
254
- ],
255
- },
256
- };
257
- mock.onGet(API.CONFIG.DISPLAY_HISTORY_V3()).reply(200, response.data);
258
- mock.onGet(cacheUrl1).reply(200, [{ x: 3, y: 4 }]);
259
- mock.onGet(cacheUrl2).reply(200, [{ x: 4, y: 5 }]);
260
- mock.onGet(cacheUrl3).reply(200, [{ x: 5, y: 6 }]);
261
- mock.onGet(cacheUrl4).reply(200, [{ x: 7, y: 8 }]);
262
- const configs = [{ id: 1 }];
263
- await act(async () => {
264
- tree = await create(wrapComponent(configs));
265
- jest.runAllTimers();
266
- });
267
- await assertChartData([
268
- { x: 1, y: 2 },
269
- { x: 3, y: 4 },
270
- { x: 5, y: 6 },
271
- { x: 2, y: 3 },
272
- ]);
273
- await act(async () => {
274
- await getPusher()
275
- .subscribe('cache-xxx')
276
- .trigger('caching-value-log-process', {
277
- success: true,
278
- });
279
- });
280
- await assertChartData([
281
- { x: 1, y: 2 },
282
- { x: 3, y: 4 },
283
- { x: 4, y: 5 },
284
- { x: 5, y: 6 },
285
- { x: 7, y: 8 },
286
- { x: 2, y: 3 },
287
- ]);
288
- });
289
- });