Skip to content

Commit

Permalink
feat: enable remote logging before login in dev settings (#2325)
Browse files Browse the repository at this point in the history
Signed-off-by: Bryce McMath <[email protected]>
  • Loading branch information
bryce-mcmath authored Dec 21, 2024
1 parent 9de564c commit 1eedfee
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 10 deletions.
12 changes: 12 additions & 0 deletions app/__mocks__/helpers/app.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import 'reflect-metadata'
import React, { PropsWithChildren, useMemo } from 'react'

import { container } from 'tsyringe'
import { MainContainer, ContainerProvider } from '@hyperledger/aries-bifold-core'

export const BasicAppContext: React.FC<PropsWithChildren> = ({ children }) => {
const context = useMemo(() => new MainContainer(container.createChildContainer()).init(), [])
return (
<ContainerProvider value={context}>{children}</ContainerProvider>
)
}
9 changes: 6 additions & 3 deletions app/__tests__/screens/Developer.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import React from 'react'

import Developer from '../../src/screens/Developer'
import { initialState, reducer } from '../../src/store'
import { BasicAppContext } from '../../__mocks__/helpers/app'

const mockNavigation = jest.fn()
jest.mock('@react-navigation/native', () => ({
Expand All @@ -28,9 +29,11 @@ describe('Developer Screen', () => {

test('screen renders correctly', () => {
const tree = render(
<StoreProvider initialState={initialState} reducer={reducer}>
<Developer />
</StoreProvider>
<BasicAppContext>
<StoreProvider initialState={initialState} reducer={reducer}>
<Developer />
</StoreProvider>
</BasicAppContext>
)

expect(tree).toMatchSnapshot()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,6 @@ exports[`Developer Screen screen renders correctly 1`] = `
>
<RCTSwitch
accessibilityRole="switch"
disabled={true}
onChange={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
Expand Down
12 changes: 6 additions & 6 deletions app/src/screens/Developer.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useAgent } from '@credo-ts/react-hooks'
import { useTheme, useStore, testIdWithKey, DispatchAction, Screens } from '@hyperledger/aries-bifold-core'
import { useTheme, useStore, testIdWithKey, DispatchAction, Screens, useServices, TOKENS } from '@hyperledger/aries-bifold-core'
import { RemoteLogger, RemoteLoggerEventTypes } from '@hyperledger/aries-bifold-remote-logs'
import { useNavigation } from '@react-navigation/native'
import React, { useState } from 'react'
Expand All @@ -14,11 +13,10 @@ import IASEnvironment from './IASEnvironment'
import RemoteLogWarning from './RemoteLogWarning'

const Settings: React.FC = () => {
const { agent } = useAgent()
const logger = agent?.config.logger as RemoteLogger
const { t } = useTranslation()
const [store, dispatch] = useStore<BCState>()
const { SettingsTheme, TextTheme, ColorPallet } = useTheme()
const [logger] = useServices([TOKENS.UTIL_LOGGER]) as [RemoteLogger]
const [environmentModalVisible, setEnvironmentModalVisible] = useState<boolean>(false)
const [devMode, setDevMode] = useState<boolean>(true)
const [useVerifierCapability, setUseVerifierCapability] = useState<boolean>(!!store.preferences.useVerifierCapability)
Expand Down Expand Up @@ -229,7 +227,10 @@ const Settings: React.FC = () => {
setRemoteLoggingEnabled(remoteLoggingEnabled)

setRemoteLoggingWarningModalVisible(false)
navigation.navigate(Screens.Home as never)

if (store.authentication.didAuthenticate) {
navigation.navigate(Screens.Home as never)
}
}

const onRemoteLoggingBackPressed = () => {
Expand Down Expand Up @@ -427,7 +428,6 @@ const Settings: React.FC = () => {
ios_backgroundColor={ColorPallet.grayscale.lightGrey}
onValueChange={toggleRemoteLoggingSwitch}
value={remoteLoggingEnabled}
disabled={!store.authentication.didAuthenticate}
/>
</SectionRow>

Expand Down

0 comments on commit 1eedfee

Please sign in to comment.