@eohjsc/react-native-smart-city 0.7.8 → 0.7.9

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/assets/images/AddNewDevice/add-scan-device-icon.svg +13 -0
  2. package/assets/images/Email.svg +9 -0
  3. package/assets/images/lan.svg +3 -0
  4. package/assets/images/wifi-open.svg +3 -0
  5. package/package.json +2 -1
  6. package/src/commons/ActionGroup/StatesGridActionTemplate.js +7 -3
  7. package/src/commons/ActionGroup/__test__/StatesGridActionTemplate.test.js +7 -3
  8. package/src/commons/AlertAction/index.js +1 -0
  9. package/src/commons/Auth/AccountItem.js +17 -3
  10. package/src/commons/Auth/AccountList.js +3 -7
  11. package/src/commons/ConnectWifi/__test__/ConnectWifi.test.js +373 -0
  12. package/src/commons/ConnectWifi/index.js +201 -0
  13. package/src/commons/ConnectWifi/styles.js +69 -0
  14. package/src/commons/Form/TextInputPassword.js +1 -1
  15. package/src/commons/OneTapTemplate/StatesGridActionTemplate.js +6 -2
  16. package/src/configs/API.js +12 -0
  17. package/src/configs/AccessibilityLabel.js +7 -0
  18. package/src/configs/Constants.js +1 -0
  19. package/src/hooks/Common/index.js +2 -2
  20. package/src/hooks/Common/useBlockBack.js +36 -0
  21. package/src/hooks/useMqtt.js +10 -5
  22. package/src/navigations/AddGatewayStack.js +2 -0
  23. package/src/navigations/AllGatewayStack.js +4 -0
  24. package/src/navigations/Main.js +2 -2
  25. package/src/navigations/UnitStack.js +32 -0
  26. package/src/screens/AddNewGateway/ConnectingWifiDevice.js +7 -6
  27. package/src/screens/AddNewGateway/ScanDeviceLocal.js +267 -0
  28. package/src/screens/AddNewGateway/ScanDeviceLocalStyles.js +58 -0
  29. package/src/screens/AddNewGateway/SelectDeviceSubUnit.js +10 -2
  30. package/src/screens/AddNewGateway/SelectDeviceType.js +19 -2
  31. package/src/screens/AddNewGateway/__test__/ScanDeviceLocal.test.js +475 -0
  32. package/src/screens/AddNewGateway/__test__/SelectDeviceType.test.js +2 -2
  33. package/src/screens/AddNewGateway/configs/API.js +8 -0
  34. package/src/screens/AddNewGateway/hooks/useConnectDevice.js +59 -0
  35. package/src/screens/AllGateway/GatewayInfo/__test__/index.test.js +58 -1
  36. package/src/screens/AllGateway/GatewayInfo/index.js +8 -6
  37. package/src/screens/AllGateway/GatewayWifi/__test__/index.test.js +319 -0
  38. package/src/screens/AllGateway/GatewayWifi/index.js +107 -0
  39. package/src/screens/AllGateway/Successfully/__test__/index.test.js +77 -0
  40. package/src/screens/AllGateway/Successfully/index.js +66 -0
  41. package/src/screens/AllGateway/Successfully/styles.js +35 -0
  42. package/src/screens/AllGateway/components/Information/index.js +17 -1
  43. package/src/screens/AllGateway/components/RowItem/index.js +12 -1
  44. package/src/screens/AllGateway/hooks/__test__/index.test.js +18 -0
  45. package/src/screens/AllGateway/hooks/useGateway.js +13 -0
  46. package/src/screens/Automate/AddNewAction/SetupConfigCondition.js +3 -3
  47. package/src/screens/Automate/AddNewAction/SetupScriptEmail.js +79 -0
  48. package/src/screens/Automate/AddNewAction/SetupScriptReceiverEmail.js +166 -0
  49. package/src/screens/Automate/AddNewAction/Styles/SetupScriptEmailStyles.js +37 -0
  50. package/src/screens/Automate/AddNewAction/Styles/SetupScriptReceiverEmailStyles.js +79 -0
  51. package/src/screens/Automate/AddNewAction/__test__/ChooseAction.test.js +1 -1
  52. package/src/screens/Automate/AddNewAction/__test__/SetupConfigCondition.test.js +13 -5
  53. package/src/screens/Automate/AddNewAction/__test__/SetupScriptEmail.test.js +76 -0
  54. package/src/screens/Automate/AddNewAction/__test__/SetupScriptReceiverEmail.test.js +105 -0
  55. package/src/screens/Automate/EditActionsList/Styles/UpdateReceiverEmailScriptStyles.js +78 -0
  56. package/src/screens/Automate/EditActionsList/UpdateEmailScript.js +80 -0
  57. package/src/screens/Automate/EditActionsList/UpdateReceiverEmailScript.js +179 -0
  58. package/src/screens/Automate/EditActionsList/__tests__/UpdateEmailScript.test.js +81 -0
  59. package/src/screens/Automate/EditActionsList/__tests__/UpdateReceiverEmailScript.test.js +83 -0
  60. package/src/screens/Automate/EditActionsList/__tests__/index.test.js +38 -5
  61. package/src/screens/Automate/EditActionsList/index.js +59 -2
  62. package/src/screens/Automate/ScriptDetail/Components/AddActionScript.js +20 -0
  63. package/src/screens/Automate/ScriptDetail/Styles/indexStyles.js +5 -3
  64. package/src/screens/Automate/ScriptDetail/__test__/index.test.js +127 -21
  65. package/src/screens/Automate/ScriptDetail/index.js +57 -14
  66. package/src/screens/SharedUnit/index.js +2 -2
  67. package/src/screens/Sharing/SelectUser.js +47 -47
  68. package/src/screens/Sharing/__test__/SelectUser.test.js +57 -103
  69. package/src/screens/SubUnit/ManageSubUnit.js +94 -90
  70. package/src/screens/SubUnit/ManageSubUnitStyles.js +4 -6
  71. package/src/screens/SubUnit/RearrageSubUnit.js +90 -0
  72. package/src/screens/SubUnit/RearrrageSubUnitStyle.js +65 -0
  73. package/src/screens/SubUnit/__test__/ManageSubUnit.test.js +35 -19
  74. package/src/screens/SubUnit/__test__/RearrangeSubUnit.test.js +129 -0
  75. package/src/screens/SubUnit/hooks/__test__/useManageSubUnit.test.js +6 -7
  76. package/src/screens/SubUnit/hooks/useManageSubUnit.js +8 -16
  77. package/src/screens/Unit/Detail.js +2 -6
  78. package/src/screens/Unit/ManageUnit.js +1 -1
  79. package/src/utils/Functions/__test__/ShortEmail.test.js +5 -0
  80. package/src/utils/I18n/translations/en.js +46 -8
  81. package/src/utils/I18n/translations/vi.js +37 -4
  82. package/src/utils/Route/index.js +7 -0
  83. package/src/commons/Auth/__test__/AccountItem.test.js +0 -31
  84. package/src/hooks/Common/useBlockBackAndroid.js +0 -21
  85. package/src/screens/SubUnit/DetailStyles.js +0 -46
@@ -0,0 +1,78 @@
1
+ import { StyleSheet } from 'react-native';
2
+ import { Colors, Constants } from '../../../../configs';
3
+ import { getBottomSpace } from 'react-native-iphone-x-helper';
4
+
5
+ export default StyleSheet.create({
6
+ wrap: {
7
+ flex: 1,
8
+ backgroundColor: Colors.White,
9
+ },
10
+ viewEmpty: {
11
+ justifyContent: 'center',
12
+ alignItems: 'center',
13
+ height: Constants.height - 200,
14
+ backgroundColor: Colors.White,
15
+ },
16
+ textCenter: {
17
+ alignSelf: 'center',
18
+ },
19
+ container: {
20
+ flex: 1,
21
+ paddingHorizontal: 16,
22
+ paddingTop: 10,
23
+ paddingBottom: getBottomSpace() + 10,
24
+ },
25
+ bottomButtonView: {
26
+ paddingTop: 24,
27
+ paddingBottom: 32,
28
+ backgroundColor: Colors.White,
29
+ borderColor: Colors.ShadownTransparent,
30
+ borderTopWidth: 1,
31
+ },
32
+ rowContainer: {
33
+ marginTop: 16,
34
+ },
35
+ border: {
36
+ flexDirection: 'row',
37
+ paddingBottom: 16,
38
+ paddingHorizontal: 16,
39
+ },
40
+ paddingLeft16: {
41
+ paddingLeft: 16,
42
+ },
43
+ avatar: {
44
+ height: 40,
45
+ width: 40,
46
+ borderRadius: 40,
47
+ backgroundColor: Colors.Primary,
48
+ },
49
+ titleName: {
50
+ fontSize: 16,
51
+ lineHeight: 24,
52
+ fontStyle: 'normal',
53
+ fontWeight: '400',
54
+ },
55
+ status: {
56
+ fontSize: 12,
57
+ lineHeight: 20,
58
+ fontStyle: 'normal',
59
+ fontWeight: '400',
60
+ color: Colors.Gray7,
61
+ },
62
+ invalid: {
63
+ fontSize: 12,
64
+ lineHeight: 20,
65
+ fontStyle: 'normal',
66
+ fontWeight: '400',
67
+ color: Colors.Red,
68
+ },
69
+ endFlex: {
70
+ flex: 1,
71
+ justifyContent: 'flex-start',
72
+ alignItems: 'flex-end',
73
+ },
74
+ textRole: {
75
+ fontSize: 12,
76
+ lineHeight: 20,
77
+ },
78
+ });
@@ -0,0 +1,80 @@
1
+ import React, { useCallback, useState } from 'react';
2
+ import _TextInput from '../../../commons/Form/TextInput';
3
+ import styles from './Styles/indexStyles';
4
+ import AccessibilityLabel from '../../../configs/AccessibilityLabel';
5
+ import { Keyboard, TouchableWithoutFeedback, View } from 'react-native';
6
+ import BottomButtonView from '../../../commons/BottomButtonView';
7
+ import { useNavigation } from '@react-navigation/native';
8
+ import Routes from '../../../utils/Route';
9
+
10
+ const UpdateEmailScript = ({
11
+ automateId,
12
+ scriptItemId,
13
+ email_script,
14
+ t,
15
+ onClosePopup,
16
+ }) => {
17
+ const { navigate } = useNavigation();
18
+ const { title, message, unit_id, str_emails, receiver_ids } = email_script;
19
+ const [formData, setFormData] = useState({
20
+ newTitle: title,
21
+ newMessage: message,
22
+ unit_id,
23
+ str_emails,
24
+ receiver_ids,
25
+ });
26
+
27
+ const onPressNext = useCallback(async () => {
28
+ onClosePopup();
29
+ navigate(Routes.UpdateReceiverEmailScript, {
30
+ automateId,
31
+ scriptItemId,
32
+ formData,
33
+ });
34
+ }, [automateId, formData, navigate, onClosePopup, scriptItemId]);
35
+
36
+ const onChangeTitle = (value) => {
37
+ setFormData((prev) => ({ ...prev, newTitle: value }));
38
+ };
39
+
40
+ const onChangeMessage = (value) => {
41
+ setFormData((prev) => ({ ...prev, newMessage: value }));
42
+ };
43
+
44
+ return (
45
+ <TouchableWithoutFeedback onPress={Keyboard.dismiss} accessible={false}>
46
+ <View>
47
+ <_TextInput
48
+ label={t('update_title_email')}
49
+ placeholder={t('title_notification')}
50
+ onChange={onChangeTitle}
51
+ textInputStyle={styles.textTitle}
52
+ value={formData.newTitle}
53
+ accessibilityLabel={AccessibilityLabel.AUTOMATE_TITLE_NOTIFY}
54
+ autoFocus
55
+ />
56
+ <_TextInput
57
+ label={t('update_message_email')}
58
+ placeholder={t('message_notification')}
59
+ onChange={onChangeMessage}
60
+ textInputStyle={styles.textMessage}
61
+ value={formData.newMessage}
62
+ accessibilityLabel={AccessibilityLabel.AUTOMATE_MESSAGE_NOTIFY}
63
+ multiline={true}
64
+ maxLength={255}
65
+ />
66
+ <View style={styles.wrapBottom}>
67
+ <BottomButtonView
68
+ mainTitle={t('next')}
69
+ onPressMain={onPressNext}
70
+ typeMain={'primary'}
71
+ accessibilityLabel={AccessibilityLabel.BUTTON_SAVE_EDIT_ACTION_LIST}
72
+ disableKeyBoardAnimated
73
+ />
74
+ </View>
75
+ </View>
76
+ </TouchableWithoutFeedback>
77
+ );
78
+ };
79
+
80
+ export default UpdateEmailScript;
@@ -0,0 +1,179 @@
1
+ import React, { useCallback, useMemo, useState, useEffect, memo } from 'react';
2
+ import { FlatList, View } from 'react-native';
3
+ import { useNavigation } from '@react-navigation/native';
4
+ import styles from './Styles/UpdateReceiverEmailScriptStyles.js';
5
+ import { CircleView, HeaderCustom, Text } from '../../../commons';
6
+ import { useTranslations } from '../../../hooks/Common/useTranslations';
7
+
8
+ import BottomButtonView from '../../../commons/BottomButtonView';
9
+ import { axiosPut, axiosGet } from '../../../utils/Apis/axios';
10
+ import { API, Colors } from '../../../configs';
11
+ import { ToastBottomHelper } from '../../../utils/Utils';
12
+ import Routes from '../../../utils/Route';
13
+ import moment from 'moment';
14
+ import { Image } from 'react-native-svg';
15
+ import CheckBox from '@react-native-community/checkbox';
16
+ import { useSCContextSelector } from '../../../context';
17
+
18
+ const UpdateReceiverEmailScript = ({ route }) => {
19
+ const t = useTranslations();
20
+ const { goBack, navigate } = useNavigation();
21
+ const { automateId, scriptItemId, formData } = route.params;
22
+ const [members, setMembers] = useState([]);
23
+ const [listUser, setListUser] = useState(formData.receiver_ids);
24
+ const currentUserId = useSCContextSelector(
25
+ (state) => state.auth.account.user.id
26
+ );
27
+
28
+ const loadMembers = useCallback(async () => {
29
+ const { success, data } = await axiosGet(
30
+ API.SHARE.UNITS_MEMBERS(formData.unit_id)
31
+ );
32
+ if (success) {
33
+ setMembers(data);
34
+ }
35
+ }, [formData.unit_id]);
36
+
37
+ useEffect(() => {
38
+ loadMembers();
39
+ }, [loadMembers]);
40
+
41
+ const onNext = useCallback(async () => {
42
+ const { success } = await axiosPut(
43
+ API.AUTOMATE.UPDATE_SCRIPT_EMAIL(automateId),
44
+ {
45
+ id: scriptItemId,
46
+ unit: formData.unit_id,
47
+ title: formData.newTitle,
48
+ message: formData.newMessage,
49
+ receiver: listUser,
50
+ }
51
+ );
52
+ if (success) {
53
+ ToastBottomHelper.success(t('update_successfully'));
54
+ navigate({
55
+ name: Routes.ScriptDetail,
56
+ merge: true,
57
+ params: { saveAt: moment().valueOf() },
58
+ });
59
+ }
60
+ }, [
61
+ automateId,
62
+ formData.newMessage,
63
+ formData.newTitle,
64
+ formData.unit_id,
65
+ listUser,
66
+ navigate,
67
+ scriptItemId,
68
+ t,
69
+ ]);
70
+
71
+ const canSave = useMemo(() => {
72
+ const { newTitle, newMessage } = formData;
73
+ return !!newTitle && !!newMessage && !!listUser.length;
74
+ }, [formData, listUser.length]);
75
+
76
+ const arrColor = useMemo(
77
+ () => [
78
+ Colors.GeekBlue3,
79
+ Colors.Purple3,
80
+ Colors.Orange3,
81
+ Colors.Volcano3,
82
+ Colors.Blue9,
83
+ Colors.Green3,
84
+ Colors.Cyan2,
85
+ ],
86
+ []
87
+ );
88
+
89
+ const onChecked = useCallback(
90
+ (id) => (checked) => {
91
+ setListUser((prevListUser) =>
92
+ checked
93
+ ? [...prevListUser, id]
94
+ : prevListUser.filter((userId) => userId !== id)
95
+ );
96
+ },
97
+ []
98
+ );
99
+
100
+ const RowMember = memo(({ member, index, onValueChange }) => {
101
+ const { id, name, avatar, share_id, email } = member;
102
+ const [role, roleColor] = useMemo(() => {
103
+ if (!share_id) {
104
+ return [t('owner'), Colors.Primary];
105
+ }
106
+ if (id === currentUserId) {
107
+ return [t('me'), Colors.Primary];
108
+ }
109
+ return [t('member'), Colors.Gray6];
110
+ }, [share_id, id]);
111
+
112
+ const firstWordsInName = useMemo(() => {
113
+ return name.charAt();
114
+ }, [name]);
115
+
116
+ const circleColor = arrColor[index % arrColor.length];
117
+
118
+ return (
119
+ <View style={styles.rowContainer}>
120
+ <View style={styles.border}>
121
+ <CheckBox
122
+ disabled={!email}
123
+ lineWidth={4}
124
+ value={listUser.includes(id)}
125
+ onValueChange={onValueChange(id)}
126
+ />
127
+ <View style={styles.paddingLeft16}>
128
+ {avatar ? (
129
+ <Image source={{ uri: avatar }} style={styles.avatar} />
130
+ ) : (
131
+ <CircleView size={40} backgroundColor={circleColor} center>
132
+ <Text color={Colors.White}>{firstWordsInName}</Text>
133
+ </CircleView>
134
+ )}
135
+ </View>
136
+ <View style={styles.paddingLeft16}>
137
+ <Text style={styles.titleName}>{name}</Text>
138
+ {email ? (
139
+ <Text style={styles.status}>{email}</Text>
140
+ ) : (
141
+ <Text style={styles.invalid}>{t('no_email')}</Text>
142
+ )}
143
+ </View>
144
+ <View style={styles.endFlex}>
145
+ <Text style={[styles.textRole, { color: roleColor }]}>{role}</Text>
146
+ </View>
147
+ </View>
148
+ </View>
149
+ );
150
+ });
151
+
152
+ return (
153
+ <View style={styles.wrap}>
154
+ <HeaderCustom isShowClose onClose={goBack} title={t('email_to')} />
155
+ <FlatList
156
+ data={members}
157
+ renderItem={({ item, index }) => (
158
+ <RowMember member={item} index={index} onValueChange={onChecked} />
159
+ )}
160
+ keyExtractor={(item) => item.id.toString()}
161
+ ListEmptyComponent={
162
+ <View style={styles.viewEmpty}>
163
+ <Text style={styles.textCenter}>{t('no_member')}</Text>
164
+ </View>
165
+ }
166
+ />
167
+ <View style={styles.container}>
168
+ <BottomButtonView
169
+ style={styles.bottomButtonView}
170
+ mainTitle={t('done')}
171
+ onPressMain={onNext}
172
+ typeMain={canSave ? 'primary' : 'disabled'}
173
+ />
174
+ </View>
175
+ </View>
176
+ );
177
+ };
178
+
179
+ export default UpdateReceiverEmailScript;
@@ -0,0 +1,81 @@
1
+ import MockAdapter from 'axios-mock-adapter';
2
+ import React from 'react';
3
+ import renderer, { act } from 'react-test-renderer';
4
+
5
+ import API from '../../../../configs/API';
6
+ import { AccessibilityLabel } from '../../../../configs/Constants';
7
+ import { SCProvider } from '../../../../context';
8
+ import { mockSCStore } from '../../../../context/mockStore';
9
+
10
+ import BottomButtonView from '../../../../commons/BottomButtonView';
11
+ import _TextInput from '../../../../commons/Form/TextInput';
12
+ import api from '../../../../utils/Apis/axios';
13
+ import UpdateEmailScript from '../UpdateEmailScript';
14
+ import Routes from '../../../../utils/Route';
15
+
16
+ const mock = new MockAdapter(api.axiosInstance);
17
+ const mockerOnClosePopup = jest.fn();
18
+
19
+ const wrapComponent = () => (
20
+ <SCProvider initState={mockSCStore({})}>
21
+ <UpdateEmailScript
22
+ automateId={1}
23
+ scriptItemId={1}
24
+ email_script={{
25
+ title: 'title',
26
+ message: 'Contend',
27
+ unit_id: 60,
28
+ str_emails: 'email0@eoh.io',
29
+ }}
30
+ t={jest.fn()}
31
+ onClosePopup={mockerOnClosePopup}
32
+ />
33
+ </SCProvider>
34
+ );
35
+
36
+ describe('Test UpdateEmailScript', () => {
37
+ let tree;
38
+
39
+ it('test update title and message', async () => {
40
+ mock.onPut(API.AUTOMATE.UPDATE_SCRIPT_EMAIL(1)).reply(200);
41
+ await act(async () => {
42
+ tree = await renderer.create(wrapComponent());
43
+ });
44
+ const instance = tree.root;
45
+ const title = instance.find(
46
+ (el) =>
47
+ el.props.accessibilityLabel ===
48
+ AccessibilityLabel.AUTOMATE_TITLE_NOTIFY && el.type === _TextInput
49
+ );
50
+ await act(async () => {
51
+ title.props.onChange('1');
52
+ });
53
+
54
+ const message = instance.find(
55
+ (el) =>
56
+ el.props.accessibilityLabel ===
57
+ AccessibilityLabel.AUTOMATE_MESSAGE_NOTIFY && el.type === _TextInput
58
+ );
59
+ await act(async () => {
60
+ message.props.onChange('2');
61
+ });
62
+ const button = instance.findByType(BottomButtonView);
63
+ expect(button.props.typeMain).toEqual('primary');
64
+ await act(async () => {
65
+ button.props.onPressMain();
66
+ });
67
+ expect(global.mockedNavigate).toHaveBeenCalledWith(
68
+ Routes.UpdateReceiverEmailScript,
69
+ {
70
+ automateId: 1,
71
+ formData: {
72
+ newMessage: '2',
73
+ newTitle: '1',
74
+ str_emails: 'email0@eoh.io',
75
+ unit_id: 60,
76
+ },
77
+ scriptItemId: 1,
78
+ }
79
+ );
80
+ });
81
+ });
@@ -0,0 +1,83 @@
1
+ import MockAdapter from 'axios-mock-adapter';
2
+ import React from 'react';
3
+ import renderer, { act } from 'react-test-renderer';
4
+
5
+ import API from '../../../../configs/API';
6
+ import { SCProvider } from '../../../../context';
7
+ import { mockSCStore } from '../../../../context/mockStore';
8
+
9
+ import BottomButtonView from '../../../../commons/BottomButtonView';
10
+ import api from '../../../../utils/Apis/axios';
11
+ import Routes from '../../../../utils/Route';
12
+ import UpdateReceiverEmailScript from '../UpdateReceiverEmailScript';
13
+ import CheckBox from '@react-native-community/checkbox';
14
+ import { ToastBottomHelper } from '../../../../utils/Utils';
15
+
16
+ const mock = new MockAdapter(api.axiosInstance);
17
+
18
+ const listUser = [
19
+ {
20
+ avatar: 'https://xxx',
21
+ email: 'user1.nh@eoh.io',
22
+ id: 140,
23
+ name: 'User 1',
24
+ },
25
+ {
26
+ avatar: null,
27
+ email: null,
28
+ id: 56,
29
+ name: 'User 2',
30
+ share_id: 5386,
31
+ },
32
+ ];
33
+ const wrapComponent = () => (
34
+ <SCProvider initState={mockSCStore({})}>
35
+ <UpdateReceiverEmailScript
36
+ route={{
37
+ params: {
38
+ automateId: 1,
39
+ scriptItemId: 1,
40
+ automate: {
41
+ id: 1,
42
+ sensor_id: 1,
43
+ },
44
+ closeScreen: Routes.ScriptDetail,
45
+ formData: {
46
+ title: 'title',
47
+ message: 'Contend',
48
+ unit_id: 1,
49
+ str_emails: 'email0@eoh.io',
50
+ receiver_ids: [],
51
+ },
52
+ },
53
+ }}
54
+ />
55
+ </SCProvider>
56
+ );
57
+
58
+ describe('Test UpdateReceiverEmailScript', () => {
59
+ let tree;
60
+
61
+ it('test update title and message', async () => {
62
+ const spyToast = jest.spyOn(ToastBottomHelper, 'success');
63
+ mock.onGet(API.SHARE.UNITS_MEMBERS(1)).reply(200, listUser);
64
+ mock.onPut(API.AUTOMATE.UPDATE_SCRIPT_EMAIL(1)).reply(200);
65
+ await act(async () => {
66
+ tree = await renderer.create(wrapComponent());
67
+ });
68
+ const instance = tree.root;
69
+ const checkboxs = instance.findAllByType(CheckBox);
70
+ expect(checkboxs).toHaveLength(2);
71
+ expect(checkboxs[0].props.disabled).toBeFalsy();
72
+ expect(checkboxs[1].props.disabled).toBeTruthy();
73
+ await act(async () => {
74
+ checkboxs[0].props.onValueChange(true);
75
+ });
76
+
77
+ const button = instance.findByType(BottomButtonView);
78
+ await act(async () => {
79
+ button.props.onPressMain();
80
+ });
81
+ expect(spyToast).toHaveBeenCalled();
82
+ });
83
+ });
@@ -16,6 +16,7 @@ import { HeaderCustom } from '../../../../commons';
16
16
  import Routes from '../../../../utils/Route';
17
17
  import UpdateNotifyScript from '../UpdateNotifyScript';
18
18
  import UpdateDelayScript from '../UpdateDelayScript';
19
+ import UpdateEmailScript from '../UpdateEmailScript';
19
20
 
20
21
  const wrapComponent = () => (
21
22
  <SCProvider initState={mockSCStore({})}>
@@ -56,6 +57,18 @@ describe('EditActionsList', () => {
56
57
  delay_script: { delay: 10 },
57
58
  order: 3,
58
59
  },
60
+ {
61
+ id: 4,
62
+ action_script: null,
63
+ notify_script: null,
64
+ email_script: {
65
+ title: 'title',
66
+ message: 'message',
67
+ unit_id: 60,
68
+ str_emails: 'email0@eoh.io',
69
+ },
70
+ order: 4,
71
+ },
59
72
  ];
60
73
 
61
74
  beforeEach(() => {
@@ -112,11 +125,12 @@ describe('EditActionsList', () => {
112
125
  AccessibilityLabel.BUTTON_REMOVE_EDIT_ACTION_LIST &&
113
126
  el.type === TouchableOpacity
114
127
  );
115
- expect(buttonRemoves).toHaveLength(3);
128
+ expect(buttonRemoves).toHaveLength(4);
116
129
  await act(async () => {
117
130
  buttonRemoves[0].props.onPress(); // remove script action
118
131
  buttonRemoves[1].props.onPress(); // remove script notify
119
132
  buttonRemoves[2].props.onPress(); // remove script delay
133
+ buttonRemoves[3].props.onPress(); // remove script email
120
134
  });
121
135
  const modalBottom = instance.findByType(ModalBottom);
122
136
  expect(modalBottom.props.isVisible).toBeTruthy();
@@ -139,7 +153,7 @@ describe('EditActionsList', () => {
139
153
  el.props.accessibilityLabel === AccessibilityLabel.BUTTON_UPDATE &&
140
154
  el.type === TouchableOpacity
141
155
  );
142
- expect(scriptItem).toHaveLength(3);
156
+ expect(scriptItem).toHaveLength(4);
143
157
  await act(async () => {
144
158
  scriptItem[0].props.onLongPress();
145
159
  });
@@ -160,7 +174,7 @@ describe('EditActionsList', () => {
160
174
  device: {
161
175
  id: 1,
162
176
  },
163
- numberActionAdded: 3,
177
+ numberActionAdded: 4,
164
178
  scriptItemId: 1,
165
179
  unitId: undefined,
166
180
  }
@@ -177,7 +191,7 @@ describe('EditActionsList', () => {
177
191
  el.props.accessibilityLabel === AccessibilityLabel.BUTTON_UPDATE &&
178
192
  el.type === TouchableOpacity
179
193
  );
180
- expect(scriptItem).toHaveLength(3);
194
+ expect(scriptItem).toHaveLength(4);
181
195
  await act(async () => {
182
196
  scriptItem[1].props.onLongPress();
183
197
  });
@@ -196,7 +210,7 @@ describe('EditActionsList', () => {
196
210
  el.props.accessibilityLabel === AccessibilityLabel.BUTTON_UPDATE &&
197
211
  el.type === TouchableOpacity
198
212
  );
199
- expect(scriptItem).toHaveLength(3);
213
+ expect(scriptItem).toHaveLength(4);
200
214
  await act(async () => {
201
215
  scriptItem[2].props.onLongPress();
202
216
  });
@@ -204,4 +218,23 @@ describe('EditActionsList', () => {
204
218
  const popUp = instance.findAllByType(UpdateDelayScript);
205
219
  expect(popUp).toHaveLength(1);
206
220
  });
221
+
222
+ it('EditActionsList update script email', async () => {
223
+ await act(async () => {
224
+ tree = await create(wrapComponent());
225
+ });
226
+ const instance = tree.root;
227
+ const scriptItem = instance.findAll(
228
+ (el) =>
229
+ el.props.accessibilityLabel === AccessibilityLabel.BUTTON_UPDATE &&
230
+ el.type === TouchableOpacity
231
+ );
232
+ expect(scriptItem).toHaveLength(4);
233
+ await act(async () => {
234
+ scriptItem[3].props.onLongPress();
235
+ });
236
+
237
+ const popUp = instance.findAllByType(UpdateEmailScript);
238
+ expect(popUp).toHaveLength(1);
239
+ });
207
240
  });