From 1eedfeee153f45dffe5f556f2511d5bfd2f6dab1 Mon Sep 17 00:00:00 2001 From: Bryce McMath <32586431+bryce-mcmath@users.noreply.github.com> Date: Fri, 20 Dec 2024 16:28:03 -0800 Subject: [PATCH] feat: enable remote logging before login in dev settings (#2325) Signed-off-by: Bryce McMath --- app/__mocks__/helpers/app.tsx | 12 ++++++++++++ app/__tests__/screens/Developer.test.tsx | 9 ++++++--- .../screens/__snapshots__/Developer.test.tsx.snap | 1 - app/src/screens/Developer.tsx | 12 ++++++------ 4 files changed, 24 insertions(+), 10 deletions(-) create mode 100644 app/__mocks__/helpers/app.tsx diff --git a/app/__mocks__/helpers/app.tsx b/app/__mocks__/helpers/app.tsx new file mode 100644 index 00000000..dc3f51fc --- /dev/null +++ b/app/__mocks__/helpers/app.tsx @@ -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 = ({ children }) => { + const context = useMemo(() => new MainContainer(container.createChildContainer()).init(), []) + return ( + {children} + ) +} \ No newline at end of file diff --git a/app/__tests__/screens/Developer.test.tsx b/app/__tests__/screens/Developer.test.tsx index ed75b256..828fb642 100644 --- a/app/__tests__/screens/Developer.test.tsx +++ b/app/__tests__/screens/Developer.test.tsx @@ -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', () => ({ @@ -28,9 +29,11 @@ describe('Developer Screen', () => { test('screen renders correctly', () => { const tree = render( - - - + + + + + ) expect(tree).toMatchSnapshot() diff --git a/app/__tests__/screens/__snapshots__/Developer.test.tsx.snap b/app/__tests__/screens/__snapshots__/Developer.test.tsx.snap index 90ce35bc..0a883aa9 100644 --- a/app/__tests__/screens/__snapshots__/Developer.test.tsx.snap +++ b/app/__tests__/screens/__snapshots__/Developer.test.tsx.snap @@ -1014,7 +1014,6 @@ exports[`Developer Screen screen renders correctly 1`] = ` > { - const { agent } = useAgent() - const logger = agent?.config.logger as RemoteLogger const { t } = useTranslation() const [store, dispatch] = useStore() const { SettingsTheme, TextTheme, ColorPallet } = useTheme() + const [logger] = useServices([TOKENS.UTIL_LOGGER]) as [RemoteLogger] const [environmentModalVisible, setEnvironmentModalVisible] = useState(false) const [devMode, setDevMode] = useState(true) const [useVerifierCapability, setUseVerifierCapability] = useState(!!store.preferences.useVerifierCapability) @@ -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 = () => { @@ -427,7 +428,6 @@ const Settings: React.FC = () => { ios_backgroundColor={ColorPallet.grayscale.lightGrey} onValueChange={toggleRemoteLoggingSwitch} value={remoteLoggingEnabled} - disabled={!store.authentication.didAuthenticate} />