@eohjsc/react-native-smart-city 0.4.41 → 0.4.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.
Files changed (85) hide show
  1. package/android/build.gradle +24 -19
  2. package/package.json +12 -14
  3. package/src/commons/Action/ItemQuickAction.js +0 -1
  4. package/src/commons/ActionGroup/ColorPickerTemplate.js +4 -3
  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 +5 -4
  8. package/src/commons/ActionGroup/OnOffTemplate/SwitchButtonTemplate.js +4 -4
  9. package/src/commons/ActionGroup/OnOffTemplate/index.js +5 -6
  10. package/src/commons/ActionGroup/OneBigButtonTemplate.js +4 -4
  11. package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +17 -6
  12. package/src/commons/ActionGroup/SliderRangeTemplate.js +3 -5
  13. package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +7 -7
  14. package/src/commons/ActionGroup/StatesGridActionTemplate.js +20 -6
  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 +2 -3
  18. package/src/commons/ActionGroup/TwoButtonTemplate/index.js +135 -133
  19. package/src/commons/ActionGroup/__test__/ColorPickerTemplate.test.js +14 -37
  20. package/src/commons/ActionGroup/__test__/NumberUpDownTemplate.test.js +31 -71
  21. package/src/commons/ActionGroup/__test__/OnOffButtonTemplate.test.js +11 -11
  22. package/src/commons/ActionGroup/__test__/OnOffSmartLock.test.js +17 -13
  23. package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +48 -44
  24. package/src/commons/ActionGroup/__test__/OneBigButtonTemplate.test.js +22 -56
  25. package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +21 -123
  26. package/src/commons/ActionGroup/__test__/SliderRangeTemplate.test.js +16 -12
  27. package/src/commons/ActionGroup/__test__/StatesGridActionTemplate.test.js +38 -73
  28. package/src/commons/ActionGroup/__test__/SwitchButtonTemplate.test.js +15 -11
  29. package/src/commons/ActionGroup/__test__/TimerActionTemplate.test.js +15 -11
  30. package/src/commons/ActionGroup/__test__/TimerActionTemplateWithutConfigValue.test.js +9 -9
  31. package/src/commons/ActionGroup/__test__/TwoButtonTemplate.test.js +31 -21
  32. package/src/commons/ActionGroup/__test__/index.test.js +21 -36
  33. package/src/commons/ActionGroup/index.js +7 -4
  34. package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +5 -0
  35. package/src/commons/Dashboard/MyUnit/index.js +2 -2
  36. package/src/commons/DateTimeRangeChange/index.js +3 -3
  37. package/src/commons/Device/HistoryChart.js +1 -1
  38. package/src/commons/Device/HorizontalBarChart.js +4 -3
  39. package/src/commons/Device/LinearChart.js +5 -3
  40. package/src/commons/FlatListDnD/__test__/index.test.js +25 -27
  41. package/src/commons/GroupCheckBox/__test__/GroupCheckBox.test.js +22 -1
  42. package/src/commons/HeaderAni/index.js +2 -12
  43. package/src/commons/MediaPlayerDetail/__test__/MediaPlayerFull.test.js +23 -1
  44. package/src/commons/OneTapTemplate/__test__/NumberUpDownActionTemplate.test.js +3 -5
  45. package/src/commons/Processing/index.js +0 -1
  46. package/src/commons/Processing/styles.js +0 -3
  47. package/src/commons/SubUnit/OneTap/ItemOneTap.js +0 -1
  48. package/src/commons/Unit/HeaderUnit/index.js +8 -15
  49. package/src/commons/UnitSummary/ConfigHistoryChart/__test__/ConfigHistoryChart.test.js +289 -0
  50. package/src/commons/UnitSummary/ConfigHistoryChart/index.js +59 -1
  51. package/src/configs/AccessibilityLabel.js +0 -1
  52. package/src/hooks/IoT/__test__/useRemoteControl.test.js +51 -52
  53. package/src/hooks/IoT/__test__/useWatchConfigs.test.js +2 -3
  54. package/src/hooks/useMqtt.js +2 -5
  55. package/src/iot/mqtt.js +0 -2
  56. package/src/navigations/UnitStack.js +2 -2
  57. package/src/screens/AddNewGateway/ConnectingDevice.js +2 -2
  58. package/src/screens/AddNewGateway/ShareWifiPassword.js +2 -2
  59. package/src/screens/AllGateway/DeviceModbusDetail/__test__/index.test.js +32 -31
  60. package/src/screens/Automate/AddNewAction/SetupConfigCondition.js +2 -19
  61. package/src/screens/Automate/AddNewAction/__test__/{SetupConfigCondition.test.js → SetupSensor.test.js} +0 -97
  62. package/src/screens/Automate/EditActionsList/__tests__/index.test.js +68 -69
  63. package/src/screens/ChangePosition/__test__/index.test.js +32 -34
  64. package/src/screens/ConfirmUnitDeletion/__test__/ConfirmUnitDeletion.test.js +11 -1
  65. package/src/screens/Device/__test__/detail.test.js +45 -40
  66. package/src/screens/Device/__test__/sensorDisplayItem.test.js +2 -14
  67. package/src/screens/Device/components/ChartWrapper.js +12 -14
  68. package/src/screens/Device/components/SensorDisplayItem.js +2 -18
  69. package/src/screens/Device/components/VisualChart.js +3 -17
  70. package/src/screens/Device/components/__test__/VisualChart.test.js +15 -12
  71. package/src/screens/Device/detail.js +15 -34
  72. package/src/screens/Device/hooks/__test__/useEvaluateValue.test.js +18 -20
  73. package/src/screens/Device/styles.js +0 -3
  74. package/src/screens/Sharing/MemberList.js +3 -16
  75. package/src/screens/Sharing/__test__/SelectPermission.test.js +137 -96
  76. package/src/screens/Template/__test__/EditTemplate.test.js +45 -48
  77. package/src/screens/Unit/SelectAddToFavorites.js +0 -1
  78. package/src/screens/Unit/__test__/SelectAddress.test.js +11 -4
  79. package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js +11 -1
  80. package/src/utils/Apis/axios.js +0 -1
  81. package/src/utils/I18n/translations/en.js +0 -2
  82. package/src/utils/I18n/translations/vi.js +0 -2
  83. package/src/utils/Monitor.js +2 -2
  84. package/src/commons/Highcharts/index.js +0 -111
  85. package/src/commons/icon/index.js +0 -57
@@ -1,4 +1,3 @@
1
- /* eslint-disable no-unused-vars */
2
1
  import React from 'react';
3
2
  import { act, create } from 'react-test-renderer';
4
3
  import MockAdapter from 'axios-mock-adapter';
@@ -34,8 +33,6 @@ const wrapComponent = ({ ...rest }) => (
34
33
  </SCProvider>
35
34
  );
36
35
 
37
- // NOTE: Hinh will fix it later
38
-
39
36
  describe('Test ChangePosition', () => {
40
37
  let tree;
41
38
 
@@ -45,36 +42,37 @@ describe('Test ChangePosition', () => {
45
42
  });
46
43
 
47
44
  it('render ChangePosition', async () => {
48
- // const mockFetchData = jest.fn();
49
- // const spyToastSuccess = jest.spyOn(ToastBottomHelper, 'success');
50
- // useRoute.mockReturnValue({
51
- // params: {
52
- // sensor: { id: 1, name: 'device' },
53
- // display: { items: [{ id: 1 }, { id: 2 }] },
54
- // setDisplay: mockSetDisplay,
55
- // station: { id: 1, name: 'station' },
56
- // evaluate: {},
57
- // fetchDataDeviceDetail: mockFetchData,
58
- // },
59
- // });
60
- // mock.onPut(API.DEVICE.ORDER_DISPLAY_ITEMS(1)).reply(200);
61
- // await act(async () => {
62
- // tree = await create(wrapComponent({}));
63
- // });
64
- // const instance = tree.root;
65
- // const flatListDnD = instance.findAllByType(DraggableFlatList);
66
- // expect(flatListDnD).toHaveLength(1);
67
- // const bottomButtonView = instance.findAllByType(BottomButtonView);
68
- // expect(bottomButtonView).toHaveLength(1);
69
- // await act(async () => {
70
- // flatListDnD[0].props.onDragEnd({ data: [{ id: 2 }, { id: 1 }] });
71
- // });
72
- // await act(async () => {
73
- // bottomButtonView[0].props.onPressMain();
74
- // });
75
- // expect(mockGoBack).toHaveBeenCalled();
76
- // expect(mockFetchData).toHaveBeenCalled();
77
- // expect(mockSetDisplay).toHaveBeenCalled();
78
- // expect(spyToastSuccess).toBeCalledWith('Updated widget successfully');
45
+ const mockFetchData = jest.fn();
46
+ const spyToastSuccess = jest.spyOn(ToastBottomHelper, 'success');
47
+ useRoute.mockReturnValue({
48
+ params: {
49
+ sensor: { id: 1, name: 'device' },
50
+ display: { items: [{ id: 1 }, { id: 2 }] },
51
+ setDisplay: mockSetDisplay,
52
+ station: { id: 1, name: 'station' },
53
+ evaluate: {},
54
+ fetchDataDeviceDetail: mockFetchData,
55
+ },
56
+ });
57
+ mock.onPut(API.DEVICE.ORDER_DISPLAY_ITEMS(1)).reply(200);
58
+ await act(async () => {
59
+ tree = await create(wrapComponent({}));
60
+ });
61
+ const instance = tree.root;
62
+ const flatListDnD = instance.findAllByType(DraggableFlatList);
63
+ expect(flatListDnD).toHaveLength(1);
64
+
65
+ const bottomButtonView = instance.findAllByType(BottomButtonView);
66
+ expect(bottomButtonView).toHaveLength(1);
67
+ await act(async () => {
68
+ flatListDnD[0].props.onDragEnd({ data: [{ id: 2 }, { id: 1 }] });
69
+ });
70
+ await act(async () => {
71
+ bottomButtonView[0].props.onPressMain();
72
+ });
73
+ expect(mockGoBack).toHaveBeenCalled();
74
+ expect(mockFetchData).toHaveBeenCalled();
75
+ expect(mockSetDisplay).toHaveBeenCalled();
76
+ expect(spyToastSuccess).toBeCalledWith('Updated widget successfully');
79
77
  });
80
78
  });
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { useState } from 'react';
2
2
  import renderer, { act } from 'react-test-renderer';
3
3
 
4
4
  import { SCProvider } from '../../../context';
@@ -30,6 +30,14 @@ jest.mock('@react-navigation/native', () => {
30
30
  };
31
31
  });
32
32
 
33
+ const mockSetState = jest.fn();
34
+ jest.mock('react', () => {
35
+ return {
36
+ ...jest.requireActual('react'),
37
+ useState: jest.fn((init) => [init, mockSetState]),
38
+ };
39
+ });
40
+
33
41
  describe('Test ConfirmUnitDeletion', () => {
34
42
  let tree;
35
43
  let route;
@@ -45,6 +53,7 @@ describe('Test ConfirmUnitDeletion', () => {
45
53
  });
46
54
 
47
55
  it('test render ConfirmUnitDeletion', async () => {
56
+ useState.mockImplementationOnce((init) => ['new_name', mockSetState]);
48
57
  await act(async () => {
49
58
  tree = await renderer.create(wrapComponent(route));
50
59
  });
@@ -56,6 +65,7 @@ describe('Test ConfirmUnitDeletion', () => {
56
65
  });
57
66
  });
58
67
  it('Onpress button ConfirmUnitDeletion ', async () => {
68
+ useState.mockImplementationOnce((init) => ['YES', mockSetState]);
59
69
  await act(async () => {
60
70
  tree = await renderer.create(wrapComponent(route));
61
71
  });
@@ -107,49 +107,54 @@ describe('test DeviceDetail', () => {
107
107
  },
108
108
  {
109
109
  configuration: {
110
- action1: '2b949045-8e03-4c07-a855-7794ade2e69c',
111
- action1_data: {
112
- color: '#00979D',
113
- command_prefer_over_bluetooth: false,
114
- command_prefer_over_googlehome: false,
115
- command_prefer_over_internet: true,
116
- googlehome_actions: [],
117
- icon: 'caret-up',
118
- id: 9,
119
- key: '2b949045-8e03-4c07-a855-7794ade2e69c',
120
- },
121
- action2: '38347d5e-4418-4ab0-978c-c82f4c034897',
122
- action2_data: {
123
- color: '#00979D',
124
- command_prefer_over_bluetooth: false,
125
- command_prefer_over_googlehome: false,
126
- command_prefer_over_internet: true,
127
- googlehome_actions: [],
128
- icon: 'stop',
129
- id: 11,
130
- key: '38347d5e-4418-4ab0-978c-c82f4c034897',
131
- },
132
- action3: 'a492e08c-8cb1-44ee-8ea0-46aaca4e5141',
133
- action3_data: {
134
- color: '#00979D',
135
- command_prefer_over_bluetooth: false,
136
- command_prefer_over_googlehome: false,
137
- command_prefer_over_internet: true,
138
- googlehome_actions: [],
139
- icon: 'caret-down',
140
- id: 10,
141
- key: 'a492e08c-8cb1-44ee-8ea0-46aaca4e5141',
110
+ id: 1,
111
+ template: 'three_button_action_template',
112
+ title: '',
113
+ configuration: {
114
+ action1: '2b949045-8e03-4c07-a855-7794ade2e69c',
115
+ action1_data: {
116
+ color: '#00979D',
117
+ command_prefer_over_bluetooth: false,
118
+ command_prefer_over_googlehome: false,
119
+ command_prefer_over_internet: true,
120
+ googlehome_actions: [],
121
+ icon: 'caret-up',
122
+ id: 9,
123
+ key: '2b949045-8e03-4c07-a855-7794ade2e69c',
124
+ },
125
+ action2: '38347d5e-4418-4ab0-978c-c82f4c034897',
126
+ action2_data: {
127
+ color: '#00979D',
128
+ command_prefer_over_bluetooth: false,
129
+ command_prefer_over_googlehome: false,
130
+ command_prefer_over_internet: true,
131
+ googlehome_actions: [],
132
+ icon: 'stop',
133
+ id: 11,
134
+ key: '38347d5e-4418-4ab0-978c-c82f4c034897',
135
+ },
136
+ action3: 'a492e08c-8cb1-44ee-8ea0-46aaca4e5141',
137
+ action3_data: {
138
+ color: '#00979D',
139
+ command_prefer_over_bluetooth: false,
140
+ command_prefer_over_googlehome: false,
141
+ command_prefer_over_internet: true,
142
+ googlehome_actions: [],
143
+ icon: 'caret-down',
144
+ id: 10,
145
+ key: 'a492e08c-8cb1-44ee-8ea0-46aaca4e5141',
146
+ },
147
+ icon1: 'caret-up',
148
+ icon2: 'stop',
149
+ icon3: 'caret-down',
150
+ text1: 'UP',
151
+ text2: 'STOP/UNLOCK',
152
+ text3: 'DOWN',
142
153
  },
143
- icon1: 'caret-up',
144
- icon2: 'stop',
145
- icon3: 'caret-down',
146
- text1: 'UP',
147
- text2: 'STOP/UNLOCK',
148
- text3: 'DOWN',
149
154
  },
150
155
  id: 19,
151
156
  order: 2,
152
- template: 'three_button_action_template',
157
+ template: 'action',
153
158
  type: 'action',
154
159
  },
155
160
  ],
@@ -744,7 +749,7 @@ describe('test DeviceDetail', () => {
744
749
 
745
750
  it('Open popup ble when server down', async () => {
746
751
  store.bluetooth.isEnabled = false;
747
- data_sensor_display.items[2].configuration.action1_data.command_prefer_over_bluetooth = true;
752
+ data_sensor_display.items[2].configuration.configuration.action1_data.command_prefer_over_bluetooth = true;
748
753
  const responseDisplay = data_sensor_display;
749
754
 
750
755
  const responseDisplayValueV2 = {
@@ -24,19 +24,6 @@ const wrapComponent = ({ ...rest }) => (
24
24
  <SensorDisplayItem {...rest} />
25
25
  </SCProvider>
26
26
  );
27
-
28
- const mockNavigate = jest.fn();
29
- jest.mock('@react-navigation/native', () => {
30
- return {
31
- ...jest.requireActual('@react-navigation/native'),
32
- useRoute: jest.fn(),
33
- useNavigation: () => ({
34
- navigate: mockNavigate,
35
- }),
36
- useFocusEffect: (func) => func(),
37
- };
38
- });
39
-
40
27
  describe('Test SensorDisplayItem', () => {
41
28
  let tree;
42
29
  it('render DetailHistoryChart', async () => {
@@ -76,7 +63,8 @@ describe('Test SensorDisplayItem', () => {
76
63
  const item = {
77
64
  id: 10452,
78
65
  order: 0,
79
- template: 'on_off_button_action_template',
66
+ template: 'action',
67
+ type: 'action',
80
68
  configuration: {
81
69
  type: 'on_off_button_action_template',
82
70
  configs: [
@@ -5,7 +5,7 @@ import DateTimeRangeChange from '../../../commons/DateTimeRangeChange';
5
5
  import moment from 'moment';
6
6
 
7
7
  const ChartWrapper = memo(
8
- ({ children, onChangeDate, showTime, isWidgetOrder, shouldRenderDate }) => {
8
+ ({ children, onChangeDate, showTime, isWidgetOrder }) => {
9
9
  const [value, setValue] = useState([
10
10
  moment().subtract(6, 'days'),
11
11
  moment(),
@@ -24,20 +24,18 @@ const ChartWrapper = memo(
24
24
 
25
25
  return (
26
26
  <View>
27
- {shouldRenderDate && (
28
- <View style={styles.headerContainer}>
29
- <View>
30
- <DateTimeRangeChange
31
- startTime={value[0]}
32
- endTime={value[1]}
33
- showTime={showTime}
34
- selectStart={selectStart}
35
- selectEnd={selectEnd}
36
- isWidgetOrder={isWidgetOrder}
37
- />
38
- </View>
27
+ <View style={styles.headerContainer}>
28
+ <View>
29
+ <DateTimeRangeChange
30
+ startTime={value[0]}
31
+ endTime={value[1]}
32
+ showTime={showTime}
33
+ selectStart={selectStart}
34
+ selectEnd={selectEnd}
35
+ isWidgetOrder={isWidgetOrder}
36
+ />
39
37
  </View>
40
- )}
38
+ </View>
41
39
  {children}
42
40
  </View>
43
41
  );
@@ -107,27 +107,11 @@ export const SensorDisplayItem = ({
107
107
  />
108
108
  </View>
109
109
  );
110
- // change response format, todo Bang refactor after fix
111
- case 'three_button_action_template': // todo refactor later with backend
112
- case 'ThreeButtonActionTemplate':
113
- case 'on_off_button_action_template': // todo refactor later with backend
114
- case 'OnOffButtonActionTemplate':
115
- case 'OnOffSimpleActionTemplate':
116
- case 'OnOffSmartLockActionTemplate':
117
- case 'one_button_action_template': // todo refactor later with backend
118
- case 'OneBigButtonActionTemplate':
119
- case 'NumberUpDownActionTemplate':
120
- case 'StatesGridActionTemplate':
121
- case 'OptionsDropdownActionTemplate':
122
- case 'TimerActionTemplate':
123
- case 'SmartTiviActionTemplate':
124
- case 'color_picker_template':
125
- case 'slider_range_template':
126
- case 'two_button_action_template':
127
- case 'switch_button_action_template':
110
+ case 'action':
128
111
  return (
129
112
  <ActionGroup
130
113
  accessibilityLabel={AccessibilityLabel.DEVICE_DETAIL_ACTION_GROUP}
114
+ actionGroup={configuration}
131
115
  doAction={doAction}
132
116
  sensor={sensor}
133
117
  id={idTemplate}
@@ -1,6 +1,7 @@
1
1
  import React, { useCallback, useEffect, useRef, useState } from 'react';
2
2
  import moment from 'moment/moment';
3
3
  import _ from 'lodash';
4
+ import HighchartsReactNative from '@eohjsc/highcharts';
4
5
 
5
6
  import ChartWrapper from './ChartWrapper';
6
7
  import { useFetchConfigHistory } from '../../../commons/UnitSummary/ConfigHistoryChart';
@@ -10,7 +11,6 @@ import ChartAggregationOption from '../../../commons/ChartAggregationOption';
10
11
  import Text from '../../../commons/Text';
11
12
  import { CHART_GROUP_TYPE } from '../../../configs/Constants';
12
13
  import { getDateRangeOfWeek } from '../../../utils/Utils';
13
- import Highcharts from '../../../commons/Highcharts';
14
14
 
15
15
  const groupByTime = (format) => (x) => x[0].format(format);
16
16
 
@@ -143,16 +143,8 @@ const chartOptions = {
143
143
  text: '',
144
144
  },
145
145
  },
146
- yAxis: {
147
- title: {
148
- enabled: false,
149
- },
150
- },
151
146
  plotOptions: {},
152
147
  series: [],
153
- exporting: {
154
- enabled: false,
155
- },
156
148
  };
157
149
 
158
150
  const groupByOptions = [
@@ -163,12 +155,7 @@ const groupByOptions = [
163
155
  { title: 'Y', data: CHART_GROUP_TYPE.YEAR },
164
156
  ];
165
157
 
166
- const VisualChart = ({
167
- item,
168
- isDemo = false,
169
- isWidgetOrder,
170
- shouldRenderDate,
171
- }) => {
158
+ const VisualChart = ({ item, isDemo = false, isWidgetOrder }) => {
172
159
  const { configuration = {} } = item;
173
160
  const {
174
161
  configs = [],
@@ -307,9 +294,8 @@ const VisualChart = ({
307
294
  dateFormat={date_format}
308
295
  showTime={show_time}
309
296
  isWidgetOrder={isWidgetOrder}
310
- shouldRenderDate
311
297
  >
312
- <Highcharts
298
+ <HighchartsReactNative
313
299
  options={options}
314
300
  styles={styles.chartStyle}
315
301
  webviewStyles={[
@@ -1,15 +1,16 @@
1
1
  import React from 'react';
2
2
  import MockAdapter from 'axios-mock-adapter';
3
3
  import moment from 'moment';
4
+ import HighchartsReactNative from '@eohjsc/highcharts';
4
5
  import { act, create } from 'react-test-renderer';
5
6
 
6
7
  import VisualChart from '../VisualChart';
7
8
  import { API } from '../../../../configs';
8
9
  import { getPusher } from '../../../../utils/Pusher';
10
+ import { flushPromises } from '../../../AllGateway/test-utils';
9
11
  import api from '../../../../utils/Apis/axios';
10
12
  import ChartAggregationOption from '../../../../commons/ChartAggregationOption';
11
13
  import DateTimeRangeChange from '../../../../commons/DateTimeRangeChange';
12
- import Highcharts from '../../../../commons/Highcharts';
13
14
 
14
15
  const render = async (component) => {
15
16
  let tree;
@@ -66,7 +67,7 @@ describe('Test LinearChartWidget', () => {
66
67
  />
67
68
  );
68
69
  const instance = tree.root;
69
- const chart = instance.findByType(Highcharts);
70
+ const chart = instance.findByType(HighchartsReactNative);
70
71
  assertChartData(chart.props.options.series[0].data, [[moment(1000), 100]]);
71
72
  });
72
73
 
@@ -119,7 +120,7 @@ describe('Test LinearChartWidget', () => {
119
120
  />
120
121
  );
121
122
  const instance = tree.root;
122
- const chart = instance.findByType(Highcharts);
123
+ const chart = instance.findByType(HighchartsReactNative);
123
124
  assertChartData(chart.props.options.series[0].data, [
124
125
  [moment(1), 2],
125
126
  [moment(3), 4],
@@ -135,6 +136,8 @@ describe('Test LinearChartWidget', () => {
135
136
  });
136
137
  });
137
138
 
139
+ await flushPromises();
140
+
138
141
  assertChartData(chart.props.options.series[0].data, [
139
142
  [moment(1), 2],
140
143
  [moment(3), 4],
@@ -179,7 +182,7 @@ describe('Test LinearChartWidget', () => {
179
182
  />
180
183
  );
181
184
  const instance = tree.root;
182
- const chart = instance.findByType(Highcharts);
185
+ const chart = instance.findByType(HighchartsReactNative);
183
186
  assertChartData(chart.props.options.series[0].data, [
184
187
  ['1970-01-01', 100],
185
188
  ['1970-01-02', 100],
@@ -227,7 +230,7 @@ describe('Test LinearChartWidget', () => {
227
230
  />
228
231
  );
229
232
  const instance = tree.root;
230
- const chart = instance.findByType(Highcharts);
233
+ const chart = instance.findByType(HighchartsReactNative);
231
234
  assertChartData(chart.props.options.series[0].data, [['1970-01-01', 200]]);
232
235
  });
233
236
 
@@ -265,7 +268,7 @@ describe('Test LinearChartWidget', () => {
265
268
  />
266
269
  );
267
270
  const instance = tree.root;
268
- const chart = instance.findByType(Highcharts);
271
+ const chart = instance.findByType(HighchartsReactNative);
269
272
  assertChartData(chart.props.options.series[0].data, [['1970-01-01', 150]]);
270
273
  });
271
274
 
@@ -289,7 +292,7 @@ describe('Test LinearChartWidget', () => {
289
292
  />
290
293
  );
291
294
  const instance = tree.root;
292
- const chart = instance.findByType(Highcharts);
295
+ const chart = instance.findByType(HighchartsReactNative);
293
296
  assertChartData(chart.props.options.series[0].data, [[moment(1000), 100]]);
294
297
  });
295
298
 
@@ -307,7 +310,7 @@ describe('Test LinearChartWidget', () => {
307
310
  />
308
311
  );
309
312
  const instance = tree.root;
310
- const chart = instance.findByType(Highcharts);
313
+ const chart = instance.findByType(HighchartsReactNative);
311
314
  expect(chart.props.options.chart.type).toEqual('column');
312
315
  });
313
316
 
@@ -325,7 +328,7 @@ describe('Test LinearChartWidget', () => {
325
328
  />
326
329
  );
327
330
  const instance = tree.root;
328
- const chart = instance.findByType(Highcharts);
331
+ const chart = instance.findByType(HighchartsReactNative);
329
332
  expect(chart.props.options.chart.type).toEqual('bar');
330
333
  });
331
334
 
@@ -343,7 +346,7 @@ describe('Test LinearChartWidget', () => {
343
346
  />
344
347
  );
345
348
  const instance = tree.root;
346
- const chart = instance.findByType(Highcharts);
349
+ const chart = instance.findByType(HighchartsReactNative);
347
350
  expect(chart.props.options.chart.type).toEqual('area');
348
351
  });
349
352
 
@@ -361,7 +364,7 @@ describe('Test LinearChartWidget', () => {
361
364
  />
362
365
  );
363
366
  const instance = tree.root;
364
- const chart = instance.findByType(Highcharts);
367
+ const chart = instance.findByType(HighchartsReactNative);
365
368
  expect(chart.props.options.chart.type).toEqual('column');
366
369
  expect(chart.props.options.plotOptions.column.stacking).toEqual('normal');
367
370
  });
@@ -380,7 +383,7 @@ describe('Test LinearChartWidget', () => {
380
383
  />
381
384
  );
382
385
  const instance = tree.root;
383
- const chart = instance.findByType(Highcharts);
386
+ const chart = instance.findByType(HighchartsReactNative);
384
387
  expect(chart.props.options.chart.type).toEqual('scatter');
385
388
  });
386
389
 
@@ -136,8 +136,7 @@ const DeviceDetail = ({ route }) => {
136
136
  }
137
137
 
138
138
  return action.some((item) => {
139
- const { configuration } = item?.configuration;
140
- return JSON.stringify(configuration).includes(
139
+ return JSON.stringify(item?.configuration)?.includes(
141
140
  '"command_prefer_over_bluetooth":true'
142
141
  );
143
142
  });
@@ -527,7 +526,7 @@ const DeviceDetail = ({ route }) => {
527
526
  });
528
527
  }
529
528
  });
530
- configIdsTemp.current = configIds.filter(Boolean);
529
+ configIdsTemp.current = configIds;
531
530
 
532
531
  configIds.map((id) => {
533
532
  params.append('config', id);
@@ -701,12 +700,7 @@ const DeviceDetail = ({ route }) => {
701
700
  ref={refMenuAction}
702
701
  accessibilityLabel={AccessibilityLabel.HEADER_DEVICE_BUTTON_MORE}
703
702
  >
704
- <Icon
705
- name={'ellipsis'}
706
- size={27}
707
- color={Colors.Black}
708
- style={styles.moreIcon}
709
- />
703
+ <Icon name={'more'} size={27} color={Colors.Black} />
710
704
  </TouchableOpacity>
711
705
  </View>
712
706
  ),
@@ -759,31 +753,18 @@ const DeviceDetail = ({ route }) => {
759
753
  >
760
754
  {display.items.map((item, index) => {
761
755
  return (
762
- <>
763
- {!item.is_configuration_ready && (
764
- <Text center>{t('bellow_widget_is_not_configured')}</Text>
765
- )}
766
- {!!item.is_configuration_ready &&
767
- !!item.configuration_error && (
768
- <Text center>
769
- {t('bellow_widget_is_wrongly_configured')}
770
- </Text>
771
- )}
772
- <SensorDisplayItem
773
- accessibilityLabel={
774
- AccessibilityLabel.SENSOR_DISPLAY_ITEM
775
- }
776
- key={(item?.id || index).toString()}
777
- item={item}
778
- evaluate={evaluate}
779
- emergency={onEmergencyButtonPress}
780
- sensor={sensor}
781
- offsetTitle={offsetTitle}
782
- setOffsetTitle={setOffsetTitle}
783
- setShowWindDirection={setShowWindDirection}
784
- background={station?.background}
785
- />
786
- </>
756
+ <SensorDisplayItem
757
+ accessibilityLabel={AccessibilityLabel.SENSOR_DISPLAY_ITEM}
758
+ key={(item?.id || index).toString()}
759
+ item={item}
760
+ evaluate={evaluate}
761
+ emergency={onEmergencyButtonPress}
762
+ sensor={sensor}
763
+ offsetTitle={offsetTitle}
764
+ setOffsetTitle={setOffsetTitle}
765
+ setShowWindDirection={setShowWindDirection}
766
+ background={station?.background}
767
+ />
787
768
  );
788
769
  })}
789
770
  </SensorConnectStatusViewHeader>
@@ -1,4 +1,3 @@
1
- /* eslint-disable no-unused-vars */
2
1
  import React from 'react';
3
2
  import { renderHook } from '@testing-library/react-hooks';
4
3
  import { useEvaluateValue, useGetEvaluateValue } from '../useEvaluateValue';
@@ -105,23 +104,22 @@ describe('Test useEvaluateValue', () => {
105
104
  expect(evaluateValue.current(2, 2).text).toBe(2);
106
105
  });
107
106
 
108
- // NOTE: Hinh will fix it later
109
- // it('test evaluate fetch from server if not exists', async () => {
110
- // const mock = new MockAdapter(api.axiosInstance);
111
- // mock.onGet(API.FETCH_VALUE_EVALUATION(111)).reply(200, {
112
- // unit_id: 1,
113
- // configs: [111],
114
- // });
115
-
116
- // const { result: evaluateValue } = renderHook(
117
- // () => useGetEvaluateValue(111),
118
- // {
119
- // wrapper: wrapper(valueEvaluations),
120
- // }
121
- // );
122
- // expect(evaluateValue.current).toBe(undefined);
123
- // await flushPromises();
124
-
125
- // expect(mock.history.get.length).toBe(1);
126
- // });
107
+ it('test evaluate fetch from server if not exists', async () => {
108
+ const mock = new MockAdapter(api.axiosInstance);
109
+ mock.onGet(API.FETCH_VALUE_EVALUATION(111)).reply(200, {
110
+ unit_id: 1,
111
+ configs: [111],
112
+ });
113
+
114
+ const { result: evaluateValue } = renderHook(
115
+ () => useGetEvaluateValue(111),
116
+ {
117
+ wrapper: wrapper(valueEvaluations),
118
+ }
119
+ );
120
+ expect(evaluateValue.current).toBe(undefined);
121
+ await flushPromises();
122
+
123
+ expect(mock.history.get.length).toBe(1);
124
+ });
127
125
  });
@@ -97,7 +97,4 @@ export default StyleSheet.create({
97
97
  marginLeft: 16,
98
98
  marginBottom: 16,
99
99
  },
100
- moreIcon: {
101
- transform: [{ rotate: '90deg' }],
102
- },
103
100
  });