@eohjsc/react-native-smart-city 0.3.29 → 0.3.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +7 -5
- package/src/Images/DevMode/close.png +0 -0
- package/src/Images/DevMode/close@2x.png +0 -0
- package/src/Images/DevMode/close@3x.png +0 -0
- package/src/Images/DevMode/plus.png +0 -0
- package/src/Images/DevMode/plus@2x.png +0 -0
- package/src/Images/DevMode/plus@3x.png +0 -0
- package/src/Images/DevMode/remove_circle.png +0 -0
- package/src/Images/DevMode/remove_circle@2x.png +0 -0
- package/src/Images/DevMode/remove_circle@3x.png +0 -0
- package/src/commons/Action/ItemQuickAction.js +2 -2
- package/src/commons/Action/__test__/ItemQuickAction.test.js +17 -9
- package/src/commons/ActionGroup/ColorPickerTemplate.js +36 -17
- package/src/commons/ActionGroup/CurtainButtonTemplate.js +6 -6
- package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +18 -13
- 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 +38 -45
- package/src/commons/ActionGroup/OnOffSmartLock/OnOffSmartLockStyle.js +1 -0
- 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 +9 -10
- package/src/commons/ActionGroup/OnOffTemplate/index.js +2 -2
- package/src/commons/ActionGroup/OneBigButtonTemplate.js +5 -5
- package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +38 -22
- package/src/commons/ActionGroup/SliderRangeTemplate.js +24 -16
- 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 +2 -2
- package/src/commons/ActionGroup/ThreeButtonTemplate.js +50 -60
- package/src/commons/ActionGroup/TwoButtonTemplate/index.js +135 -133
- 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 +7 -5
- package/src/commons/ActionGroup/index.js +35 -10
- 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 +13 -3
- package/src/commons/BackDefault/index.js +2 -2
- package/src/commons/BottomButtonView/index.js +4 -4
- package/src/commons/Button/index.js +2 -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/DevMode/CardDevMode.js +42 -0
- package/src/commons/DevMode/EmptyComponent.js +18 -0
- package/src/commons/DevMode/Item.js +21 -0
- package/src/commons/DevMode/Styles/CardStyles.js +40 -0
- package/src/commons/DevMode/Styles/EmptyComponentStyles.js +15 -0
- package/src/commons/DevMode/Styles/ItemStyles.js +27 -0
- package/src/commons/DevMode/Styles/TextWithLabelStyles.js +36 -0
- package/src/commons/DevMode/TextWithLabel.js +30 -0
- package/src/commons/DevMode/index.js +5 -1
- package/src/commons/Device/ConnectedViewHeader.js +2 -2
- package/src/commons/Device/DeviceAlertStatus.js +3 -3
- package/src/commons/Device/DisconnectedView.js +2 -2
- package/src/commons/Device/Emergency/EmergencyButton.js +2 -2
- package/src/commons/Device/Emergency/EmergencyDetail.js +1 -1
- 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 +10 -11
- package/src/commons/Device/ItemDevice.js +27 -20
- package/src/commons/Device/PMSensor/PMSensorIndicatior.js +1 -1
- package/src/commons/Device/RainningSensor/CurrentRainSensor.js +1 -1
- package/src/commons/Device/SensorConnectedStatus.js +5 -2
- package/src/commons/Device/WindDirection/Compass/index.js +6 -3
- package/src/commons/Device/WindSpeed/Anemometer/index.js +1 -1
- 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/Header/HeaderCustom.js +8 -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 +6 -5
- package/src/commons/NavBar/index.js +4 -4
- package/src/commons/OneTapTemplate/NumberUpDownActionTemplate.js +11 -5
- 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 -12
- 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 +55 -0
- package/src/commons/SelectUnit/__test__/SelectUnit.test.js +120 -0
- package/src/commons/SelectUnit/index.js +106 -0
- package/src/commons/SelectUnit/styles.js +54 -0
- package/src/commons/Sharing/WrapHeaderScrollable.js +6 -4
- package/src/commons/SubUnit/OneTap/ItemOneTap.js +7 -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/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 +12 -14
- package/src/configs/AccessibilityLabel.js +608 -0
- package/src/configs/Colors.js +4 -0
- package/src/configs/Constants.js +1 -593
- package/src/configs/Images.js +3 -0
- package/src/context/actionType.ts +19 -3
- package/src/context/mockStore.ts +18 -3
- package/src/context/reducer.ts +66 -9
- package/src/hoc/withRemoteControl.js +1 -0
- package/src/hooks/Common/index.js +2 -2
- package/src/hooks/Common/useDevicesStatus.js +1 -1
- 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/IoT/useValueEvaluation.js +10 -19
- package/src/iot/RemoteControl/{GoogleHome.js → HomeAssistant.js} +27 -23
- 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 +51 -21
- package/src/navigations/Main.js +28 -4
- package/src/navigations/SmartIrStack.js +3 -3
- package/src/navigations/UnitStack.js +5 -8
- 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 +44 -191
- package/src/screens/AddCommon/SelectUnit.js +51 -204
- package/src/screens/AddCommon/__test__/SelectSubUnit.test.js +7 -50
- package/src/screens/AddCommon/__test__/SelectUnit.test.js +28 -26
- 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 +5 -1
- package/src/screens/AddNewAction/SelectAction.js +36 -20
- package/src/screens/AddNewAction/SelectSensorDevices.js +3 -3
- package/src/screens/AddNewAction/__test__/SelectAction.test.js +3 -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 +11 -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/ConnectingZigbeeDevice.js +60 -0
- package/src/screens/AddNewGateway/PlugAndPlay/FirstWarning.js +21 -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 +57 -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 +52 -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 +302 -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__/ConnectingZigbeeDevice.test.js +62 -0
- package/src/screens/AddNewGateway/__test__/RenameNewDevices.test.js +191 -0
- package/src/screens/AddNewGateway/__test__/ScanGatewayQR.test.js +73 -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 +89 -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 +294 -0
- package/src/screens/AddNewGateway/hooks/__Tests__/index.test.js +27 -0
- 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/DetailHistoryChart.js +7 -5
- package/src/screens/Device/components/SensorConnectStatusViewHeader.js +16 -17
- package/src/screens/Device/components/SensorDisplayItem.js +51 -26
- package/src/screens/Device/detail.js +65 -38
- package/src/screens/Device/hooks/useEvaluateValue.js +0 -2
- package/src/screens/Device/hooks/useFavoriteDevice.js +4 -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 +30 -13
- package/src/screens/EmergencyContacts/EmergencyContactsAddNew.js +11 -7
- package/src/screens/EmergencyContacts/EmergencyContactsList.js +1 -1
- package/src/screens/EmergencyContacts/EmergencyContactsSelectContacts.js +9 -10
- 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/Notification/__test__/NotificationItem.test.js +6 -30
- package/src/screens/Notification/components/NotificationItem.js +3 -19
- 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 +8 -4
- package/src/screens/ScriptDetail/index.js +7 -5
- 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/Sharing/Components/SensorItem.js +6 -3
- package/src/screens/Sharing/Components/Styles/SensorItemStyles.js +4 -0
- package/src/screens/Sharing/Components/Styles/TitleCheckBoxStyles.js +4 -0
- package/src/screens/Sharing/Components/TitleCheckBox.js +17 -8
- package/src/screens/Sharing/Components/__test__/SensorItem.test.js +4 -2
- package/src/screens/Sharing/InfoMemberUnit.js +7 -6
- package/src/screens/Sharing/MemberList.js +4 -4
- package/src/screens/Sharing/SelectPermission.js +9 -4
- package/src/screens/Sharing/SelectUser.js +9 -5
- package/src/screens/Sharing/__test__/InfoMemberUnit.test.js +3 -2
- 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/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 +7 -4
- package/src/screens/TDSGuide/__test__/TDSGuide.test.js +4 -2
- package/src/screens/TDSGuide/index.js +2 -2
- package/src/screens/Template/EditTemplate.js +152 -0
- package/src/screens/Template/GatewayList.js +51 -0
- package/src/screens/Template/Information.js +41 -0
- package/src/screens/Template/Styles/EditTemplateStyle.js +109 -0
- package/src/screens/Template/Styles/GatewayStyles.js +46 -0
- package/src/screens/Template/Styles/InformationStyles.js +16 -0
- package/src/screens/Template/Styles/detailStyles.js +35 -0
- package/src/screens/Template/Styles/indexStyles.js +2 -33
- package/src/screens/Template/__test__/EditTemplate.test.js +89 -0
- package/src/screens/Template/__test__/GatewayList.test.js +26 -0
- package/src/screens/Template/__test__/Information.test.js +16 -0
- package/src/screens/Template/__test__/detail.test.js +68 -0
- package/src/screens/Template/__test__/index.test.js +26 -1
- package/src/screens/Template/detail.js +154 -0
- package/src/screens/Template/index.js +38 -32
- package/src/screens/UVIndexGuide/__test__/UVIndexGuide.test.js +3 -2
- package/src/screens/UVIndexGuide/index.js +2 -2
- package/src/screens/Unit/AddMenu.js +6 -20
- package/src/screens/Unit/ChooseLocation.js +1 -1
- package/src/screens/Unit/Detail.js +14 -9
- package/src/screens/Unit/ManageUnit.js +21 -15
- package/src/screens/Unit/MyAllUnit/index.js +1 -1
- package/src/screens/Unit/SelectAddToFavorites.js +11 -2
- package/src/screens/Unit/SelectAddress.js +4 -4
- package/src/screens/Unit/SmartAccount.js +1 -1
- package/src/screens/Unit/SmartAccountItem.js +3 -3
- package/src/screens/Unit/Station/__test__/index.test.js +19 -3
- 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 +90 -55
- 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 +42 -25
- package/src/screens/Unit/__test__/SmartAccountItem.test.js +4 -3
- package/src/screens/Unit/components/AutomateScript/index.js +8 -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 +25 -10
- package/src/utils/I18n/translations/vi.json +22 -9
- package/src/utils/Route/index.js +22 -10
- package/src/commons/Connecting/index.js +0 -67
- package/src/commons/ConnectingProcess/DeviceItem/DeviceItem.js +0 -28
- package/src/commons/ConnectingProcess/DeviceItem/DeviceItemStyles.js +0 -41
- 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/commons/ConnectingProcess/styles.js +0 -69
- 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 -307
- 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,89 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { act, create } from 'react-test-renderer';
|
|
3
|
+
|
|
4
|
+
import SelectDeviceType from '../SelectDeviceType';
|
|
5
|
+
import { SCProvider } from '../../../context';
|
|
6
|
+
import { mockSCStore } from '../../../context/mockStore';
|
|
7
|
+
import Button from '../../../commons/Button';
|
|
8
|
+
import Routes from '../../../utils/Route';
|
|
9
|
+
|
|
10
|
+
const wrapComponent = (route) => (
|
|
11
|
+
<SCProvider initState={mockSCStore({})}>
|
|
12
|
+
<SelectDeviceType route={route} />
|
|
13
|
+
</SCProvider>
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
jest.mock('react', () => {
|
|
17
|
+
return { ...jest.requireActual('react'), memo: (x) => x };
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const mockedNavigate = jest.fn();
|
|
21
|
+
const mockedGoBack = jest.fn();
|
|
22
|
+
|
|
23
|
+
jest.mock('@react-navigation/native', () => {
|
|
24
|
+
return {
|
|
25
|
+
...jest.requireActual('@react-navigation/native'),
|
|
26
|
+
useNavigation: () => ({
|
|
27
|
+
navigate: mockedNavigate,
|
|
28
|
+
goBack: mockedGoBack,
|
|
29
|
+
}),
|
|
30
|
+
useIsFocused: () => true,
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
describe('Test select device type', () => {
|
|
35
|
+
let tree;
|
|
36
|
+
let route;
|
|
37
|
+
|
|
38
|
+
afterEach(() => {
|
|
39
|
+
mockedNavigate.mockClear();
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
beforeEach(() => {
|
|
43
|
+
route = {
|
|
44
|
+
params: {
|
|
45
|
+
unitId: 1,
|
|
46
|
+
stationId: 1,
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
test('render select type', async () => {
|
|
52
|
+
await act(async () => {
|
|
53
|
+
tree = await create(wrapComponent(route));
|
|
54
|
+
});
|
|
55
|
+
const instance = tree.root;
|
|
56
|
+
const buttons = instance.findAllByType(Button);
|
|
57
|
+
expect(buttons).toHaveLength(4);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const selectDeviceType = async (index) => {
|
|
61
|
+
await act(async () => {
|
|
62
|
+
tree = await create(wrapComponent(route));
|
|
63
|
+
});
|
|
64
|
+
const instance = tree.root;
|
|
65
|
+
const buttons = instance.findAllByType(Button);
|
|
66
|
+
await act(async () => {
|
|
67
|
+
buttons[index].props.onPress();
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
expect(mockedNavigate).toBeCalled();
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
test('select modbus', async () => {
|
|
74
|
+
await selectDeviceType(0);
|
|
75
|
+
expect(mockedNavigate.mock.calls[0][0]).toEqual(Routes.SelectModbusGateway);
|
|
76
|
+
});
|
|
77
|
+
test('select zigbee', async () => {
|
|
78
|
+
await selectDeviceType(1);
|
|
79
|
+
expect(mockedNavigate.mock.calls[0][0]).toEqual(Routes.SelectZigbeeGateway);
|
|
80
|
+
});
|
|
81
|
+
test('select gateway', async () => {
|
|
82
|
+
await selectDeviceType(2);
|
|
83
|
+
expect(mockedNavigate.mock.calls[0][0]).toEqual(Routes.ScanGatewayQR);
|
|
84
|
+
});
|
|
85
|
+
test('select wifi', async () => {
|
|
86
|
+
await selectDeviceType(3);
|
|
87
|
+
expect(mockedNavigate.mock.calls[0][0]).toEqual(Routes.ScanWifiDeviceQR);
|
|
88
|
+
});
|
|
89
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import renderer, { act } from 'react-test-renderer';
|
|
3
|
+
|
|
4
|
+
import SelectDeviceUnit from '../SelectDeviceUnit';
|
|
5
|
+
import AccessibilityLabel from '../../../configs/AccessibilityLabel';
|
|
6
|
+
import { SCProvider } from '../../../context';
|
|
7
|
+
import { mockSCStore } from '../../../context/mockStore';
|
|
8
|
+
|
|
9
|
+
const mockedGoBack = jest.fn();
|
|
10
|
+
const mockedNavigate = jest.fn();
|
|
11
|
+
jest.mock('@react-navigation/native', () => {
|
|
12
|
+
return {
|
|
13
|
+
...jest.requireActual('@react-navigation/native'),
|
|
14
|
+
useNavigation: () => ({
|
|
15
|
+
navigate: mockedNavigate,
|
|
16
|
+
goBack: mockedGoBack,
|
|
17
|
+
}),
|
|
18
|
+
};
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const wrapComponent = (route) => (
|
|
22
|
+
<SCProvider initState={mockSCStore({})}>
|
|
23
|
+
<SelectDeviceUnit route={route} />
|
|
24
|
+
</SCProvider>
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
describe('test single SelectUnit', () => {
|
|
28
|
+
let tree;
|
|
29
|
+
|
|
30
|
+
test('click next', async () => {
|
|
31
|
+
const route = { params: { addType: 'AddSubUnit' } };
|
|
32
|
+
await act(async () => {
|
|
33
|
+
tree = renderer.create(wrapComponent(route));
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const instance = tree.root;
|
|
37
|
+
const goBack = instance.find(
|
|
38
|
+
(item) =>
|
|
39
|
+
item.props.accessibilityLabel ===
|
|
40
|
+
`${AccessibilityLabel.PREFIX.SELECT_UNIT}${AccessibilityLabel.VIEW_BUTTON_BOTTOM_RIGHT_BUTTON}`
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
await act(async () => {
|
|
44
|
+
goBack.props.onPress();
|
|
45
|
+
});
|
|
46
|
+
expect(mockedNavigate).toBeCalled();
|
|
47
|
+
});
|
|
48
|
+
});
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { act, create } from 'react-test-renderer';
|
|
3
|
+
|
|
4
|
+
import SelectModbusGateway from '../SelectModbusGateway';
|
|
5
|
+
import { SCProvider } from '../../../context';
|
|
6
|
+
import { mockSCStore } from '../../../context/mockStore';
|
|
7
|
+
import SelectGateway from '../../../commons/SelectGateway';
|
|
8
|
+
import Routes from '../../../utils/Route';
|
|
9
|
+
|
|
10
|
+
const wrapComponent = (route) => (
|
|
11
|
+
<SCProvider initState={mockSCStore({})}>
|
|
12
|
+
<SelectModbusGateway route={route} />
|
|
13
|
+
</SCProvider>
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
jest.mock('react', () => {
|
|
17
|
+
return { ...jest.requireActual('react'), memo: (x) => x };
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const mockedNavigate = jest.fn();
|
|
21
|
+
const mockedGoBack = jest.fn();
|
|
22
|
+
|
|
23
|
+
jest.mock('@react-navigation/native', () => {
|
|
24
|
+
return {
|
|
25
|
+
...jest.requireActual('@react-navigation/native'),
|
|
26
|
+
useNavigation: () => ({
|
|
27
|
+
navigate: mockedNavigate,
|
|
28
|
+
goBack: mockedGoBack,
|
|
29
|
+
}),
|
|
30
|
+
useIsFocused: () => true,
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
describe('Test select modbus gateway', () => {
|
|
35
|
+
let tree;
|
|
36
|
+
let route;
|
|
37
|
+
|
|
38
|
+
afterEach(() => {
|
|
39
|
+
mockedNavigate.mockClear();
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
beforeEach(() => {
|
|
43
|
+
route = {
|
|
44
|
+
params: {
|
|
45
|
+
unitId: 1,
|
|
46
|
+
stationId: 2,
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
test('render gateway', async () => {
|
|
52
|
+
await act(async () => {
|
|
53
|
+
tree = await create(wrapComponent(route));
|
|
54
|
+
});
|
|
55
|
+
const instance = tree.root;
|
|
56
|
+
const safeAreaView = instance.findAllByType(SelectGateway);
|
|
57
|
+
expect(safeAreaView).toHaveLength(1);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
test('select gateway', async () => {
|
|
61
|
+
await act(async () => {
|
|
62
|
+
tree = await create(wrapComponent(route));
|
|
63
|
+
});
|
|
64
|
+
const instance = tree.root;
|
|
65
|
+
const selectGateway = instance.findByType(SelectGateway);
|
|
66
|
+
|
|
67
|
+
await act(async () => {
|
|
68
|
+
selectGateway.props.onPressNext({ id: 3 });
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
expect(mockedNavigate).toBeCalledWith(Routes.ScanModbusQR, {
|
|
72
|
+
unitId: 1,
|
|
73
|
+
stationId: 2,
|
|
74
|
+
chipId: 3,
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
});
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { act, create } from 'react-test-renderer';
|
|
3
|
+
|
|
4
|
+
import SelectZigbeeGateway from '../SelectZigbeeGateway';
|
|
5
|
+
import { SCProvider } from '../../../context';
|
|
6
|
+
import { mockSCStore } from '../../../context/mockStore';
|
|
7
|
+
import SelectGateway from '../../../commons/SelectGateway';
|
|
8
|
+
import Routes from '../../../utils/Route';
|
|
9
|
+
|
|
10
|
+
const wrapComponent = (route) => (
|
|
11
|
+
<SCProvider initState={mockSCStore({})}>
|
|
12
|
+
<SelectZigbeeGateway route={route} />
|
|
13
|
+
</SCProvider>
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
jest.mock('react', () => {
|
|
17
|
+
return { ...jest.requireActual('react'), memo: (x) => x };
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const mockedNavigate = jest.fn();
|
|
21
|
+
const mockedGoBack = jest.fn();
|
|
22
|
+
|
|
23
|
+
jest.mock('@react-navigation/native', () => {
|
|
24
|
+
return {
|
|
25
|
+
...jest.requireActual('@react-navigation/native'),
|
|
26
|
+
useNavigation: () => ({
|
|
27
|
+
navigate: mockedNavigate,
|
|
28
|
+
goBack: mockedGoBack,
|
|
29
|
+
}),
|
|
30
|
+
useIsFocused: () => true,
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
describe('Test select zigbee gateway', () => {
|
|
35
|
+
let tree;
|
|
36
|
+
let route;
|
|
37
|
+
|
|
38
|
+
afterEach(() => {
|
|
39
|
+
mockedNavigate.mockClear();
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
beforeEach(() => {
|
|
43
|
+
route = {
|
|
44
|
+
params: {
|
|
45
|
+
unitId: 1,
|
|
46
|
+
stationId: 2,
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
test('render gateway', async () => {
|
|
52
|
+
await act(async () => {
|
|
53
|
+
tree = await create(wrapComponent(route));
|
|
54
|
+
});
|
|
55
|
+
const instance = tree.root;
|
|
56
|
+
const safeAreaView = instance.findAllByType(SelectGateway);
|
|
57
|
+
expect(safeAreaView).toHaveLength(1);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
test('select gateway', async () => {
|
|
61
|
+
await act(async () => {
|
|
62
|
+
tree = await create(wrapComponent(route));
|
|
63
|
+
});
|
|
64
|
+
const instance = tree.root;
|
|
65
|
+
const selectGateway = instance.findByType(SelectGateway);
|
|
66
|
+
|
|
67
|
+
await act(async () => {
|
|
68
|
+
selectGateway.props.onPressNext({ id: 3 });
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
expect(mockedNavigate).toBeCalledWith(Routes.ConnectingZigbeeDevice, {
|
|
72
|
+
unitId: 1,
|
|
73
|
+
stationId: 2,
|
|
74
|
+
chipId: 3,
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
});
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import renderer, { act } from 'react-test-renderer';
|
|
3
|
+
|
|
4
|
+
import ShareWifiPassword from '../ShareWifiPassword';
|
|
5
|
+
import { SCProvider } from '../../../context';
|
|
6
|
+
import { mockSCStore } from '../../../context/mockStore';
|
|
7
|
+
import ButtonPopup from '../../../commons/ButtonPopup';
|
|
8
|
+
import TextInputPassword from '../../../commons/Form/TextInputPassword';
|
|
9
|
+
import { Platform, TouchableOpacity } from 'react-native';
|
|
10
|
+
import WifiManager from 'react-native-wifi-reborn';
|
|
11
|
+
import dgram from 'react-native-udp';
|
|
12
|
+
import Routes from '../../../utils/Route';
|
|
13
|
+
import Toast from 'react-native-toast-message';
|
|
14
|
+
|
|
15
|
+
const mockedGoBack = jest.fn();
|
|
16
|
+
const mockedNavigate = jest.fn();
|
|
17
|
+
jest.mock('@react-navigation/native', () => {
|
|
18
|
+
return {
|
|
19
|
+
...jest.requireActual('@react-navigation/native'),
|
|
20
|
+
useNavigation: () => ({
|
|
21
|
+
navigate: mockedNavigate,
|
|
22
|
+
goBack: mockedGoBack,
|
|
23
|
+
}),
|
|
24
|
+
useIsFocused: () => true,
|
|
25
|
+
};
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const wrapComponent = (route) => (
|
|
29
|
+
<SCProvider initState={mockSCStore({})}>
|
|
30
|
+
<ShareWifiPassword route={route} />
|
|
31
|
+
</SCProvider>
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
describe('test share wifi password', () => {
|
|
35
|
+
let tree;
|
|
36
|
+
|
|
37
|
+
beforeEach(() => {
|
|
38
|
+
const socket = dgram.createSocket({});
|
|
39
|
+
socket.on.mockClear();
|
|
40
|
+
socket.bind.mockClear();
|
|
41
|
+
socket.send.mockClear();
|
|
42
|
+
socket.close.mockClear();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
test('render share wifi', async () => {
|
|
46
|
+
const route = { params: {} };
|
|
47
|
+
await act(async () => {
|
|
48
|
+
tree = renderer.create(wrapComponent(route));
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const instance = tree.root;
|
|
52
|
+
const popups = instance.findAllByType(ButtonPopup);
|
|
53
|
+
expect(popups).toHaveLength(1);
|
|
54
|
+
const passwordFields = instance.findAllByType(TextInputPassword);
|
|
55
|
+
expect(passwordFields).toHaveLength(1);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
test('auto connect to wifi prefix on ios', async () => {
|
|
59
|
+
Platform.OS = 'ios';
|
|
60
|
+
const route = { params: { prefix: 'robot' } };
|
|
61
|
+
await act(async () => {
|
|
62
|
+
tree = await renderer.create(wrapComponent(route));
|
|
63
|
+
});
|
|
64
|
+
expect(WifiManager.connectToProtectedSSIDPrefix).toBeCalled();
|
|
65
|
+
expect(WifiManager.connectToProtectedSSIDPrefix.mock.calls[0][0]).toEqual(
|
|
66
|
+
'eoh.robot.'
|
|
67
|
+
);
|
|
68
|
+
const socket = dgram.createSocket();
|
|
69
|
+
expect(socket.bind).toBeCalled();
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
test('fail connect to wifi prefix on ios', async () => {
|
|
73
|
+
Platform.OS = 'ios';
|
|
74
|
+
const route = { params: { prefix: 'robot' } };
|
|
75
|
+
WifiManager.connectToProtectedSSIDPrefix.mockImplementationOnce(
|
|
76
|
+
async () => {
|
|
77
|
+
throw 'Cannot connect to protected prefix SSID';
|
|
78
|
+
}
|
|
79
|
+
);
|
|
80
|
+
await act(async () => {
|
|
81
|
+
tree = await renderer.create(wrapComponent(route));
|
|
82
|
+
});
|
|
83
|
+
const socket = dgram.createSocket();
|
|
84
|
+
expect(socket.bind).not.toBeCalled();
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
test('auto connect to wifi android', async () => {
|
|
88
|
+
Platform.OS = 'android';
|
|
89
|
+
const route = { params: { prefix: 'robot' } };
|
|
90
|
+
WifiManager.loadWifiList.mockImplementationOnce(async () => [
|
|
91
|
+
{ SSID: 'random-name' },
|
|
92
|
+
{ SSID: 'eoh.lite.xxx' },
|
|
93
|
+
{ SSID: 'eoh.robot.xxx' },
|
|
94
|
+
]);
|
|
95
|
+
await act(async () => {
|
|
96
|
+
tree = await renderer.create(wrapComponent(route));
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
expect(WifiManager.connectToProtectedSSID).toBeCalled();
|
|
100
|
+
expect(WifiManager.connectToProtectedSSID.mock.calls[0][0]).toEqual(
|
|
101
|
+
'eoh.robot.xxx'
|
|
102
|
+
);
|
|
103
|
+
const socket = dgram.createSocket();
|
|
104
|
+
expect(socket.bind).toBeCalled();
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
test('fail connect to wifi android', async () => {
|
|
108
|
+
Platform.OS = 'android';
|
|
109
|
+
const route = { params: { prefix: 'robot' } };
|
|
110
|
+
WifiManager.reScanAndLoadWifiList.mockImplementationOnce(async () => [
|
|
111
|
+
{ SSID: 'random-name' },
|
|
112
|
+
{ SSID: 'eoh.lite.xxx' },
|
|
113
|
+
{ SSID: 'eoh.robot.xxx' },
|
|
114
|
+
]);
|
|
115
|
+
WifiManager.connectToProtectedSSID.mockImplementationOnce(async () => {
|
|
116
|
+
throw 'Cannot connect to wifi';
|
|
117
|
+
});
|
|
118
|
+
await act(async () => {
|
|
119
|
+
tree = await renderer.create(wrapComponent(route));
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
const socket = dgram.createSocket();
|
|
123
|
+
expect(socket.bind).not.toBeCalled();
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
test('fail load wifi list android', async () => {
|
|
127
|
+
Platform.OS = 'android';
|
|
128
|
+
const route = { params: { prefix: 'robot' } };
|
|
129
|
+
WifiManager.reScanAndLoadWifiList.mockImplementationOnce(async () => {
|
|
130
|
+
throw 'Cannot load wifi list to wifi';
|
|
131
|
+
});
|
|
132
|
+
await act(async () => {
|
|
133
|
+
tree = await renderer.create(wrapComponent(route));
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
const socket = dgram.createSocket();
|
|
137
|
+
expect(socket.bind).not.toBeCalled();
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
test('request wifi list from device', async () => {
|
|
141
|
+
jest.useFakeTimers();
|
|
142
|
+
Platform.OS = 'android';
|
|
143
|
+
const route = { params: { prefix: 'robot' } };
|
|
144
|
+
await act(async () => {
|
|
145
|
+
tree = await renderer.create(wrapComponent(route));
|
|
146
|
+
});
|
|
147
|
+
jest.runOnlyPendingTimers();
|
|
148
|
+
const socket = dgram.createSocket({});
|
|
149
|
+
expect(socket.send).toBeCalled();
|
|
150
|
+
const data = JSON.parse(socket.send.mock.calls[0][0]);
|
|
151
|
+
expect(data.type).toEqual('scan');
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
test('got wifi list from device', async () => {
|
|
155
|
+
Platform.OS = 'android';
|
|
156
|
+
const route = { params: { prefix: 'robot' } };
|
|
157
|
+
await act(async () => {
|
|
158
|
+
tree = await renderer.create(wrapComponent(route));
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
const socket = dgram.createSocket({});
|
|
162
|
+
expect(socket.on).toBeCalled();
|
|
163
|
+
expect(socket.on.mock.calls[0][0]).toEqual('message');
|
|
164
|
+
|
|
165
|
+
expect(
|
|
166
|
+
tree.root.findAll((el) => el.type === TouchableOpacity)
|
|
167
|
+
).toHaveLength(4);
|
|
168
|
+
|
|
169
|
+
await act(async () => {
|
|
170
|
+
socket.on.mock.calls[0][1](
|
|
171
|
+
JSON.stringify({
|
|
172
|
+
wifi: [{ ssid: 'wifi 1' }, { ssid: 'wifi.2' }],
|
|
173
|
+
})
|
|
174
|
+
);
|
|
175
|
+
});
|
|
176
|
+
// todo Bang should test wifi display
|
|
177
|
+
expect(socket.close).toBeCalled();
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
test('got error while request wifi list from device', async () => {
|
|
181
|
+
Platform.OS = 'android';
|
|
182
|
+
const route = { params: { prefix: 'robot' } };
|
|
183
|
+
await act(async () => {
|
|
184
|
+
tree = await renderer.create(wrapComponent(route));
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
const socket = dgram.createSocket({});
|
|
188
|
+
expect(socket.on).toBeCalledTimes(2);
|
|
189
|
+
expect(socket.on.mock.calls[1][0]).toEqual('error');
|
|
190
|
+
|
|
191
|
+
await act(async () => {
|
|
192
|
+
socket.on.mock.calls[1][1]();
|
|
193
|
+
});
|
|
194
|
+
expect(Toast.show).toBeCalled();
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
const sendPasswordToGateway = async () => {
|
|
198
|
+
jest.useFakeTimers();
|
|
199
|
+
Platform.OS = 'android';
|
|
200
|
+
const route = { params: { prefix: 'robot' } };
|
|
201
|
+
await act(async () => {
|
|
202
|
+
tree = await renderer.create(wrapComponent(route));
|
|
203
|
+
});
|
|
204
|
+
const popup = tree.root.find((el) => el.type === ButtonPopup);
|
|
205
|
+
|
|
206
|
+
const socket = dgram.createSocket({});
|
|
207
|
+
socket.on.mockClear();
|
|
208
|
+
socket.close.mockClear();
|
|
209
|
+
socket.send.mockClear();
|
|
210
|
+
|
|
211
|
+
await act(async () => {
|
|
212
|
+
await popup.props.onPressMain();
|
|
213
|
+
});
|
|
214
|
+
jest.runOnlyPendingTimers();
|
|
215
|
+
|
|
216
|
+
expect(socket.send).toBeCalled();
|
|
217
|
+
expect(socket.on).toBeCalled();
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
test('send password to gateway', async () => {
|
|
221
|
+
await sendPasswordToGateway();
|
|
222
|
+
const socket = dgram.createSocket({});
|
|
223
|
+
expect(socket.on.mock.calls[0][0]).toEqual('message');
|
|
224
|
+
expect(JSON.parse(socket.send.mock.calls[0][0]).type).toEqual('connect');
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
test('error share password to gateway', async () => {
|
|
228
|
+
await sendPasswordToGateway();
|
|
229
|
+
const socket = dgram.createSocket({});
|
|
230
|
+
expect(socket.on.mock.calls[1][0]).toEqual('error');
|
|
231
|
+
|
|
232
|
+
await act(async () => {
|
|
233
|
+
socket.on.mock.calls[1][1]();
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
expect(Toast.show).toBeCalled();
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
const receiveGatewayInfo = async (
|
|
240
|
+
info = {
|
|
241
|
+
gateway: {},
|
|
242
|
+
}
|
|
243
|
+
) => {
|
|
244
|
+
jest.useFakeTimers();
|
|
245
|
+
Platform.OS = 'android';
|
|
246
|
+
const route = { params: { prefix: 'robot' } };
|
|
247
|
+
await act(async () => {
|
|
248
|
+
tree = await renderer.create(wrapComponent(route));
|
|
249
|
+
});
|
|
250
|
+
const popup = tree.root.find((el) => el.type === ButtonPopup);
|
|
251
|
+
|
|
252
|
+
const socket = dgram.createSocket({});
|
|
253
|
+
socket.on.mockClear();
|
|
254
|
+
socket.close.mockClear();
|
|
255
|
+
socket.send.mockClear();
|
|
256
|
+
|
|
257
|
+
await act(async () => {
|
|
258
|
+
await popup.props.onPressMain();
|
|
259
|
+
});
|
|
260
|
+
jest.runOnlyPendingTimers();
|
|
261
|
+
|
|
262
|
+
expect(socket.on).toBeCalled();
|
|
263
|
+
expect(socket.on.mock.calls[0][0]).toEqual('message');
|
|
264
|
+
|
|
265
|
+
await act(async () => {
|
|
266
|
+
socket.on.mock.calls[0][1](JSON.stringify(info));
|
|
267
|
+
});
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
test('close socket after gateway success connect to wifi', async () => {
|
|
271
|
+
await receiveGatewayInfo();
|
|
272
|
+
const socket = dgram.createSocket({});
|
|
273
|
+
expect(socket.close).toBeCalled();
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
test('not close socket after gateway fail connect to wifi', async () => {
|
|
277
|
+
await receiveGatewayInfo({});
|
|
278
|
+
const socket = dgram.createSocket({});
|
|
279
|
+
expect(socket.close).not.toBeCalled();
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
test('go to connecting after restore wifi', async () => {
|
|
283
|
+
await receiveGatewayInfo();
|
|
284
|
+
WifiManager.getCurrentWifiSSID.mockImplementationOnce(
|
|
285
|
+
async () => 'other-random-name'
|
|
286
|
+
);
|
|
287
|
+
jest.runOnlyPendingTimers(); // check SSID interval
|
|
288
|
+
await new Promise(jest.requireActual('timers').setImmediate);
|
|
289
|
+
expect(mockedNavigate).toBeCalled();
|
|
290
|
+
expect(mockedNavigate.mock.calls[0][0]).toEqual(
|
|
291
|
+
Routes.ConnectingWifiDevice
|
|
292
|
+
);
|
|
293
|
+
});
|
|
294
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { act, renderHook } from '@testing-library/react-hooks';
|
|
2
|
+
import MockAdapter from 'axios-mock-adapter';
|
|
3
|
+
import api from '../../../../utils/Apis/axios';
|
|
4
|
+
import { useConnectGateway } from '..';
|
|
5
|
+
|
|
6
|
+
import { API } from '../../../../configs';
|
|
7
|
+
|
|
8
|
+
const mock = new MockAdapter(api.axiosInstance);
|
|
9
|
+
jest.mock('@react-navigation/native', () => {
|
|
10
|
+
return {
|
|
11
|
+
...jest.requireActual('@react-navigation/native'),
|
|
12
|
+
useNavigation: () => ({
|
|
13
|
+
dangerouslyGetParent: () => ({
|
|
14
|
+
dangerouslyGetState: jest.fn(),
|
|
15
|
+
}),
|
|
16
|
+
}),
|
|
17
|
+
};
|
|
18
|
+
});
|
|
19
|
+
describe('Test useHomeAssistantConnection', () => {
|
|
20
|
+
it('test connectGoogleHome all connected', async () => {
|
|
21
|
+
const { result } = renderHook(() => useConnectGateway(1));
|
|
22
|
+
await act(async () => {
|
|
23
|
+
await result.current.onPressDone();
|
|
24
|
+
});
|
|
25
|
+
mock.onGet(API.UNIT.UNIT_DETAIL(1)).reply(200, {});
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -7,12 +7,12 @@ import { Colors } from '../../configs';
|
|
|
7
7
|
import { Section, ViewButtonBottom } from '../../commons';
|
|
8
8
|
import Text from '../../commons/Text';
|
|
9
9
|
import Routes from '../../utils/Route';
|
|
10
|
-
import {
|
|
10
|
+
import { AccessibilityLabel } from '../../configs/Constants';
|
|
11
11
|
import styles from './AddNewGatewayStyles';
|
|
12
12
|
|
|
13
13
|
const AddNewGateway = memo(({ route }) => {
|
|
14
14
|
const t = useTranslations();
|
|
15
|
-
const { unit_id, wifiName, wifiPass, imei } = route
|
|
15
|
+
const { unit_id, wifiName, wifiPass, imei } = route?.params || {};
|
|
16
16
|
const { navigate, goBack } = useNavigation();
|
|
17
17
|
const [phoneNumber, setPhoneNumber] = useState('');
|
|
18
18
|
const [chipName, setChipName] = useState('');
|
|
@@ -55,7 +55,7 @@ const AddNewGateway = memo(({ route }) => {
|
|
|
55
55
|
return (
|
|
56
56
|
<SafeAreaView style={styles.wrap}>
|
|
57
57
|
<Text
|
|
58
|
-
|
|
58
|
+
accessibilityLabel={AccessibilityLabel.ADD_NEW_GATEWAY_ADD}
|
|
59
59
|
semibold
|
|
60
60
|
size={20}
|
|
61
61
|
color={Colors.Black}
|
|
@@ -64,7 +64,7 @@ const AddNewGateway = memo(({ route }) => {
|
|
|
64
64
|
{t('add_new_gateway')}
|
|
65
65
|
</Text>
|
|
66
66
|
<Text
|
|
67
|
-
|
|
67
|
+
accessibilityLabel={AccessibilityLabel.ADD_NEW_GATEWAY_THEN_SELECT}
|
|
68
68
|
size={14}
|
|
69
69
|
color={Colors.Gray8}
|
|
70
70
|
style={styles.textNote}
|
|
@@ -4,7 +4,7 @@ import { Platform, TextInput, TouchableOpacity } from 'react-native';
|
|
|
4
4
|
import { act, create } from 'react-test-renderer';
|
|
5
5
|
|
|
6
6
|
import AddNewOneTap from '..';
|
|
7
|
-
import {
|
|
7
|
+
import { AccessibilityLabel } from '../../../configs/Constants';
|
|
8
8
|
import { SCProvider } from '../../../context';
|
|
9
9
|
import { mockSCStore } from '../../../context/mockStore';
|
|
10
10
|
import Routes from '../../../utils/Route';
|
|
@@ -80,7 +80,8 @@ describe('test AddNewOneTap', () => {
|
|
|
80
80
|
const instance = tree.root;
|
|
81
81
|
const inputName = instance.findAll(
|
|
82
82
|
(el) =>
|
|
83
|
-
el.props.
|
|
83
|
+
el.props.accessibilityLabel === AccessibilityLabel.NAME_YOUR_BUTTON &&
|
|
84
|
+
el.type === TextInput
|
|
84
85
|
);
|
|
85
86
|
expect(inputName).toHaveLength(1);
|
|
86
87
|
|
|
@@ -90,7 +91,7 @@ describe('test AddNewOneTap', () => {
|
|
|
90
91
|
|
|
91
92
|
const item = instance.findAll(
|
|
92
93
|
(el) =>
|
|
93
|
-
el.props.
|
|
94
|
+
el.props.accessibilityLabel === AccessibilityLabel.BOTTOM_VIEW_MAIN &&
|
|
94
95
|
el.type === TouchableOpacity
|
|
95
96
|
);
|
|
96
97
|
|
|
@@ -114,7 +115,7 @@ describe('test AddNewOneTap', () => {
|
|
|
114
115
|
|
|
115
116
|
const item = tree.root.findAll(
|
|
116
117
|
(el) =>
|
|
117
|
-
el.props.
|
|
118
|
+
el.props.accessibilityLabel === AccessibilityLabel.BOTTOM_VIEW_MAIN &&
|
|
118
119
|
el.type === TouchableOpacity
|
|
119
120
|
);
|
|
120
121
|
|