From 28f1dab0c9538f8e01e693f094d236a055411b1d Mon Sep 17 00:00:00 2001 From: "Jason C. Leach" Date: Wed, 29 Nov 2023 14:24:12 -0800 Subject: [PATCH 1/4] feat: add url override Signed-off-by: Jason C. Leach --- packages/legacy/core/App/constants.ts | 6 ++---- packages/legacy/core/App/contexts/configuration.tsx | 5 +++-- packages/legacy/core/App/defaultConfiguration.ts | 5 +++-- packages/legacy/core/App/screens/ScanHelp.tsx | 3 ++- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/packages/legacy/core/App/constants.ts b/packages/legacy/core/App/constants.ts index 0682eb1dcb..3b06618b99 100644 --- a/packages/legacy/core/App/constants.ts +++ b/packages/legacy/core/App/constants.ts @@ -1,13 +1,11 @@ import { PINValidationRules } from './types/security' -const lengthOfhiddenAttributes = 10 +const lengthOfHiddenAttributes = 10 const unicodeForBulletCharacter = '\u2022' -export const whereToUseWalletUrl = 'http://example.com' - export const dateIntFormat = 'YYYYMMDD' -export const hiddenFieldValue = Array(lengthOfhiddenAttributes).fill(unicodeForBulletCharacter).join('') +export const hiddenFieldValue = Array(lengthOfHiddenAttributes).fill(unicodeForBulletCharacter).join('') // Used to property prefix TestIDs so they can be looked up // by on-device automated testing systems like SauceLabs. export const testIdPrefix = 'com.ariesbifold:id/' diff --git a/packages/legacy/core/App/contexts/configuration.tsx b/packages/legacy/core/App/contexts/configuration.tsx index 127ce6c72d..058446c071 100644 --- a/packages/legacy/core/App/contexts/configuration.tsx +++ b/packages/legacy/core/App/contexts/configuration.tsx @@ -34,13 +34,11 @@ export interface ConfigurationContext { OCABundleResolver: OCABundleResolverType proofTemplateBaseUrl?: string scan: React.FC - useBiometry: React.FC record: React.FC PINSecurity: PINSecurityParams indyLedgers: IndyVdrPoolConfig[] settings: SettingSection[] customNotification: NotificationConfiguration - useCustomNotifications: () => { total: number; notifications: any } supportedLanguages: Locales[] connectionTimerDelay?: number autoRedirectConnectionToHome?: boolean @@ -50,6 +48,9 @@ export interface ConfigurationContext { enableReuseConnections?: boolean showPreface?: boolean disableOnboardingSkip?: boolean + useBiometry: React.FC + useCustomNotifications: () => { total: number; notifications: any } + whereToUseWalletUrl: string } export const ConfigurationContext = createContext(null as unknown as ConfigurationContext) diff --git a/packages/legacy/core/App/defaultConfiguration.ts b/packages/legacy/core/App/defaultConfiguration.ts index da5c998244..ebe307d007 100644 --- a/packages/legacy/core/App/defaultConfiguration.ts +++ b/packages/legacy/core/App/defaultConfiguration.ts @@ -36,7 +36,6 @@ export const defaultConfiguration: ConfigurationContext = { brandingOverlayType: BrandingOverlayType.Branding10, }), scan: Scan, - useBiometry: UseBiometry, record: Record, PINSecurity: { rules: PINRules, displayHelper: false }, indyLedgers: defaultIndyLedgers, @@ -49,10 +48,12 @@ export const defaultConfiguration: ConfigurationContext = { buttonTitle: '', pageTitle: '', }, - useCustomNotifications: useNotifications, proofRequestTemplates: useProofRequestTemplates, enableTours: false, supportedLanguages: Object.keys(translationResources) as Locales[], showPreface: false, disableOnboardingSkip: false, + useCustomNotifications: useNotifications, + useBiometry: UseBiometry, + whereToUseWalletUrl: 'https://example.com', } diff --git a/packages/legacy/core/App/screens/ScanHelp.tsx b/packages/legacy/core/App/screens/ScanHelp.tsx index 61d00efc93..b72a9387a1 100644 --- a/packages/legacy/core/App/screens/ScanHelp.tsx +++ b/packages/legacy/core/App/screens/ScanHelp.tsx @@ -4,12 +4,13 @@ import { Linking, ScrollView, StyleSheet, Text } from 'react-native' import { SafeAreaView } from 'react-native-safe-area-context' import Link from '../components/texts/Link' -import { whereToUseWalletUrl } from '../constants' import { useTheme } from '../contexts/theme' import { testIdWithKey } from '../utils/testable' +import { useConfiguration } from '../contexts/configuration' const ScanHelp: React.FC = () => { const { t } = useTranslation() + const { whereToUseWalletUrl } = useConfiguration() const { TextTheme } = useTheme() const style = StyleSheet.create({ From 34535489c7a3fe7286f84743d903d2fe18e33b41 Mon Sep 17 00:00:00 2001 From: "Jason C. Leach" Date: Wed, 29 Nov 2023 14:30:21 -0800 Subject: [PATCH 2/4] feat: add url override Signed-off-by: Jason C. Leach --- packages/legacy/core/__tests__/contexts/configuration.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/legacy/core/__tests__/contexts/configuration.ts b/packages/legacy/core/__tests__/contexts/configuration.ts index 84d4f41812..d584f58c46 100644 --- a/packages/legacy/core/__tests__/contexts/configuration.ts +++ b/packages/legacy/core/__tests__/contexts/configuration.ts @@ -6,7 +6,6 @@ import { useNotifications } from '../../App/hooks/notifications' import { useProofRequestTemplates } from '../../verifier/request-templates' import { Locales } from '../../App/localization' - const configurationContext: ConfigurationContext = { pages: () => [], terms: () => null, @@ -48,6 +47,7 @@ const configurationContext: ConfigurationContext = { useCustomNotifications: useNotifications, proofRequestTemplates: useProofRequestTemplates, supportedLanguages: [Locales.en, Locales.fr, Locales.ptBr], + whereToUseWalletUrl: 'https://example.com', } export default configurationContext From 6ceb9b872b5162096ef560f78a762cd602aa4b45 Mon Sep 17 00:00:00 2001 From: "Jason C. Leach" Date: Wed, 29 Nov 2023 14:39:08 -0800 Subject: [PATCH 3/4] fix: unit tests Signed-off-by: Jason C. Leach --- .../core/__tests__/screens/ScanHelp.test.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/legacy/core/__tests__/screens/ScanHelp.test.tsx b/packages/legacy/core/__tests__/screens/ScanHelp.test.tsx index 90ccace27d..a6aa0e9f69 100644 --- a/packages/legacy/core/__tests__/screens/ScanHelp.test.tsx +++ b/packages/legacy/core/__tests__/screens/ScanHelp.test.tsx @@ -2,6 +2,8 @@ import { fireEvent, render } from '@testing-library/react-native' import React from 'react' import ScanHelp from '../../App/screens/ScanHelp' +import { ConfigurationContext } from '../../App/contexts/configuration' +import configurationContext from '../contexts/configuration' import { testIdWithKey } from '../../App/utils/testable' jest.mock('@react-navigation/core', () => { @@ -13,12 +15,20 @@ jest.mock('@react-navigation/native', () => { describe('ScanHelp Screen', () => { test('Renders correctly', async () => { - const tree = render() + const tree = render( + + + + ) expect(tree).toMatchSnapshot() }) test('Link button exists and is accessible', async () => { - const tree = render() + const tree = render( + + + + ) const { getByTestId } = tree const linkButton = getByTestId(testIdWithKey('WhereToUseLink')) From 1c1b3acb32874ed8248ce3a4bf5bedb1a2c58264 Mon Sep 17 00:00:00 2001 From: "Jason C. Leach" Date: Wed, 29 Nov 2023 14:46:41 -0800 Subject: [PATCH 4/4] fix: lint error Signed-off-by: Jason C. Leach --- packages/legacy/core/App/screens/ScanHelp.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/legacy/core/App/screens/ScanHelp.tsx b/packages/legacy/core/App/screens/ScanHelp.tsx index b72a9387a1..e4aeda0d2f 100644 --- a/packages/legacy/core/App/screens/ScanHelp.tsx +++ b/packages/legacy/core/App/screens/ScanHelp.tsx @@ -4,9 +4,9 @@ import { Linking, ScrollView, StyleSheet, Text } from 'react-native' import { SafeAreaView } from 'react-native-safe-area-context' import Link from '../components/texts/Link' +import { useConfiguration } from '../contexts/configuration' import { useTheme } from '../contexts/theme' import { testIdWithKey } from '../utils/testable' -import { useConfiguration } from '../contexts/configuration' const ScanHelp: React.FC = () => { const { t } = useTranslation()