@eohjsc/react-native-smart-city 0.4.47 → 0.4.49

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 (75) hide show
  1. package/README.md +1 -5
  2. package/android/build.gradle +24 -19
  3. package/package.json +12 -15
  4. package/src/commons/ActionGroup/__test__/ColorPickerTemplate.test.js +3 -6
  5. package/src/commons/ActionGroup/__test__/TwoButtonTemplate.test.js +11 -1
  6. package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +5 -0
  7. package/src/commons/Dashboard/MyPinnedSharedUnit/index.js +6 -1
  8. package/src/commons/DateTimeRangeChange/index.js +3 -3
  9. package/src/commons/Device/Hanet/ItemHanetDevice.js +1 -5
  10. package/src/commons/Device/HorizontalBarChart.js +3 -0
  11. package/src/commons/Device/ItemAddNew/index.js +2 -6
  12. package/src/commons/Device/ItemDevice.js +1 -5
  13. package/src/commons/FlatListDnD/__test__/index.test.js +25 -27
  14. package/src/commons/GroupCheckBox/__test__/GroupCheckBox.test.js +22 -1
  15. package/src/commons/HeaderAni/index.js +2 -12
  16. package/src/commons/MediaPlayerDetail/__test__/MediaPlayerFull.test.js +23 -1
  17. package/src/commons/SubUnit/OneTap/ItemOneTap.js +2 -10
  18. package/src/commons/Unit/HeaderUnit/index.js +7 -18
  19. package/src/commons/Unit/SharedUnit.js +43 -58
  20. package/src/commons/Unit/__test__/SharedUnit.test.js +100 -60
  21. package/src/commons/UnitSummary/ConfigHistoryChart/__test__/ConfigHistoryChart.test.js +289 -0
  22. package/src/commons/UnitSummary/ConfigHistoryChart/index.js +59 -1
  23. package/src/commons/WrapParallaxScrollView/index.js +0 -4
  24. package/src/configs/API.js +1 -0
  25. package/src/configs/AccessibilityLabel.js +0 -3
  26. package/src/hooks/IoT/__test__/useRemoteControl.test.js +51 -52
  27. package/src/hooks/IoT/__test__/useWatchConfigs.test.js +2 -3
  28. package/src/navigations/AutomateStack.js +2 -5
  29. package/src/navigations/NotificationStack.js +2 -28
  30. package/src/navigations/SharedStack.js +2 -8
  31. package/src/navigations/UnitStack.js +2 -2
  32. package/src/screens/AddNewGateway/ConnectingWifiDevice.js +5 -4
  33. package/src/screens/AddNewGateway/ConnectingWifiGuide.js +47 -12
  34. package/src/screens/AddNewGateway/RenameNewDevices.js +126 -10
  35. package/src/screens/AddNewGateway/RenameNewDevicesStyles.js +26 -5
  36. package/src/screens/AddNewGateway/ShareWifiPassword.js +39 -7
  37. package/src/screens/AddNewGateway/__test__/ConnectingWifiDevice.test.js +36 -7
  38. package/src/screens/AddNewGateway/__test__/ConnectingWifiGuide.test.js +41 -32
  39. package/src/screens/AddNewGateway/__test__/RenameNewDevices.test.js +106 -2
  40. package/src/screens/AddNewGateway/__test__/ShareWifiPassword.test.js +35 -2
  41. package/src/screens/AllGateway/DeviceModbusDetail/__test__/index.test.js +32 -31
  42. package/src/screens/Automate/EditActionsList/__tests__/index.test.js +68 -69
  43. package/src/screens/Automate/ScriptDetail/Styles/indexStyles.js +0 -1
  44. package/src/screens/Automate/ScriptDetail/index.js +7 -4
  45. package/src/screens/ChangePosition/__test__/index.test.js +32 -34
  46. package/src/screens/ConfirmUnitDeletion/__test__/ConfirmUnitDeletion.test.js +11 -1
  47. package/src/screens/Device/__test__/detail.test.js +3 -3
  48. package/src/screens/Device/components/ChartWrapper.js +12 -14
  49. package/src/screens/Device/components/VisualChart.js +1 -7
  50. package/src/screens/Device/components/__test__/VisualChart.test.js +3 -0
  51. package/src/screens/Device/detail.js +7 -12
  52. package/src/screens/Device/hooks/__test__/useEvaluateValue.test.js +18 -20
  53. package/src/screens/Device/styles.js +0 -3
  54. package/src/screens/Notification/__test__/Notification.test.js +8 -14
  55. package/src/screens/Notification/components/NotificationItem.js +0 -1
  56. package/src/screens/Notification/index.js +48 -42
  57. package/src/screens/Notification/styles/indexStyles.js +3 -6
  58. package/src/screens/SharedUnit/index.js +4 -1
  59. package/src/screens/Sharing/Components/CheckBoxCustom.js +14 -2
  60. package/src/screens/Sharing/MemberList.js +3 -16
  61. package/src/screens/Sharing/__test__/SelectPermission.test.js +137 -96
  62. package/src/screens/SmartAccount/Connecting/index.js +0 -1
  63. package/src/screens/SmartAccount/__test__/Connecting.test.js +92 -0
  64. package/src/screens/Template/__test__/EditTemplate.test.js +1 -7
  65. package/src/screens/Unit/__test__/SelectAddress.test.js +11 -4
  66. package/src/screens/Unit/components/SharedUnit/index.js +9 -6
  67. package/src/screens/Unit/components/__test__/SharedUnit.test.js +15 -19
  68. package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js +11 -1
  69. package/src/utils/I18n/translations/en.js +19 -5
  70. package/src/utils/I18n/translations/vi.js +19 -5
  71. package/src/utils/Monitor.js +2 -2
  72. package/src/Images/Common/pushpin-full.svg +0 -3
  73. package/src/Images/Common/pushpin-outline.svg +0 -3
  74. package/src/Images/Common/star-full.svg +0 -3
  75. package/src/Images/Common/star-outline.svg +0 -3
@@ -1,6 +1,5 @@
1
1
  import React from 'react';
2
2
  import renderer, { act } from 'react-test-renderer';
3
- import Toast from 'react-native-toast-message';
4
3
  import { Platform, TouchableOpacity, Alert } from 'react-native';
5
4
  import WifiManager from 'react-native-wifi-reborn';
6
5
  import dgram from 'react-native-udp';
@@ -13,7 +12,7 @@ import AccessibilityLabel from '../../../configs/AccessibilityLabel';
13
12
 
14
13
  const mockedGoBack = jest.fn();
15
14
  const mockedNavigate = jest.fn();
16
- const mockedRetry = jest.fn();
15
+ jest.spyOn(Alert, 'alert').mockImplementation(() => {});
17
16
  jest.mock('@react-navigation/native', () => {
18
17
  return {
19
18
  ...jest.requireActual('@react-navigation/native'),
@@ -53,6 +52,7 @@ describe('test share wifi password', () => {
53
52
  socket.bind.mockClear();
54
53
  socket.send.mockClear();
55
54
  socket.close.mockClear();
55
+ Alert.alert.mockReset();
56
56
  });
57
57
 
58
58
  it('render connect wifi guide', async () => {
@@ -123,7 +123,6 @@ describe('test share wifi password', () => {
123
123
  });
124
124
 
125
125
  it('fail connect to wifi android show alert push cancel', async () => {
126
- jest.spyOn(Alert, 'alert');
127
126
  Platform.OS = 'android';
128
127
  const route = { params: routeParams };
129
128
  WifiManager.reScanAndLoadWifiList.mockImplementationOnce(async () => [
@@ -138,9 +137,11 @@ describe('test share wifi password', () => {
138
137
  tree = await renderer.create(wrapComponent(route));
139
138
  });
140
139
  await ConnectWifiActionButton(tree.root);
141
- expect(Alert.alert.mock.calls[0][0]).toEqual("Cannot find Device's Wifi");
140
+ expect(Alert.alert.mock.calls[0][0]).toEqual(
141
+ 'The devices wifi "eoh.robot." could not be found'
142
+ );
142
143
  expect(Alert.alert.mock.calls[0][1]).toEqual(
143
- 'Try to turn on device or Try again'
144
+ 'Try to turn on device or try again'
144
145
  );
145
146
  await act(async () => {
146
147
  Alert.alert.mock.calls[0][2][0].onPress();
@@ -149,16 +150,6 @@ describe('test share wifi password', () => {
149
150
  });
150
151
 
151
152
  it('fail connect to wifi android show error push retry', async () => {
152
- jest.spyOn(Alert, 'alert');
153
- Alert.alert(
154
- "Cannot find Device's Wifi",
155
- 'Try to turn on device or Try again',
156
- [
157
- { text: 'Cancel', onPress: mockedGoBack },
158
- { text: 'Retry', onPress: mockedRetry },
159
- ]
160
- );
161
-
162
153
  Platform.OS = 'android';
163
154
  const route = { params: routeParams };
164
155
  WifiManager.reScanAndLoadWifiList.mockImplementationOnce(async () => [
@@ -173,14 +164,23 @@ describe('test share wifi password', () => {
173
164
  tree = await renderer.create(wrapComponent(route));
174
165
  });
175
166
  await ConnectWifiActionButton(tree.root);
176
- expect(Alert.alert.mock.calls[1][0]).toEqual("Cannot find Device's Wifi");
177
- expect(Alert.alert.mock.calls[1][1]).toEqual(
178
- 'Try to turn on device or Try again'
167
+ expect(Alert.alert.mock.calls).toHaveLength(1);
168
+ expect(Alert.alert.mock.calls[0][0]).toEqual(
169
+ 'The devices wifi "eoh.robot." could not be found'
170
+ );
171
+ expect(Alert.alert.mock.calls[0][1]).toEqual(
172
+ 'Try to turn on device or try again'
179
173
  );
180
174
  await act(async () => {
181
- Alert.alert.mock.calls[1][2][1].onPress();
175
+ Alert.alert.mock.calls[0][2][1].onPress();
182
176
  });
183
- expect(mockedRetry).toBeCalledTimes(1);
177
+ expect(Alert.alert.mock.calls).toHaveLength(2);
178
+ expect(Alert.alert.mock.calls[1][0]).toEqual(
179
+ "Cannot connect to device's wifi eoh.robot.xxx"
180
+ );
181
+ expect(Alert.alert.mock.calls[1][1]).toEqual(
182
+ 'Try to turn on device or try again'
183
+ );
184
184
  });
185
185
 
186
186
  it('fail load wifi list android', async () => {
@@ -244,17 +244,23 @@ describe('test share wifi password', () => {
244
244
  });
245
245
  // todo Bang should test wifi display
246
246
  expect(socket.close).toBeCalled();
247
-
248
- expect(mockedNavigate).toBeCalledWith('ShareWifiPassword', {
249
- unit: {
250
- id: 1,
251
- },
252
- subUnit: {
253
- id: 1,
254
- },
255
- wifiList: [{ ssid: 'wifi 1' }, { ssid: 'wifi.2' }],
256
- qrData: { org_slug: 'eoh', prefix: 'robot' },
257
- });
247
+ expect(mockedNavigate).toBeCalledWith(
248
+ 'ShareWifiPassword',
249
+ expect.objectContaining({
250
+ qrData: {
251
+ org_slug: 'eoh',
252
+ prefix: 'robot',
253
+ },
254
+ wifiList: [
255
+ {
256
+ ssid: 'wifi 1',
257
+ },
258
+ {
259
+ ssid: 'wifi.2',
260
+ },
261
+ ],
262
+ })
263
+ );
258
264
 
259
265
  // expect(mockedNavigate.mock.calls[0][0]).toEqual(Routes.ShareWifiPassword);
260
266
  });
@@ -274,6 +280,9 @@ describe('test share wifi password', () => {
274
280
  await act(async () => {
275
281
  socket.on.mock.calls[1][1]();
276
282
  });
277
- expect(Toast.show).toBeCalled();
283
+
284
+ expect(Alert.alert.mock.calls[0][0]).toEqual(
285
+ 'Fail trigger scan wifi on device undefined'
286
+ );
278
287
  });
279
288
  });
@@ -11,6 +11,7 @@ import AccessibilityLabel from '../../../configs/AccessibilityLabel';
11
11
  import Text from '../../../commons/Text';
12
12
  import _TextInput from '../../../commons/Form/TextInput';
13
13
  import API from '../../../configs/API';
14
+ import { CheckBoxCustom } from '../../Sharing/Components';
14
15
 
15
16
  const wrapComponent = (route) => (
16
17
  <SCProvider initState={mockSCStore({})}>
@@ -336,7 +337,7 @@ describe('Test rename new devices', () => {
336
337
  );
337
338
  });
338
339
 
339
- it('update end device name', async () => {
340
+ it('update end device name and select end device', async () => {
340
341
  mock.onGet().reply(200, {
341
342
  id: 1,
342
343
  can_rename: true,
@@ -345,6 +346,14 @@ describe('Test rename new devices', () => {
345
346
  id: 1,
346
347
  name: 'sensor',
347
348
  end_devices: [
349
+ {
350
+ id: 3,
351
+ name: 'end_device 3',
352
+ },
353
+ {
354
+ id: 2,
355
+ name: 'end_device 2',
356
+ },
348
357
  {
349
358
  id: 1,
350
359
  name: 'end_device',
@@ -365,22 +374,29 @@ describe('Test rename new devices', () => {
365
374
  `${AccessibilityLabel.CONNECTED_DEVICE_RENAME_DEVICE}-end_device-1` &&
366
375
  el.type === _TextInput
367
376
  );
377
+ const checkBoxCustom = instance.findAllByType(CheckBoxCustom);
378
+
368
379
  await act(async () => {
369
380
  chipNameField.props.onChange('new name');
370
381
  });
371
382
 
383
+ await act(async () => {
384
+ checkBoxCustom[1].props.onPress();
385
+ });
386
+
372
387
  const doneButton = instance.find(
373
388
  (el) =>
374
389
  el.props.accessibilityLabel === AccessibilityLabel.BUTTON_DONE &&
375
390
  el.type === TouchableOpacity
376
391
  );
377
392
  mock.onPost(API.CHIP.RENAME_DEVICES(1)).reply(200);
393
+ mock.onPost(API.DEVICE.DELETE_END_DEVICES()).reply(200);
378
394
 
379
395
  await act(async () => {
380
396
  doneButton.props.onPress();
381
397
  });
382
398
 
383
- expect(mock.history.post).toHaveLength(1);
399
+ expect(mock.history.post).toHaveLength(2);
384
400
  expect(mock.history.post[0].data).toEqual(
385
401
  JSON.stringify({
386
402
  id: 1,
@@ -390,6 +406,10 @@ describe('Test rename new devices', () => {
390
406
  id: 1,
391
407
  name: 'sensor',
392
408
  end_devices: [
409
+ {
410
+ id: 2,
411
+ name: 'end_device 2',
412
+ },
393
413
  {
394
414
  id: 1,
395
415
  name: 'new name',
@@ -438,4 +458,88 @@ describe('Test rename new devices', () => {
438
458
  expect(mock.history.post).toHaveLength(0);
439
459
  mockedDispatchNavigate();
440
460
  });
461
+
462
+ it('should handle onPress event for CheckBoxCustom select all', async () => {
463
+ mock.onGet().reply(200, {
464
+ id: 1,
465
+ can_rename: true,
466
+ sensors: [
467
+ {
468
+ id: 1,
469
+ name: 'sensor',
470
+ end_devices: [
471
+ {
472
+ id: 1,
473
+ name: 'end_device',
474
+ },
475
+ {
476
+ id: 2,
477
+ name: 'end_device 2',
478
+ },
479
+ ],
480
+ },
481
+ ],
482
+ });
483
+
484
+ await act(async () => {
485
+ tree = await create(wrapComponent(route));
486
+ });
487
+ const instance = tree.root;
488
+ const checkBoxCustom = instance.findAllByType(CheckBoxCustom);
489
+ expect(checkBoxCustom[0].props.isChecked).toEqual(true);
490
+
491
+ await act(async () => {
492
+ await checkBoxCustom[0].props.onPress();
493
+ });
494
+
495
+ expect(checkBoxCustom[0].props.isChecked).toEqual(false);
496
+
497
+ await act(async () => {
498
+ await checkBoxCustom[0].props.onPress();
499
+ });
500
+
501
+ expect(checkBoxCustom[0].props.isChecked).toEqual(true);
502
+ });
503
+
504
+ it('should handle onPress event for CheckBoxCustom detail', async () => {
505
+ mock.onGet().reply(200, {
506
+ id: 1,
507
+ can_rename: true,
508
+ sensors: [
509
+ {
510
+ id: 1,
511
+ name: 'sensor',
512
+ end_devices: [
513
+ {
514
+ id: 1,
515
+ name: 'end_device',
516
+ },
517
+ {
518
+ id: 2,
519
+ name: 'end_device 2',
520
+ },
521
+ ],
522
+ },
523
+ ],
524
+ });
525
+
526
+ await act(async () => {
527
+ tree = await create(wrapComponent(route));
528
+ });
529
+ const instance = tree.root;
530
+ const checkBoxCustom = instance.findAllByType(CheckBoxCustom);
531
+ expect(checkBoxCustom[1].props.isChecked).toEqual(true);
532
+
533
+ await act(async () => {
534
+ await checkBoxCustom[1].props.onPress();
535
+ });
536
+
537
+ expect(checkBoxCustom[1].props.isChecked).toEqual(false);
538
+
539
+ await act(async () => {
540
+ await checkBoxCustom[1].props.onPress();
541
+ });
542
+
543
+ expect(checkBoxCustom[1].props.isChecked).toEqual(true);
544
+ });
441
545
  });
@@ -1,9 +1,10 @@
1
1
  import React from 'react';
2
2
  import renderer, { act } from 'react-test-renderer';
3
- import { Platform, TouchableOpacity } from 'react-native';
3
+ import { Alert, Platform, TouchableOpacity } from 'react-native';
4
4
  import dgram from 'react-native-udp';
5
5
  import Toast from 'react-native-toast-message';
6
6
  import WifiManager from 'react-native-wifi-reborn';
7
+ import NetInfo from '@react-native-community/netinfo';
7
8
 
8
9
  import ShareWifiPassword from '../ShareWifiPassword';
9
10
  import { SCProvider } from '../../../context';
@@ -16,6 +17,10 @@ import { flushPromises } from '../../AllGateway/test-utils';
16
17
 
17
18
  const mockedGoBack = jest.fn();
18
19
  const mockedNavigate = jest.fn();
20
+ const mockedReconnectWifiSSID = jest.fn();
21
+ jest.spyOn(Alert, 'alert').mockImplementation(() => {});
22
+ jest.mock('@react-native-community/netinfo');
23
+
19
24
  jest.mock('@react-navigation/native', () => {
20
25
  return {
21
26
  ...jest.requireActual('@react-navigation/native'),
@@ -42,6 +47,8 @@ describe('test share wifi password', () => {
42
47
  socket.bind.mockClear();
43
48
  socket.send.mockClear();
44
49
  socket.close.mockClear();
50
+ Alert.alert.mockReset();
51
+ mockedNavigate.mockClear();
45
52
  });
46
53
 
47
54
  it('render share wifi', async () => {
@@ -115,7 +122,13 @@ describe('test share wifi password', () => {
115
122
  ) => {
116
123
  jest.useFakeTimers();
117
124
  Platform.OS = 'android';
118
- const route = { params: { prefix: 'robot' } };
125
+ const route = {
126
+ params: {
127
+ prefix: 'robot',
128
+ wifiDevice: 'eoh.era.xxx',
129
+ reconnectWifiSSID: mockedReconnectWifiSSID,
130
+ },
131
+ };
119
132
  await act(async () => {
120
133
  tree = await renderer.create(wrapComponent(route));
121
134
  });
@@ -141,6 +154,26 @@ describe('test share wifi password', () => {
141
154
  });
142
155
  };
143
156
 
157
+ it('enter wrong password to gateway and disconnect to wifi device', async () => {
158
+ await receiveGatewayInfo({
159
+ status: 'error',
160
+ });
161
+ expect(mockedReconnectWifiSSID).toBeCalled();
162
+ expect(Alert.alert.mock.calls).toHaveLength(1);
163
+ expect(Alert.alert.mock.calls[0][0]).toEqual('Cannot connect to wifi ""');
164
+
165
+ NetInfo.triggerEvent({ isConnected: true, isInternetReachable: true });
166
+ expect(Alert.alert.mock.calls).toHaveLength(2);
167
+ expect(Alert.alert.mock.calls[1][0]).toEqual(
168
+ 'The connection to the wifi device has been lost.'
169
+ );
170
+ await act(async () => {
171
+ Alert.alert.mock.calls[1][2][0].onPress();
172
+ });
173
+ expect(mockedNavigate).toBeCalled();
174
+ expect(mockedNavigate.mock.calls[0][0]).toEqual(Routes.ConnectingWifiGuide);
175
+ });
176
+
144
177
  it('close socket after gateway success connect to wifi', async () => {
145
178
  await receiveGatewayInfo();
146
179
  const socket = dgram.createSocket({});
@@ -17,7 +17,7 @@ import api from '../../../../utils/Apis/axios';
17
17
  import { API } from '../../../../configs';
18
18
  import { PERMISSION_TYPE } from '../../../../configs/Constants';
19
19
  import Detail from '../../components/Detail';
20
- // import ModalPopupCT from '../../../../commons/ModalPopupCT';
20
+ import ModalPopupCT from '../../../../commons/ModalPopupCT';
21
21
  import { fetchGatewayCT, flushPromises } from '../../test-utils';
22
22
 
23
23
  const mock = new MockAdapter(api.axiosInstance);
@@ -133,6 +133,8 @@ describe('Test DeviceModbusDetail', () => {
133
133
  const menuActionMore = detail?.findAllByType(MenuActionMore);
134
134
  expect(menuActionMore[0].props.isVisible).toEqual(true);
135
135
 
136
+ await flushPromises();
137
+
136
138
  await act(async () => {
137
139
  await menuActionMore[0].props.listMenuItem[0].doAction();
138
140
  });
@@ -143,39 +145,38 @@ describe('Test DeviceModbusDetail', () => {
143
145
  });
144
146
  });
145
147
 
146
- // NOTE: Hinh will fix it later
147
- // it('test render DeviceModbusDetail onPress more and onPress Delete modbus', async () => {
148
- // await act(async () => {
149
- // tree = await create(wrapComponent());
150
- // });
151
- // await flushPromises();
152
- // const instance = tree.root;
153
- // const detail = instance?.findByType(Detail);
154
- // await headerCustomOnPressMore(detail);
155
- // const menuActionMore = detail?.findByType(MenuActionMore);
156
- // expect(menuActionMore.props.isVisible).toEqual(true);
148
+ it('test render DeviceModbusDetail onPress more and onPress Delete modbus', async () => {
149
+ await act(async () => {
150
+ tree = await create(wrapComponent());
151
+ });
152
+ await flushPromises();
153
+ const instance = tree.root;
154
+ const detail = instance?.findByType(Detail);
155
+ await headerCustomOnPressMore(detail);
156
+ const menuActionMore = detail?.findByType(MenuActionMore);
157
+ expect(menuActionMore.props.isVisible).toEqual(true);
157
158
 
158
- // await act(async () => {
159
- // menuActionMore.props.listMenuItem[1].doAction();
160
- // });
161
- // await flushPromises();
159
+ await act(async () => {
160
+ menuActionMore.props.listMenuItem[1].doAction();
161
+ });
162
+ await flushPromises();
162
163
 
163
- // const modal = instance.findByType(ModalPopupCT);
164
- // mock.onDelete(API.DEV_MODE.ZIGBEE.DEVICE_DETAIL(1, 1)).reply(200);
165
- // await act(async () => {
166
- // await modal.props.onPressConfirm();
167
- // });
168
- // await flushPromises();
164
+ const modal = instance.findByType(ModalPopupCT);
165
+ mock.onDelete(API.DEV_MODE.ZIGBEE.DEVICE_DETAIL(1, 1)).reply(200);
166
+ await act(async () => {
167
+ await modal.props.onPressConfirm();
168
+ });
169
+ await flushPromises();
169
170
 
170
- // expect(mockPop).toBeCalledWith(1);
171
- // expect(Toast.show).toBeCalledWith({
172
- // position: 'bottom',
173
- // text1: 'Delete successfully!',
174
- // text2: undefined,
175
- // type: 'success',
176
- // visibilityTime: 1000,
177
- // });
178
- // });
171
+ expect(mockPop).toBeCalledWith(1);
172
+ expect(Toast.show).toBeCalledWith({
173
+ position: 'bottom',
174
+ text1: 'Delete successfully!',
175
+ text2: undefined,
176
+ type: 'success',
177
+ visibilityTime: 1000,
178
+ });
179
+ });
179
180
 
180
181
  it('test render DeviceZigbeeDetail onPress TabPanel config write', async () => {
181
182
  mock.onGet(API.DEV_MODE.MODBUS.REGISTER(1, 1)).reply(200, [
@@ -1,4 +1,3 @@
1
- /* eslint-disable no-unused-vars */
2
1
  import React from 'react';
3
2
  import DraggableFlatList from 'react-native-draggable-flatlist';
4
3
  import { create, act } from 'react-test-renderer';
@@ -38,78 +37,78 @@ describe('EditActionsList', () => {
38
37
  mockedNavigate.mockClear();
39
38
  });
40
39
  it('render EditActionsList', async () => {
41
- // await act(async () => {
42
- // tree = await create(wrapComponent());
43
- // });
44
- // const instance = tree.root;
45
- // const draggableFlatList = instance.findAllByType(DraggableFlatList);
46
- // const modalBottom = instance.findAllByType(ModalBottom);
47
- // expect(draggableFlatList).toHaveLength(1);
48
- // expect(modalBottom).toHaveLength(1);
40
+ await act(async () => {
41
+ tree = await create(wrapComponent());
42
+ });
43
+ const instance = tree.root;
44
+ const draggableFlatList = instance.findAllByType(DraggableFlatList);
45
+ const modalBottom = instance.findAllByType(ModalBottom);
46
+ expect(draggableFlatList).toHaveLength(1);
47
+ expect(modalBottom).toHaveLength(1);
48
+ });
49
+ it('EditActionsList onPress cancel', async () => {
50
+ await act(async () => {
51
+ tree = await create(wrapComponent());
52
+ });
53
+ const instance = tree.root;
54
+ const buttonCancel = instance.find(
55
+ (el) =>
56
+ el.props.accessibilityLabel ===
57
+ AccessibilityLabel.BUTTON_CANCEL_EDIT_ACTION_LIST &&
58
+ el.type === TouchableOpacity
59
+ );
60
+ expect(buttonCancel).toBeDefined();
61
+ await act(async () => {
62
+ buttonCancel.props.onPress();
63
+ });
64
+ expect(mockedNavigate).toHaveBeenCalled();
49
65
  });
50
- // it('EditActionsList onPress cancel', async () => {
51
- // await act(async () => {
52
- // tree = await create(wrapComponent());
53
- // });
54
- // const instance = tree.root;
55
- // const buttonCancel = instance.find(
56
- // (el) =>
57
- // el.props.accessibilityLabel ===
58
- // AccessibilityLabel.BUTTON_CANCEL_EDIT_ACTION_LIST &&
59
- // el.type === TouchableOpacity
60
- // );
61
- // expect(buttonCancel).toBeDefined();
62
- // await act(async () => {
63
- // buttonCancel.props.onPress();
64
- // });
65
- // expect(mockedNavigate).toHaveBeenCalled();
66
- // });
67
- // it('EditActionsList onPress save', async () => {
68
- // mock.onPut(API.AUTOMATE.ORDER_SCRIPT_ACTION(1)).reply(200);
69
- // await act(async () => {
70
- // tree = await create(wrapComponent());
71
- // });
72
- // const instance = tree.root;
73
- // const buttonSave = instance.find(
74
- // (el) =>
75
- // el.props.accessibilityLabel ===
76
- // AccessibilityLabel.BUTTON_SAVE_EDIT_ACTION_LIST &&
77
- // el.type === TouchableOpacity
78
- // );
79
- // expect(buttonSave).toBeDefined();
66
+ it('EditActionsList onPress save', async () => {
67
+ mock.onPut(API.AUTOMATE.ORDER_SCRIPT_ACTION(1)).reply(200);
68
+ await act(async () => {
69
+ tree = await create(wrapComponent());
70
+ });
71
+ const instance = tree.root;
72
+ const buttonSave = instance.find(
73
+ (el) =>
74
+ el.props.accessibilityLabel ===
75
+ AccessibilityLabel.BUTTON_SAVE_EDIT_ACTION_LIST &&
76
+ el.type === TouchableOpacity
77
+ );
78
+ expect(buttonSave).toBeDefined();
80
79
 
81
- // await act(async () => {
82
- // buttonSave.props.onPress();
83
- // });
80
+ await act(async () => {
81
+ buttonSave.props.onPress();
82
+ });
84
83
 
85
- // expect(mock.history.put).toHaveLength(1);
86
- // });
84
+ expect(mock.history.put).toHaveLength(1);
85
+ });
87
86
 
88
- // it('EditActionsList has remove button', async () => {
89
- // await act(async () => {
90
- // tree = await create(wrapComponent());
91
- // });
92
- // const instance = tree.root;
93
- // const buttonRemove = instance.find(
94
- // (el) =>
95
- // el.props.accessibilityLabel ===
96
- // AccessibilityLabel.BUTTON_REMOVE_EDIT_ACTION_LIST &&
97
- // el.type === TouchableOpacity
98
- // );
99
- // expect(buttonRemove).toBeDefined();
100
- // });
87
+ it('EditActionsList has remove button', async () => {
88
+ await act(async () => {
89
+ tree = await create(wrapComponent());
90
+ });
91
+ const instance = tree.root;
92
+ const buttonRemove = instance.find(
93
+ (el) =>
94
+ el.props.accessibilityLabel ===
95
+ AccessibilityLabel.BUTTON_REMOVE_EDIT_ACTION_LIST &&
96
+ el.type === TouchableOpacity
97
+ );
98
+ expect(buttonRemove).toBeDefined();
99
+ });
101
100
 
102
- // it('EditActionsList modal onPress remove', async () => {
103
- // await act(async () => {
104
- // tree = await create(wrapComponent());
105
- // });
106
- // const instance = tree.root;
107
- // const modalBottom = instance.findAllByType(ModalBottom);
108
- // await act(async () => {
109
- // modalBottom[0].props.onRemove();
110
- // });
101
+ it('EditActionsList modal onPress remove', async () => {
102
+ await act(async () => {
103
+ tree = await create(wrapComponent());
104
+ });
105
+ const instance = tree.root;
106
+ const modalBottom = instance.findAllByType(ModalBottom);
107
+ await act(async () => {
108
+ modalBottom[0].props.onRemove();
109
+ });
111
110
 
112
- // mock.onDelete(API.AUTOMATE.DELETE_SCRIPT_ACTION(1, 1)).reply(200);
113
- // expect(mock.history.delete).toHaveLength(1);
114
- // });
111
+ mock.onDelete(API.AUTOMATE.DELETE_SCRIPT_ACTION(1, 1)).reply(200);
112
+ expect(mock.history.delete).toHaveLength(1);
113
+ });
115
114
  });
@@ -63,7 +63,6 @@ export default StyleSheet.create({
63
63
  },
64
64
  moreButton: {
65
65
  marginLeft: -5,
66
- transform: [{ rotate: '90deg' }],
67
66
  },
68
67
  wrapStyle: {
69
68
  borderRadius: 8,
@@ -7,6 +7,7 @@ import React, {
7
7
  } from 'react';
8
8
  import { Image, Platform, TouchableOpacity, View } from 'react-native';
9
9
  import { PopoverMode } from 'react-native-popover-view';
10
+ import { IconFill, IconOutline } from '@ant-design/icons-react-native';
10
11
  import { Icon } from '@ant-design/react-native';
11
12
 
12
13
  import { useTranslations } from '../../../hooks/Common/useTranslations';
@@ -30,8 +31,6 @@ import RenameScript from './Components/RenameScript';
30
31
  import DeleteScript from './Components/DeleteScript';
31
32
  import Images from '../../../configs/Images';
32
33
  import { useBackendPermission } from '../../../utils/Permission/backend';
33
- import StarFull from '../../../Images/Common/star-full.svg';
34
- import StarOutline from '../../../Images/Common/star-outline.svg';
35
34
 
36
35
  const PreventDoubleTouch = withPreventDoubleClick(TouchableOpacity);
37
36
 
@@ -161,7 +160,7 @@ const ScriptDetail = ({ route }) => {
161
160
  style={[styles.headerButton, styles.moreButton]}
162
161
  accessibilityLabel={AccessibilityLabel.ICON_MORE}
163
162
  >
164
- <Icon name={'ellipsis'} size={27} color={Colors.Black} />
163
+ <Icon name={'more'} size={27} color={Colors.Black} />
165
164
  </TouchableOpacity>
166
165
  </View>
167
166
  ),
@@ -377,7 +376,11 @@ const ButtonStar = ({ automate }) => {
377
376
  onPress={onPressStar}
378
377
  accessibilityLabel={AccessibilityLabel.HEADER_SCRIPT_DETAIL_BUTTON_STAR}
379
378
  >
380
- {isStarred ? <StarFull /> : <StarOutline />}
379
+ {isStarred ? (
380
+ <IconFill name="star" size={25} color={Colors.Yellow6} />
381
+ ) : (
382
+ <IconOutline name="star" size={25} />
383
+ )}
381
384
  </PreventDoubleTouch>
382
385
  );
383
386
  };