@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.
- package/android/build.gradle +24 -19
- package/package.json +12 -14
- package/src/commons/Action/ItemQuickAction.js +0 -1
- package/src/commons/ActionGroup/ColorPickerTemplate.js +4 -3
- package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +3 -3
- package/src/commons/ActionGroup/OnOffSmartLock/OnOffSmartLock.js +2 -2
- package/src/commons/ActionGroup/OnOffTemplate/OnOffButtonTemplate.js +5 -4
- package/src/commons/ActionGroup/OnOffTemplate/SwitchButtonTemplate.js +4 -4
- package/src/commons/ActionGroup/OnOffTemplate/index.js +5 -6
- package/src/commons/ActionGroup/OneBigButtonTemplate.js +4 -4
- package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +17 -6
- package/src/commons/ActionGroup/SliderRangeTemplate.js +3 -5
- package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +7 -7
- package/src/commons/ActionGroup/StatesGridActionTemplate.js +20 -6
- package/src/commons/ActionGroup/ThreeButtonTemplate/__test__/ThreeButtonTemplate.test.js +6 -6
- package/src/commons/ActionGroup/ThreeButtonTemplate/index.js +2 -2
- package/src/commons/ActionGroup/TimerActionTemplate.js +2 -3
- package/src/commons/ActionGroup/TwoButtonTemplate/index.js +135 -133
- package/src/commons/ActionGroup/__test__/ColorPickerTemplate.test.js +14 -37
- package/src/commons/ActionGroup/__test__/NumberUpDownTemplate.test.js +31 -71
- package/src/commons/ActionGroup/__test__/OnOffButtonTemplate.test.js +11 -11
- package/src/commons/ActionGroup/__test__/OnOffSmartLock.test.js +17 -13
- package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +48 -44
- package/src/commons/ActionGroup/__test__/OneBigButtonTemplate.test.js +22 -56
- package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +21 -123
- package/src/commons/ActionGroup/__test__/SliderRangeTemplate.test.js +16 -12
- package/src/commons/ActionGroup/__test__/StatesGridActionTemplate.test.js +38 -73
- package/src/commons/ActionGroup/__test__/SwitchButtonTemplate.test.js +15 -11
- package/src/commons/ActionGroup/__test__/TimerActionTemplate.test.js +15 -11
- package/src/commons/ActionGroup/__test__/TimerActionTemplateWithutConfigValue.test.js +9 -9
- package/src/commons/ActionGroup/__test__/TwoButtonTemplate.test.js +31 -21
- package/src/commons/ActionGroup/__test__/index.test.js +21 -36
- package/src/commons/ActionGroup/index.js +7 -4
- package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +5 -0
- package/src/commons/Dashboard/MyUnit/index.js +2 -2
- package/src/commons/DateTimeRangeChange/index.js +3 -3
- package/src/commons/Device/HistoryChart.js +1 -1
- package/src/commons/Device/HorizontalBarChart.js +4 -3
- package/src/commons/Device/LinearChart.js +5 -3
- package/src/commons/FlatListDnD/__test__/index.test.js +25 -27
- package/src/commons/GroupCheckBox/__test__/GroupCheckBox.test.js +22 -1
- package/src/commons/HeaderAni/index.js +2 -12
- package/src/commons/MediaPlayerDetail/__test__/MediaPlayerFull.test.js +23 -1
- package/src/commons/OneTapTemplate/__test__/NumberUpDownActionTemplate.test.js +3 -5
- package/src/commons/Processing/index.js +0 -1
- package/src/commons/Processing/styles.js +0 -3
- package/src/commons/SubUnit/OneTap/ItemOneTap.js +0 -1
- package/src/commons/Unit/HeaderUnit/index.js +8 -15
- package/src/commons/UnitSummary/ConfigHistoryChart/__test__/ConfigHistoryChart.test.js +289 -0
- package/src/commons/UnitSummary/ConfigHistoryChart/index.js +59 -1
- package/src/configs/AccessibilityLabel.js +0 -1
- package/src/hooks/IoT/__test__/useRemoteControl.test.js +51 -52
- package/src/hooks/IoT/__test__/useWatchConfigs.test.js +2 -3
- package/src/hooks/useMqtt.js +2 -5
- package/src/iot/mqtt.js +0 -2
- package/src/navigations/UnitStack.js +2 -2
- package/src/screens/AddNewGateway/ConnectingDevice.js +2 -2
- package/src/screens/AddNewGateway/ShareWifiPassword.js +2 -2
- package/src/screens/AllGateway/DeviceModbusDetail/__test__/index.test.js +32 -31
- package/src/screens/Automate/AddNewAction/SetupConfigCondition.js +2 -19
- package/src/screens/Automate/AddNewAction/__test__/{SetupConfigCondition.test.js → SetupSensor.test.js} +0 -97
- package/src/screens/Automate/EditActionsList/__tests__/index.test.js +68 -69
- package/src/screens/ChangePosition/__test__/index.test.js +32 -34
- package/src/screens/ConfirmUnitDeletion/__test__/ConfirmUnitDeletion.test.js +11 -1
- package/src/screens/Device/__test__/detail.test.js +45 -40
- package/src/screens/Device/__test__/sensorDisplayItem.test.js +2 -14
- package/src/screens/Device/components/ChartWrapper.js +12 -14
- package/src/screens/Device/components/SensorDisplayItem.js +2 -18
- package/src/screens/Device/components/VisualChart.js +3 -17
- package/src/screens/Device/components/__test__/VisualChart.test.js +15 -12
- package/src/screens/Device/detail.js +15 -34
- package/src/screens/Device/hooks/__test__/useEvaluateValue.test.js +18 -20
- package/src/screens/Device/styles.js +0 -3
- package/src/screens/Sharing/MemberList.js +3 -16
- package/src/screens/Sharing/__test__/SelectPermission.test.js +137 -96
- package/src/screens/Template/__test__/EditTemplate.test.js +45 -48
- package/src/screens/Unit/SelectAddToFavorites.js +0 -1
- package/src/screens/Unit/__test__/SelectAddress.test.js +11 -4
- package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js +11 -1
- package/src/utils/Apis/axios.js +0 -1
- package/src/utils/I18n/translations/en.js +0 -2
- package/src/utils/I18n/translations/vi.js +0 -2
- package/src/utils/Monitor.js +2 -2
- package/src/commons/Highcharts/index.js +0 -111
- 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
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
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: '
|
|
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: '
|
|
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
|
|
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
|
-
{
|
|
28
|
-
<View
|
|
29
|
-
<
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
|
|
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
|
-
<
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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
|
-
|
|
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
|
|
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
|
-
{
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
{
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
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
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
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
|
});
|