@eohjsc/react-native-smart-city 0.2.26 → 0.2.27
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/assets/images/Illustrations.svg +83 -0
- package/assets/images/{WeatherChange.svg → ValueChange.svg} +0 -0
- package/index.js +2 -0
- package/package.json +3 -1
- package/src/Images/Common/file.png +0 -0
- package/src/Images/Common/fullscreen.png +0 -0
- package/src/commons/ActionGroup/OnOffTemplate/index.js +5 -0
- package/src/commons/ActionGroup/__test__/NumberUpDownTemplate.test.js +294 -0
- package/src/commons/ActionGroup/__test__/NumberUpDownTemplateWithNullConfigValue.test.js +60 -0
- package/src/commons/AlertAction/__test__/AlertAction.test.js +6 -6
- package/src/commons/AlertAction/index.js +2 -0
- package/src/commons/Automate/ItemAutomate.js +7 -1
- package/src/commons/Automate/__test__/ItemAutomate.test.js +16 -0
- package/src/commons/Automate/__test__/ItemScriptAction.test.js +16 -0
- package/src/commons/BackDefault/__test__/BackDefault.test.js +21 -0
- package/src/commons/BottomScrollPicker/index.js +5 -1
- package/src/commons/BottomSheet/index.js +10 -5
- package/src/commons/ButtonPopup/__test__/__snapshots__/ButtonPopup.test.js.snap +2 -0
- package/src/commons/ButtonPopup/index.js +2 -0
- package/src/commons/Calendar/index.js +72 -0
- package/src/commons/Calendar/styles.js +11 -0
- package/src/commons/Device/ItemAddNew/index.js +2 -2
- package/src/commons/Explore/__test__/HeaderExplore.test.js +25 -0
- package/src/commons/Explore/__test__/LocationItem.test.js +31 -0
- package/src/commons/Header/HeaderCustom.js +7 -3
- package/src/commons/HeaderAni/index.js +31 -3
- package/src/commons/HorizontalPicker/index.js +134 -0
- package/src/commons/HorizontalPicker/styles.js +56 -0
- package/src/commons/Modal/__test__/ModalBottom.test.js +39 -0
- package/src/commons/RowItem/__test__/RowItem.test.js +16 -0
- package/src/commons/RowItem/index.js +61 -0
- package/src/commons/RowItem/styles.js +53 -0
- package/src/commons/Sharing/WrapHeaderScrollable.js +78 -74
- package/src/commons/SubUnit/OneTap/ItemOneTap.js +73 -69
- package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +47 -1
- package/src/commons/SubUnit/OneTap/index.js +2 -2
- package/src/commons/Unit/__test__/SharedUnit.test.js +330 -0
- package/src/commons/WheelDateTimePicker/index.js +16 -8
- package/src/commons/index.js +2 -0
- package/src/configs/API.js +5 -1
- package/src/configs/Constants.js +18 -3
- package/src/configs/Theme.js +20 -0
- package/src/context/SCContext.tsx +2 -2
- package/src/context/mockStore.ts +3 -1
- package/src/hooks/Common/__test__/useStatusbar.test.js +28 -0
- package/src/navigations/AutomateStack.js +45 -0
- package/src/navigations/UnitStack.js +33 -14
- package/src/navigations/utils.js +8 -0
- package/src/screens/AddNewAction/Components/LoadingSelectAction.js +40 -0
- package/src/screens/AddNewAction/Components/index.js +3 -0
- package/src/screens/AddNewAction/SelectAction.js +147 -62
- package/src/screens/AddNewAction/{SelectDevice.js → SelectSensorDevices.js} +42 -12
- package/src/screens/AddNewAction/SetupSensor.js +221 -0
- package/src/screens/AddNewAction/Styles/SelectActionStyles.js +43 -5
- package/src/screens/AddNewAction/Styles/{SelectDeviceStyles.js → SelectSensorDevicesStyles.js} +0 -0
- package/src/screens/AddNewAction/Styles/SetupSensorStyles.js +76 -0
- package/src/screens/AddNewAction/__test__/SelectAction.test.js +0 -19
- package/src/screens/AddNewAction/__test__/{SelectDevice.test.js → SelectSensorDevices.test.js} +3 -3
- package/src/screens/AddNewAction/__test__/SetupSensor.test.js +125 -0
- package/src/screens/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +69 -12
- package/src/screens/AddNewAutoSmart/index.js +42 -14
- package/src/screens/AddNewOneTap/AddNewOneTapStyles.js +4 -3
- package/src/screens/AddNewOneTap/__test__/AddNewOneTap.test.js +1 -0
- package/src/screens/AddNewOneTap/index.js +7 -4
- package/src/screens/AllCamera/__test__/index.test.js +103 -0
- package/src/screens/Automate/Components/Loading.js +64 -0
- package/src/screens/Automate/Styles/indexStyles.js +64 -0
- package/src/screens/Automate/__test__/Loading.test.js +16 -0
- package/src/screens/Automate/__test__/index.test.js +93 -0
- package/src/screens/Automate/index.js +148 -0
- package/src/screens/Device/__test__/detail.test.js +64 -0
- package/src/screens/Device/detail.js +17 -7
- package/src/screens/EditActionsList/index.js +2 -2
- package/src/screens/GuestInfo/__test__/index.test.js +176 -0
- package/src/screens/GuestInfo/components/AccessScheduleItem.js +6 -1
- package/src/screens/GuestInfo/components/AccessScheduleSheet.js +26 -15
- package/src/screens/GuestInfo/components/HeaderGuestInfo.js +6 -1
- package/src/screens/GuestInfo/components/RecurringDetail.js +9 -2
- package/src/screens/GuestInfo/components/TemporaryDetail.js +9 -2
- package/src/screens/GuestInfo/constant.js +2 -2
- package/src/screens/GuestInfo/index.js +4 -5
- package/src/screens/PlayBackCamera/Timer.js +1 -1
- package/src/screens/ScriptDetail/Styles/indexStyles.js +14 -0
- package/src/screens/ScriptDetail/__test__/index.test.js +119 -0
- package/src/screens/ScriptDetail/hooks/index.js +55 -0
- package/src/screens/ScriptDetail/index.js +124 -23
- package/src/screens/SelectUnit/Styles/indexStyles.js +55 -0
- package/src/screens/SelectUnit/__test__/index.test.js +85 -0
- package/src/screens/SelectUnit/index.js +100 -0
- package/src/screens/SetSchedule/__test__/index.test.js +97 -0
- package/src/screens/SetSchedule/components/RepeatOptionsPopup.js +56 -0
- package/src/screens/SetSchedule/components/RowItem.js +27 -0
- package/src/screens/SetSchedule/components/SelectWeekday.js +65 -0
- package/src/screens/SetSchedule/index.js +139 -0
- package/src/screens/SetSchedule/styles/RepeatOptionsPopupStyles.js +22 -0
- package/src/screens/SetSchedule/styles/RowItemStyles.js +29 -0
- package/src/screens/SetSchedule/styles/SelectWeekdayStyles.js +26 -0
- package/src/screens/{AddNewScriptAction/AddNewScriptActionStyles.js → SetSchedule/styles/indexStyles.js} +6 -12
- package/src/screens/Sharing/__test__/MemberList.test.js +21 -28
- package/src/screens/SubUnit/EditSubUnit.js +274 -0
- package/src/screens/SubUnit/EditSubUnitStyles.js +119 -0
- package/src/screens/SubUnit/ManageSubUnit.js +112 -370
- package/src/screens/SubUnit/ManageSubUnitStyles.js +40 -0
- package/src/screens/SubUnit/__test__/EditSubUnit.test.js +427 -0
- package/src/screens/SubUnit/__test__/ManageSubUnit.test.js +42 -386
- package/src/screens/SubUnit/hooks/__test__/useManageSubUnit.test.js +85 -0
- package/src/screens/SubUnit/hooks/useManageSubUnit.js +35 -0
- package/src/screens/Unit/Detail.js +3 -2
- package/src/screens/Unit/ManageUnit.js +10 -0
- package/src/screens/Unit/components/SearchLocation/__test__/RowLocation.test.js +36 -0
- package/src/screens/Unit/components/__test__/MyUnit.test.js +35 -0
- package/src/screens/Unit/components/__test__/MyUnitDevice.test.js +32 -0
- package/src/screens/UnitSummary/components/__test__/UnitSummary.test.js +67 -0
- package/src/screens/UnitSummary/components/__test__/index.test.js +48 -0
- package/src/screens/UnitSummary/components/index.js +1 -37
- package/src/screens/UnitSummary/components/indexstyles.js +39 -0
- package/src/utils/Apis/axios.js +0 -4
- package/src/utils/I18n/translations/en.json +30 -4
- package/src/utils/I18n/translations/vi.json +29 -3
- package/src/utils/Route/index.js +6 -1
- package/src/utils/__test__/InitData.test.js +20 -0
- package/src/commons/Automate/ItemAddNewScriptAction.js +0 -30
- package/src/screens/AddNewScriptAction/index.js +0 -100
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { create, act } from 'react-test-renderer';
|
|
4
|
+
import moment from 'moment';
|
|
5
|
+
import { useNavigation } from '@react-navigation/native';
|
|
6
|
+
|
|
7
|
+
import SharedUnit from '../SharedUnit';
|
|
8
|
+
import { TESTID } from '../../../configs/Constants';
|
|
9
|
+
import { API } from '../../../configs';
|
|
10
|
+
import Routes from '../../../utils/Route';
|
|
11
|
+
import { SCProvider } from '../../../context';
|
|
12
|
+
import { mockSCStore } from '../../../context/mockStore';
|
|
13
|
+
|
|
14
|
+
jest.mock('axios');
|
|
15
|
+
|
|
16
|
+
const mockNavigate = jest.fn();
|
|
17
|
+
jest.mock('@react-navigation/native', () => {
|
|
18
|
+
return {
|
|
19
|
+
...jest.requireActual('@react-navigation/native'),
|
|
20
|
+
useNavigation: () => ({
|
|
21
|
+
navigate: mockNavigate,
|
|
22
|
+
}),
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const wrapComponent = (item, navigation, isOptions, mockedRenewItem) => (
|
|
27
|
+
<SCProvider initState={mockSCStore({})}>
|
|
28
|
+
<SharedUnit
|
|
29
|
+
item={item}
|
|
30
|
+
navigation={navigation}
|
|
31
|
+
isOptions={isOptions}
|
|
32
|
+
renewItem={mockedRenewItem}
|
|
33
|
+
/>
|
|
34
|
+
</SCProvider>
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
describe('Test SharedUnit', () => {
|
|
38
|
+
let tree, item, unit;
|
|
39
|
+
|
|
40
|
+
beforeEach(() => {
|
|
41
|
+
axios.post.mockClear();
|
|
42
|
+
|
|
43
|
+
unit = {
|
|
44
|
+
background: '',
|
|
45
|
+
icon: '',
|
|
46
|
+
id: 3,
|
|
47
|
+
name: 'name',
|
|
48
|
+
owner_name: 'owner_name',
|
|
49
|
+
short_summaries: [],
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
item = {
|
|
53
|
+
created_at: moment('2021-01-26T03:00:00.677514Z'),
|
|
54
|
+
id: 69,
|
|
55
|
+
is_pin: false,
|
|
56
|
+
is_star: false,
|
|
57
|
+
unit: unit,
|
|
58
|
+
user: 1,
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
test('test create SharedUnit unit is not pin, not star', async () => {
|
|
63
|
+
const navigation = useNavigation();
|
|
64
|
+
|
|
65
|
+
await act(async () => {
|
|
66
|
+
tree = await create(wrapComponent(item, navigation));
|
|
67
|
+
});
|
|
68
|
+
const instance = tree.root;
|
|
69
|
+
const touchSharedUnit = instance.find(
|
|
70
|
+
(el) => el.props.testID === TESTID.TOUCH_SHARED_UNIT + '-69'
|
|
71
|
+
);
|
|
72
|
+
act(() => {
|
|
73
|
+
touchSharedUnit.props.onPress();
|
|
74
|
+
});
|
|
75
|
+
expect(mockNavigate).toHaveBeenCalledWith(Routes.UnitStack, {
|
|
76
|
+
screen: Routes.UnitDetail,
|
|
77
|
+
params: {
|
|
78
|
+
unitId: 3,
|
|
79
|
+
unitData: unit,
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const iconRemovePinSharedUnit = instance.findAll(
|
|
84
|
+
(el) => el.props.testID === TESTID.ICON_REMOVE_PIN_SHARED_UNIT + '-69'
|
|
85
|
+
);
|
|
86
|
+
expect(iconRemovePinSharedUnit).toHaveLength(0);
|
|
87
|
+
|
|
88
|
+
const iconAddPinSharedUnit = instance.find(
|
|
89
|
+
(el) => el.props.testID === TESTID.ICON_ADD_PIN_SHARED_UNIT + '-69'
|
|
90
|
+
);
|
|
91
|
+
act(() => {
|
|
92
|
+
iconAddPinSharedUnit.props.onPress();
|
|
93
|
+
});
|
|
94
|
+
expect(axios.post).toHaveBeenCalledWith(API.UNIT.PIN_UNIT(3));
|
|
95
|
+
|
|
96
|
+
const iconAddStarSharedUnit = instance.find(
|
|
97
|
+
(el) => el.props.testID === TESTID.ICON_ADD_STAR_SHARED_UNIT + '-69'
|
|
98
|
+
);
|
|
99
|
+
act(() => {
|
|
100
|
+
iconAddStarSharedUnit.props.onPress();
|
|
101
|
+
});
|
|
102
|
+
expect(axios.post).toHaveBeenCalledWith(API.UNIT.STAR_UNIT(3));
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
test('test create SharedUnit unit without unit owner', async () => {
|
|
106
|
+
const navigation = useNavigation();
|
|
107
|
+
delete unit.owner_name;
|
|
108
|
+
|
|
109
|
+
await act(async () => {
|
|
110
|
+
tree = await create(wrapComponent(item, navigation));
|
|
111
|
+
});
|
|
112
|
+
const instance = tree.root;
|
|
113
|
+
const ownerName = instance.findAll(
|
|
114
|
+
(el) => el.props.testID === TESTID.SHARED_UNIT_OWN_BY
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
expect(ownerName).toHaveLength(0);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
test('test create SharedUnit unit isOption false', async () => {
|
|
121
|
+
const navigation = useNavigation();
|
|
122
|
+
|
|
123
|
+
await act(async () => {
|
|
124
|
+
tree = await create(wrapComponent(item, navigation, false));
|
|
125
|
+
});
|
|
126
|
+
const instance = tree.root;
|
|
127
|
+
|
|
128
|
+
const iconAddPinSharedUnit = instance.findAll(
|
|
129
|
+
(el) => el.props.testID === TESTID.ICON_ADD_PIN_SHARED_UNIT + '-69'
|
|
130
|
+
);
|
|
131
|
+
const iconStarUnit = instance.findAll(
|
|
132
|
+
(el) => el.props.testID === TESTID.ICON_ADD_STAR_SHARED_UNIT + '-69'
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
expect(iconAddPinSharedUnit).toHaveLength(0);
|
|
136
|
+
expect(iconStarUnit).toHaveLength(0);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
test('test create SharedUnit unit is pin, is star', async () => {
|
|
140
|
+
const navigation = useNavigation();
|
|
141
|
+
item.is_pin = true;
|
|
142
|
+
item.is_star = true;
|
|
143
|
+
|
|
144
|
+
await act(async () => {
|
|
145
|
+
tree = await create(wrapComponent(item, navigation));
|
|
146
|
+
});
|
|
147
|
+
const instance = tree.root;
|
|
148
|
+
const iconRemovePinSharedUnit = instance.find(
|
|
149
|
+
(el) => el.props.testID === TESTID.ICON_REMOVE_PIN_SHARED_UNIT + '-69'
|
|
150
|
+
);
|
|
151
|
+
act(() => {
|
|
152
|
+
iconRemovePinSharedUnit.props.onPress();
|
|
153
|
+
});
|
|
154
|
+
expect(axios.post).toHaveBeenCalledWith(API.UNIT.UNPIN_UNIT(3));
|
|
155
|
+
|
|
156
|
+
const iconRemoveStarSharedUnit = instance.find(
|
|
157
|
+
(el) => el.props.testID === TESTID.ICON_REMOVE_STAR_SHARED_UNIT + '-69'
|
|
158
|
+
);
|
|
159
|
+
act(() => {
|
|
160
|
+
iconRemoveStarSharedUnit.props.onPress();
|
|
161
|
+
});
|
|
162
|
+
expect(axios.post).toHaveBeenCalledWith(API.UNIT.UNSTAR_UNIT(3));
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
test('test pin SharedUnit success', async () => {
|
|
166
|
+
const navigation = useNavigation();
|
|
167
|
+
const mockedRenewItem = jest.fn();
|
|
168
|
+
await act(async () => {
|
|
169
|
+
tree = await create(
|
|
170
|
+
wrapComponent(item, navigation, true, mockedRenewItem)
|
|
171
|
+
);
|
|
172
|
+
});
|
|
173
|
+
const instance = tree.root;
|
|
174
|
+
|
|
175
|
+
const response = {
|
|
176
|
+
success: true,
|
|
177
|
+
status: 200,
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
jest.spyOn(axios, 'post').mockImplementation(() => {
|
|
181
|
+
return response;
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
const iconAddPinSharedUnit = instance.find(
|
|
185
|
+
(el) => el.props.testID === TESTID.ICON_ADD_PIN_SHARED_UNIT + '-69'
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
const iconStarUnit = instance.find(
|
|
189
|
+
(el) => el.props.testID === TESTID.ICON_ADD_STAR_SHARED_UNIT + '-69'
|
|
190
|
+
);
|
|
191
|
+
|
|
192
|
+
await act(async () => {
|
|
193
|
+
await iconAddPinSharedUnit.props.onPress();
|
|
194
|
+
await iconStarUnit.props.onPress();
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
expect(mockedRenewItem).toHaveBeenCalledTimes(2);
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
test('test pin SharedUnit unsuccess', async () => {
|
|
201
|
+
const navigation = useNavigation();
|
|
202
|
+
const mockedRenewItem = jest.fn();
|
|
203
|
+
await act(async () => {
|
|
204
|
+
tree = await create(
|
|
205
|
+
wrapComponent(item, navigation, true, mockedRenewItem)
|
|
206
|
+
);
|
|
207
|
+
});
|
|
208
|
+
const instance = tree.root;
|
|
209
|
+
|
|
210
|
+
const response = {
|
|
211
|
+
success: false,
|
|
212
|
+
status: 500,
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
jest.spyOn(axios, 'post').mockImplementation(() => {
|
|
216
|
+
return response;
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
const iconAddPinSharedUnit = instance.find(
|
|
220
|
+
(el) => el.props.testID === TESTID.ICON_ADD_PIN_SHARED_UNIT + '-69'
|
|
221
|
+
);
|
|
222
|
+
|
|
223
|
+
const iconStarUnit = instance.find(
|
|
224
|
+
(el) => el.props.testID === TESTID.ICON_ADD_STAR_SHARED_UNIT + '-69'
|
|
225
|
+
);
|
|
226
|
+
|
|
227
|
+
await act(async () => {
|
|
228
|
+
await iconAddPinSharedUnit.props.onPress();
|
|
229
|
+
await iconStarUnit.props.onPress();
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
const iconRemovePinSharedUnit = instance.findAll(
|
|
233
|
+
(el) => el.props.testID === TESTID.ICON_REMOVE_PIN_SHARED_UNIT + '-69'
|
|
234
|
+
);
|
|
235
|
+
|
|
236
|
+
const iconRemoveStartUnit = instance.findAll(
|
|
237
|
+
(el) => el.props.testID === TESTID.ICON_REMOVE_STAR_SHARED_UNIT + '-69'
|
|
238
|
+
);
|
|
239
|
+
|
|
240
|
+
expect(mockedRenewItem).toHaveBeenCalledTimes(0);
|
|
241
|
+
expect(iconRemovePinSharedUnit).toHaveLength(0);
|
|
242
|
+
expect(iconRemoveStartUnit).toHaveLength(0);
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
test('test unpin SharedUnit success', async () => {
|
|
246
|
+
const navigation = useNavigation();
|
|
247
|
+
item.is_pin = true;
|
|
248
|
+
item.is_star = true;
|
|
249
|
+
const mockedRenewItem = jest.fn();
|
|
250
|
+
|
|
251
|
+
await act(async () => {
|
|
252
|
+
tree = await create(
|
|
253
|
+
wrapComponent(item, navigation, true, mockedRenewItem)
|
|
254
|
+
);
|
|
255
|
+
});
|
|
256
|
+
const instance = tree.root;
|
|
257
|
+
|
|
258
|
+
const response = {
|
|
259
|
+
success: true,
|
|
260
|
+
status: 200,
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
jest.spyOn(axios, 'post').mockImplementation(() => {
|
|
264
|
+
return response;
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
const iconRemovePinSharedUnit = instance.find(
|
|
268
|
+
(el) => el.props.testID === TESTID.ICON_REMOVE_PIN_SHARED_UNIT + '-69'
|
|
269
|
+
);
|
|
270
|
+
|
|
271
|
+
const iconRemoveStartUnit = instance.find(
|
|
272
|
+
(el) => el.props.testID === TESTID.ICON_REMOVE_STAR_SHARED_UNIT + '-69'
|
|
273
|
+
);
|
|
274
|
+
|
|
275
|
+
await act(async () => {
|
|
276
|
+
await iconRemovePinSharedUnit.props.onPress();
|
|
277
|
+
await iconRemoveStartUnit.props.onPress();
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
expect(mockedRenewItem).toHaveBeenCalledTimes(2);
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
test('test unpin SharedUnit unsuccess', async () => {
|
|
284
|
+
const navigation = useNavigation();
|
|
285
|
+
item.is_pin = true;
|
|
286
|
+
item.is_star = true;
|
|
287
|
+
const mockedRenewItem = jest.fn();
|
|
288
|
+
|
|
289
|
+
await act(async () => {
|
|
290
|
+
tree = await create(
|
|
291
|
+
wrapComponent(item, navigation, true, mockedRenewItem)
|
|
292
|
+
);
|
|
293
|
+
});
|
|
294
|
+
const instance = tree.root;
|
|
295
|
+
|
|
296
|
+
const response = {
|
|
297
|
+
success: false,
|
|
298
|
+
status: 500,
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
jest.spyOn(axios, 'post').mockImplementation(() => {
|
|
302
|
+
return response;
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
const iconRemovePinSharedUnit = instance.find(
|
|
306
|
+
(el) => el.props.testID === TESTID.ICON_REMOVE_PIN_SHARED_UNIT + '-69'
|
|
307
|
+
);
|
|
308
|
+
|
|
309
|
+
const iconRemoveStartUnit = instance.find(
|
|
310
|
+
(el) => el.props.testID === TESTID.ICON_REMOVE_STAR_SHARED_UNIT + '-69'
|
|
311
|
+
);
|
|
312
|
+
|
|
313
|
+
await act(async () => {
|
|
314
|
+
await iconRemovePinSharedUnit.props.onPress();
|
|
315
|
+
await iconRemoveStartUnit.props.onPress();
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
const iconAddPinSharedUnit = instance.findAll(
|
|
319
|
+
(el) => el.props.testID === TESTID.ICON_ADD_PIN_SHARED_UNIT + '-69'
|
|
320
|
+
);
|
|
321
|
+
|
|
322
|
+
const iconStarUnit = instance.findAll(
|
|
323
|
+
(el) => el.props.testID === TESTID.ICON_ADD_STAR_SHARED_UNIT + '-69'
|
|
324
|
+
);
|
|
325
|
+
|
|
326
|
+
expect(mockedRenewItem).toHaveBeenCalledTimes(0);
|
|
327
|
+
expect(iconAddPinSharedUnit).toHaveLength(0);
|
|
328
|
+
expect(iconStarUnit).toHaveLength(0);
|
|
329
|
+
});
|
|
330
|
+
});
|
|
@@ -10,6 +10,7 @@ import ViewButtonBottom from '../ViewButtonBottom';
|
|
|
10
10
|
|
|
11
11
|
import { getDateData } from '../../utils/Converter/time';
|
|
12
12
|
import styles from './styles';
|
|
13
|
+
import { TESTID } from '../../configs/Constants';
|
|
13
14
|
|
|
14
15
|
const formatNumber = (number) => {
|
|
15
16
|
return {
|
|
@@ -26,6 +27,7 @@ const WheelDateTimePicker = ({
|
|
|
26
27
|
isVisible,
|
|
27
28
|
defaultValue,
|
|
28
29
|
onPicked,
|
|
30
|
+
onCancel,
|
|
29
31
|
onHide,
|
|
30
32
|
}) => {
|
|
31
33
|
const t = useTranslations();
|
|
@@ -35,7 +37,7 @@ const WheelDateTimePicker = ({
|
|
|
35
37
|
|
|
36
38
|
const { dateData, indexInitialDate, indexInitialHour, indexInitialMinute } =
|
|
37
39
|
useMemo(() => {
|
|
38
|
-
const date = defaultValue ? moment(defaultValue) : moment();
|
|
40
|
+
const date = defaultValue ? moment(defaultValue) : moment().second(0);
|
|
39
41
|
const maximumDate = moment(date).add(15, 'days');
|
|
40
42
|
const minimumDate = moment(date).add(-15, 'days');
|
|
41
43
|
const [dateData, indexDate] =
|
|
@@ -77,17 +79,17 @@ const WheelDateTimePicker = ({
|
|
|
77
79
|
[setMinuteSelected]
|
|
78
80
|
);
|
|
79
81
|
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
}, [
|
|
82
|
+
const onPickerCancel = useCallback(() => {
|
|
83
|
+
onCancel && onCancel();
|
|
84
|
+
}, [onCancel]);
|
|
83
85
|
|
|
84
86
|
const onDone = useCallback(() => {
|
|
85
87
|
const newDateTime = moment(dateSelected);
|
|
86
88
|
newDateTime.hour(hourSelected);
|
|
87
89
|
newDateTime.minute(minuteSelected);
|
|
88
90
|
onPicked && onPicked(newDateTime.valueOf());
|
|
89
|
-
|
|
90
|
-
}, [dateSelected, hourSelected, minuteSelected,
|
|
91
|
+
onCancel && onCancel();
|
|
92
|
+
}, [dateSelected, hourSelected, minuteSelected, onCancel, onPicked]);
|
|
91
93
|
|
|
92
94
|
const title = useMemo(() => {
|
|
93
95
|
if (mode === 'time') {
|
|
@@ -97,7 +99,12 @@ const WheelDateTimePicker = ({
|
|
|
97
99
|
}, [t, mode]);
|
|
98
100
|
|
|
99
101
|
return (
|
|
100
|
-
<BottomSheet
|
|
102
|
+
<BottomSheet
|
|
103
|
+
isVisible={isVisible}
|
|
104
|
+
onBackdropPress={onPickerCancel}
|
|
105
|
+
onHide={onHide}
|
|
106
|
+
title={title}
|
|
107
|
+
>
|
|
101
108
|
{mode === 'time' ? (
|
|
102
109
|
<View style={styles.container}>
|
|
103
110
|
<Picker
|
|
@@ -149,9 +156,10 @@ const WheelDateTimePicker = ({
|
|
|
149
156
|
)}
|
|
150
157
|
<ViewButtonBottom
|
|
151
158
|
leftTitle={t('cancel')}
|
|
152
|
-
onLeftClick={
|
|
159
|
+
onLeftClick={onPickerCancel}
|
|
153
160
|
rightTitle={t('done')}
|
|
154
161
|
onRightClick={onDone}
|
|
162
|
+
testIDPrefix={TESTID.WHEEL_DATE_TIME_PICKER}
|
|
155
163
|
/>
|
|
156
164
|
</BottomSheet>
|
|
157
165
|
);
|
package/src/commons/index.js
CHANGED
|
@@ -14,6 +14,7 @@ import MenuActionAddnew from './MenuActionAddnew';
|
|
|
14
14
|
import MenuActionList from './MenuActionList';
|
|
15
15
|
import RadioCircle from './RadioCircle';
|
|
16
16
|
import { CircleButton } from './CircleButton';
|
|
17
|
+
import HorizontalPicker from './HorizontalPicker';
|
|
17
18
|
|
|
18
19
|
export {
|
|
19
20
|
ButtonPopup,
|
|
@@ -32,4 +33,5 @@ export {
|
|
|
32
33
|
MenuActionList,
|
|
33
34
|
RadioCircle,
|
|
34
35
|
CircleButton,
|
|
36
|
+
HorizontalPicker,
|
|
35
37
|
};
|
package/src/configs/API.js
CHANGED
|
@@ -85,7 +85,7 @@ const API = {
|
|
|
85
85
|
AUTOMATE: {
|
|
86
86
|
ACTION_ONE_TAP: (id) =>
|
|
87
87
|
SCConfig.apiRoot + `/property_manager/automate/${id}/action_one_tap/`,
|
|
88
|
-
|
|
88
|
+
SCRIPT: (id) =>
|
|
89
89
|
SCConfig.apiRoot + `/property_manager/automate/${id}/script/`,
|
|
90
90
|
ORDER_SCRIPT_ACTION: (id) =>
|
|
91
91
|
SCConfig.apiRoot +
|
|
@@ -96,6 +96,10 @@ const API = {
|
|
|
96
96
|
ADD_SCRIPT_ACTION: (id) =>
|
|
97
97
|
SCConfig.apiRoot + `/property_manager/automate/${id}/add_script_action/`,
|
|
98
98
|
CREATE_AUTOMATE: () => SCConfig.apiRoot + '/property_manager/automate/',
|
|
99
|
+
GET_AUTOMATES: () => SCConfig.apiRoot + '/accounts/automates/',
|
|
100
|
+
GET_ALL_UNITS: () => SCConfig.apiRoot + '/property_manager/units/all_unit/',
|
|
101
|
+
GET_SENSOR_CONFIG: (id) =>
|
|
102
|
+
SCConfig.apiRoot + `/property_manager/sensors/${id}/display_configs/`,
|
|
99
103
|
},
|
|
100
104
|
GOOGLE_HOME: {
|
|
101
105
|
CHECK_SEND_EMAIL: () =>
|
package/src/configs/Constants.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Platform, Dimensions, StatusBar } from 'react-native';
|
|
2
2
|
import { RFValue } from 'react-native-responsive-fontsize';
|
|
3
3
|
import OneTap from '../../assets/images/OneTap.svg';
|
|
4
|
-
import
|
|
4
|
+
import ValueChange from '../../assets/images/ValueChange.svg';
|
|
5
5
|
import Schedule from '../../assets/images/Schedule.svg';
|
|
6
6
|
|
|
7
7
|
const X_WIDTH = 375;
|
|
@@ -93,6 +93,11 @@ export const AUTOMATE_TYPE = {
|
|
|
93
93
|
SCHEDULE: 'schedule',
|
|
94
94
|
};
|
|
95
95
|
|
|
96
|
+
export const AUTOMATE_SELECT = {
|
|
97
|
+
SELECT_DEVICES: 'select_devices',
|
|
98
|
+
SELECT_SENSOR: 'select_sensor',
|
|
99
|
+
};
|
|
100
|
+
|
|
96
101
|
export const AUTOMATES = {
|
|
97
102
|
one_tap: {
|
|
98
103
|
value: AUTOMATE_TYPE.ONE_TAP,
|
|
@@ -102,9 +107,9 @@ export const AUTOMATES = {
|
|
|
102
107
|
},
|
|
103
108
|
value_change: {
|
|
104
109
|
value: AUTOMATE_TYPE.VALUE_CHANGE,
|
|
105
|
-
title: '
|
|
110
|
+
title: 'Value change',
|
|
106
111
|
explanation: 'Short Explanation',
|
|
107
|
-
icon:
|
|
112
|
+
icon: ValueChange,
|
|
108
113
|
},
|
|
109
114
|
schedule: {
|
|
110
115
|
value: AUTOMATE_TYPE.SCHEDULE,
|
|
@@ -521,4 +526,14 @@ export const TESTID = {
|
|
|
521
526
|
// Add New Device LG
|
|
522
527
|
ADD_NEW_DEVICE_LG_ADD: 'ADD_NEW_DEVICE_LG_ADD',
|
|
523
528
|
ADD_NEW_DEVICE_LG_THEN_SELECT: 'ADD_NEW_DEVICE_LG_THEN_SELECT',
|
|
529
|
+
|
|
530
|
+
// WheelDateTimePicker
|
|
531
|
+
WHEEL_DATE_TIME_PICKER: 'WHEEL_DATE_TIME_PICKER',
|
|
532
|
+
|
|
533
|
+
// GuestInfo
|
|
534
|
+
SAVE_ACCESS_SCHEDULE: 'SAVE_ACCESS_SCHEDULE',
|
|
535
|
+
ACCESS_SCHEDULE_RADIO_BUTTON: 'ACCESS_SCHEDULE_RADIO_BUTTON',
|
|
536
|
+
ACCESS_SCHEDULE_SHEET: 'ACCESS_SCHEDULE_SHEET',
|
|
537
|
+
RECURRING_TEXT_BUTTON: 'RECURRING_TEXT_BUTTON',
|
|
538
|
+
TEMPORARY_TEXT_BUTTON: 'TEMPORARY_TEXT_BUTTON',
|
|
524
539
|
};
|
package/src/configs/Theme.js
CHANGED
|
@@ -85,4 +85,24 @@ export default StyleSheet.create({
|
|
|
85
85
|
justifyContent: 'center',
|
|
86
86
|
alignItems: 'center',
|
|
87
87
|
},
|
|
88
|
+
menuIcon: {
|
|
89
|
+
paddingLeft: 16,
|
|
90
|
+
height: '100%',
|
|
91
|
+
justifyContent: 'center',
|
|
92
|
+
},
|
|
93
|
+
wrap: {
|
|
94
|
+
flex: 1,
|
|
95
|
+
backgroundColor: Colors.White,
|
|
96
|
+
},
|
|
97
|
+
shadowView: {
|
|
98
|
+
shadowColor: Colors.Gray7,
|
|
99
|
+
backgroundColor: Colors.White,
|
|
100
|
+
shadowOffset: {
|
|
101
|
+
width: 0,
|
|
102
|
+
height: 3,
|
|
103
|
+
},
|
|
104
|
+
shadowOpacity: 0.22,
|
|
105
|
+
shadowRadius: 3,
|
|
106
|
+
elevation: 3,
|
|
107
|
+
},
|
|
88
108
|
});
|
|
@@ -29,10 +29,10 @@ type Reducer<StateData, Action> = (
|
|
|
29
29
|
action: Action
|
|
30
30
|
) => StateData;
|
|
31
31
|
|
|
32
|
-
export const SCProvider = ({ children }) => {
|
|
32
|
+
export const SCProvider = ({ children, initState = initialState }) => {
|
|
33
33
|
const [stateData, dispatch] = useReducer<Reducer<ContextData, Action>>(
|
|
34
34
|
reducer,
|
|
35
|
-
|
|
35
|
+
initState
|
|
36
36
|
);
|
|
37
37
|
|
|
38
38
|
const setAuth = (authData: AuthData) => {
|
package/src/context/mockStore.ts
CHANGED
|
@@ -16,7 +16,7 @@ export const mockDataStore: ContextData = {
|
|
|
16
16
|
},
|
|
17
17
|
},
|
|
18
18
|
},
|
|
19
|
-
language: '
|
|
19
|
+
language: 'en',
|
|
20
20
|
listDevice: {
|
|
21
21
|
sentEmail: false,
|
|
22
22
|
},
|
|
@@ -24,6 +24,7 @@ export const mockDataStore: ContextData = {
|
|
|
24
24
|
backgroundColor: '',
|
|
25
25
|
barStyle: '',
|
|
26
26
|
},
|
|
27
|
+
listAction: [],
|
|
27
28
|
};
|
|
28
29
|
|
|
29
30
|
export const mockSCStore = (data: ContextData): ContextData => {
|
|
@@ -45,5 +46,6 @@ export const mockSCStore = (data: ContextData): ContextData => {
|
|
|
45
46
|
mockDataStore?.statusBar?.backgroundColor,
|
|
46
47
|
barStyle: data?.statusBar?.barStyle || mockDataStore?.statusBar?.barStyle,
|
|
47
48
|
},
|
|
49
|
+
listAction: [...mockDataStore.listAction, ...(data?.listAction || [])],
|
|
48
50
|
};
|
|
49
51
|
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { useStatusBarPreview, useHiddenStatusBar } from '../useStatusBar';
|
|
2
|
+
|
|
3
|
+
describe('test useStatusBarPreview', () => {
|
|
4
|
+
let Platform;
|
|
5
|
+
beforeEach(() => {
|
|
6
|
+
Platform = require('react-native').Platform;
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it('test useStatusBarPreview on android', () => {
|
|
10
|
+
Platform.OS = 'ios';
|
|
11
|
+
useStatusBarPreview();
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('test useStatusBarPreview on iOS', () => {
|
|
15
|
+
Platform.OS = 'android';
|
|
16
|
+
useStatusBarPreview();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('test useHiddenStatusBar on android', () => {
|
|
20
|
+
Platform.OS = 'ios';
|
|
21
|
+
useHiddenStatusBar(false);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('test useHiddenStatusBar on iOS', () => {
|
|
25
|
+
Platform.OS = 'android';
|
|
26
|
+
useHiddenStatusBar(true);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React, { memo, useCallback } from 'react';
|
|
2
|
+
import { TouchableOpacity } from 'react-native';
|
|
3
|
+
import { createStackNavigator } from '@react-navigation/stack';
|
|
4
|
+
import { useNavigation } from '@react-navigation/core';
|
|
5
|
+
import { Icon } from '@ant-design/react-native';
|
|
6
|
+
|
|
7
|
+
import Routes from '../utils/Route';
|
|
8
|
+
import { screenOptions } from './utils';
|
|
9
|
+
import { useTranslations } from '../hooks/Common/useTranslations';
|
|
10
|
+
import { Colors, Theme } from '../configs';
|
|
11
|
+
import Automate from '../screens/Automate';
|
|
12
|
+
|
|
13
|
+
const Stack = createStackNavigator();
|
|
14
|
+
|
|
15
|
+
const AutomateStack = memo(() => {
|
|
16
|
+
const t = useTranslations();
|
|
17
|
+
const navigation = useNavigation();
|
|
18
|
+
|
|
19
|
+
const toggleDrawer = useCallback(() => {
|
|
20
|
+
navigation.toggleDrawer();
|
|
21
|
+
}, [navigation]);
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<Stack.Navigator
|
|
25
|
+
screenOptions={{
|
|
26
|
+
...screenOptions,
|
|
27
|
+
headerShown: true,
|
|
28
|
+
title: t('automate_scripts'),
|
|
29
|
+
headerLeft: () => (
|
|
30
|
+
<TouchableOpacity style={Theme.menuIcon} onPress={toggleDrawer}>
|
|
31
|
+
<Icon name={'menu'} color={Colors.Black} />
|
|
32
|
+
</TouchableOpacity>
|
|
33
|
+
),
|
|
34
|
+
headerTitleAlign: 'left',
|
|
35
|
+
headerStyle: {
|
|
36
|
+
backgroundColor: Colors.Gray2,
|
|
37
|
+
},
|
|
38
|
+
}}
|
|
39
|
+
>
|
|
40
|
+
<Stack.Screen name={Routes.Automate} component={Automate} />
|
|
41
|
+
</Stack.Navigator>
|
|
42
|
+
);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
export default AutomateStack;
|