@eohjsc/react-native-smart-city 0.7.42 → 0.7.44
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/package.json +1 -1
- package/src/commons/Dashboard/MyDashboardDevice/index.js +1 -0
- package/src/commons/Dashboard/MyUnit/index.js +1 -0
- package/src/commons/Device/PowerConsumptionChart.js +63 -31
- package/src/configs/AccessibilityLabel.js +1 -0
- package/src/iot/mqtt.js +4 -2
- package/src/navigations/UnitStack.js +2 -2
- package/src/screens/ActivityLog/ItemLog.js +69 -16
- package/src/screens/ActivityLog/__test__/ItemLog.test.js +169 -2
- package/src/screens/ActivityLog/index.js +2 -2
- package/src/screens/ActivityLog/styles/itemLogStyles.js +35 -0
- package/src/screens/AddNewGateway/RenameNewDevices.js +1 -1
- package/src/screens/AddNewGateway/__test__/RenameNewDevices.test.js +1 -1
- package/src/screens/Automate/AddNewAction/NewActionWrapper.js +24 -4
- package/src/screens/Automate/AddNewAction/__test__/SelectControlDevices.test.js +75 -11
- package/src/screens/Automate/AddNewAction/__test__/SelectMonitorDevices.test.js +5 -1
- package/src/screens/Automate/AddNewAutoSmart/AddTypeSmart.js +3 -2
- package/src/screens/Automate/EditActionsList/__tests__/index.test.js +20 -1
- package/src/screens/Automate/EditActionsList/index.js +18 -9
- package/src/screens/Automate/MultiUnits.js +2 -0
- package/src/screens/Automate/OneTap/__test__/AddNewOneTap.test.js +5 -0
- package/src/screens/Automate/Scenario/__test__/AddNewOneTap.test.js +5 -0
- package/src/screens/Automate/ScriptDetail/Styles/indexStyles.js +3 -0
- package/src/screens/Automate/ScriptDetail/__test__/index.test.js +41 -12
- package/src/screens/Automate/ScriptDetail/index.js +3 -3
- package/src/screens/Automate/SetSchedule/__test__/AddEditConditionSchedule.test.js +4 -0
- package/src/screens/Automate/SetSchedule/__test__/index.test.js +4 -0
- package/src/screens/Automate/__test__/MultiUnits.test.js +6 -4
- package/src/screens/Automate/__test__/index.test.js +1 -0
- package/src/screens/Automate/index.js +1 -0
- package/src/screens/ConfirmUnitDeletion/__test__/ConfirmUnitDeletion.test.js +1 -1
- package/src/screens/ConfirmUnitDeletion/index.js +1 -1
- package/src/screens/CreatePassword/__test__/index.test.js +11 -2
- package/src/screens/CreatePassword/index.js +12 -1
- package/src/screens/Device/components/SensorDisplayItem.js +1 -0
- package/src/screens/Device/styles.js +1 -1
- package/src/screens/EnterPassword/index.js +1 -1
- package/src/screens/Notification/components/NotificationItem.js +1 -4
- package/src/screens/Sharing/__test__/UnitMemberList.test.js +1 -1
- package/src/screens/Sharing/hooks/__test__/index.test.js +2 -2
- package/src/screens/Sharing/hooks/index.js +1 -1
- package/src/screens/SmartAccount/ListDevice/index.js +1 -1
- package/src/screens/SubUnit/AddSubUnit.js +2 -2
- package/src/screens/SubUnit/__test__/AddSubUnit.test.js +1 -1
- package/src/screens/SyncLGDevice/AddLGDevice.js +3 -3
- package/src/screens/SyncLGDevice/__test__/AddLGDevice.test.js +5 -5
- package/src/screens/Unit/Detail.js +1 -3
- package/src/screens/Unit/__test__/Detail.test.js +4 -4
- package/src/screens/UnitSummary/components/PowerConsumption/__test__/PowerConsumption.test.js +32 -0
- package/src/utils/I18n/translations/en.js +1 -0
- package/src/utils/I18n/translations/vi.js +1 -0
|
@@ -23,19 +23,10 @@ const wrapComponent = (route) => (
|
|
|
23
23
|
|
|
24
24
|
describe('Test SelectMonitorDevices', () => {
|
|
25
25
|
const mockedNavigate = useNavigation().navigate;
|
|
26
|
+
const mockedGetState = useNavigation().getState;
|
|
26
27
|
|
|
27
28
|
let tree;
|
|
28
|
-
|
|
29
|
-
params: {
|
|
30
|
-
unitId: 1,
|
|
31
|
-
automateId: 1,
|
|
32
|
-
scriptName: 'scriptName test',
|
|
33
|
-
automate: {
|
|
34
|
-
sensor_id: 1,
|
|
35
|
-
},
|
|
36
|
-
closeScreen: Routes.ScriptDetail,
|
|
37
|
-
},
|
|
38
|
-
};
|
|
29
|
+
let route;
|
|
39
30
|
const response = [
|
|
40
31
|
{
|
|
41
32
|
id: 1,
|
|
@@ -48,7 +39,21 @@ describe('Test SelectMonitorDevices', () => {
|
|
|
48
39
|
];
|
|
49
40
|
|
|
50
41
|
beforeEach(() => {
|
|
42
|
+
route = {
|
|
43
|
+
params: {
|
|
44
|
+
unitId: 1,
|
|
45
|
+
automateId: 1,
|
|
46
|
+
scriptName: 'scriptName test',
|
|
47
|
+
automate: {
|
|
48
|
+
sensor_id: 1,
|
|
49
|
+
},
|
|
50
|
+
closeScreen: Routes.ScriptDetail,
|
|
51
|
+
},
|
|
52
|
+
};
|
|
51
53
|
mockedNavigate.mockClear();
|
|
54
|
+
mockedGetState.mockReturnValue({
|
|
55
|
+
routes: [{ name: 'Home' }],
|
|
56
|
+
});
|
|
52
57
|
useRoute.mockImplementation(() => route);
|
|
53
58
|
});
|
|
54
59
|
|
|
@@ -116,4 +121,63 @@ describe('Test SelectMonitorDevices', () => {
|
|
|
116
121
|
unitId: 1,
|
|
117
122
|
});
|
|
118
123
|
});
|
|
124
|
+
|
|
125
|
+
it('test onPressClose when routes has closeScreen', async () => {
|
|
126
|
+
mockedGetState.mockReturnValue({
|
|
127
|
+
index: 2,
|
|
128
|
+
routes: [{ name: 'Home' }, { name: Routes.ScriptDetail, params: {} }],
|
|
129
|
+
});
|
|
130
|
+
mock.onGet(API.UNIT.DEVICE_CONTROL(1)).reply(200, response);
|
|
131
|
+
await act(async () => {
|
|
132
|
+
tree = await renderer.create(wrapComponent(route));
|
|
133
|
+
});
|
|
134
|
+
const instance = tree.root;
|
|
135
|
+
const iconClose = instance.findAll(
|
|
136
|
+
(el) =>
|
|
137
|
+
el.props.accessibilityLabel === AccessibilityLabel.ICON_CLOSE &&
|
|
138
|
+
el.type === TouchableOpacity
|
|
139
|
+
);
|
|
140
|
+
expect(iconClose).toHaveLength(1);
|
|
141
|
+
|
|
142
|
+
await act(async () => {
|
|
143
|
+
iconClose[0].props.onPress();
|
|
144
|
+
});
|
|
145
|
+
expect(global.mockedPop).toHaveBeenCalledWith(1);
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
it('test onPressClose when routes has closeStack', async () => {
|
|
149
|
+
route.params.closeStack = Routes.AutomateStack;
|
|
150
|
+
mock.onGet(API.UNIT.DEVICE_CONTROL(1)).reply(200, response);
|
|
151
|
+
await act(async () => {
|
|
152
|
+
tree = await renderer.create(wrapComponent(route));
|
|
153
|
+
});
|
|
154
|
+
const instance = tree.root;
|
|
155
|
+
const iconClose = instance.findAll(
|
|
156
|
+
(el) =>
|
|
157
|
+
el.props.accessibilityLabel === AccessibilityLabel.ICON_CLOSE &&
|
|
158
|
+
el.type === TouchableOpacity
|
|
159
|
+
);
|
|
160
|
+
expect(iconClose).toHaveLength(1);
|
|
161
|
+
|
|
162
|
+
await act(async () => {
|
|
163
|
+
iconClose[0].props.onPress();
|
|
164
|
+
});
|
|
165
|
+
expect(global.mockedNavigate).toHaveBeenCalledWith(Routes.Main, {
|
|
166
|
+
screen: Routes.DrawerMain,
|
|
167
|
+
params: {
|
|
168
|
+
screen: Routes.AutomateStack,
|
|
169
|
+
params: {
|
|
170
|
+
screen: Routes.ScriptDetail,
|
|
171
|
+
params: {
|
|
172
|
+
automate: { sensor_id: 1 },
|
|
173
|
+
automateId: 1,
|
|
174
|
+
closeScreen: Routes.ScriptDetail,
|
|
175
|
+
closeStack: Routes.AutomateStack,
|
|
176
|
+
scriptName: 'scriptName test',
|
|
177
|
+
unitId: 1,
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
});
|
|
182
|
+
});
|
|
119
183
|
});
|
|
@@ -2,7 +2,7 @@ import MockAdapter from 'axios-mock-adapter';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import renderer, { act } from 'react-test-renderer';
|
|
4
4
|
|
|
5
|
-
import { useRoute } from '@react-navigation/native';
|
|
5
|
+
import { useNavigation, useRoute } from '@react-navigation/native';
|
|
6
6
|
import { TouchableOpacity } from 'react-native';
|
|
7
7
|
import API from '../../../../configs/API';
|
|
8
8
|
import { AccessibilityLabel } from '../../../../configs/Constants';
|
|
@@ -41,9 +41,13 @@ describe('Test SelectMonitorDevices', () => {
|
|
|
41
41
|
],
|
|
42
42
|
},
|
|
43
43
|
];
|
|
44
|
+
const mockedGetState = useNavigation().getState;
|
|
44
45
|
|
|
45
46
|
beforeEach(() => {
|
|
46
47
|
useRoute.mockImplementation(() => route);
|
|
48
|
+
mockedGetState.mockReturnValue({
|
|
49
|
+
routes: [{ name: 'Home' }],
|
|
50
|
+
});
|
|
47
51
|
});
|
|
48
52
|
|
|
49
53
|
it('test onPressClose', async () => {
|
|
@@ -15,7 +15,7 @@ const AddTypeSmart = ({ smartTypes, route }) => {
|
|
|
15
15
|
const t = useTranslations();
|
|
16
16
|
const { setAction } = useContext(SCContext);
|
|
17
17
|
const { navigate, goBack } = useNavigation();
|
|
18
|
-
const { automate = {}, closeScreen } = route?.params || {};
|
|
18
|
+
const { automate = {}, closeScreen, closeStack } = route?.params || {};
|
|
19
19
|
const { id, unit, type } = automate;
|
|
20
20
|
|
|
21
21
|
const [selectedIndex, setSelectedIndex] = useState(
|
|
@@ -37,6 +37,7 @@ const AddTypeSmart = ({ smartTypes, route }) => {
|
|
|
37
37
|
},
|
|
38
38
|
unitId: unit,
|
|
39
39
|
closeScreen: closeScreen,
|
|
40
|
+
closeStack: closeStack,
|
|
40
41
|
};
|
|
41
42
|
setAction(Action.IS_CREATE_CONDITION, false);
|
|
42
43
|
setAction(Action.IS_UPDATE_CONDITION, false);
|
|
@@ -47,7 +48,7 @@ const AddTypeSmart = ({ smartTypes, route }) => {
|
|
|
47
48
|
|
|
48
49
|
navigate(dataAutomate.route, params);
|
|
49
50
|
},
|
|
50
|
-
[smartTypes, automate, unit, closeScreen, setAction, navigate]
|
|
51
|
+
[smartTypes, automate, unit, closeScreen, closeStack, setAction, navigate]
|
|
51
52
|
);
|
|
52
53
|
|
|
53
54
|
const onSelectType = (index) => {
|
|
@@ -30,6 +30,8 @@ jest.mock('react-native-parsed-text', () => () => []);
|
|
|
30
30
|
describe('EditActionsList', () => {
|
|
31
31
|
let tree;
|
|
32
32
|
const mockedNavigate = useNavigation().navigate;
|
|
33
|
+
const mockedGetState = useNavigation().getState;
|
|
34
|
+
|
|
33
35
|
let actionsList = [
|
|
34
36
|
{
|
|
35
37
|
id: 1,
|
|
@@ -80,6 +82,9 @@ describe('EditActionsList', () => {
|
|
|
80
82
|
},
|
|
81
83
|
});
|
|
82
84
|
mockedNavigate.mockClear();
|
|
85
|
+
mockedGetState.mockReturnValue({
|
|
86
|
+
routes: [{ name: 'Home' }, { name: Routes.ScriptDetail, params: {} }],
|
|
87
|
+
});
|
|
83
88
|
});
|
|
84
89
|
|
|
85
90
|
it('EditActionsList reorder actions', async () => {
|
|
@@ -110,7 +115,21 @@ describe('EditActionsList', () => {
|
|
|
110
115
|
await act(async () => {
|
|
111
116
|
headerCustom[0].props.onGoBack();
|
|
112
117
|
});
|
|
113
|
-
expect(global.
|
|
118
|
+
expect(global.mockedReset).toHaveBeenCalledWith({
|
|
119
|
+
index: 1,
|
|
120
|
+
routes: [
|
|
121
|
+
{ name: 'Home' },
|
|
122
|
+
{
|
|
123
|
+
name: Routes.ScriptDetail,
|
|
124
|
+
params: {
|
|
125
|
+
automate: {
|
|
126
|
+
id: 1,
|
|
127
|
+
},
|
|
128
|
+
newActionsList: actionsList,
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
],
|
|
132
|
+
});
|
|
114
133
|
});
|
|
115
134
|
|
|
116
135
|
it('EditActionsList onPress remove action', async () => {
|
|
@@ -30,7 +30,7 @@ import UpdateSmsScript from './UpdateSmsScript';
|
|
|
30
30
|
|
|
31
31
|
const EditActionsList = () => {
|
|
32
32
|
const t = useTranslations();
|
|
33
|
-
const { navigate } = useNavigation();
|
|
33
|
+
const { navigate, getState, reset } = useNavigation();
|
|
34
34
|
const { params = {} } = useRoute() || {};
|
|
35
35
|
const { data, id, unitId } = params;
|
|
36
36
|
const [itemRemove, setItemRemove] = useState({});
|
|
@@ -59,15 +59,24 @@ const EditActionsList = () => {
|
|
|
59
59
|
);
|
|
60
60
|
|
|
61
61
|
const onGoBack = useCallback(() => {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
62
|
+
const state = getState();
|
|
63
|
+
const index = state.routes.findIndex((r) => r.name === Routes.ScriptDetail);
|
|
64
|
+
const route = state.routes[index];
|
|
65
|
+
reset({
|
|
66
|
+
routes: [
|
|
67
|
+
...state.routes.slice(0, index),
|
|
68
|
+
{
|
|
69
|
+
name: Routes.ScriptDetail,
|
|
70
|
+
params: {
|
|
71
|
+
...route.params,
|
|
72
|
+
newActionsList: actionsList,
|
|
73
|
+
automate: { id: id },
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
index,
|
|
69
78
|
});
|
|
70
|
-
}, [actionsList,
|
|
79
|
+
}, [actionsList, getState, id, reset]);
|
|
71
80
|
|
|
72
81
|
const onPressRemove = (item) => {
|
|
73
82
|
setIsVisible(true);
|
|
@@ -107,6 +107,7 @@ const MultiUnits = () => {
|
|
|
107
107
|
unit: unitId,
|
|
108
108
|
},
|
|
109
109
|
closeScreen: currentRouteName,
|
|
110
|
+
closeStack: Routes.AutomateStack,
|
|
110
111
|
},
|
|
111
112
|
});
|
|
112
113
|
return;
|
|
@@ -117,6 +118,7 @@ const MultiUnits = () => {
|
|
|
117
118
|
params: {
|
|
118
119
|
automate: { unit: unitId },
|
|
119
120
|
closeScreen: currentRouteName,
|
|
121
|
+
closeStack: Routes.AutomateStack,
|
|
120
122
|
},
|
|
121
123
|
});
|
|
122
124
|
}, [
|
|
@@ -38,8 +38,13 @@ let tree;
|
|
|
38
38
|
|
|
39
39
|
describe('test OneTap', () => {
|
|
40
40
|
const mockedNavigate = useNavigation().navigate;
|
|
41
|
+
const mockedGetState = useNavigation().getState;
|
|
42
|
+
|
|
41
43
|
beforeEach(() => {
|
|
42
44
|
mockedNavigate.mockClear();
|
|
45
|
+
mockedGetState.mockReturnValue({
|
|
46
|
+
routes: [{ name: 'Home' }],
|
|
47
|
+
});
|
|
43
48
|
mockAllowInAppReview.mockClear();
|
|
44
49
|
mockAskReview.mockClear();
|
|
45
50
|
});
|
|
@@ -26,8 +26,13 @@ let tree;
|
|
|
26
26
|
|
|
27
27
|
describe('test OneTap', () => {
|
|
28
28
|
const mockedNavigate = useNavigation().navigate;
|
|
29
|
+
const mockedGetState = useNavigation().getState;
|
|
30
|
+
|
|
29
31
|
beforeEach(() => {
|
|
30
32
|
mockedNavigate.mockClear();
|
|
33
|
+
mockedGetState.mockReturnValue({
|
|
34
|
+
routes: [{ name: 'Home' }],
|
|
35
|
+
});
|
|
31
36
|
});
|
|
32
37
|
|
|
33
38
|
it('create OneTap success', async () => {
|
|
@@ -290,11 +290,14 @@ describe('Test ScriptDetail', () => {
|
|
|
290
290
|
menuActionMore.props.listMenuItem[0].doAction();
|
|
291
291
|
});
|
|
292
292
|
|
|
293
|
-
expect(global.mockedNavigate).
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
293
|
+
expect(global.mockedNavigate).toHaveBeenCalledWith(
|
|
294
|
+
Routes.SelectMonitorDevices,
|
|
295
|
+
{
|
|
296
|
+
automate: route.params.preAutomate,
|
|
297
|
+
closeScreen: Routes.ScriptDetail,
|
|
298
|
+
routeName: null,
|
|
299
|
+
}
|
|
300
|
+
);
|
|
298
301
|
});
|
|
299
302
|
|
|
300
303
|
it('test edit condition value change multi unit', async () => {
|
|
@@ -322,7 +325,7 @@ describe('Test ScriptDetail', () => {
|
|
|
322
325
|
menuActionMore.props.listMenuItem[0].doAction();
|
|
323
326
|
});
|
|
324
327
|
|
|
325
|
-
expect(global.mockedNavigate).
|
|
328
|
+
expect(global.mockedNavigate).toHaveBeenCalledWith(Routes.SelectUnit, {
|
|
326
329
|
automate: route.params.preAutomate,
|
|
327
330
|
routeName: Routes.SelectMonitorDevices,
|
|
328
331
|
});
|
|
@@ -354,7 +357,7 @@ describe('Test ScriptDetail', () => {
|
|
|
354
357
|
menuActionMore.props.listMenuItem[0].doAction();
|
|
355
358
|
});
|
|
356
359
|
|
|
357
|
-
expect(global.mockedNavigate).
|
|
360
|
+
expect(global.mockedNavigate).toHaveBeenCalledWith(
|
|
358
361
|
Routes.AddEditConditionSchedule,
|
|
359
362
|
{
|
|
360
363
|
automate: route.params.preAutomate,
|
|
@@ -467,7 +470,7 @@ describe('Test ScriptDetail', () => {
|
|
|
467
470
|
await buttonEditScript.props.onPress();
|
|
468
471
|
});
|
|
469
472
|
|
|
470
|
-
expect(global.mockedNavigate).
|
|
473
|
+
expect(global.mockedNavigate).toHaveBeenCalledWith(Routes.EditActionsList, {
|
|
471
474
|
data: data.script_items,
|
|
472
475
|
id: 1,
|
|
473
476
|
unitId: 2,
|
|
@@ -503,6 +506,7 @@ describe('Test ScriptDetail', () => {
|
|
|
503
506
|
(el) =>
|
|
504
507
|
el.props.accessibilityLabel === AccessibilityLabel.AUTOMATE_CONDITION
|
|
505
508
|
);
|
|
509
|
+
expect(showPopup.props.disabled).toBeFalsy();
|
|
506
510
|
await act(async () => {
|
|
507
511
|
await showPopup.props.onPress();
|
|
508
512
|
});
|
|
@@ -538,6 +542,31 @@ describe('Test ScriptDetail', () => {
|
|
|
538
542
|
);
|
|
539
543
|
});
|
|
540
544
|
|
|
545
|
+
it('test disable update need all condition', async () => {
|
|
546
|
+
route.params.preAutomate.can_edit = false;
|
|
547
|
+
await act(async () => {
|
|
548
|
+
tree = await create(
|
|
549
|
+
wrapComponent(route, {
|
|
550
|
+
auth: {
|
|
551
|
+
account: {
|
|
552
|
+
user: {
|
|
553
|
+
permissions: {
|
|
554
|
+
max_conditions_per_automation: 1,
|
|
555
|
+
},
|
|
556
|
+
},
|
|
557
|
+
},
|
|
558
|
+
},
|
|
559
|
+
})
|
|
560
|
+
);
|
|
561
|
+
});
|
|
562
|
+
const instance = tree.root;
|
|
563
|
+
const showPopup = instance.find(
|
|
564
|
+
(el) =>
|
|
565
|
+
el.props.accessibilityLabel === AccessibilityLabel.AUTOMATE_CONDITION
|
|
566
|
+
);
|
|
567
|
+
expect(showPopup.props.disabled).toBeTruthy();
|
|
568
|
+
});
|
|
569
|
+
|
|
541
570
|
it('test cannot edit condition because not owner', async () => {
|
|
542
571
|
route.params.preAutomate.can_edit = false;
|
|
543
572
|
const spyToastError = jest.spyOn(ToastBottomHelper, 'error');
|
|
@@ -597,7 +626,7 @@ describe('Test ScriptDetail', () => {
|
|
|
597
626
|
menuActionMore.props.listMenuItem[0].doAction();
|
|
598
627
|
});
|
|
599
628
|
|
|
600
|
-
expect(spyToastError).
|
|
629
|
+
expect(spyToastError).toHaveBeenCalledWith(
|
|
601
630
|
getTranslate('en', 'this_script_has_been_disabled')
|
|
602
631
|
);
|
|
603
632
|
});
|
|
@@ -902,7 +931,7 @@ describe('Test ScriptDetail', () => {
|
|
|
902
931
|
params: {
|
|
903
932
|
unitId: route.params.preAutomate.unit,
|
|
904
933
|
automateId: route.params.preAutomate.id,
|
|
905
|
-
closeScreen:
|
|
934
|
+
closeScreen: undefined,
|
|
906
935
|
numberActionCanAdd: 2,
|
|
907
936
|
scriptItems: [],
|
|
908
937
|
routeName: null,
|
|
@@ -1213,7 +1242,7 @@ describe('Test ScriptDetail', () => {
|
|
|
1213
1242
|
await act(async () => {
|
|
1214
1243
|
menuActionMore.props.listMenuItem[0].doAction();
|
|
1215
1244
|
});
|
|
1216
|
-
expect(global.mockedNavigate).
|
|
1245
|
+
expect(global.mockedNavigate).toHaveBeenCalledWith(Routes.DeviceDetail, {
|
|
1217
1246
|
sensorId: 1,
|
|
1218
1247
|
unitId: 1,
|
|
1219
1248
|
});
|
|
@@ -1222,7 +1251,7 @@ describe('Test ScriptDetail', () => {
|
|
|
1222
1251
|
await act(async () => {
|
|
1223
1252
|
menuActionMore.props.listMenuItem[1].doAction();
|
|
1224
1253
|
});
|
|
1225
|
-
expect(global.mockedNavigate).
|
|
1254
|
+
expect(global.mockedNavigate).toHaveBeenCalledWith(Routes.UnitDetail, {
|
|
1226
1255
|
unitId: 1,
|
|
1227
1256
|
});
|
|
1228
1257
|
});
|
|
@@ -672,7 +672,8 @@ const ScriptDetail = ({ route }) => {
|
|
|
672
672
|
</Text>
|
|
673
673
|
<Card style={styles.card}>
|
|
674
674
|
<TouchableOpacity
|
|
675
|
-
style={styles.boxCondition}
|
|
675
|
+
style={[styles.boxCondition, !can_edit && styles.disabledEdit]}
|
|
676
|
+
disabled={!can_edit}
|
|
676
677
|
onPress={onShowSelectCondition}
|
|
677
678
|
accessibilityLabel={AccessibilityLabel.AUTOMATE_CONDITION}
|
|
678
679
|
>
|
|
@@ -697,6 +698,7 @@ const ScriptDetail = ({ route }) => {
|
|
|
697
698
|
</>
|
|
698
699
|
);
|
|
699
700
|
}, [
|
|
701
|
+
can_edit,
|
|
700
702
|
max_conditions_per_automation,
|
|
701
703
|
needAllCondition,
|
|
702
704
|
numberConditionsUsed,
|
|
@@ -870,7 +872,6 @@ const ScriptDetail = ({ route }) => {
|
|
|
870
872
|
/>
|
|
871
873
|
<AddActionScript
|
|
872
874
|
automate={automate}
|
|
873
|
-
closeScreen={closeScreen}
|
|
874
875
|
scriptItems={data}
|
|
875
876
|
isVisible={isShowAddAction}
|
|
876
877
|
setIsVisible={setIsShowAddAction}
|
|
@@ -879,7 +880,6 @@ const ScriptDetail = ({ route }) => {
|
|
|
879
880
|
/>
|
|
880
881
|
<ModalAddCondition
|
|
881
882
|
automate={automate}
|
|
882
|
-
closeScreen={closeScreen}
|
|
883
883
|
numberActionAdded={data.length}
|
|
884
884
|
isVisible={isShowAddCondition}
|
|
885
885
|
setIsVisible={setIsShowAddCondition}
|
|
@@ -51,10 +51,14 @@ describe('Test AddEditConditionSchedule', () => {
|
|
|
51
51
|
};
|
|
52
52
|
|
|
53
53
|
const mockedNavigate = useNavigation().navigate;
|
|
54
|
+
const mockedGetState = useNavigation().getState;
|
|
54
55
|
|
|
55
56
|
beforeEach(() => {
|
|
56
57
|
mock.reset();
|
|
57
58
|
mockedNavigate.mockClear();
|
|
59
|
+
mockedGetState.mockReturnValue({
|
|
60
|
+
routes: [{ name: 'Home' }],
|
|
61
|
+
});
|
|
58
62
|
Date.now = jest.fn(() => new Date('2025-01-01T19:00:00.000Z'));
|
|
59
63
|
});
|
|
60
64
|
|
|
@@ -35,9 +35,13 @@ describe('Test SetSchedule', () => {
|
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
const mockedNavigate = useNavigation().navigate;
|
|
38
|
+
const mockedGetState = useNavigation().getState;
|
|
38
39
|
|
|
39
40
|
beforeEach(() => {
|
|
40
41
|
mockedNavigate.mockClear();
|
|
42
|
+
mockedGetState.mockReturnValue({
|
|
43
|
+
routes: [{ name: 'Home' }],
|
|
44
|
+
});
|
|
41
45
|
Date.now = jest.fn(() => new Date('2021-01-24T12:00:00.000Z'));
|
|
42
46
|
});
|
|
43
47
|
|
|
@@ -107,7 +107,7 @@ describe('Test MultiUnits', () => {
|
|
|
107
107
|
await act(async () => {
|
|
108
108
|
ItemOneTaps[0].props.onPressItem();
|
|
109
109
|
});
|
|
110
|
-
expect(global.mockedNavigate).
|
|
110
|
+
expect(global.mockedNavigate).toHaveBeenCalledWith(Routes.UnitStack, {
|
|
111
111
|
screen: Routes.ScriptDetail,
|
|
112
112
|
params: {
|
|
113
113
|
preAutomate: response[1],
|
|
@@ -117,11 +117,12 @@ describe('Test MultiUnits', () => {
|
|
|
117
117
|
await act(async () => {
|
|
118
118
|
ItemAddNews[0].props.onAddNew();
|
|
119
119
|
});
|
|
120
|
-
expect(global.mockedNavigate).
|
|
120
|
+
expect(global.mockedNavigate).toHaveBeenCalledWith(Routes.UnitStack, {
|
|
121
121
|
screen: Routes.AddAutomationTypeSmart,
|
|
122
122
|
params: {
|
|
123
123
|
automate: { unit: undefined },
|
|
124
124
|
closeScreen: undefined,
|
|
125
|
+
closeStack: Routes.AutomateStack,
|
|
125
126
|
},
|
|
126
127
|
});
|
|
127
128
|
});
|
|
@@ -203,6 +204,7 @@ describe('Test MultiUnits', () => {
|
|
|
203
204
|
unit: undefined,
|
|
204
205
|
},
|
|
205
206
|
closeScreen: undefined,
|
|
207
|
+
closeStack: Routes.AutomateStack,
|
|
206
208
|
},
|
|
207
209
|
});
|
|
208
210
|
});
|
|
@@ -254,7 +256,7 @@ describe('Test MultiUnits', () => {
|
|
|
254
256
|
itemAddNews[0].props.onAddNew();
|
|
255
257
|
});
|
|
256
258
|
expect(global.mockedNavigate).not.toBeCalled();
|
|
257
|
-
expect(spyToastError).
|
|
259
|
+
expect(spyToastError).toHaveBeenCalledWith(
|
|
258
260
|
getTranslate('en', 'reach_max_automations_per_unit', { length: 0 }),
|
|
259
261
|
'',
|
|
260
262
|
7000
|
|
@@ -291,7 +293,7 @@ describe('Test MultiUnits', () => {
|
|
|
291
293
|
itemAddNews[0].props.onAddNew();
|
|
292
294
|
});
|
|
293
295
|
expect(global.mockedNavigate).not.toBeCalled();
|
|
294
|
-
expect(spyToastError).
|
|
296
|
+
expect(spyToastError).toHaveBeenCalledWith(
|
|
295
297
|
getTranslate('en', 'no_permission_smart_script_for_multi_unit'),
|
|
296
298
|
'',
|
|
297
299
|
7000
|
|
@@ -71,7 +71,7 @@ describe('Test ConfirmUnitDeletion', () => {
|
|
|
71
71
|
touchableOpacity.props.onPress();
|
|
72
72
|
});
|
|
73
73
|
expect(spyToast).toHaveBeenLastCalledWith('Unit was deleted successfully.');
|
|
74
|
-
expect(mockNavigate).toHaveBeenCalledWith(Routes.
|
|
74
|
+
expect(mockNavigate).toHaveBeenCalledWith(Routes.Main);
|
|
75
75
|
});
|
|
76
76
|
|
|
77
77
|
it('Onpress button ConfirmUnitDeletion response error', async () => {
|
|
@@ -34,7 +34,7 @@ const ConfirmUnitDeletion = ({ route }) => {
|
|
|
34
34
|
if (success) {
|
|
35
35
|
setAction(Action.DELETE_UNIT_SUCCESSFULLY);
|
|
36
36
|
ToastBottomHelper.success(t('unit_deleted_successfully'));
|
|
37
|
-
navigation.navigate(Routes.
|
|
37
|
+
navigation.navigate(Routes.Main);
|
|
38
38
|
}
|
|
39
39
|
} else {
|
|
40
40
|
setErrorText(t('please_enter_correct'));
|
|
@@ -104,8 +104,17 @@ describe('test CreatePassword', () => {
|
|
|
104
104
|
expect(spyToastSuccess).toHaveBeenCalledWith(
|
|
105
105
|
t('create_password_successfully')
|
|
106
106
|
);
|
|
107
|
-
expect(navigate).toHaveBeenCalledWith(Routes.
|
|
108
|
-
|
|
107
|
+
expect(navigate).toHaveBeenCalledWith(Routes.Main, {
|
|
108
|
+
screen: Routes.DrawerMain,
|
|
109
|
+
params: {
|
|
110
|
+
screen: Routes.DashboardStack,
|
|
111
|
+
params: {
|
|
112
|
+
screen: Routes.Dashboard,
|
|
113
|
+
params: {
|
|
114
|
+
needLogout: true,
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
},
|
|
109
118
|
});
|
|
110
119
|
});
|
|
111
120
|
|
|
@@ -76,7 +76,18 @@ const CreatePassword = ({ route }) => {
|
|
|
76
76
|
|
|
77
77
|
if (success) {
|
|
78
78
|
ToastBottomHelper.success(t('create_password_successfully'));
|
|
79
|
-
navigate(Routes.
|
|
79
|
+
navigate(Routes.Main, {
|
|
80
|
+
screen: Routes.DrawerMain,
|
|
81
|
+
params: {
|
|
82
|
+
screen: Routes.DashboardStack,
|
|
83
|
+
params: {
|
|
84
|
+
screen: Routes.Dashboard,
|
|
85
|
+
params: {
|
|
86
|
+
needLogout: true,
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
});
|
|
80
91
|
}
|
|
81
92
|
}, [newPassword, confirmPassword, navigate, t]);
|
|
82
93
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useNavigation
|
|
1
|
+
import { useNavigation } from '@react-navigation/native';
|
|
2
2
|
import moment from 'moment';
|
|
3
3
|
import React, { memo, useCallback, useState } from 'react';
|
|
4
4
|
import { Image, TouchableOpacity, View } from 'react-native';
|
|
@@ -21,7 +21,6 @@ import styles from '../styles/NotificationItemStyles';
|
|
|
21
21
|
const NotificationItem = memo(({ item }) => {
|
|
22
22
|
const t = useTranslations();
|
|
23
23
|
const navigation = useNavigation();
|
|
24
|
-
const { name: currentScreen } = useRoute();
|
|
25
24
|
const language = useSCContextSelector((state) => state.language);
|
|
26
25
|
const { id, icon, created_at, is_read, params, content_code } = item;
|
|
27
26
|
const [isRead, setIsRead] = useState(is_read);
|
|
@@ -439,7 +438,6 @@ const NotificationItem = memo(({ item }) => {
|
|
|
439
438
|
navigation.navigate(Routes.UnitStack, {
|
|
440
439
|
screen: Routes.ScriptDetail,
|
|
441
440
|
params: {
|
|
442
|
-
closeScreen: currentScreen,
|
|
443
441
|
preAutomate: { id: automate_id },
|
|
444
442
|
},
|
|
445
443
|
});
|
|
@@ -452,7 +450,6 @@ const NotificationItem = memo(({ item }) => {
|
|
|
452
450
|
}, [
|
|
453
451
|
params,
|
|
454
452
|
content_code,
|
|
455
|
-
currentScreen,
|
|
456
453
|
customColorText,
|
|
457
454
|
t,
|
|
458
455
|
logo,
|
|
@@ -154,7 +154,7 @@ describe('test MemberList', () => {
|
|
|
154
154
|
await act(async () => {
|
|
155
155
|
await rightHeaderButton.props.onPress();
|
|
156
156
|
});
|
|
157
|
-
expect(mockNavigate).toHaveBeenCalledWith(Routes.
|
|
157
|
+
expect(mockNavigate).toHaveBeenCalledWith(Routes.Main);
|
|
158
158
|
expect(spyToastSuccess).toHaveBeenCalledTimes(1);
|
|
159
159
|
});
|
|
160
160
|
|