@eohjsc/react-native-smart-city 0.3.31 → 0.3.34
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/AddNewDevice/add-gateway-icon.svg +13 -0
- package/assets/images/AddNewDevice/add-modbus-device-icon.svg +8 -0
- package/assets/images/AddNewDevice/add-wifi-device-icon.svg +4 -0
- package/assets/images/AddNewDevice/add-zigbee-device-icon.svg +4 -0
- package/assets/images/AddNewDevice/interact-smartphone-icon.svg +14 -0
- package/index.js +2 -0
- package/package.json +8 -5
- package/src/Images/SmartAccount/DienQuang.png +0 -0
- package/src/Images/SmartAccount/DienQuang@2x.png +0 -0
- package/src/Images/SmartAccount/DienQuang@3x.png +0 -0
- package/src/Images/SmartAccount/LG.png +0 -0
- package/src/Images/SmartAccount/LG@2x.png +0 -0
- package/src/Images/SmartAccount/LG@3x.png +0 -0
- package/src/Images/SmartAccount/Samsung.png +0 -0
- package/src/Images/SmartAccount/Samsung@2x.png +0 -0
- package/src/Images/SmartAccount/Samsung@3x.png +0 -0
- package/src/commons/Action/ItemQuickAction.js +20 -4
- package/src/commons/Action/__test__/ItemQuickAction.test.js +35 -11
- package/src/commons/ActionGroup/CurtainButtonTemplate.js +6 -6
- package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +9 -6
- package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/ButtonWrapper.js +5 -2
- package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/__test__/index.test.js +10 -4
- package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/index.js +4 -4
- package/src/commons/ActionGroup/OnOffSmartLock/OnOffSmartLock.js +2 -2
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/ItemPasscode.js +1 -1
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/__test__/index.test.js +2 -2
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/index.js +2 -2
- package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/ButtonWrapper.js +2 -2
- package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/__test__/index.test.js +12 -6
- package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/index.js +8 -4
- package/src/commons/ActionGroup/OnOffTemplate/OnOffButtonTemplate.js +4 -6
- package/src/commons/ActionGroup/OnOffTemplate/index.js +28 -10
- package/src/commons/ActionGroup/OneBigButtonTemplate.js +1 -1
- package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +25 -12
- package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +25 -9
- package/src/commons/ActionGroup/SmartTiviActionTemplate/__test__/ControlPlay.test.js +13 -7
- package/src/commons/ActionGroup/SmartTiviActionTemplate/__test__/RectangleButton.test.js +9 -5
- package/src/commons/ActionGroup/SmartTiviActionTemplate/__test__/SmartTiviActionTemplate.test.js +25 -9
- package/src/commons/ActionGroup/SmartTiviActionTemplate/component/CircleButton.js +16 -6
- package/src/commons/ActionGroup/SmartTiviActionTemplate/component/ControlPlay.js +10 -4
- package/src/commons/ActionGroup/SmartTiviActionTemplate/component/RectangleButton.js +7 -3
- package/src/commons/ActionGroup/StatesGridActionTemplate.js +21 -7
- package/src/commons/ActionGroup/ThreeButtonTemplate.js +5 -5
- package/src/commons/ActionGroup/TwoButtonTemplate/index.js +4 -4
- package/src/commons/ActionGroup/__test__/NumberUpDownTemplate.test.js +7 -7
- package/src/commons/ActionGroup/__test__/OnOffSmartLock.test.js +3 -3
- package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +3 -3
- package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +9 -5
- package/src/commons/ActionGroup/__test__/index.test.js +5 -3
- package/src/commons/ActionTemplate/OnOffButtonAction.js +14 -5
- package/src/commons/ActionTemplate/__test__/OnOffButtonAction.test.js +23 -2
- package/src/commons/ActionTemplate/__test__/index.test.js +2 -0
- package/src/commons/ActionTemplate/index.js +1 -0
- package/src/commons/AlertAction/index.js +2 -2
- package/src/commons/Auth/AccountItem.js +9 -3
- package/src/commons/Auth/__test__/AccountItem.test.js +6 -3
- package/src/commons/Automate/ItemAutomate.js +22 -3
- package/src/commons/BackDefault/index.js +2 -2
- package/src/commons/BottomButtonView/index.js +4 -5
- package/src/commons/Button/index.js +0 -2
- package/src/commons/ButtonPopup/index.js +3 -3
- package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +3 -2
- package/src/commons/Dashboard/MyPinnedSharedUnit/index.js +4 -2
- package/src/commons/Dashboard/MyUnit/__test__/MyUnit.test.js +6 -3
- package/src/commons/Dashboard/MyUnit/index.js +5 -3
- package/src/commons/Device/ConnectedViewHeader.js +2 -2
- package/src/commons/Device/DeviceAlertStatus.js +2 -2
- package/src/commons/Device/DisconnectedView.js +2 -2
- package/src/commons/Device/Emergency/EmergencyButton.js +2 -2
- package/src/commons/Device/Emergency/__test__/EmergencyButton.test.js +3 -2
- package/src/commons/Device/FlatListItems.js +2 -2
- package/src/commons/Device/ItemAddNew/index.js +7 -12
- package/src/commons/Device/ItemDevice.js +16 -11
- package/src/commons/Device/SensorConnectedStatus.js +5 -2
- package/src/commons/Device/WindDirection/Compass/index.js +5 -2
- package/src/commons/Device/__test__/DeviceAlertStatus.test.js +8 -4
- package/src/commons/Device/__test__/FlatListItems.test.js +3 -2
- package/src/commons/Device/__test__/SensorConnectedStatus.test.js +4 -2
- package/src/commons/Explore/ActivityIndicator/index.js +5 -2
- package/src/commons/Explore/SearchBox/__test__/SearchBox.test.js +3 -3
- package/src/commons/Explore/SearchBox/index.js +2 -2
- package/src/commons/FieldTemplate/ChooseUserField/ChoosePopup.js +4 -4
- package/src/commons/FieldTemplate/ChooseUserField/__test__/index.test.js +11 -8
- package/src/commons/FieldTemplate/ChooseUserField/index.js +2 -2
- package/src/commons/FieldTemplate/PasscodeField/__test__/index.test.js +3 -2
- package/src/commons/FieldTemplate/PasscodeField/index.js +2 -2
- package/src/commons/FieldTemplate/ScheduleField/__test__/index.test.js +12 -7
- package/src/commons/Form/TextInput.js +2 -2
- package/src/commons/Form/TextInputPassword.js +2 -2
- package/src/commons/GroupCheckBox/__test__/GroupCheckBox.test.js +5 -3
- package/src/commons/GroupCheckBox/index.js +2 -2
- package/src/commons/HeaderAni/index.js +2 -3
- package/src/commons/MediaPlayerDetail/index.js +2 -2
- package/src/commons/MenuActionList/index.js +2 -2
- package/src/commons/MenuActionMore/index.js +2 -3
- package/src/commons/NavBar/index.js +2 -3
- package/src/commons/OneTapTemplate/NumberUpDownActionTemplate.js +12 -6
- package/src/commons/OneTapTemplate/OptionsDropdownActionTemplate.js +7 -3
- package/src/commons/OneTapTemplate/StatesGridActionTemplate.js +4 -2
- package/src/commons/OneTapTemplate/__test__/NumberUpDownActionTemplate.test.js +11 -8
- package/src/commons/OneTapTemplate/__test__/OptionsDropdownActionTemplate.test.js +9 -5
- package/src/commons/OneTapTemplate/__test__/StatesGridActionTemplate.test.js +5 -3
- package/src/commons/Popover/index.js +2 -13
- package/src/commons/PreventAccess/__test__/PreventAccess.test.js +5 -3
- package/src/commons/PreventAccess/index.js +3 -3
- package/src/commons/{Connecting → Processing}/__test__/Connecting.test.js +5 -4
- package/src/commons/Processing/index.js +93 -0
- package/src/commons/{Connecting → Processing}/styles.js +9 -1
- package/src/commons/SelectGateway/index.js +105 -0
- package/src/commons/SelectGateway/styles.js +55 -0
- package/src/commons/SelectSubUnit/__test__/SelectSubUnit.test.js +106 -0
- package/src/commons/SelectSubUnit/index.js +124 -0
- package/src/commons/SelectSubUnit/styles.js +52 -0
- package/src/commons/SelectUnit/__test__/SelectUnit.test.js +120 -0
- package/src/commons/SelectUnit/index.js +105 -0
- package/src/commons/SelectUnit/styles.js +53 -0
- package/src/commons/Sharing/WrapHeaderScrollable.js +2 -2
- package/src/commons/SubUnit/OneTap/ItemOneTap.js +4 -4
- package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +25 -10
- package/src/commons/SubUnit/OneTap/index.js +9 -4
- package/src/commons/SubUnit/ShortDetail.js +11 -29
- package/src/commons/SubUnit/__test__/ShortDetail.test.js +15 -10
- package/src/commons/SummaryItem/index.js +2 -2
- package/src/commons/Tabbar/__test__/index.test.js +97 -0
- package/src/commons/Unit/HeaderUnit/index.js +4 -5
- package/src/commons/Unit/SharedUnit.js +10 -8
- package/src/commons/Unit/__test__/HeaderUnit.test.js +13 -5
- package/src/commons/Unit/__test__/SharedUnit.test.js +30 -11
- package/src/commons/UnitSummary/AirQuality/__test__/index.test.js +13 -8
- package/src/commons/UnitSummary/AirQuality/index.js +7 -3
- package/src/commons/UnitSummary/TotalPowerBox.js +2 -2
- package/src/commons/UnitSummary/TotalPowerConsumption/index.js +2 -2
- package/src/commons/UnitSummary/__test__/TotalPowerBox.test.js +3 -2
- package/src/commons/UnitSummary/__test__/TotalPowerConsumption.test.js +4 -2
- package/src/commons/ViewButtonBottom/index.js +4 -4
- package/src/commons/WheelDateTimePicker/index.js +5 -3
- package/src/commons/WrapParallaxScrollView/index.js +2 -1
- package/src/configs/API.js +16 -14
- package/src/configs/AccessibilityLabel.js +629 -0
- package/src/configs/Constants.js +1 -604
- package/src/configs/Images.js +2 -0
- package/src/context/actionType.ts +10 -3
- package/src/context/mockStore.ts +6 -3
- package/src/context/reducer.ts +45 -8
- package/src/hoc/__test__/withRemoteControl.test.js +24 -0
- package/src/hoc/withRemoteControl.js +1 -0
- package/src/hooks/Common/__test__/useAndroidTranslucentStatusBar.test.js +55 -0
- package/src/hooks/Common/index.js +2 -2
- package/src/hooks/Common/useDevicesStatus.js +19 -15
- package/src/hooks/Common/{useGGHomeDeviceConnected.js → useHomeAssistantDeviceConnected.js} +3 -3
- package/src/hooks/Common/usePopover.js +6 -1
- package/src/hooks/IoT/__test__/{useGGHomeConnection.test.js → useHomeAssistantConnection.test.js} +18 -18
- package/src/hooks/IoT/__test__/useRemoteControl.test.js +17 -12
- package/src/hooks/IoT/index.js +2 -2
- package/src/hooks/IoT/useHomeAssistantConnection.js +91 -0
- package/src/hooks/IoT/useRemoteControl.js +6 -6
- package/src/hooks/__test__/useInitDeepLink.test.js +28 -0
- package/src/hooks/useReceiveNotifications.js +2 -4
- package/src/iot/RemoteControl/{GoogleHome.js → HomeAssistant.js} +21 -17
- package/src/iot/RemoteControl/LG.js +2 -1
- package/src/iot/RemoteControl/__test__/{GoogleHome.test.js → HomeAssistant.test.js} +30 -30
- package/src/navigations/AddDeviceStack.js +0 -14
- package/src/navigations/AddGatewayStack.js +56 -21
- package/src/navigations/Main.js +2 -2
- package/src/navigations/SmartAccountStack.js +52 -0
- package/src/navigations/SmartIrStack.js +3 -3
- package/src/navigations/UnitStack.js +1 -1
- package/src/screens/AQIGuide/__test__/AQIGuide.test.js +5 -3
- package/src/screens/AQIGuide/index.js +5 -3
- package/src/screens/ActivityLog/FilterPopup.js +2 -2
- package/src/screens/ActivityLog/__test__/FilterPopup.test.js +2 -2
- package/src/screens/ActivityLog/__test__/index.test.js +3 -2
- package/src/screens/ActivityLog/index.js +3 -3
- package/src/screens/AddCommon/SelectSubUnit.js +49 -192
- package/src/screens/AddCommon/SelectUnit.js +58 -204
- package/src/screens/AddCommon/__test__/SelectSubUnit.test.js +25 -61
- package/src/screens/AddCommon/__test__/SelectUnit.test.js +41 -32
- package/src/screens/AddLocationMaps/__test__/index.test.js +13 -7
- package/src/screens/AddLocationMaps/index.js +3 -3
- package/src/screens/AddNewAction/Device/index.js +2 -2
- package/src/screens/AddNewAction/SelectAction.js +16 -7
- package/src/screens/AddNewAction/SelectSensorDevices.js +3 -3
- package/src/screens/AddNewAction/__test__/SelectAction.test.js +2 -2
- package/src/screens/AddNewAction/__test__/SelectSensorDevices.test.js +8 -3
- package/src/screens/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +11 -7
- package/src/screens/AddNewAutoSmart/index.js +9 -12
- package/src/screens/AddNewDevice/ConnectingDevices.js +1 -1
- package/src/screens/AddNewDevice/__test__/AddNewDevice.test.js +7 -4
- package/src/screens/AddNewDevice/index.js +4 -4
- package/src/screens/AddNewGateway/ConnectingDevice.js +40 -0
- package/src/screens/AddNewGateway/ConnectingModbusDevice.js +61 -0
- package/src/screens/AddNewGateway/ConnectingWifiDevice.js +70 -0
- package/src/screens/AddNewGateway/ConnectingWifiGuide.js +167 -0
- package/src/screens/AddNewGateway/ConnectingWifiGuideStyles.js +58 -0
- package/src/screens/AddNewGateway/ConnectingZigbeeDevice.js +60 -0
- package/src/screens/AddNewGateway/PlugAndPlay/FirstWarning.js +16 -8
- package/src/screens/AddNewGateway/PlugAndPlay/__test__/FirstWarning.test.js +23 -4
- package/src/screens/AddNewGateway/RenameNewDevices.js +141 -0
- package/src/screens/AddNewGateway/RenameNewDevicesStyles.js +75 -0
- package/src/screens/AddNewGateway/ScanGatewayQR.js +80 -0
- package/src/screens/AddNewGateway/ScanModbusQR.js +53 -0
- package/src/screens/AddNewGateway/ScanWifiDeviceQR.js +55 -0
- package/src/screens/AddNewGateway/SelectDeviceSubUnit.js +31 -0
- package/src/screens/AddNewGateway/SelectDeviceType.js +147 -0
- package/src/screens/AddNewGateway/SelectDeviceTypeStyles.js +51 -0
- package/src/screens/AddNewGateway/SelectDeviceUnit.js +29 -0
- package/src/screens/AddNewGateway/SelectModbusGateway.js +34 -0
- package/src/screens/AddNewGateway/SelectZigbeeGateway.js +34 -0
- package/src/screens/AddNewGateway/ShareWifiPassword.js +198 -0
- package/src/screens/AddNewGateway/ShareWifiPasswordStyles.js +44 -0
- package/src/screens/AddNewGateway/__test__/AddNewGateway.test.js +7 -4
- package/src/screens/AddNewGateway/__test__/ConnectingModbusDevice.test.js +63 -0
- package/src/screens/AddNewGateway/__test__/{SelectGateway.test.js → ConnectingWifiDevice.test.js} +15 -10
- package/src/screens/AddNewGateway/__test__/ConnectingWifiGuide.test.js +224 -0
- package/src/screens/AddNewGateway/__test__/ConnectingZigbeeDevice.test.js +62 -0
- package/src/screens/AddNewGateway/__test__/RenameNewDevices.test.js +191 -0
- package/src/screens/AddNewGateway/__test__/ScanGatewayQR.test.js +72 -0
- package/src/screens/AddNewGateway/__test__/ScanModbusQR.test.js +75 -0
- package/src/screens/AddNewGateway/__test__/ScanWifiDeviceQR.test.js +73 -0
- package/src/screens/AddNewGateway/__test__/SelectDeviceSubUnit.test.js +47 -0
- package/src/screens/AddNewGateway/__test__/SelectDeviceType.test.js +124 -0
- package/src/screens/AddNewGateway/__test__/SelectDeviceUnit.test.js +48 -0
- package/src/screens/AddNewGateway/__test__/SelectModbusGateway.test.js +77 -0
- package/src/screens/AddNewGateway/__test__/SelectZigbeeGateway.test.js +77 -0
- package/src/screens/AddNewGateway/__test__/ShareWifiPassword.test.js +155 -0
- package/src/screens/AddNewGateway/hooks/__Tests__/index.test.js +1 -1
- package/src/screens/AddNewGateway/index.js +4 -4
- package/src/screens/AddNewOneTap/__test__/AddNewOneTap.test.js +5 -4
- package/src/screens/AddNewOneTap/index.js +4 -4
- package/src/screens/Automate/__test__/index.test.js +2 -2
- package/src/screens/Automate/index.js +6 -2
- package/src/screens/ConfirmUnitDeletion/__test__/ConfirmUnitDeletion.test.js +3 -2
- package/src/screens/ConfirmUnitDeletion/index.js +3 -3
- package/src/screens/Device/EditDevice/__test__/EditDevice.test.js +5 -5
- package/src/screens/Device/EditDevice/index.js +3 -3
- package/src/screens/Device/__test__/detail.test.js +38 -22
- package/src/screens/Device/components/SensorConnectStatusViewHeader.js +6 -6
- package/src/screens/Device/components/SensorDisplayItem.js +2 -2
- package/src/screens/Device/detail.js +28 -22
- package/src/screens/Device/hooks/useEvaluateValue.js +0 -2
- package/src/screens/DeviceInfo/__test__/index.test.js +8 -4
- package/src/screens/DeviceInfo/index.js +10 -6
- package/src/screens/Drawer/index.js +21 -9
- package/src/screens/EditActionsList/__tests__/index.test.js +120 -0
- package/src/screens/EditActionsList/index.js +15 -5
- package/src/screens/EmergencyContacts/EmergencyContactsAddNew.js +8 -4
- package/src/screens/EmergencyContacts/EmergencyContactsList.js +1 -1
- package/src/screens/EmergencyContacts/EmergencyContactsSelectContacts.js +5 -3
- package/src/screens/EmergencyContacts/__test__/EmergencyContactAddNew.test.js +9 -5
- package/src/screens/EmergencyContacts/__test__/EmergencyContactList.test.js +7 -3
- package/src/screens/EmergencyContacts/__test__/EmergencyContactsSelectContacts.test.js +7 -3
- package/src/screens/EmergencySetting/__test__/DropDownItem.test.js +3 -2
- package/src/screens/EmergencySetting/components/DropDownItem.js +2 -2
- package/src/screens/EnterPassword/__test__/EnterPassword.test.js +6 -3
- package/src/screens/EnterPassword/index.js +5 -3
- package/src/screens/GuestInfo/__test__/index.test.js +18 -12
- package/src/screens/GuestInfo/components/AccessScheduleItem.js +2 -2
- package/src/screens/GuestInfo/components/AccessScheduleSheet.js +3 -3
- package/src/screens/GuestInfo/components/HeaderGuestInfo.js +2 -2
- package/src/screens/GuestInfo/components/RecurringDetail.js +4 -4
- package/src/screens/GuestInfo/components/TemporaryDetail.js +3 -3
- package/src/screens/GuestInfo/index.js +1 -1
- package/src/screens/HanetCamera/Detail.js +10 -4
- package/src/screens/HanetCamera/ManageAccess.js +4 -4
- package/src/screens/HanetCamera/MemberInfo.js +1 -1
- package/src/screens/HanetCamera/__test__/Detail.test.js +5 -3
- package/src/screens/HanetCamera/__test__/ManageAccess.test.js +10 -4
- package/src/screens/HanetCamera/__test__/MemberInfo.test.js +4 -2
- package/src/screens/HanetCamera/components/RequestFaceIDPopup.js +2 -2
- package/src/screens/ManageAccess/index.js +1 -1
- package/src/screens/MoveToAnotherSubUnit/__test__/index.test.js +4 -4
- package/src/screens/MoveToAnotherSubUnit/index.js +2 -2
- package/src/screens/PlayBackCamera/__test__/index.test.js +9 -6
- package/src/screens/PlayBackCamera/index.js +6 -6
- package/src/screens/ScanChipQR/components/QRScan/__test__/QRScan.test.js +1 -1
- package/src/screens/ScanChipQR/components/QRScan/index.js +10 -3
- package/src/screens/ScriptDetail/__test__/index.test.js +43 -38
- package/src/screens/ScriptDetail/index.js +26 -16
- package/src/screens/SelectUnit/__test__/index.test.js +4 -3
- package/src/screens/SelectUnit/index.js +3 -3
- package/src/screens/SetSchedule/index.js +1 -1
- package/src/screens/SharedUnit/__test__/ShareUnit.test.js +25 -0
- package/src/screens/SharedUnit/index.js +2 -0
- package/src/screens/Sharing/Components/{SensorItem.js → DeviceItem.js} +40 -30
- package/src/screens/Sharing/Components/Styles/{SensorItemStyles.js → DeviceItemStyles.js} +0 -0
- package/src/screens/Sharing/Components/__test__/{SensorItem.test.js → DeviceItem.test.js} +10 -8
- package/src/screens/Sharing/Components/index.js +2 -2
- package/src/screens/Sharing/InfoMemberUnit.js +7 -6
- package/src/screens/Sharing/MemberList.js +4 -4
- package/src/screens/Sharing/SelectPermission.js +139 -123
- package/src/screens/Sharing/SelectUser.js +9 -5
- package/src/screens/Sharing/Styles/SelectPermissionStyles.js +2 -2
- package/src/screens/Sharing/__test__/InfoMemberUnit.test.js +3 -2
- package/src/screens/Sharing/__test__/SelectPermission.test.js +67 -14
- package/src/screens/Sharing/__test__/SelectUser.test.js +7 -4
- package/src/screens/SideMenuDetail/__test__/index.test.js +11 -7
- package/src/screens/SideMenuDetail/index.js +2 -2
- package/src/screens/SmartAccount/Connecting/index.js +171 -0
- package/src/{commons/ConnectingProcess/styles.js → screens/SmartAccount/Connecting/style.js} +3 -22
- package/src/screens/SmartAccount/ListDevice/DeviceItem.js +45 -0
- package/src/screens/SmartAccount/ListDevice/__test__/DeviceItem.test.js +34 -0
- package/src/screens/SmartAccount/ListDevice/__test__/ListDevice.test.js +139 -0
- package/src/screens/SmartAccount/ListDevice/index.js +186 -0
- package/src/screens/SmartAccount/ListDevice/styles/DeviceItemStyles.js +70 -0
- package/src/screens/SmartAccount/ListDevice/styles/index.js +85 -0
- package/src/screens/SmartAccount/SuccessfullyConnected/DeviceItem.js +37 -0
- package/src/{commons/ConnectingProcess/DeviceItem → screens/SmartAccount/SuccessfullyConnected}/DeviceItemStyles.js +13 -5
- package/src/screens/SmartAccount/SuccessfullyConnected/__test__/DeviceItem.test.js +65 -0
- package/src/screens/SmartAccount/SuccessfullyConnected/__test__/SuccessfullyConnected.test.js +88 -0
- package/src/screens/SmartAccount/SuccessfullyConnected/index.js +101 -0
- package/src/screens/SmartAccount/SuccessfullyConnected/styles.js +42 -0
- package/src/screens/SmartAccount/__test__/Connecting.test.js +86 -0
- package/src/screens/SmartAccount/__test__/SmartAccount.test.js +249 -0
- package/src/screens/SmartAccount/index.js +172 -0
- package/src/screens/SmartAccount/style.js +70 -0
- package/src/screens/SmartIr/__test__/GroupButtonByType.test.js +4 -2
- package/src/screens/SmartIr/__test__/SelectDeviceType.test.js +5 -5
- package/src/screens/SmartIr/__test__/SmartIr.test.js +14 -6
- package/src/screens/SmartIr/components/GroupButtonByType/GroupButtonByType.js +4 -2
- package/src/screens/SmartIr/components/{SelectDeviceType.js → SelectIrDeviceType.js} +2 -2
- package/src/screens/SmartIr/index.js +1 -1
- package/src/screens/SubUnit/AddSubUnit.js +7 -3
- package/src/screens/SubUnit/Detail.js +6 -6
- package/src/screens/SubUnit/EditSubUnit.js +10 -6
- package/src/screens/SubUnit/ManageSubUnit.js +2 -2
- package/src/screens/SubUnit/__test__/AddSubUnit.test.js +6 -3
- package/src/screens/SubUnit/__test__/Detail.test.js +5 -3
- package/src/screens/SubUnit/__test__/EditSubUnit.test.js +9 -5
- package/src/screens/SubUnit/__test__/ManageSubUnit.test.js +3 -2
- package/src/screens/SyncLGDevice/AddLGDevice.js +4 -4
- package/src/screens/SyncLGDevice/__test__/AddLGDevice.test.js +44 -14
- package/src/screens/TDSGuide/__test__/TDSGuide.test.js +4 -2
- package/src/screens/TDSGuide/index.js +2 -2
- package/src/screens/Template/EditTemplate.js +2 -1
- package/src/screens/Template/__test__/detail.test.js +9 -1
- package/src/screens/Template/index.js +0 -1
- package/src/screens/UVIndexGuide/__test__/UVIndexGuide.test.js +3 -2
- package/src/screens/UVIndexGuide/index.js +2 -2
- package/src/screens/Unit/AddMenu.js +10 -25
- package/src/screens/Unit/ChooseLocation.js +1 -1
- package/src/screens/Unit/Detail.js +10 -10
- package/src/screens/Unit/ManageUnit.js +21 -15
- package/src/screens/Unit/MyAllUnit/index.js +1 -1
- package/src/screens/Unit/SelectAddToFavorites.js +7 -8
- package/src/screens/Unit/SelectAddress.js +4 -4
- package/src/screens/Unit/SmartAccount.js +8 -5
- package/src/screens/Unit/SmartAccountItem.js +3 -3
- package/src/screens/Unit/Station/__test__/index.test.js +1 -1
- package/src/screens/Unit/Station/index.js +2 -2
- package/src/screens/Unit/Summaries.js +2 -2
- package/src/screens/Unit/__test__/CheckSendEmail.test.js +6 -6
- package/src/screens/Unit/__test__/Detail.test.js +17 -12
- package/src/screens/Unit/__test__/ManageUnit.test.js +40 -18
- package/src/screens/Unit/__test__/SelectAddress.test.js +15 -8
- package/src/screens/Unit/__test__/SmartAccount.test.js +8 -5
- package/src/screens/Unit/__test__/SmartAccountItem.test.js +4 -3
- package/src/screens/Unit/components/AutomateScript/index.js +5 -2
- package/src/screens/Unit/components/ListMyAllUnit/index.js +1 -1
- package/src/screens/Unit/components/MyAllUnit/__test__/Header.test.js +9 -5
- package/src/screens/Unit/components/MyAllUnit/index.js +1 -1
- package/src/screens/Unit/components/MyUnitDevice/index.js +8 -5
- package/src/screens/Unit/components/SharedUnit/index.js +12 -6
- package/src/screens/Unit/components/__test__/MyUnitDevice.test.js +2 -2
- package/src/screens/Unit/components/__test__/SharedUnit.test.js +24 -9
- package/src/screens/Unit/hook/useUnitConnectRemoteDevices.js +25 -11
- package/src/screens/UnitSummary/__test__/index.test.js +4 -2
- package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js +4 -2
- package/src/screens/UnitSummary/components/3PPowerConsumption/index.js +2 -2
- package/src/screens/UnitSummary/components/PowerConsumption/__test__/PowerConsumption.test.js +4 -2
- package/src/screens/UnitSummary/components/PowerConsumption/index.js +2 -2
- package/src/screens/UnitSummary/components/RunningDevices/__test__/index.test.js +5 -4
- package/src/screens/UnitSummary/components/RunningDevices/index.js +6 -3
- package/src/screens/UnitSummary/components/TotalPowerBox/index.js +2 -2
- package/src/screens/UnitSummary/components/TotalPowerConsumption/index.js +2 -2
- package/src/screens/UnitSummary/components/__test__/TotalPowerBox.test.js +3 -2
- package/src/screens/UnitSummary/components/__test__/TotalPowerConsumption.test.js +4 -2
- package/src/screens/UnitSummary/index.js +10 -8
- package/src/screens/WaterQualityGuide/__test__/index.test.js +17 -12
- package/src/screens/WaterQualityGuide/index.js +26 -10
- package/src/utils/Apis/axios.js +1 -0
- package/src/utils/I18n/translations/en.json +36 -11
- package/src/utils/I18n/translations/vi.json +36 -10
- package/src/utils/Route/index.js +19 -10
- package/src/utils/Utils.js +6 -7
- package/src/utils/Validation.js +4 -0
- package/src/commons/Connecting/index.js +0 -67
- package/src/commons/ConnectingProcess/DeviceItem/DeviceItem.js +0 -28
- package/src/commons/ConnectingProcess/__test__/Connecting.test.js +0 -163
- package/src/commons/ConnectingProcess/__test__/DeviceItem.test.js +0 -19
- package/src/commons/ConnectingProcess/index.js +0 -213
- package/src/hooks/IoT/useGGHomeConnection.js +0 -91
- package/src/iot/RemoteControl/index.js +0 -55
- package/src/screens/AddNewDevice/ConnectDevices.js +0 -184
- package/src/screens/AddNewDevice/__test__/ConnectDevices.test.js +0 -131
- package/src/screens/AddNewGateway/ConnectedGateway.js +0 -139
- package/src/screens/AddNewGateway/ConnectingGateway.js +0 -137
- package/src/screens/AddNewGateway/PlugAndPlay/ConnectWifiWarning.js +0 -214
- package/src/screens/AddNewGateway/PlugAndPlay/GatewayWifiList.js +0 -319
- package/src/screens/AddNewGateway/PlugAndPlay/__test__/ConnectWifiWarning.test.js +0 -75
- package/src/screens/AddNewGateway/PlugAndPlay/__test__/GatewayWifiList.test.js +0 -130
- package/src/screens/AddNewGateway/SelectGateway.js +0 -133
- package/src/screens/AddNewGateway/SetupGatewayWifi.js +0 -207
- package/src/screens/AddNewGateway/__test__/ConnectedGateway.test.js +0 -71
- package/src/screens/AddNewGateway/__test__/ConnectingGateway.test.js +0 -96
- package/src/screens/AddNewGateway/__test__/SetupGateway.test.js +0 -120
- package/src/screens/ScanChipQR/__test__/ScanChipQR.test.js +0 -115
- package/src/screens/ScanChipQR/hooks/index.js +0 -120
- package/src/screens/ScanChipQR/index.js +0 -29
- package/src/screens/ScanSensorQR/__test__/ScanSensorQR.test.js +0 -111
- package/src/screens/ScanSensorQR/hooks/index.js +0 -40
- package/src/screens/ScanSensorQR/index.js +0 -39
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import { useNavigation } from '@react-navigation/native';
|
|
3
|
+
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
4
|
+
import SelectGateway from '../../commons/SelectGateway';
|
|
5
|
+
import Routes from '../../utils/Route';
|
|
6
|
+
|
|
7
|
+
const SelectZigbeeGateway = ({ route }) => {
|
|
8
|
+
const t = useTranslations();
|
|
9
|
+
const navigation = useNavigation();
|
|
10
|
+
const { unitId, stationId } = route?.params || {};
|
|
11
|
+
|
|
12
|
+
const onPressNext = useCallback(
|
|
13
|
+
(gateway) => {
|
|
14
|
+
navigation.navigate(Routes.ConnectingZigbeeDevice, {
|
|
15
|
+
unitId,
|
|
16
|
+
stationId,
|
|
17
|
+
chipId: gateway.id,
|
|
18
|
+
});
|
|
19
|
+
},
|
|
20
|
+
[navigation, unitId, stationId]
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<SelectGateway
|
|
25
|
+
onPressNext={onPressNext}
|
|
26
|
+
title={t('text_select_a_gateway')}
|
|
27
|
+
subTitle={t('text_select_a_gateway')}
|
|
28
|
+
unitId={unitId}
|
|
29
|
+
type="zigbee"
|
|
30
|
+
/>
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export default SelectZigbeeGateway;
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import React, { useCallback, useState } from 'react';
|
|
2
|
+
import WifiManager from 'react-native-wifi-reborn';
|
|
3
|
+
import { Alert, ScrollView, TouchableOpacity, View } from 'react-native';
|
|
4
|
+
import dgram from 'react-native-udp';
|
|
5
|
+
|
|
6
|
+
import { ToastBottomHelper } from '../../utils/Utils';
|
|
7
|
+
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
8
|
+
import { HeaderCustom } from '../../commons/Header';
|
|
9
|
+
import Text from '../../commons/Text';
|
|
10
|
+
import WifiIcon from '../../../assets/images/wifi.svg';
|
|
11
|
+
import ButtonPopup from '../../commons/ButtonPopup';
|
|
12
|
+
import AccessibilityLabel from '../../configs/AccessibilityLabel';
|
|
13
|
+
import { Colors } from '../../configs';
|
|
14
|
+
import TextInputPassword from '../../commons/Form/TextInputPassword';
|
|
15
|
+
import styles from './ShareWifiPasswordStyles';
|
|
16
|
+
import { useNavigation } from '@react-navigation/native';
|
|
17
|
+
import Routes from '../../utils/Route';
|
|
18
|
+
|
|
19
|
+
const WifiItem = ({ item, setIsShowPopupPassword, setSelectedWifi }) => {
|
|
20
|
+
const showPopupPassword = useCallback(
|
|
21
|
+
(ssid) => {
|
|
22
|
+
setIsShowPopupPassword(true);
|
|
23
|
+
setSelectedWifi(ssid);
|
|
24
|
+
},
|
|
25
|
+
[setIsShowPopupPassword, setSelectedWifi]
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<TouchableOpacity
|
|
30
|
+
style={styles.listItem}
|
|
31
|
+
onPress={() => showPopupPassword(item.ssid)}
|
|
32
|
+
accessibilityLabel={`${AccessibilityLabel.SELECT_WIFI}${item.ssid}`}
|
|
33
|
+
>
|
|
34
|
+
<Text type="H4" style={styles.textItem}>
|
|
35
|
+
{item.ssid}
|
|
36
|
+
</Text>
|
|
37
|
+
<View style={styles.wifiIcon}>
|
|
38
|
+
<WifiIcon />
|
|
39
|
+
</View>
|
|
40
|
+
</TouchableOpacity>
|
|
41
|
+
);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const ShareWifiPassword = ({ route }) => {
|
|
45
|
+
const { wifiList, unitId, stationId } = route?.params || {};
|
|
46
|
+
const t = useTranslations();
|
|
47
|
+
const navigation = useNavigation();
|
|
48
|
+
|
|
49
|
+
const [isShowPopupPassword, setIsShowPopupPassword] = useState(false);
|
|
50
|
+
const [selectedWifi, setSelectedWifi] = useState('');
|
|
51
|
+
const [selectedWifiPassword, setSelectedWifiPassword] = useState('');
|
|
52
|
+
|
|
53
|
+
const hidePopupPassword = useCallback(() => {
|
|
54
|
+
setIsShowPopupPassword(false);
|
|
55
|
+
}, []);
|
|
56
|
+
|
|
57
|
+
const shareWifiToDevice = useCallback(
|
|
58
|
+
(socket, i) => {
|
|
59
|
+
const timeoutSendConnect = setTimeout(async () => {
|
|
60
|
+
i--;
|
|
61
|
+
socket.send(
|
|
62
|
+
JSON.stringify({
|
|
63
|
+
type: 'connect',
|
|
64
|
+
data: { wifi: { ssid: selectedWifi, pass: selectedWifiPassword } },
|
|
65
|
+
}),
|
|
66
|
+
undefined,
|
|
67
|
+
undefined,
|
|
68
|
+
54321,
|
|
69
|
+
'192.168.27.1',
|
|
70
|
+
undefined
|
|
71
|
+
);
|
|
72
|
+
if (i > 0) {
|
|
73
|
+
shareWifiToDevice(socket, i);
|
|
74
|
+
clearTimeout(timeoutSendConnect);
|
|
75
|
+
}
|
|
76
|
+
}, 1000);
|
|
77
|
+
},
|
|
78
|
+
[selectedWifiPassword, selectedWifi]
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
const handleSocketOnMsg = useCallback(
|
|
82
|
+
(currentSsid, msg) => {
|
|
83
|
+
const data = JSON.parse(msg.toString());
|
|
84
|
+
if (!Object.prototype.hasOwnProperty.call(data, 'gateway')) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
const gatewayInfo = data.gateway;
|
|
88
|
+
const checkWifiInterval = setInterval(async () => {
|
|
89
|
+
let ssid;
|
|
90
|
+
try {
|
|
91
|
+
ssid = await WifiManager.getCurrentWifiSSID();
|
|
92
|
+
} catch (e) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (ssid !== currentSsid) {
|
|
97
|
+
clearInterval(checkWifiInterval);
|
|
98
|
+
navigation.navigate(Routes.ConnectingWifiDevice, {
|
|
99
|
+
unitId,
|
|
100
|
+
stationId,
|
|
101
|
+
gateway: gatewayInfo,
|
|
102
|
+
selectedWifi: {
|
|
103
|
+
ssid: selectedWifi,
|
|
104
|
+
password: selectedWifiPassword,
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}, 1000);
|
|
109
|
+
|
|
110
|
+
return true;
|
|
111
|
+
},
|
|
112
|
+
[navigation, selectedWifi, selectedWifiPassword, stationId, unitId]
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
const onPasswordReady = useCallback(async () => {
|
|
116
|
+
const socket = dgram.createSocket({ type: 'udp4' });
|
|
117
|
+
socket.bind(54321);
|
|
118
|
+
let currentSsid;
|
|
119
|
+
try {
|
|
120
|
+
currentSsid = await WifiManager.getCurrentWifiSSID();
|
|
121
|
+
} catch (e) {
|
|
122
|
+
Alert.alert(t('cannot_get_current_wifi_ssid'));
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
socket.on('message', (msg, rinfo) => {
|
|
127
|
+
if (handleSocketOnMsg(currentSsid, msg)) {
|
|
128
|
+
socket.close();
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
socket.on('error', () => {
|
|
132
|
+
ToastBottomHelper.error(t('server_error'));
|
|
133
|
+
// todo Bang handle error
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
setIsShowPopupPassword(false);
|
|
137
|
+
shareWifiToDevice(socket, 3);
|
|
138
|
+
}, [handleSocketOnMsg, shareWifiToDevice, t]);
|
|
139
|
+
|
|
140
|
+
return (
|
|
141
|
+
<View style={styles.screen}>
|
|
142
|
+
<HeaderCustom
|
|
143
|
+
onGoBack={navigation.goBack}
|
|
144
|
+
title={t('connect_home_wifi')}
|
|
145
|
+
isShowSeparator
|
|
146
|
+
/>
|
|
147
|
+
<View>
|
|
148
|
+
<Text style={styles.title} semibold type="H3">
|
|
149
|
+
{t('set_network')}
|
|
150
|
+
</Text>
|
|
151
|
+
<Text style={styles.subTitle} type="Body">
|
|
152
|
+
{t('select_network')}
|
|
153
|
+
</Text>
|
|
154
|
+
|
|
155
|
+
<ScrollView
|
|
156
|
+
style={styles.listContainer}
|
|
157
|
+
scrollIndicatorInsets={{ right: 1 }}
|
|
158
|
+
>
|
|
159
|
+
{!!wifiList?.length &&
|
|
160
|
+
wifiList.map((item, index) => {
|
|
161
|
+
return (
|
|
162
|
+
<WifiItem
|
|
163
|
+
key={index}
|
|
164
|
+
item={item}
|
|
165
|
+
setSelectedWifi={setSelectedWifi}
|
|
166
|
+
setIsShowPopupPassword={setIsShowPopupPassword}
|
|
167
|
+
/>
|
|
168
|
+
);
|
|
169
|
+
})}
|
|
170
|
+
</ScrollView>
|
|
171
|
+
</View>
|
|
172
|
+
|
|
173
|
+
<ButtonPopup
|
|
174
|
+
accessibilityLabel={AccessibilityLabel.GATEWAY_WIFI_LIST.BUTTON_POPUP}
|
|
175
|
+
visible={isShowPopupPassword}
|
|
176
|
+
mainTitle={t('connect')}
|
|
177
|
+
onPressMain={onPasswordReady}
|
|
178
|
+
secondaryTitle={t('cancel')}
|
|
179
|
+
typeSecondary={'cancel'}
|
|
180
|
+
onPressSecondary={hidePopupPassword}
|
|
181
|
+
hideClose
|
|
182
|
+
>
|
|
183
|
+
<>
|
|
184
|
+
<Text>{t('enter_wifi_password')}</Text>
|
|
185
|
+
<TextInputPassword
|
|
186
|
+
secureTextEntry
|
|
187
|
+
placeholder={t('password')}
|
|
188
|
+
onChange={setSelectedWifiPassword}
|
|
189
|
+
value={selectedWifiPassword}
|
|
190
|
+
textInputStyle={styles.input}
|
|
191
|
+
selectionColor={Colors.Primary}
|
|
192
|
+
/>
|
|
193
|
+
</>
|
|
194
|
+
</ButtonPopup>
|
|
195
|
+
</View>
|
|
196
|
+
);
|
|
197
|
+
};
|
|
198
|
+
export default ShareWifiPassword;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
import { Colors } from '../../configs';
|
|
3
|
+
|
|
4
|
+
export default StyleSheet.create({
|
|
5
|
+
screen: {
|
|
6
|
+
flex: 1,
|
|
7
|
+
backgroundColor: Colors.Gray2,
|
|
8
|
+
},
|
|
9
|
+
title: {
|
|
10
|
+
marginVertical: 16,
|
|
11
|
+
marginLeft: 16,
|
|
12
|
+
},
|
|
13
|
+
subTitle: {
|
|
14
|
+
marginBottom: 16,
|
|
15
|
+
marginLeft: 16,
|
|
16
|
+
},
|
|
17
|
+
listContainer: {
|
|
18
|
+
borderWidth: 1,
|
|
19
|
+
backgroundColor: Colors.White,
|
|
20
|
+
borderRadius: 20,
|
|
21
|
+
borderColor: Colors.Gray4,
|
|
22
|
+
},
|
|
23
|
+
listItem: {
|
|
24
|
+
borderBottomColor: Colors.Gray4,
|
|
25
|
+
flex: 1,
|
|
26
|
+
flexDirection: 'row',
|
|
27
|
+
justifyContent: 'space-between',
|
|
28
|
+
alignItems: 'center',
|
|
29
|
+
},
|
|
30
|
+
textItem: {
|
|
31
|
+
paddingVertical: 16,
|
|
32
|
+
paddingLeft: 16,
|
|
33
|
+
},
|
|
34
|
+
wifiIcon: {
|
|
35
|
+
paddingRight: 16,
|
|
36
|
+
},
|
|
37
|
+
input: {
|
|
38
|
+
height: 40,
|
|
39
|
+
marginVertical: 12,
|
|
40
|
+
borderWidth: 1,
|
|
41
|
+
padding: 10,
|
|
42
|
+
borderColor: Colors.Gray5,
|
|
43
|
+
},
|
|
44
|
+
});
|
|
@@ -4,7 +4,7 @@ import MockAdapter from 'axios-mock-adapter';
|
|
|
4
4
|
|
|
5
5
|
import AddNewGateway from '../index';
|
|
6
6
|
import GroupCheckBox from '../../../commons/GroupCheckBox';
|
|
7
|
-
import {
|
|
7
|
+
import { AccessibilityLabel } from '../../../configs/Constants';
|
|
8
8
|
import { ViewButtonBottom } from '../../../commons';
|
|
9
9
|
import { TextInput } from 'react-native';
|
|
10
10
|
import { getTranslate } from '../../../utils/I18n';
|
|
@@ -54,7 +54,7 @@ describe('Test AddNewGateway', () => {
|
|
|
54
54
|
});
|
|
55
55
|
|
|
56
56
|
const getText = (instance, id) => {
|
|
57
|
-
return instance.find((el) => el.props.
|
|
57
|
+
return instance.find((el) => el.props.accessibilityLabel === id);
|
|
58
58
|
};
|
|
59
59
|
|
|
60
60
|
test('create', async () => {
|
|
@@ -62,8 +62,11 @@ describe('Test AddNewGateway', () => {
|
|
|
62
62
|
tree = await create(wrapComponent(route));
|
|
63
63
|
});
|
|
64
64
|
const instance = tree.root;
|
|
65
|
-
const textAdd = getText(instance,
|
|
66
|
-
const textThen = getText(
|
|
65
|
+
const textAdd = getText(instance, AccessibilityLabel.ADD_NEW_GATEWAY_ADD);
|
|
66
|
+
const textThen = getText(
|
|
67
|
+
instance,
|
|
68
|
+
AccessibilityLabel.ADD_NEW_GATEWAY_THEN_SELECT
|
|
69
|
+
);
|
|
67
70
|
expect(textAdd.props.children).toEqual(
|
|
68
71
|
getTranslate('en', 'add_new_gateway')
|
|
69
72
|
);
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { act, create } from 'react-test-renderer';
|
|
3
|
+
import MockAdapter from 'axios-mock-adapter';
|
|
4
|
+
import ConnectingModbusDevice from '../ConnectingModbusDevice';
|
|
5
|
+
import { SCProvider } from '../../../context';
|
|
6
|
+
import { mockSCStore } from '../../../context/mockStore';
|
|
7
|
+
import api from '../../../utils/Apis/axios';
|
|
8
|
+
import Processing from '../../../commons/Processing';
|
|
9
|
+
|
|
10
|
+
const wrapComponent = (route) => (
|
|
11
|
+
<SCProvider initState={mockSCStore({})}>
|
|
12
|
+
<ConnectingModbusDevice route={route} />
|
|
13
|
+
</SCProvider>
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
const mock = new MockAdapter(api.axiosInstance);
|
|
17
|
+
|
|
18
|
+
jest.mock('react', () => {
|
|
19
|
+
return { ...jest.requireActual('react'), memo: (x) => x };
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const mockedNavigate = jest.fn();
|
|
23
|
+
const mockedGoBack = jest.fn();
|
|
24
|
+
|
|
25
|
+
jest.mock('@react-navigation/native', () => {
|
|
26
|
+
return {
|
|
27
|
+
...jest.requireActual('@react-navigation/native'),
|
|
28
|
+
useNavigation: () => ({
|
|
29
|
+
navigate: mockedNavigate,
|
|
30
|
+
goBack: mockedGoBack,
|
|
31
|
+
}),
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
describe('Test connecting modbus device', () => {
|
|
36
|
+
let tree;
|
|
37
|
+
let route;
|
|
38
|
+
|
|
39
|
+
afterEach(() => {
|
|
40
|
+
mockedNavigate.mockClear();
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
beforeEach(() => {
|
|
44
|
+
route = {
|
|
45
|
+
params: {
|
|
46
|
+
unitId: 1,
|
|
47
|
+
stationId: 2,
|
|
48
|
+
chipId: 3,
|
|
49
|
+
qrData: {},
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test('rendering', async () => {
|
|
55
|
+
await act(async () => {
|
|
56
|
+
tree = await create(wrapComponent(route));
|
|
57
|
+
});
|
|
58
|
+
const instance = tree.root;
|
|
59
|
+
expect(instance.findAllByType(Processing)).toHaveLength(1);
|
|
60
|
+
|
|
61
|
+
expect(mock.history.post).toHaveLength(1);
|
|
62
|
+
});
|
|
63
|
+
});
|
package/src/screens/AddNewGateway/__test__/{SelectGateway.test.js → ConnectingWifiDevice.test.js}
RENAMED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { act, create } from 'react-test-renderer';
|
|
3
|
-
|
|
4
|
-
import
|
|
3
|
+
import MockAdapter from 'axios-mock-adapter';
|
|
4
|
+
import ConnectingWifiDevice from '../ConnectingWifiDevice';
|
|
5
5
|
import { SCProvider } from '../../../context';
|
|
6
6
|
import { mockSCStore } from '../../../context/mockStore';
|
|
7
|
-
import
|
|
7
|
+
import api from '../../../utils/Apis/axios';
|
|
8
|
+
import Processing from '../../../commons/Processing';
|
|
8
9
|
|
|
9
10
|
const wrapComponent = (route) => (
|
|
10
11
|
<SCProvider initState={mockSCStore({})}>
|
|
11
|
-
<
|
|
12
|
+
<ConnectingWifiDevice route={route} />
|
|
12
13
|
</SCProvider>
|
|
13
14
|
);
|
|
14
15
|
|
|
16
|
+
const mock = new MockAdapter(api.axiosInstance);
|
|
17
|
+
|
|
15
18
|
jest.mock('react', () => {
|
|
16
19
|
return { ...jest.requireActual('react'), memo: (x) => x };
|
|
17
20
|
});
|
|
@@ -26,11 +29,10 @@ jest.mock('@react-navigation/native', () => {
|
|
|
26
29
|
navigate: mockedNavigate,
|
|
27
30
|
goBack: mockedGoBack,
|
|
28
31
|
}),
|
|
29
|
-
useIsFocused: () => true,
|
|
30
32
|
};
|
|
31
33
|
});
|
|
32
34
|
|
|
33
|
-
describe('Test
|
|
35
|
+
describe('Test connecting wifi device', () => {
|
|
34
36
|
let tree;
|
|
35
37
|
let route;
|
|
36
38
|
|
|
@@ -41,17 +43,20 @@ describe('Test AddNewGatewaySelectGateway', () => {
|
|
|
41
43
|
beforeEach(() => {
|
|
42
44
|
route = {
|
|
43
45
|
params: {
|
|
44
|
-
|
|
46
|
+
unitId: 1,
|
|
47
|
+
stationId: 2,
|
|
48
|
+
gateway: {},
|
|
49
|
+
selectedWifi: {},
|
|
45
50
|
},
|
|
46
51
|
};
|
|
47
52
|
});
|
|
48
53
|
|
|
49
|
-
test('
|
|
54
|
+
test('rendering', async () => {
|
|
50
55
|
await act(async () => {
|
|
51
56
|
tree = await create(wrapComponent(route));
|
|
52
57
|
});
|
|
53
58
|
const instance = tree.root;
|
|
54
|
-
|
|
55
|
-
expect(
|
|
59
|
+
expect(instance.findAllByType(Processing)).toHaveLength(1);
|
|
60
|
+
expect(mock.history.post).toHaveLength(1);
|
|
56
61
|
});
|
|
57
62
|
});
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import renderer, { act } from 'react-test-renderer';
|
|
3
|
+
import Toast from 'react-native-toast-message';
|
|
4
|
+
|
|
5
|
+
import { SCProvider } from '../../../context';
|
|
6
|
+
import { mockSCStore } from '../../../context/mockStore';
|
|
7
|
+
import { Platform, TouchableOpacity } from 'react-native';
|
|
8
|
+
import WifiManager from 'react-native-wifi-reborn';
|
|
9
|
+
import dgram from 'react-native-udp';
|
|
10
|
+
import ConnectingWifiGuide from '../ConnectingWifiGuide';
|
|
11
|
+
import InteractSmartphoneIcon from '../../../../assets/images/AddNewDevice/interact-smartphone-icon.svg';
|
|
12
|
+
import AccessibilityLabel from '../../../configs/AccessibilityLabel';
|
|
13
|
+
|
|
14
|
+
const mockedGoBack = jest.fn();
|
|
15
|
+
const mockedNavigate = jest.fn();
|
|
16
|
+
jest.mock('@react-navigation/native', () => {
|
|
17
|
+
return {
|
|
18
|
+
...jest.requireActual('@react-navigation/native'),
|
|
19
|
+
useNavigation: () => ({
|
|
20
|
+
navigate: mockedNavigate,
|
|
21
|
+
goBack: mockedGoBack,
|
|
22
|
+
}),
|
|
23
|
+
useIsFocused: () => true,
|
|
24
|
+
};
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const wrapComponent = (route) => (
|
|
28
|
+
<SCProvider initState={mockSCStore({})}>
|
|
29
|
+
<ConnectingWifiGuide route={route} />
|
|
30
|
+
</SCProvider>
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
const ConnectWifiActionButton = async (instance) => {
|
|
34
|
+
const buttonOnActionPress = instance.find(
|
|
35
|
+
(el) =>
|
|
36
|
+
el.props.accessibilityLabel ===
|
|
37
|
+
`${AccessibilityLabel.PREFIX.BUTTON_CONNECT_WIFI}${AccessibilityLabel.BOTTOM_VIEW_MAIN}` &&
|
|
38
|
+
el.type === TouchableOpacity
|
|
39
|
+
);
|
|
40
|
+
await act(async () => {
|
|
41
|
+
buttonOnActionPress.props.onPress();
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
describe('test share wifi password', () => {
|
|
46
|
+
let tree;
|
|
47
|
+
|
|
48
|
+
beforeEach(() => {
|
|
49
|
+
const socket = dgram.createSocket({});
|
|
50
|
+
socket.on.mockClear();
|
|
51
|
+
socket.bind.mockClear();
|
|
52
|
+
socket.send.mockClear();
|
|
53
|
+
socket.close.mockClear();
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
test('render connect wifi guide', async () => {
|
|
57
|
+
const route = { params: {} };
|
|
58
|
+
await act(async () => {
|
|
59
|
+
tree = renderer.create(wrapComponent(route));
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
const instance = tree.root;
|
|
63
|
+
const icon = instance.findByType(InteractSmartphoneIcon);
|
|
64
|
+
expect(icon).toBeTruthy();
|
|
65
|
+
const button = instance.findAllByType(TouchableOpacity);
|
|
66
|
+
expect(button).toHaveLength(2);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test('auto connect to wifi prefix on ios', async () => {
|
|
70
|
+
Platform.OS = 'ios';
|
|
71
|
+
const route = { params: { prefix: 'robot' } };
|
|
72
|
+
await act(async () => {
|
|
73
|
+
tree = await renderer.create(wrapComponent(route));
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
await ConnectWifiActionButton(tree.root);
|
|
77
|
+
|
|
78
|
+
expect(WifiManager.connectToProtectedSSIDPrefix).toBeCalled();
|
|
79
|
+
expect(WifiManager.connectToProtectedSSIDPrefix.mock.calls[0][0]).toEqual(
|
|
80
|
+
'eoh.robot.'
|
|
81
|
+
);
|
|
82
|
+
const socket = dgram.createSocket();
|
|
83
|
+
expect(socket.bind).toBeCalled();
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
test('fail connect to wifi prefix on ios', async () => {
|
|
87
|
+
Platform.OS = 'ios';
|
|
88
|
+
const route = { params: { prefix: 'robot' } };
|
|
89
|
+
WifiManager.connectToProtectedSSIDPrefix.mockImplementationOnce(
|
|
90
|
+
async () => {
|
|
91
|
+
throw 'Cannot connect to protected prefix SSID';
|
|
92
|
+
}
|
|
93
|
+
);
|
|
94
|
+
await act(async () => {
|
|
95
|
+
tree = await renderer.create(wrapComponent(route));
|
|
96
|
+
});
|
|
97
|
+
await ConnectWifiActionButton(tree.root);
|
|
98
|
+
const socket = dgram.createSocket();
|
|
99
|
+
expect(socket.bind).not.toBeCalled();
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
test('auto connect to wifi android', async () => {
|
|
103
|
+
Platform.OS = 'android';
|
|
104
|
+
const route = { params: { prefix: 'robot' } };
|
|
105
|
+
WifiManager.loadWifiList.mockImplementationOnce(async () => [
|
|
106
|
+
{ SSID: 'random-name' },
|
|
107
|
+
{ SSID: 'eoh.lite.xxx' },
|
|
108
|
+
{ SSID: 'eoh.robot.xxx' },
|
|
109
|
+
]);
|
|
110
|
+
await act(async () => {
|
|
111
|
+
tree = await renderer.create(wrapComponent(route));
|
|
112
|
+
});
|
|
113
|
+
await ConnectWifiActionButton(tree.root);
|
|
114
|
+
|
|
115
|
+
expect(WifiManager.connectToProtectedSSID).toBeCalled();
|
|
116
|
+
expect(WifiManager.connectToProtectedSSID.mock.calls[0][0]).toEqual(
|
|
117
|
+
'eoh.robot.xxx'
|
|
118
|
+
);
|
|
119
|
+
const socket = dgram.createSocket();
|
|
120
|
+
expect(socket.bind).toBeCalled();
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
test('fail connect to wifi android', async () => {
|
|
124
|
+
Platform.OS = 'android';
|
|
125
|
+
const route = { params: { prefix: 'robot' } };
|
|
126
|
+
WifiManager.reScanAndLoadWifiList.mockImplementationOnce(async () => [
|
|
127
|
+
{ SSID: 'random-name' },
|
|
128
|
+
{ SSID: 'eoh.lite.xxx' },
|
|
129
|
+
{ SSID: 'eoh.robot.xxx' },
|
|
130
|
+
]);
|
|
131
|
+
WifiManager.connectToProtectedSSID.mockImplementationOnce(async () => {
|
|
132
|
+
throw 'Cannot connect to wifi';
|
|
133
|
+
});
|
|
134
|
+
await act(async () => {
|
|
135
|
+
tree = await renderer.create(wrapComponent(route));
|
|
136
|
+
});
|
|
137
|
+
await ConnectWifiActionButton(tree.root);
|
|
138
|
+
|
|
139
|
+
const socket = dgram.createSocket();
|
|
140
|
+
expect(socket.bind).not.toBeCalled();
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
test('fail load wifi list android', async () => {
|
|
144
|
+
Platform.OS = 'android';
|
|
145
|
+
const route = { params: { prefix: 'robot' } };
|
|
146
|
+
WifiManager.reScanAndLoadWifiList.mockImplementationOnce(async () => {
|
|
147
|
+
throw 'Cannot load wifi list to wifi';
|
|
148
|
+
});
|
|
149
|
+
await act(async () => {
|
|
150
|
+
tree = await renderer.create(wrapComponent(route));
|
|
151
|
+
});
|
|
152
|
+
await ConnectWifiActionButton(tree.root);
|
|
153
|
+
|
|
154
|
+
const socket = dgram.createSocket();
|
|
155
|
+
expect(socket.bind).not.toBeCalled();
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
test('request wifi list from device', async () => {
|
|
159
|
+
jest.useFakeTimers();
|
|
160
|
+
Platform.OS = 'android';
|
|
161
|
+
const route = { params: { prefix: 'robot' } };
|
|
162
|
+
await act(async () => {
|
|
163
|
+
tree = await renderer.create(wrapComponent(route));
|
|
164
|
+
});
|
|
165
|
+
await ConnectWifiActionButton(tree.root);
|
|
166
|
+
jest.runOnlyPendingTimers();
|
|
167
|
+
const socket = dgram.createSocket({});
|
|
168
|
+
expect(socket.send).toBeCalled();
|
|
169
|
+
const data = JSON.parse(socket.send.mock.calls[0][0]);
|
|
170
|
+
expect(data.type).toEqual('scan');
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
test('got wifi list from device', async () => {
|
|
174
|
+
Platform.OS = 'android';
|
|
175
|
+
const route = {
|
|
176
|
+
params: { prefix: 'robot', qrData: 'abc123', unitId: 1, stationId: 1 },
|
|
177
|
+
};
|
|
178
|
+
await act(async () => {
|
|
179
|
+
tree = await renderer.create(wrapComponent(route));
|
|
180
|
+
});
|
|
181
|
+
await ConnectWifiActionButton(tree.root);
|
|
182
|
+
|
|
183
|
+
const socket = dgram.createSocket({});
|
|
184
|
+
expect(socket.on).toBeCalled();
|
|
185
|
+
expect(socket.on.mock.calls[0][0]).toEqual('message');
|
|
186
|
+
|
|
187
|
+
await act(async () => {
|
|
188
|
+
socket.on.mock.calls[0][1](
|
|
189
|
+
JSON.stringify({
|
|
190
|
+
wifi: [{ ssid: 'wifi 1' }, { ssid: 'wifi.2' }],
|
|
191
|
+
})
|
|
192
|
+
);
|
|
193
|
+
});
|
|
194
|
+
// todo Bang should test wifi display
|
|
195
|
+
expect(socket.close).toBeCalled();
|
|
196
|
+
|
|
197
|
+
expect(mockedNavigate).toBeCalledWith('ShareWifiPassword', {
|
|
198
|
+
unitId: 1,
|
|
199
|
+
stationId: 1,
|
|
200
|
+
wifiList: [{ ssid: 'wifi 1' }, { ssid: 'wifi.2' }],
|
|
201
|
+
qrData: 'abc123',
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
// expect(mockedNavigate.mock.calls[0][0]).toEqual(Routes.ShareWifiPassword);
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
test('got error while request wifi list from device', async () => {
|
|
208
|
+
Platform.OS = 'android';
|
|
209
|
+
const route = { params: { prefix: 'robot' } };
|
|
210
|
+
await act(async () => {
|
|
211
|
+
tree = await renderer.create(wrapComponent(route));
|
|
212
|
+
});
|
|
213
|
+
await ConnectWifiActionButton(tree.root);
|
|
214
|
+
|
|
215
|
+
const socket = dgram.createSocket({});
|
|
216
|
+
expect(socket.on).toBeCalledTimes(2);
|
|
217
|
+
expect(socket.on.mock.calls[1][0]).toEqual('error');
|
|
218
|
+
|
|
219
|
+
await act(async () => {
|
|
220
|
+
socket.on.mock.calls[1][1]();
|
|
221
|
+
});
|
|
222
|
+
expect(Toast.show).toBeCalled();
|
|
223
|
+
});
|
|
224
|
+
});
|