From 3635649c0e1c3d7b1a3a24bb36c4a83a5a9ee3f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Poche=C4=87?= Date: Thu, 22 Oct 2026 10:25:45 +0200 Subject: [PATCH] Add Wise business onboarding intake form --- src/CONST/index.ts | 4 + src/ROUTES.ts | 9 + src/SCREENS.ts | 2 + src/components/DynamicForm/index.tsx | 18 +- .../DynamicForm/renderers/textRenderers.tsx | 3 + .../utils/formatDynamicFieldValue.ts | 3 + src/languages/de.ts | 33 ++++ src/languages/el.ts | 33 ++++ src/languages/en.ts | 34 ++++ src/languages/es.ts | 33 ++++ src/languages/fr.ts | 33 ++++ src/languages/it.ts | 33 ++++ src/languages/ja.ts | 33 ++++ src/languages/nl.ts | 33 ++++ src/languages/pl.ts | 33 ++++ src/languages/pt-BR.ts | 33 ++++ src/languages/zh-hans.ts | 33 ++++ src/libs/CountryUtils.ts | 13 +- .../ModalStackNavigators/index.tsx | 3 + src/libs/Navigation/linkingConfig/config.ts | 2 + .../paramLists/AccountSettingsParamList.ts | 8 + .../PrivatePersonalDetailsPage.tsx | 11 +- .../Wise/WiseAcceptTermsPage.tsx | 134 +++++++++++++++ .../Wise/WiseBusinessOnboardingPage.tsx | 104 ++++++++++++ .../Wise/forms/US.ts | 67 ++++++++ .../Wise/forms/getIndustryCategoryOptions.ts | 12 ++ .../Wise/getWiseBusinessOnboardingPrefill.ts | 71 ++++++++ .../WiseGlobalReimbursementsIntroPage.tsx | 2 + .../wiseBusinessOnboardingDynamicRouteTest.ts | 99 +++++++++++ .../Wallet/WiseAcceptTermsPageTest.tsx | 103 ++++++++++++ .../Wallet/WiseBusinessOnboardingPageTest.tsx | 158 ++++++++++++++++++ tests/unit/CountryUtils.test.ts | 21 ++- .../DynamicForm/DynamicFormFieldsTest.tsx | 16 ++ .../DynamicForm/DynamicFormFlowTest.tsx | 95 +++++++++-- .../formatDynamicFieldValueTest.ts | 28 ++++ .../getWiseBusinessOnboardingPrefillTest.ts | 132 +++++++++++++++ 36 files changed, 1455 insertions(+), 27 deletions(-) create mode 100644 src/pages/settings/Wallet/EnableGlobalReimbursements/Wise/WiseAcceptTermsPage.tsx create mode 100644 src/pages/settings/Wallet/EnableGlobalReimbursements/Wise/WiseBusinessOnboardingPage.tsx create mode 100644 src/pages/settings/Wallet/EnableGlobalReimbursements/Wise/forms/US.ts create mode 100644 src/pages/settings/Wallet/EnableGlobalReimbursements/Wise/forms/getIndustryCategoryOptions.ts create mode 100644 src/pages/settings/Wallet/EnableGlobalReimbursements/Wise/getWiseBusinessOnboardingPrefill.ts create mode 100644 tests/navigation/wiseBusinessOnboardingDynamicRouteTest.ts create mode 100644 tests/ui/pages/settings/Wallet/WiseAcceptTermsPageTest.tsx create mode 100644 tests/ui/pages/settings/Wallet/WiseBusinessOnboardingPageTest.tsx create mode 100644 tests/unit/components/DynamicForm/formatDynamicFieldValueTest.ts create mode 100644 tests/unit/pages/settings/Wallet/EnableGlobalReimbursements/getWiseBusinessOnboardingPrefillTest.ts diff --git a/src/CONST/index.ts b/src/CONST/index.ts index b89caed8b868..1f8cd2bf7c2c 100644 --- a/src/CONST/index.ts +++ b/src/CONST/index.ts @@ -1003,6 +1003,10 @@ const CONST = { CORPAY: 'CORPAY', }, WISE: { + /** Wise's legal pages, linked from the terms page of the onboarding */ + TERMS_URL: 'https://wise.com/terms-and-conditions', + PRIVACY_URL: 'https://wise.com/privacy-policy', + /** Server-derived state of the Wise onboarding */ ONBOARDING_STATUS: { IN_REVIEW: 'IN_REVIEW', diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 907e4e98a20f..7b22060f52b5 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -232,6 +232,15 @@ const DYNAMIC_ROUTES = { entryScreens: [SCREENS.SETTINGS.WALLET.ROOT, SCREENS.WORKSPACE.WORKFLOWS], getRoute: (bankAccountID: number | undefined) => `global-reimbursements/${bankAccountID}` as const, }, + WISE_BUSINESS_ONBOARDING: { + path: 'business-onboarding/:subPage?/:action?', + entryScreens: [SCREENS.SETTINGS.WALLET.DYNAMIC_WISE_GLOBAL_REIMBURSEMENTS_INTRO], + getRoute: (subPage?: string, action?: 'edit') => `business-onboarding${subPage ? `/${subPage}` : ''}${subPage && action ? `/${action}` : ''}` as const, + }, + WISE_ACCEPT_TERMS: { + path: 'accept-terms', + entryScreens: [SCREENS.SETTINGS.WALLET.DYNAMIC_WISE_BUSINESS_ONBOARDING], + }, BANK_ACCOUNT_VERIFY_ACCOUNT: { path: 'verify-bank-account', entryScreens: [SCREENS.REIMBURSEMENT_ACCOUNT], diff --git a/src/SCREENS.ts b/src/SCREENS.ts index e98c70277973..f8ec882ae881 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -210,6 +210,8 @@ const SCREENS = { SHARE_BANK_ACCOUNT: 'Settings_Wallet_Share_Bank_Account', EDIT_BANK_ACCOUNT_NICKNAME: 'Settings_Wallet_Edit_Bank_Account_Nickname', DYNAMIC_WISE_GLOBAL_REIMBURSEMENTS_INTRO: 'Dynamic_Settings_Wallet_Wise_Global_Reimbursements_Intro', + DYNAMIC_WISE_BUSINESS_ONBOARDING: 'Dynamic_Settings_Wallet_Wise_Business_Onboarding', + DYNAMIC_WISE_ACCEPT_TERMS: 'Dynamic_Settings_Wallet_Wise_Accept_Terms', TRAVEL_CVV: 'Settings_Wallet_Travel_CVV', TRAVEL_CVV_VERIFY_ACCOUNT: 'Settings_Wallet_Travel_CVV_VerifyAccount', PERSONAL_CARD_DETAILS: 'Settings_Wallet_Personal_Card_Details', diff --git a/src/components/DynamicForm/index.tsx b/src/components/DynamicForm/index.tsx index 380be536fda2..a7f1a4bcff34 100644 --- a/src/components/DynamicForm/index.tsx +++ b/src/components/DynamicForm/index.tsx @@ -1,5 +1,6 @@ import ActivityIndicator from '@components/ActivityIndicator'; +import useAndroidBackButtonHandler from '@hooks/useAndroidBackButtonHandler'; import useLocalize from '@hooks/useLocalize'; import useOnyx from '@hooks/useOnyx'; import useSubPage from '@hooks/useSubPage'; @@ -13,6 +14,7 @@ import {clearSensitiveAnswers, forgetSensitiveAnswers, saveDraftAnswers, saveSen import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import type {DynamicFormListField, DynamicFormListItem, DynamicFormPage} from '@src/types/onyx'; +import {isEmptyObject} from '@src/types/utils/EmptyObject'; import isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue'; import {Str} from 'expensify-common'; @@ -154,6 +156,14 @@ function DynamicFormFlow({ clearSensitiveAnswers(formID); }, [isRedirecting, formID]); + // A visit that opens without a page waits for the earlier visit's sensitive answers to be gone, so no input starts from them. The flow can be left without + // its own Back, such as by a swipe back, which leaves them in memory. + const hasSensitiveAnswers = !isEmptyObject(sensitiveAnswersByForm?.[formID]); + const [isClearingEarlierVisit, setIsClearingEarlierVisit] = useState(isRedirecting); + if (isClearingEarlierVisit && !hasSensitiveAnswers) { + setIsClearingEarlierVisit(false); + } + // A submission that finishes without an error drops the sensitive answers const wasSubmittingRef = useRef(false); useEffect(() => { @@ -292,6 +302,12 @@ function DynamicFormFlow({ prevPage(); }; + // A flow on replaced routes has no page stack for Android's back to pop, so it takes the header's steps + useAndroidBackButtonHandler(() => { + goBack(); + return true; + }); + // An entry editor highlights its list's step, and the confirmation page the last one const stepPage = shownPages.find((page) => page.key === currentPageName) ?? (listItemPage && findListPage(listItemPage.listKey)); // The indicator draws no names and keys its steps by them, so the unique page keys stand in for titles an untitled page does not have @@ -314,7 +330,7 @@ function DynamicFormFlow({ stepIndex={stepIndex} shouldShowStepIndicator={isStepIndicatorAsked && stepNames.length > 1} > - {isDraftLoading || isRedirecting || isOnUnavailablePage || (!hasPageToShow && pages.length > 0) ? ( + {isDraftLoading || isRedirecting || isClearingEarlierVisit || isOnUnavailablePage || (!hasPageToShow && pages.length > 0) ? ( diff --git a/src/components/DynamicForm/renderers/textRenderers.tsx b/src/components/DynamicForm/renderers/textRenderers.tsx index 7a240126b953..59debed17733 100644 --- a/src/components/DynamicForm/renderers/textRenderers.tsx +++ b/src/components/DynamicForm/renderers/textRenderers.tsx @@ -9,6 +9,8 @@ import TextInput from '@components/TextInput'; import getTextInputAutocorrectProps from '@libs/getTextInputAutocorrectProps'; +import variables from '@styles/variables'; + import CONST from '@src/CONST'; import type {DynamicFormNumberField, DynamicFormTextField} from '@src/types/onyx'; @@ -61,6 +63,7 @@ function renderTextInput( inputMode={inputMode} multiline={isMultiline} autoGrowHeight={isMultiline} + maxAutoGrowHeight={isMultiline ? variables.textInputAutoGrowMaxHeight : undefined} {...(isMultiline ? {} : getTextInputAutocorrectProps())} /> ), diff --git a/src/components/DynamicForm/utils/formatDynamicFieldValue.ts b/src/components/DynamicForm/utils/formatDynamicFieldValue.ts index 28692b0875ad..84844b87da30 100644 --- a/src/components/DynamicForm/utils/formatDynamicFieldValue.ts +++ b/src/components/DynamicForm/utils/formatDynamicFieldValue.ts @@ -55,6 +55,9 @@ function formatDynamicFieldValue(field: DynamicFormField, values: DynamicFormVal return `${answer}%`; case 'address': return formatAddress(field.key, values, translate); + case 'text': + // A row shows one line, so a multiline answer is joined into it, which also gives a cut answer its ellipsis + return field.multiline ? answer.replaceAll(/\s*\r?\n\s*/g, ' ').trim() : answer; default: return answer; } diff --git a/src/languages/de.ts b/src/languages/de.ts index b266179670b7..f618428ce25d 100644 --- a/src/languages/de.ts +++ b/src/languages/de.ts @@ -2851,6 +2851,39 @@ const translations: TranslationDeepObject = { accountRequiresAttention: 'Dieses Konto erfordert Ihre Aufmerksamkeit', unlock: 'Entsperren', }, + wiseOnboarding: { + confirmationTitle: 'Lassen Sie uns prüfen, ob alles stimmt', + representative: { + title: 'Wir benötigen einige Angaben von Ihnen', + description: 'Wir sind verpflichtet, diese Informationen zur Zahlungsabwicklung zu erheben.', + legalFirstName: 'Rechtlicher Vorname', + legalLastName: 'Rechtlicher Nachname', + ssn: 'Sozialversicherungsnummer oder ITIN', + idDocument: 'Identitätsprüfung', + idDocumentDescription: 'Bitte laden Sie einen amtlichen Ausweis hoch.', + }, + business: { + title: 'Geben Sie Ihre Unternehmensdaten ein', + legalName: 'Rechtlicher Firmenname', + companyRole: 'Ihre Rolle im Unternehmen', + companyRoleOwner: 'Eigentümer', + companyRoleDirector: 'Geschäftsführer', + companyRoleOther: 'Sonstiges', + industryCategories: 'Branchenkategorie', + description: 'Unternehmensbeschreibung', + descriptionHint: 'Beschreiben Sie kurz, was Ihr Unternehmen macht.', + }, + terms: { + title: 'Bedingungen akzeptieren', + subtitle: 'Bitte akzeptieren Sie die folgenden Bedingungen.', + certify: 'Ich bestätige, dass meine Angaben wahr und korrekt sind.', + expensifyTerms: `Ich stimme den Allgemeinen Geschäftsbedingungen und der Datenschutzerklärung von Expensify zu.`, + expensifyTermsAccessibilityLabel: 'Ich stimme den Allgemeinen Geschäftsbedingungen und der Datenschutzerklärung von Expensify zu.', + wiseTerms: `Ich stimme den Allgemeinen Geschäftsbedingungen und der Datenschutzerklärung von Wise zu.`, + wiseTermsAccessibilityLabel: 'Ich stimme den Allgemeinen Geschäftsbedingungen und der Datenschutzerklärung von Wise zu.', + error: 'Bitte akzeptieren Sie alle Bedingungen, um fortzufahren.', + }, + }, wiseGlobalReimbursementsIntro: { title: 'Globale Rückerstattungen einrichten?', subtitle: 'Zahlen Sie Mitglieder weltweit in ihrer lokalen Währung.', diff --git a/src/languages/el.ts b/src/languages/el.ts index 91e95965f360..d0037df85b3e 100644 --- a/src/languages/el.ts +++ b/src/languages/el.ts @@ -2907,6 +2907,39 @@ const translations: TranslationDeepObject = { accountRequiresAttention: 'Αυτός ο λογαριασμός χρειάζεται προσοχή', unlock: 'Ξεκλείδωμα', }, + wiseOnboarding: { + confirmationTitle: 'Ας ελέγξουμε ότι όλα είναι σωστά', + representative: { + title: 'Χρειαζόμαστε μερικά στοιχεία σας', + description: 'Είμαστε υποχρεωμένοι να συλλέξουμε αυτές τις πληροφορίες για την επεξεργασία πληρωμών.', + legalFirstName: 'Επίσημο μικρό όνομα', + legalLastName: 'Νόμιμο επώνυμο', + ssn: 'Αριθμός κοινωνικής ασφάλισης ή ITIN', + idDocument: 'Επαλήθευση ταυτότητας', + idDocumentDescription: 'Ανεβάστε ένα επίσημο έγγραφο ταυτότητας.', + }, + business: { + title: 'Εισαγάγετε τα στοιχεία της επιχείρησής σας', + legalName: 'Επίσημη επωνυμία επιχείρησης', + companyRole: 'Ο ρόλος σας στην εταιρεία', + companyRoleOwner: 'Ιδιοκτήτης', + companyRoleDirector: 'Διευθυντής', + companyRoleOther: 'Άλλο', + industryCategories: 'Κατηγορία κλάδου', + description: 'Περιγραφή επιχείρησης', + descriptionHint: 'Περιγράψτε σύντομα τι κάνει η εταιρεία σας.', + }, + terms: { + title: 'Αποδοχή όρων', + subtitle: 'Αποδεχτείτε τους παρακάτω όρους.', + certify: 'Βεβαιώνω ότι οι πληροφορίες που έδωσα είναι αληθείς και ακριβείς.', + expensifyTerms: `Αποδέχομαι τους όρους και προϋποθέσεις και την πολιτική απορρήτου της Expensify.`, + expensifyTermsAccessibilityLabel: 'Αποδέχομαι τους όρους και προϋποθέσεις και την πολιτική απορρήτου της Expensify.', + wiseTerms: `Αποδέχομαι τους όρους και προϋποθέσεις και την πολιτική απορρήτου της Wise.`, + wiseTermsAccessibilityLabel: 'Αποδέχομαι τους όρους και προϋποθέσεις και την πολιτική απορρήτου της Wise.', + error: 'Αποδεχτείτε όλους τους όρους για να συνεχίσετε.', + }, + }, wiseGlobalReimbursementsIntro: { title: 'Να ρυθμιστούν οι παγκόσμιες αποζημιώσεις;', subtitle: 'Πληρώστε μέλη παγκοσμίως στο τοπικό τους νόμισμα.', diff --git a/src/languages/en.ts b/src/languages/en.ts index 62f0a9fde7b5..cfae29e89cde 100644 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2927,6 +2927,40 @@ const translations = { editNickname: 'Edit nickname', nickname: 'Nickname', editNicknameInstruction: 'Give the bank account a nickname that sets it apart from others.', + wiseOnboarding: { + confirmationTitle: "Let's double check that everything looks right", + representative: { + title: 'We need some details from you', + description: "We're required to collect this information to process payments.", + legalFirstName: 'Legal first name', + legalLastName: 'Legal last name', + // @context US Social Security Number, not a national ID of the reader's country. + ssn: 'Social Security Number or ITIN', + idDocument: 'ID verification', + idDocumentDescription: 'Please upload a government-issued ID.', + }, + business: { + title: 'Enter your business info', + legalName: 'Legal business name', + companyRole: 'Your role at the company', + companyRoleOwner: 'Owner', + companyRoleDirector: 'Director', + companyRoleOther: 'Other', + industryCategories: 'Industry category', + description: 'Business description', + descriptionHint: 'Briefly describe what your company does.', + }, + terms: { + title: 'Accept terms', + subtitle: 'Please accept the terms below.', + certify: "I certify that the information I've provided is true and accurate.", + expensifyTerms: `I agree to the Expensify terms and conditions and privacy policy.`, + expensifyTermsAccessibilityLabel: 'I agree to the Expensify terms and conditions and privacy policy.', + wiseTerms: `I agree to the Wise terms and conditions and privacy policy.`, + wiseTermsAccessibilityLabel: 'I agree to the Wise terms and conditions and privacy policy.', + error: 'Please accept all of the terms to continue.', + }, + }, wiseGlobalReimbursementsIntro: { headerTitle: 'Global reimbursements', title: 'Set up global reimbursements?', diff --git a/src/languages/es.ts b/src/languages/es.ts index 3a2419adfe53..461bf4f4f196 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2756,6 +2756,39 @@ const translations: TranslationDeepObject = { accountRequiresAttention: 'Esta cuenta requiere atención', unlock: 'Desbloquear', }, + wiseOnboarding: { + confirmationTitle: 'Comprobemos que todo esté correcto', + representative: { + title: 'Necesitamos algunos datos tuyos', + description: 'Debemos recopilar esta información para procesar pagos.', + legalFirstName: 'Nombre legal', + legalLastName: 'Apellidos legales', + ssn: 'Número de seguro social o ITIN', + idDocument: 'Verificación de identidad', + idDocumentDescription: 'Sube un documento de identidad oficial.', + }, + business: { + title: 'Introduce los datos de tu empresa', + legalName: 'Razón social', + companyRole: 'Tu cargo en la empresa', + companyRoleOwner: 'Propietario', + companyRoleDirector: 'Director', + companyRoleOther: 'Otro', + industryCategories: 'Categoría del sector', + description: 'Descripción de la empresa', + descriptionHint: 'Describe brevemente a qué se dedica tu empresa.', + }, + terms: { + title: 'Aceptar términos', + subtitle: 'Acepta los términos a continuación.', + certify: 'Certifico que la información que he proporcionado es verdadera y exacta.', + expensifyTerms: `Acepto los términos y condiciones y la política de privacidad de Expensify.`, + expensifyTermsAccessibilityLabel: 'Acepto los términos y condiciones y la política de privacidad de Expensify.', + wiseTerms: `Acepto los términos y condiciones y la política de privacidad de Wise.`, + wiseTermsAccessibilityLabel: 'Acepto los términos y condiciones y la política de privacidad de Wise.', + error: 'Acepta todos los términos para continuar.', + }, + }, wiseGlobalReimbursementsIntro: { title: '¿Configurar reembolsos globales?', subtitle: 'Paga a miembros de todo el mundo en su moneda local.', diff --git a/src/languages/fr.ts b/src/languages/fr.ts index 82e02b34e51a..e6f9332437df 100644 --- a/src/languages/fr.ts +++ b/src/languages/fr.ts @@ -2856,6 +2856,39 @@ const translations: TranslationDeepObject = { accountRequiresAttention: 'Ce compte nécessite une attention particulière', unlock: 'Déverrouiller', }, + wiseOnboarding: { + confirmationTitle: 'Vérifions que tout est correct', + representative: { + title: 'Nous avons besoin de quelques informations', + description: 'Nous sommes tenus de recueillir ces informations pour traiter les paiements.', + legalFirstName: 'Prénom légal', + legalLastName: 'Nom de famille légal', + ssn: 'Numéro de sécurité sociale ou ITIN', + idDocument: 'Vérification d’identité', + idDocumentDescription: 'Veuillez téléverser une pièce d’identité officielle.', + }, + business: { + title: 'Saisissez les informations de votre entreprise', + legalName: 'Raison sociale', + companyRole: 'Votre rôle dans l’entreprise', + companyRoleOwner: 'Propriétaire', + companyRoleDirector: 'Directeur', + companyRoleOther: 'Autre', + industryCategories: 'Secteur d’activité', + description: 'Description de l’entreprise', + descriptionHint: 'Décrivez brièvement ce que fait votre entreprise.', + }, + terms: { + title: 'Accepter les conditions', + subtitle: 'Veuillez accepter les conditions ci-dessous.', + certify: 'Je certifie que les informations fournies sont exactes et véridiques.', + expensifyTerms: `J’accepte les conditions générales et la politique de confidentialité d’Expensify.`, + expensifyTermsAccessibilityLabel: 'J’accepte les conditions générales et la politique de confidentialité d’Expensify.', + wiseTerms: `J’accepte les conditions générales et la politique de confidentialité de Wise.`, + wiseTermsAccessibilityLabel: 'J’accepte les conditions générales et la politique de confidentialité de Wise.', + error: 'Veuillez accepter toutes les conditions pour continuer.', + }, + }, wiseGlobalReimbursementsIntro: { title: 'Configurer les remboursements globaux ?', subtitle: 'Payez des membres partout dans le monde dans leur devise locale.', diff --git a/src/languages/it.ts b/src/languages/it.ts index 8cc08900cd31..d12d388ee2e1 100644 --- a/src/languages/it.ts +++ b/src/languages/it.ts @@ -2840,6 +2840,39 @@ const translations: TranslationDeepObject = { accountRequiresAttention: 'Questo conto richiede attenzione', unlock: 'Sblocca', }, + wiseOnboarding: { + confirmationTitle: 'Verifichiamo che sia tutto corretto', + representative: { + title: 'Ci servono alcuni dati', + description: 'Siamo tenuti a raccogliere queste informazioni per elaborare i pagamenti.', + legalFirstName: 'Nome legale', + legalLastName: 'Cognome legale', + ssn: 'Numero di previdenza sociale o ITIN', + idDocument: "Verifica dell'identità", + idDocumentDescription: "Carica un documento d'identità ufficiale.", + }, + business: { + title: "Inserisci i dati dell'azienda", + legalName: 'Ragione sociale', + companyRole: "Il tuo ruolo nell'azienda", + companyRoleOwner: 'Titolare', + companyRoleDirector: 'Amministratore', + companyRoleOther: 'Altro', + industryCategories: 'Categoria di settore', + description: "Descrizione dell'azienda", + descriptionHint: 'Descrivi brevemente di cosa si occupa la tua azienda.', + }, + terms: { + title: 'Accetta i termini', + subtitle: 'Accetta i termini riportati di seguito.', + certify: 'Certifico che le informazioni fornite sono vere e accurate.', + expensifyTerms: `Accetto i termini e condizioni e l’informativa sulla privacy di Expensify.`, + expensifyTermsAccessibilityLabel: 'Accetto i termini e condizioni e l’informativa sulla privacy di Expensify.', + wiseTerms: `Accetto i termini e condizioni e l’informativa sulla privacy di Wise.`, + wiseTermsAccessibilityLabel: 'Accetto i termini e condizioni e l’informativa sulla privacy di Wise.', + error: 'Accetta tutti i termini per continuare.', + }, + }, wiseGlobalReimbursementsIntro: { title: 'Configurare i rimborsi globali?', subtitle: 'Paga i membri in tutto il mondo nella loro valuta locale.', diff --git a/src/languages/ja.ts b/src/languages/ja.ts index f40ef600826f..feb4a691a9ae 100644 --- a/src/languages/ja.ts +++ b/src/languages/ja.ts @@ -2819,6 +2819,39 @@ const translations: TranslationDeepObject = { accountRequiresAttention: 'このアカウントには対応が必要です', unlock: 'ロック解除', }, + wiseOnboarding: { + confirmationTitle: '内容に間違いがないか確認しましょう', + representative: { + title: 'あなたの情報が必要です', + description: '支払いを処理するため、この情報の収集が義務付けられています。', + legalFirstName: '法的な名', + legalLastName: '法的な姓', + ssn: '社会保障番号またはITIN', + idDocument: '本人確認', + idDocumentDescription: '政府発行の身分証明書をアップロードしてください。', + }, + business: { + title: '会社情報を入力', + legalName: '正式な会社名', + companyRole: '会社でのあなたの役割', + companyRoleOwner: 'オーナー', + companyRoleDirector: '取締役', + companyRoleOther: 'その他', + industryCategories: '業種カテゴリー', + description: '事業内容', + descriptionHint: '会社の事業内容を簡単に説明してください。', + }, + terms: { + title: '規約に同意', + subtitle: '以下の規約に同意してください。', + certify: '提供した情報が真実かつ正確であることを証明します。', + expensifyTerms: `Expensifyの利用規約およびプライバシーポリシーに同意します。`, + expensifyTermsAccessibilityLabel: 'Expensifyの利用規約およびプライバシーポリシーに同意します。', + wiseTerms: `Wiseの利用規約およびプライバシーポリシーに同意します。`, + wiseTermsAccessibilityLabel: 'Wiseの利用規約およびプライバシーポリシーに同意します。', + error: '続行するにはすべての規約に同意してください。', + }, + }, wiseGlobalReimbursementsIntro: { title: 'グローバル払い戻しを設定しますか?', subtitle: '世界中のメンバーに現地通貨で支払えます。', diff --git a/src/languages/nl.ts b/src/languages/nl.ts index 56739889131c..b91dbeae9f31 100644 --- a/src/languages/nl.ts +++ b/src/languages/nl.ts @@ -2844,6 +2844,39 @@ const translations: TranslationDeepObject = { accountRequiresAttention: 'Deze account vereist aandacht', unlock: 'Ontgrendelen', }, + wiseOnboarding: { + confirmationTitle: 'Laten we controleren of alles klopt', + representative: { + title: 'We hebben wat gegevens van je nodig', + description: 'We zijn verplicht deze informatie te verzamelen om betalingen te verwerken.', + legalFirstName: 'Wettelijke voornaam', + legalLastName: 'Wettelijke achternaam', + ssn: 'Amerikaans Social Security Number (SSN) of ITIN', + idDocument: 'Identiteitsverificatie', + idDocumentDescription: 'Upload een officieel identiteitsbewijs.', + }, + business: { + title: 'Voer je bedrijfsgegevens in', + legalName: 'Wettelijke bedrijfsnaam', + companyRole: 'Je rol in het bedrijf', + companyRoleOwner: 'Eigenaar', + companyRoleDirector: 'Directeur', + companyRoleOther: 'Overig', + industryCategories: 'Branchecategorie', + description: 'Bedrijfsomschrijving', + descriptionHint: 'Beschrijf kort wat je bedrijf doet.', + }, + terms: { + title: 'Voorwaarden accepteren', + subtitle: 'Accepteer de onderstaande voorwaarden.', + certify: 'Ik verklaar dat de door mij verstrekte informatie waar en juist is.', + expensifyTerms: `Ik ga akkoord met de algemene voorwaarden en het privacybeleid van Expensify.`, + expensifyTermsAccessibilityLabel: 'Ik ga akkoord met de algemene voorwaarden en het privacybeleid van Expensify.', + wiseTerms: `Ik ga akkoord met de algemene voorwaarden en het privacybeleid van Wise.`, + wiseTermsAccessibilityLabel: 'Ik ga akkoord met de algemene voorwaarden en het privacybeleid van Wise.', + error: 'Accepteer alle voorwaarden om door te gaan.', + }, + }, wiseGlobalReimbursementsIntro: { title: 'Wereldwijde terugbetalingen instellen?', subtitle: 'Betaal leden wereldwijd in hun eigen lokale valuta.', diff --git a/src/languages/pl.ts b/src/languages/pl.ts index 7fbe47811243..ffb8c9049428 100644 --- a/src/languages/pl.ts +++ b/src/languages/pl.ts @@ -2878,6 +2878,39 @@ const translations: TranslationDeepObject = { accountRequiresAttention: 'To konto wymaga uwagi', unlock: 'Odblokuj', }, + wiseOnboarding: { + confirmationTitle: 'Sprawdźmy, czy wszystko się zgadza', + representative: { + title: 'Potrzebujemy kilku informacji', + description: 'Musimy zebrać te informacje, aby przetwarzać płatności.', + legalFirstName: 'Imię (zgodnie z dokumentem tożsamości)', + legalLastName: 'Nazwisko zgodne z dokumentami', + ssn: 'Numer ubezpieczenia społecznego lub ITIN', + idDocument: 'Weryfikacja tożsamości', + idDocumentDescription: 'Prześlij urzędowy dokument tożsamości.', + }, + business: { + title: 'Wpisz dane firmy', + legalName: 'Prawna nazwa firmy', + companyRole: 'Twoja rola w firmie', + companyRoleOwner: 'Właściciel', + companyRoleDirector: 'Członek zarządu', + companyRoleOther: 'Inna', + industryCategories: 'Kategoria branży', + description: 'Opis działalności', + descriptionHint: 'Krótko opisz, czym zajmuje się Twoja firma.', + }, + terms: { + title: 'Akceptacja warunków', + subtitle: 'Zaakceptuj poniższe warunki.', + certify: 'Oświadczam, że podane przeze mnie informacje są prawdziwe i dokładne.', + expensifyTerms: `Akceptuję regulamin i politykę prywatności Expensify.`, + expensifyTermsAccessibilityLabel: 'Akceptuję regulamin i politykę prywatności Expensify.', + wiseTerms: `Akceptuję regulamin i politykę prywatności Wise.`, + wiseTermsAccessibilityLabel: 'Akceptuję regulamin i politykę prywatności Wise.', + error: 'Zaakceptuj wszystkie warunki, aby kontynuować.', + }, + }, wiseGlobalReimbursementsIntro: { title: 'Skonfigurować globalne zwroty kosztów?', subtitle: 'Płać członkom na całym świecie w ich lokalnej walucie.', diff --git a/src/languages/pt-BR.ts b/src/languages/pt-BR.ts index 374f235d7f7b..f6a52e3a9240 100644 --- a/src/languages/pt-BR.ts +++ b/src/languages/pt-BR.ts @@ -2835,6 +2835,39 @@ const translations: TranslationDeepObject = { accountRequiresAttention: 'Esta conta precisa de atenção', unlock: 'Desbloquear', }, + wiseOnboarding: { + confirmationTitle: 'Vamos conferir se está tudo certo', + representative: { + title: 'Precisamos de alguns dados seus', + description: 'Somos obrigados a coletar essas informações para processar pagamentos.', + legalFirstName: 'Primeiro nome legal', + legalLastName: 'Sobrenome legal', + ssn: 'Número do seguro social ou ITIN', + idDocument: 'Verificação de identidade', + idDocumentDescription: 'Envie um documento de identidade oficial.', + }, + business: { + title: 'Informe os dados da sua empresa', + legalName: 'Razão social', + companyRole: 'Sua função na empresa', + companyRoleOwner: 'Proprietário', + companyRoleDirector: 'Diretor', + companyRoleOther: 'Outro', + industryCategories: 'Categoria do setor', + description: 'Descrição da empresa', + descriptionHint: 'Descreva brevemente o que sua empresa faz.', + }, + terms: { + title: 'Aceitar termos', + subtitle: 'Aceite os termos abaixo.', + certify: 'Certifico que as informações fornecidas são verdadeiras e precisas.', + expensifyTerms: `Concordo com os termos e condições e a política de privacidade da Expensify.`, + expensifyTermsAccessibilityLabel: 'Concordo com os termos e condições e a política de privacidade da Expensify.', + wiseTerms: `Concordo com os termos e condições e a política de privacidade da Wise.`, + wiseTermsAccessibilityLabel: 'Concordo com os termos e condições e a política de privacidade da Wise.', + error: 'Aceite todos os termos para continuar.', + }, + }, wiseGlobalReimbursementsIntro: { title: 'Configurar reembolsos globais?', subtitle: 'Pague membros no mundo todo na moeda local deles.', diff --git a/src/languages/zh-hans.ts b/src/languages/zh-hans.ts index 49d479d6153d..919da03b230c 100644 --- a/src/languages/zh-hans.ts +++ b/src/languages/zh-hans.ts @@ -2745,6 +2745,39 @@ const translations: TranslationDeepObject = { accountRequiresAttention: '此账户需要处理', unlock: '解锁', }, + wiseOnboarding: { + confirmationTitle: '请确认所有信息无误', + representative: { + title: '我们需要您的一些信息', + description: '为处理付款,我们必须收集这些信息。', + legalFirstName: '法定名字', + legalLastName: '法定姓氏', + ssn: '社会安全号码或 ITIN', + idDocument: '身份验证', + idDocumentDescription: '请上传政府签发的身份证件。', + }, + business: { + title: '输入您的企业信息', + legalName: '企业法定名称', + companyRole: '您在公司的职位', + companyRoleOwner: '所有者', + companyRoleDirector: '董事', + companyRoleOther: '其他', + industryCategories: '行业类别', + description: '企业描述', + descriptionHint: '简要描述贵公司的业务。', + }, + terms: { + title: '接受条款', + subtitle: '请接受以下条款。', + certify: '我确认所提供的信息真实准确。', + expensifyTerms: `我同意 Expensify 的条款和条件以及隐私政策。`, + expensifyTermsAccessibilityLabel: '我同意 Expensify 的条款和条件以及隐私政策。', + wiseTerms: `我同意 Wise 的条款和条件以及隐私政策。`, + wiseTermsAccessibilityLabel: '我同意 Wise 的条款和条件以及隐私政策。', + error: '请接受所有条款以继续。', + }, + }, wiseGlobalReimbursementsIntro: {title: '设置全球报销?', subtitle: '按当地货币向全球成员付款。', getStarted: '开始使用', headerTitle: '全球报销'}, wiseGlobalReimbursementsBanner: {title: '向全球付款', subtitle: '在您的美元账户中启用全球报销。'}, }, diff --git a/src/libs/CountryUtils.ts b/src/libs/CountryUtils.ts index cc4d6a2c3279..59fc4efdc5b7 100644 --- a/src/libs/CountryUtils.ts +++ b/src/libs/CountryUtils.ts @@ -3,6 +3,8 @@ import type {Country} from '@src/CONST'; import type {PersonalDetailsForm} from '@src/types/form'; import type {Address} from '@src/types/onyx/PrivatePersonalDetails'; +import {CONST as COMMON_CONST} from 'expensify-common'; + type AddressType = PersonalDetailsForm | Address | undefined; /** @@ -36,4 +38,13 @@ function getCountryCode(countryValue: string | undefined): Country | undefined { return countryValue as Country | undefined; } -export {normalizeCountryCode, getCountryCode}; +// StateSelector keys on 2-letter codes, but stored addresses may use full state names (e.g. "California"). +function resolveStateCode(stateValue: string): string { + if (!stateValue || stateValue in COMMON_CONST.STATES) { + return stateValue; + } + const match = Object.entries(COMMON_CONST.STATES).find(([, v]) => v.stateName.toLowerCase() === stateValue.toLowerCase()); + return match ? match[0] : stateValue; +} + +export {normalizeCountryCode, getCountryCode, resolveStateCode}; diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index 814d0b8e6453..feca566ed7dc 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -499,6 +499,9 @@ const SettingsModalStackNavigator = createModalStackNavigator require('../../../../pages/settings/Wallet/ShareBankAccount/ShareBankAccount').default, [SCREENS.SETTINGS.WALLET.EDIT_BANK_ACCOUNT_NICKNAME]: () => require('../../../../pages/settings/Wallet/EditBankAccountNicknamePage').default, [SCREENS.SETTINGS.WALLET.DYNAMIC_WISE_GLOBAL_REIMBURSEMENTS_INTRO]: () => require('../../../../pages/settings/Wallet/WiseGlobalReimbursementsIntroPage').default, + [SCREENS.SETTINGS.WALLET.DYNAMIC_WISE_BUSINESS_ONBOARDING]: () => + require('../../../../pages/settings/Wallet/EnableGlobalReimbursements/Wise/WiseBusinessOnboardingPage').default, + [SCREENS.SETTINGS.WALLET.DYNAMIC_WISE_ACCEPT_TERMS]: () => require('../../../../pages/settings/Wallet/EnableGlobalReimbursements/Wise/WiseAcceptTermsPage').default, [SCREENS.SETTINGS.WALLET.TRAVEL_CVV]: () => require('../../../../pages/settings/Wallet/TravelCVVPage/TravelCVVPage').default, [SCREENS.SETTINGS.WALLET.TRAVEL_CVV_VERIFY_ACCOUNT]: () => require('../../../../pages/settings/Wallet/TravelCVVPage/TravelCVVVerifyAccountPage').default, [SCREENS.SETTINGS.WALLET.PERSONAL_CARD_FIX_CONNECTION]: () => require('@pages/settings/Wallet/PersonalCards/FixPersonalCardConnectionPage').default, diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index bc2ad27fa393..1aaec6b5d7ab 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -261,6 +261,8 @@ const config: LinkingOptions['config'] = { exact: true, }, [SCREENS.SETTINGS.WALLET.DYNAMIC_WISE_GLOBAL_REIMBURSEMENTS_INTRO]: DYNAMIC_ROUTES.WISE_GLOBAL_REIMBURSEMENTS_INTRO.path, + [SCREENS.SETTINGS.WALLET.DYNAMIC_WISE_BUSINESS_ONBOARDING]: DYNAMIC_ROUTES.WISE_BUSINESS_ONBOARDING.path, + [SCREENS.SETTINGS.WALLET.DYNAMIC_WISE_ACCEPT_TERMS]: DYNAMIC_ROUTES.WISE_ACCEPT_TERMS.path, [SCREENS.SETTINGS.WALLET.EDIT_BANK_ACCOUNT_NICKNAME]: { path: ROUTES.SETTINGS_WALLET_EDIT_BANK_ACCOUNT_NICKNAME.route, exact: true, diff --git a/src/libs/Navigation/paramLists/AccountSettingsParamList.ts b/src/libs/Navigation/paramLists/AccountSettingsParamList.ts index 6def8fbda1c3..0a8e11fc36e9 100644 --- a/src/libs/Navigation/paramLists/AccountSettingsParamList.ts +++ b/src/libs/Navigation/paramLists/AccountSettingsParamList.ts @@ -187,6 +187,14 @@ type AccountSettingsParamList = { [SCREENS.SETTINGS.WALLET.DYNAMIC_WISE_GLOBAL_REIMBURSEMENTS_INTRO]: { bankAccountID: string; }; + [SCREENS.SETTINGS.WALLET.DYNAMIC_WISE_BUSINESS_ONBOARDING]: { + bankAccountID: string; + subPage?: string; + action?: 'edit'; + }; + [SCREENS.SETTINGS.WALLET.DYNAMIC_WISE_ACCEPT_TERMS]: { + bankAccountID: string; + }; [SCREENS.SETTINGS.WALLET.EDIT_BANK_ACCOUNT_NICKNAME]: { bankAccountID: string; }; diff --git a/src/pages/settings/Profile/PersonalDetails/PrivatePersonalDetailsPage.tsx b/src/pages/settings/Profile/PersonalDetails/PrivatePersonalDetailsPage.tsx index 6a02556b3d40..9e34278bcebf 100644 --- a/src/pages/settings/Profile/PersonalDetails/PrivatePersonalDetailsPage.tsx +++ b/src/pages/settings/Profile/PersonalDetails/PrivatePersonalDetailsPage.tsx @@ -18,7 +18,7 @@ import useOnyx from '@hooks/useOnyx'; import useThemeStyles from '@hooks/useThemeStyles'; import {clearDraftValues, setDraftValues} from '@libs/actions/FormActions'; -import {normalizeCountryCode} from '@libs/CountryUtils'; +import {normalizeCountryCode, resolveStateCode} from '@libs/CountryUtils'; import {appendCountryCode} from '@libs/LoginUtils'; import Navigation from '@libs/Navigation/Navigation'; import type {PlatformStackRouteProp} from '@libs/Navigation/PlatformStackNavigation/types'; @@ -40,15 +40,6 @@ import {CONST as COMMON_CONST} from 'expensify-common'; import React, {useEffect, useRef, useState} from 'react'; import {View} from 'react-native'; -// StateSelector keys on 2-letter codes, but stored addresses may use full state names (e.g. "California"). -function resolveStateCode(stateValue: string): string { - if (!stateValue || stateValue in COMMON_CONST.STATES) { - return stateValue; - } - const match = Object.entries(COMMON_CONST.STATES).find(([, v]) => v.stateName.toLowerCase() === stateValue.toLowerCase()); - return match ? match[0] : stateValue; -} - function PrivatePersonalDetailsPage() { const route = useRoute>(); const fieldToFocus = route.params?.fieldToFocus; diff --git a/src/pages/settings/Wallet/EnableGlobalReimbursements/Wise/WiseAcceptTermsPage.tsx b/src/pages/settings/Wallet/EnableGlobalReimbursements/Wise/WiseAcceptTermsPage.tsx new file mode 100644 index 000000000000..c43be579eca3 --- /dev/null +++ b/src/pages/settings/Wallet/EnableGlobalReimbursements/Wise/WiseAcceptTermsPage.tsx @@ -0,0 +1,134 @@ +import CheckboxWithLabel from '@components/CheckboxWithLabel'; +import FormAlertWithSubmitButton from '@components/FormAlertWithSubmitButton'; +import FullScreenLoadingIndicator from '@components/FullscreenLoadingIndicator'; +import Header from '@components/Header'; +import RenderHTML from '@components/RenderHTML'; +import ScreenWrapper from '@components/ScreenWrapper'; +import ScrollView from '@components/ScrollView'; +import Text from '@components/Text'; + +import useDynamicBackPath from '@hooks/useDynamicBackPath'; +import useLocalize from '@hooks/useLocalize'; +import usePermissions from '@hooks/usePermissions'; +import useThemeStyles from '@hooks/useThemeStyles'; + +import Navigation from '@navigation/Navigation'; + +import {clearSensitiveAnswers} from '@userActions/DynamicForm'; + +import CONST from '@src/CONST'; +import type {TranslationPaths} from '@src/languages/types'; +import ONYXKEYS from '@src/ONYXKEYS'; +import {DYNAMIC_ROUTES} from '@src/ROUTES'; + +import React, {useEffect, useState} from 'react'; +import {View} from 'react-native'; + +type TermKey = 'certify' | 'expensifyTerms' | 'wiseTerms'; + +const TERM_KEYS: TermKey[] = ['certify', 'expensifyTerms', 'wiseTerms']; + +function TermLabel({termKey}: {termKey: TermKey}) { + const {translate} = useLocalize(); + return ; +} + +function CertifyLabel() { + return ; +} + +function ExpensifyTermsLabel() { + return ; +} + +function WiseTermsLabel() { + return ; +} + +// The certify term has no links, so its text doubles as its accessibility label +const TERM_ACCESSIBILITY_LABELS = { + certify: 'walletPage.wiseOnboarding.terms.certify', + expensifyTerms: 'walletPage.wiseOnboarding.terms.expensifyTermsAccessibilityLabel', + wiseTerms: 'walletPage.wiseOnboarding.terms.wiseTermsAccessibilityLabel', +} as const satisfies Record; + +// CheckboxWithLabel takes a label component without props, so each term gets its own +const TERM_LABELS: Record React.JSX.Element> = { + certify: CertifyLabel, + expensifyTerms: ExpensifyTermsLabel, + wiseTerms: WiseTermsLabel, +}; + +/** The last page of our own onboarding, after the confirmation page. Every box is required to continue. */ +function WiseAcceptTermsPage() { + const confirmationPath = useDynamicBackPath(DYNAMIC_ROUTES.WISE_ACCEPT_TERMS.path); + const styles = useThemeStyles(); + const {translate} = useLocalize(); + const [accepted, setAccepted] = useState>({certify: false, expensifyTerms: false, wiseTerms: false}); + const [shouldShowError, setShouldShowError] = useState(false); + const {isBetaEnabledOrUnknown} = usePermissions(); + const isWiseReimbursementsBetaEnabled = isBetaEnabledOrUnknown(CONST.BETAS.WISE_REIMBURSEMENTS); + + const goBackToConfirmation = () => Navigation.goBack(confirmationPath); + + useEffect(() => { + if (isWiseReimbursementsBetaEnabled !== false) { + return; + } + goBackToConfirmation(); + }, [isWiseReimbursementsBetaEnabled, goBackToConfirmation]); + + const confirm = () => { + if (!TERM_KEYS.every((key) => accepted[key])) { + setShouldShowError(true); + return; + } + clearSensitiveAnswers(ONYXKEYS.FORMS.WISE_BUSINESS_ONBOARDING_FORM); + Navigation.dismissModal(); + }; + + if (!isWiseReimbursementsBetaEnabled) { + return ; + } + + return ( + +
+ + +
+ + {translate('walletPage.wiseOnboarding.terms.title')} + {translate('walletPage.wiseOnboarding.terms.subtitle')} + {TERM_KEYS.map((key) => ( + { + setAccepted((current) => ({...current, [key]: !!isChecked})); + setShouldShowError(false); + }} + accessibilityLabel={translate(TERM_ACCESSIBILITY_LABELS[key])} + LabelComponent={TERM_LABELS[key]} + /> + ))} + + + +
+ ); +} + +export default WiseAcceptTermsPage; diff --git a/src/pages/settings/Wallet/EnableGlobalReimbursements/Wise/WiseBusinessOnboardingPage.tsx b/src/pages/settings/Wallet/EnableGlobalReimbursements/Wise/WiseBusinessOnboardingPage.tsx new file mode 100644 index 000000000000..10aea9f945a0 --- /dev/null +++ b/src/pages/settings/Wallet/EnableGlobalReimbursements/Wise/WiseBusinessOnboardingPage.tsx @@ -0,0 +1,104 @@ +import DynamicFormFlow from '@components/DynamicForm'; +import toDynamicFormValues from '@components/DynamicForm/utils/toDynamicFormValues'; +import FullScreenLoadingIndicator from '@components/FullscreenLoadingIndicator'; + +import useDynamicBackPath from '@hooks/useDynamicBackPath'; +import useLocalize from '@hooks/useLocalize'; +import useOnyx from '@hooks/useOnyx'; +import usePermissions from '@hooks/usePermissions'; + +import {isBankAccountEligibleForGlobalReimbursements} from '@libs/BankAccountUtils'; +import createDynamicRoute from '@libs/Navigation/helpers/dynamicRoutesUtils/createDynamicRoute'; +import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types'; + +import Navigation from '@navigation/Navigation'; +import type {SettingsNavigatorParamList} from '@navigation/types'; + +import NotFoundPage from '@pages/ErrorPage/NotFoundPage'; + +import {saveDraftAnswers} from '@userActions/DynamicForm'; + +import CONST from '@src/CONST'; +import ONYXKEYS from '@src/ONYXKEYS'; +import {DYNAMIC_ROUTES} from '@src/ROUTES'; +import type SCREENS from '@src/SCREENS'; +import isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue'; + +import React, {useEffect, useState} from 'react'; + +import US from './forms/US'; +import getWiseBusinessOnboardingPrefill, {getMissingPrefill} from './getWiseBusinessOnboardingPrefill'; + +type WiseBusinessOnboardingPageProps = PlatformStackScreenProps; + +/** The business details we collect before Wise's own page: the representative, the business, and a confirmation of both */ +function WiseBusinessOnboardingPage({route}: WiseBusinessOnboardingPageProps) { + const bankAccountID = Number(route.params.bankAccountID); + const introPath = useDynamicBackPath(DYNAMIC_ROUTES.WISE_BUSINESS_ONBOARDING.path); + const [bankAccountList, bankAccountListMetadata] = useOnyx(ONYXKEYS.BANK_ACCOUNT_LIST); + const [isLoadingPaymentMethods = true] = useOnyx(ONYXKEYS.IS_LOADING_PAYMENT_METHODS); + const [privatePersonalDetails, privatePersonalDetailsMetadata] = useOnyx(ONYXKEYS.PRIVATE_PERSONAL_DETAILS); + const [draft, draftMetadata] = useOnyx(ONYXKEYS.FORMS.WISE_BUSINESS_ONBOARDING_FORM_DRAFT); + const bankAccount = bankAccountList?.[bankAccountID]; + + const {translate} = useLocalize(); + const {isBetaEnabledOrUnknown} = usePermissions(); + const isWiseReimbursementsBetaEnabled = isBetaEnabledOrUnknown(CONST.BETAS.WISE_REIMBURSEMENTS); + + const goBackToIntro = () => Navigation.goBack(introPath); + + // Close the page instead of showing "not found" when the user lacks the beta. Wait for betas to load first + useEffect(() => { + if (isWiseReimbursementsBetaEnabled !== false) { + return; + } + goBackToIntro(); + }, [isWiseReimbursementsBetaEnabled, goBackToIntro]); + + // On a cold direct link the account list can be empty until the payment-method fetch finishes, so wait for it + const isWaitingForBankAccount = !bankAccount && !!isLoadingPaymentMethods; + const isLoading = isLoadingOnyxValue(bankAccountListMetadata, privatePersonalDetailsMetadata, draftMetadata) || isWaitingForBankAccount; + // The flow's inputs read the draft once, when a page mounts, so the prefill lands in the draft before the flow renders. It runs once per visit, since + // swapping the flow for a loader later would drop an SSN the user is typing. + const [isPrefillDone, setIsPrefillDone] = useState(false); + const missingPrefill = isLoading || isPrefillDone ? {} : getMissingPrefill(getWiseBusinessOnboardingPrefill(bankAccount, privatePersonalDetails), toDynamicFormValues(draft)); + const isPrefillPending = Object.keys(missingPrefill).length > 0; + if (!isLoading && !isPrefillDone && !isPrefillPending) { + setIsPrefillDone(true); + } + + useEffect(() => { + if (!isPrefillPending) { + return; + } + saveDraftAnswers(ONYXKEYS.FORMS.WISE_BUSINESS_ONBOARDING_FORM, missingPrefill); + }, [isPrefillPending, missingPrefill]); + + if (!isPrefillDone || !isWiseReimbursementsBetaEnabled) { + return ; + } + + if (!isBankAccountEligibleForGlobalReimbursements(bankAccount?.accountData, bankAccount?.bankCurrency)) { + return ; + } + + return ( + createDynamicRoute(DYNAMIC_ROUTES.WISE_BUSINESS_ONBOARDING.getRoute(pageName, action), introPath)} + shouldReplaceRoute + onBack={goBackToIntro} + // The terms page comes after the confirmation page, so the SSN stays in memory until the terms page is done with it + isSubmitting={false} + onSubmit={() => Navigation.navigate(createDynamicRoute(DYNAMIC_ROUTES.WISE_ACCEPT_TERMS.path))} + /> + ); +} + +export default WiseBusinessOnboardingPage; diff --git a/src/pages/settings/Wallet/EnableGlobalReimbursements/Wise/forms/US.ts b/src/pages/settings/Wallet/EnableGlobalReimbursements/Wise/forms/US.ts new file mode 100644 index 000000000000..b084b8048077 --- /dev/null +++ b/src/pages/settings/Wallet/EnableGlobalReimbursements/Wise/forms/US.ts @@ -0,0 +1,67 @@ +import CONST from '@src/CONST'; +import type {DynamicFormSchema} from '@src/types/onyx'; + +import getIndustryCategoryOptions from './getIndustryCategoryOptions'; + +/** The US business onboarding form. Each page's key names the onboarding step its answers belong to. */ +const US: DynamicFormSchema = { + pages: [ + { + key: 'representative', + titleKey: 'walletPage.wiseOnboarding.representative.title', + descriptionKey: 'walletPage.wiseOnboarding.representative.description', + content: [ + {key: 'firstName', type: 'text', required: true, rule: 'legalName', labelKey: 'walletPage.wiseOnboarding.representative.legalFirstName'}, + {key: 'lastName', type: 'text', required: true, rule: 'legalName', labelKey: 'walletPage.wiseOnboarding.representative.legalLastName'}, + {key: 'phoneNumber', type: 'text', required: true, rule: 'phone', labelKey: 'common.phoneNumber'}, + {key: 'dateOfBirth', type: 'date', required: true, rule: 'dateOfBirth', labelKey: 'common.dob'}, + {key: 'address', type: 'address', required: true, labelKey: 'common.address'}, + {key: 'ssn', type: 'text', required: true, sensitive: true, regex: '^\\d{9}$', example: '123456789', labelKey: 'walletPage.wiseOnboarding.representative.ssn'}, + { + key: 'idDocument', + type: 'file', + required: true, + maxFiles: 5, + labelKey: 'walletPage.wiseOnboarding.representative.idDocument', + descriptionKey: 'walletPage.wiseOnboarding.representative.idDocumentDescription', + }, + ], + }, + { + key: 'business', + titleKey: 'walletPage.wiseOnboarding.business.title', + content: [ + {key: 'companyName', type: 'text', required: true, readonly: true, labelKey: 'walletPage.wiseOnboarding.business.legalName'}, + { + key: 'companyRole', + type: 'select', + required: true, + labelKey: 'walletPage.wiseOnboarding.business.companyRole', + values: [ + {key: CONST.WISE.COMPANY_ROLE.OWNER, labelKey: 'walletPage.wiseOnboarding.business.companyRoleOwner'}, + {key: CONST.WISE.COMPANY_ROLE.DIRECTOR, labelKey: 'walletPage.wiseOnboarding.business.companyRoleDirector'}, + {key: CONST.WISE.COMPANY_ROLE.OTHER, labelKey: 'walletPage.wiseOnboarding.business.companyRoleOther'}, + ], + }, + { + key: 'industryCategories', + type: 'multiselect', + required: true, + labelKey: 'walletPage.wiseOnboarding.business.industryCategories', + values: getIndustryCategoryOptions(), + }, + { + key: 'description', + type: 'text', + required: true, + multiline: true, + maxLength: 1000, + labelKey: 'walletPage.wiseOnboarding.business.description', + descriptionKey: 'walletPage.wiseOnboarding.business.descriptionHint', + }, + ], + }, + ], +}; + +export default US; diff --git a/src/pages/settings/Wallet/EnableGlobalReimbursements/Wise/forms/getIndustryCategoryOptions.ts b/src/pages/settings/Wallet/EnableGlobalReimbursements/Wise/forms/getIndustryCategoryOptions.ts new file mode 100644 index 000000000000..b36751f138cb --- /dev/null +++ b/src/pages/settings/Wallet/EnableGlobalReimbursements/Wise/forms/getIndustryCategoryOptions.ts @@ -0,0 +1,12 @@ +import CONST from '@src/CONST'; +import type {DynamicFormFieldOption} from '@src/types/onyx'; + +/** Wise's category names as options, labelled in plain words: SOFTWARE_DEVELOPMENT_PUBLISHING reads "Software development publishing" */ +function getIndustryCategoryOptions(): DynamicFormFieldOption[] { + return CONST.WISE.INDUSTRY_CATEGORIES.map((key) => { + const words = key.toLowerCase().replaceAll('_', ' '); + return {key, label: words.charAt(0).toUpperCase() + words.slice(1)}; + }); +} + +export default getIndustryCategoryOptions; diff --git a/src/pages/settings/Wallet/EnableGlobalReimbursements/Wise/getWiseBusinessOnboardingPrefill.ts b/src/pages/settings/Wallet/EnableGlobalReimbursements/Wise/getWiseBusinessOnboardingPrefill.ts new file mode 100644 index 000000000000..c5a20a535c47 --- /dev/null +++ b/src/pages/settings/Wallet/EnableGlobalReimbursements/Wise/getWiseBusinessOnboardingPrefill.ts @@ -0,0 +1,71 @@ +import type {DynamicFormValues} from '@components/DynamicForm/types'; +import getAddressInputKeys from '@components/DynamicForm/utils/getAddressInputKeys'; +import isCountryCode from '@components/DynamicForm/utils/isCountryCode'; + +import {getCountryCode, resolveStateCode} from '@libs/CountryUtils'; +import {getCurrentAddress, getStreetLines} from '@libs/PersonalDetailsUtils'; + +import CONST from '@src/CONST'; +import type {BankAccount, PrivatePersonalDetails} from '@src/types/onyx'; + +import type {OnyxEntry} from 'react-native-onyx'; + +import {CONST as COMMON_CONST} from 'expensify-common'; + +/** The state picker lists US states by code, so a US state that is not one is left out */ +function getStateCode(countryCode: string | undefined, state: string | undefined): string | undefined { + if (countryCode !== CONST.COUNTRY.US) { + return state; + } + const stateCode = resolveStateCode(state ?? ''); + return stateCode in COMMON_CONST.STATES ? stateCode : undefined; +} + +/** Answers the onboarding form starts with: the representative from the user's private details, and the business name from the bank account */ +function getWiseBusinessOnboardingPrefill(bankAccount: OnyxEntry, privatePersonalDetails: OnyxEntry): DynamicFormValues { + const address = getCurrentAddress(privatePersonalDetails); + const [street1, street2] = getStreetLines(address?.street); + const addressKeys = getAddressInputKeys('address'); + + // Older addresses can hold names, such as "United States" and "California", where the pickers take codes. A part that does not resolve is left for the user to pick. + const country = getCountryCode(address?.country || undefined); + const countryCode = country && isCountryCode(country) ? country : undefined; + const state = getStateCode(countryCode, address?.state); + + return { + firstName: privatePersonalDetails?.legalFirstName, + lastName: privatePersonalDetails?.legalLastName, + phoneNumber: privatePersonalDetails?.phoneNumber, + dateOfBirth: privatePersonalDetails?.dob, + [addressKeys.street]: [street1, address?.street2 ?? street2].filter(Boolean).join(', '), + [addressKeys.city]: address?.city, + [addressKeys.state]: state, + [addressKeys.zipCode]: address?.zip, + [addressKeys.country]: countryCode, + companyName: bankAccount?.accountData?.addressName, + }; +} + +/** + * The prefill answers the draft does not hold yet. A key the draft already has is the user's, even when they cleared it. + * The business name is the exception: it is a read-only row, so it follows the bank account. + */ +function getMissingPrefill(prefill: DynamicFormValues, draft: DynamicFormValues): DynamicFormValues { + const missing: DynamicFormValues = {}; + for (const [key, value] of Object.entries(prefill)) { + if (key === 'companyName') { + const companyName = value ?? ''; + if ((draft[key] ?? '') !== companyName) { + missing[key] = companyName; + } + continue; + } + if (value && draft[key] === undefined) { + missing[key] = value; + } + } + return missing; +} + +export default getWiseBusinessOnboardingPrefill; +export {getMissingPrefill}; diff --git a/src/pages/settings/Wallet/WiseGlobalReimbursementsIntroPage.tsx b/src/pages/settings/Wallet/WiseGlobalReimbursementsIntroPage.tsx index a2208077d5fd..3a0f2b326cba 100644 --- a/src/pages/settings/Wallet/WiseGlobalReimbursementsIntroPage.tsx +++ b/src/pages/settings/Wallet/WiseGlobalReimbursementsIntroPage.tsx @@ -15,6 +15,7 @@ import useThemeStyles from '@hooks/useThemeStyles'; import {dismissProductTraining} from '@libs/actions/Welcome'; import {isBankAccountEligibleForGlobalReimbursements} from '@libs/BankAccountUtils'; +import createDynamicRoute from '@libs/Navigation/helpers/dynamicRoutesUtils/createDynamicRoute'; import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types'; import Navigation from '@navigation/Navigation'; @@ -93,6 +94,7 @@ function WiseGlobalReimbursementsIntroPage({route}: WiseGlobalReimbursementsIntr // Starting onboarding for any account retires both banners for good dismissProductTraining(CONST.WISE_GLOBAL_REIMBURSEMENTS_WALLET_BANNER); dismissProductTraining(CONST.WISE_GLOBAL_REIMBURSEMENTS_WORKSPACE_BANNER); + Navigation.navigate(createDynamicRoute(DYNAMIC_ROUTES.WISE_BUSINESS_ONBOARDING.getRoute())); }} /> diff --git a/tests/navigation/wiseBusinessOnboardingDynamicRouteTest.ts b/tests/navigation/wiseBusinessOnboardingDynamicRouteTest.ts new file mode 100644 index 000000000000..6a7e58faa7e9 --- /dev/null +++ b/tests/navigation/wiseBusinessOnboardingDynamicRouteTest.ts @@ -0,0 +1,99 @@ +import createDynamicRoute from '@libs/Navigation/helpers/dynamicRoutesUtils/createDynamicRoute'; +import stripDynamicRouteSuffixFromPath from '@libs/Navigation/helpers/dynamicRoutesUtils/stripDynamicRouteSuffixFromPath'; +import getStateFromPath from '@libs/Navigation/helpers/getStateFromPath'; + +import CONST from '@src/CONST'; +import ROUTES, {DYNAMIC_ROUTES} from '@src/ROUTES'; +import SCREENS from '@src/SCREENS'; + +import type {NavigationState, PartialState} from '@react-navigation/native'; + +const BANK_ACCOUNT_ID = 9053192; +const POLICY_ID = 'ABCDEF1234567890'; + +type FocusedRoute = {name?: string; params?: unknown}; + +function getFocusedRoute(state: PartialState): FocusedRoute { + let current: PartialState | undefined = state; + let route: FocusedRoute = {}; + + while (current?.routes) { + const nextRoute = current.routes.at(current.index ?? current.routes.length - 1); + route = {name: nextRoute?.name, params: nextRoute?.params}; + current = nextRoute?.state; + } + + return route; +} + +const ENTRY_POINTS = [ + ['Wallet', ROUTES.SETTINGS_WALLET], + ['Workspace Workflows > Payments', ROUTES.WORKSPACE_WORKFLOWS.getRoute(POLICY_ID, CONST.TAB.WORKFLOWS.PAYMENTS)], +] as const; + +function getIntroPath(basePath: string) { + return createDynamicRoute(DYNAMIC_ROUTES.WISE_GLOBAL_REIMBURSEMENTS_INTRO.getRoute(BANK_ACCOUNT_ID), basePath); +} + +describe('Wise business onboarding dynamic routes', () => { + it.each(ENTRY_POINTS)('opens a page of the onboarding on top of the intro from %s', (_label, basePath) => { + // Given the onboarding suffix with a page, appended to the intro page + const route = createDynamicRoute(DYNAMIC_ROUTES.WISE_BUSINESS_ONBOARDING.getRoute('business', 'edit'), getIntroPath(basePath)); + + // When the URL is parsed into navigation state + const focusedRoute = getFocusedRoute(getStateFromPath(route)); + + // Then the onboarding screen is focused with the page from its suffix and the bank account from the intro underneath + expect(focusedRoute.name).toBe(SCREENS.SETTINGS.WALLET.DYNAMIC_WISE_BUSINESS_ONBOARDING); + expect(focusedRoute.params).toMatchObject({bankAccountID: String(BANK_ACCOUNT_ID), subPage: 'business', action: 'edit'}); + }); + + it('opens the onboarding without a page, so the flow picks where to resume', () => { + // Given Get started on the intro, which leaves the page out + const route = createDynamicRoute(DYNAMIC_ROUTES.WISE_BUSINESS_ONBOARDING.getRoute(), getIntroPath(ROUTES.SETTINGS_WALLET)); + + // When the URL is parsed into navigation state + const focusedRoute = getFocusedRoute(getStateFromPath(route)); + + // Then the onboarding screen opens with no page for the flow to override + expect(focusedRoute.name).toBe(SCREENS.SETTINGS.WALLET.DYNAMIC_WISE_BUSINESS_ONBOARDING); + expect(focusedRoute.params).not.toHaveProperty('subPage'); + }); + + it.each(ENTRY_POINTS)('opens the terms on top of the confirmation page from %s', (_label, basePath) => { + // Given the terms suffix appended to the onboarding's confirmation page + const confirmationPath = createDynamicRoute(DYNAMIC_ROUTES.WISE_BUSINESS_ONBOARDING.getRoute(CONST.DYNAMIC_FORM.CONFIRMATION_PAGE_KEY), getIntroPath(basePath)); + const route = createDynamicRoute(DYNAMIC_ROUTES.WISE_ACCEPT_TERMS.path, confirmationPath); + + // When the URL is parsed into navigation state + const focusedRoute = getFocusedRoute(getStateFromPath(route)); + + // Then the terms screen is focused, and going back strips one layer to land on the confirmation page + expect(focusedRoute.name).toBe(SCREENS.SETTINGS.WALLET.DYNAMIC_WISE_ACCEPT_TERMS); + expect(focusedRoute.params).toMatchObject({bankAccountID: String(BANK_ACCOUNT_ID)}); + expect(stripDynamicRouteSuffixFromPath(route, DYNAMIC_ROUTES.WISE_ACCEPT_TERMS.path)).toBe(confirmationPath); + }); + + it.each(ENTRY_POINTS)('goes back from the onboarding to the intro from %s', (_label, basePath) => { + // Given a page of the onboarding opened on top of the intro + const introPath = getIntroPath(basePath); + const route = createDynamicRoute(DYNAMIC_ROUTES.WISE_BUSINESS_ONBOARDING.getRoute('representative'), introPath); + + // When computing the back path from the current URL + const backPath = stripDynamicRouteSuffixFromPath(route, DYNAMIC_ROUTES.WISE_BUSINESS_ONBOARDING.path); + + // Then going back lands on the intro page + expect(backPath).toBe(introPath); + }); + + it('does not open the onboarding straight from Wallet, since the intro comes first', () => { + // Given the onboarding suffix appended to Wallet without the intro + const route = createDynamicRoute(DYNAMIC_ROUTES.WISE_BUSINESS_ONBOARDING.getRoute('representative'), ROUTES.SETTINGS_WALLET); + + // When the URL is parsed into navigation state + const focusedRoute = getFocusedRoute(getStateFromPath(route)); + + // Then the entry screen check rejects it + expect(focusedRoute.name).not.toBe(SCREENS.SETTINGS.WALLET.DYNAMIC_WISE_BUSINESS_ONBOARDING); + }); +}); diff --git a/tests/ui/pages/settings/Wallet/WiseAcceptTermsPageTest.tsx b/tests/ui/pages/settings/Wallet/WiseAcceptTermsPageTest.tsx new file mode 100644 index 000000000000..0cb5c239d657 --- /dev/null +++ b/tests/ui/pages/settings/Wallet/WiseAcceptTermsPageTest.tsx @@ -0,0 +1,103 @@ +import {fireEvent, render, screen} from '@testing-library/react-native'; + +import Navigation from '@navigation/Navigation'; + +import WiseAcceptTermsPage from '@pages/settings/Wallet/EnableGlobalReimbursements/Wise/WiseAcceptTermsPage'; + +import {clearSensitiveAnswers} from '@userActions/DynamicForm'; + +import ONYXKEYS from '@src/ONYXKEYS'; + +import type ReactNative from 'react-native'; + +import React from 'react'; + +import * as TestHelper from '../../../../utils/TestHelper'; + +const mockTranslate = TestHelper.translateLocal; + +// The real useFocusEffect throws outside a navigator +jest.mock('@react-navigation/native', () => ({...jest.requireActual>('@react-navigation/native'), useFocusEffect: jest.fn()})); +jest.mock('@navigation/Navigation', () => ({dismissModal: jest.fn(), goBack: jest.fn()})); +jest.mock('@userActions/DynamicForm', () => ({clearSensitiveAnswers: jest.fn()})); +jest.mock('@hooks/useDynamicBackPath', () => () => 'settings/wallet/global-reimbursements/1/business-onboarding/confirm'); +jest.mock('@hooks/usePermissions', () => () => ({isBetaEnabledOrUnknown: () => true})); +jest.mock('@hooks/useLocalize', () => () => ({translate: mockTranslate, preferredLocale: 'en'})); +jest.mock('@hooks/useThemeStyles', () => () => new Proxy({}, {get: () => ({})})); +jest.mock('@hooks/useNetwork', () => () => ({isOffline: false})); +jest.mock('@components/ScreenWrapper', () => { + const reactNative = jest.requireActual('react-native'); + return {__esModule: true, default: ({children}: {children: React.ReactNode}) => {children}}; +}); +jest.mock('@components/Header', () => { + const Header = ({children}: {children: React.ReactNode}) => children; + Header.BackButton = () => null; + Header.Title = () => null; + return {__esModule: true, default: Header}; +}); +jest.mock('@components/RenderHTML', () => ({__esModule: true, default: () => null})); +jest.mock('@components/CheckboxWithLabel', () => { + const reactNative = jest.requireActual('react-native'); + return { + __esModule: true, + default: ({accessibilityLabel, isChecked, onInputChange}: {accessibilityLabel: string; isChecked: boolean; onInputChange: (isChecked: boolean) => void}) => ( + onInputChange(!isChecked)} + /> + ), + }; +}); + +const ERROR = mockTranslate('walletPage.wiseOnboarding.terms.error'); +const CONFIRM = mockTranslate('common.confirm'); +const TERM_LABELS = [ + mockTranslate('walletPage.wiseOnboarding.terms.certify'), + mockTranslate('walletPage.wiseOnboarding.terms.expensifyTermsAccessibilityLabel'), + mockTranslate('walletPage.wiseOnboarding.terms.wiseTermsAccessibilityLabel'), +]; + +function pressConfirm() { + fireEvent.press(screen.getByText(CONFIRM)); +} + +describe('WiseAcceptTermsPage', () => { + beforeEach(() => { + jest.clearAllMocks(); + }); + + it('keeps the page open with an error until every box is ticked, then closes the flow', () => { + // Given the terms page with only two of the three boxes ticked + render(); + fireEvent.press(screen.getByLabelText(TERM_LABELS.at(0) ?? '')); + fireEvent.press(screen.getByLabelText(TERM_LABELS.at(1) ?? '')); + + // When the user presses Confirm + pressConfirm(); + + // Then the page asks for every term and stays open, since the doc requires all of them + expect(screen.getByText(ERROR)).toBeOnTheScreen(); + expect(Navigation.dismissModal).not.toHaveBeenCalled(); + + // When the last box is ticked and Confirm is pressed again + fireEvent.press(screen.getByLabelText(TERM_LABELS.at(2) ?? '')); + pressConfirm(); + + // Then the button still works after the error, the SSN kept in memory for this page is dropped, and the flow closes + expect(clearSensitiveAnswers).toHaveBeenCalledWith(ONYXKEYS.FORMS.WISE_BUSINESS_ONBOARDING_FORM); + expect(Navigation.dismissModal).toHaveBeenCalledTimes(1); + }); + + it('hides the error once the user changes a box', () => { + // Given the error shown after Confirm with nothing ticked + render(); + pressConfirm(); + expect(screen.getByText(ERROR)).toBeOnTheScreen(); + + // When the user ticks a box + fireEvent.press(screen.getByLabelText(TERM_LABELS.at(0) ?? '')); + + // Then the error goes away until the next Confirm + expect(screen.queryByText(ERROR)).not.toBeOnTheScreen(); + }); +}); diff --git a/tests/ui/pages/settings/Wallet/WiseBusinessOnboardingPageTest.tsx b/tests/ui/pages/settings/Wallet/WiseBusinessOnboardingPageTest.tsx new file mode 100644 index 000000000000..7906bdd9b235 --- /dev/null +++ b/tests/ui/pages/settings/Wallet/WiseBusinessOnboardingPageTest.tsx @@ -0,0 +1,158 @@ +import {act, render, screen} from '@testing-library/react-native'; + +import OnyxListItemProvider from '@components/OnyxListItemProvider'; + +import {navigationRef} from '@libs/Navigation/Navigation'; +import createPlatformStackNavigator from '@libs/Navigation/PlatformStackNavigation/createPlatformStackNavigator'; +import type {SettingsNavigatorParamList} from '@libs/Navigation/types'; + +import WiseBusinessOnboardingPage from '@pages/settings/Wallet/EnableGlobalReimbursements/Wise/WiseBusinessOnboardingPage'; + +import {saveDraftAnswers} from '@userActions/DynamicForm'; + +import CONST from '@src/CONST'; +import ONYXKEYS from '@src/ONYXKEYS'; +import SCREENS from '@src/SCREENS'; +import type {BankAccount, PrivatePersonalDetails} from '@src/types/onyx'; + +import type ReactNative from 'react-native'; + +import {NavigationContainer} from '@react-navigation/native'; +import React from 'react'; +import Onyx from 'react-native-onyx'; + +import waitForBatchedUpdatesWithAct from '../../../../utils/waitForBatchedUpdatesWithAct'; + +const FLOW_TEST_ID = 'DynamicFormFlow'; +const LOADER_TEST_ID = 'FullScreenLoadingIndicator'; +const NOT_FOUND_TEST_ID = 'NotFoundPage'; +const BANK_ACCOUNT_ID = 1; + +const mockFlowMount = jest.fn(); + +jest.mock('@components/DynamicForm', () => { + const {useEffect} = jest.requireActual('react'); + const reactNative = jest.requireActual('react-native'); + function MockDynamicFormFlow() { + useEffect(() => { + mockFlowMount(); + }, []); + return ; + } + return {__esModule: true, default: MockDynamicFormFlow}; +}); +jest.mock('@components/FullscreenLoadingIndicator', () => { + const reactNative = jest.requireActual('react-native'); + return {__esModule: true, default: () => }; +}); +jest.mock('@pages/ErrorPage/NotFoundPage', () => { + const reactNative = jest.requireActual('react-native'); + return {__esModule: true, default: () => }; +}); +jest.mock('@userActions/DynamicForm', () => ({saveDraftAnswers: jest.fn()})); +jest.mock('@hooks/useDynamicBackPath', () => jest.fn(() => 'settings/wallet/global-reimbursements/1')); +jest.mock('@hooks/useLocalize', () => jest.fn(() => ({translate: (key: string) => key}))); + +const ELIGIBLE_BANK_ACCOUNT: BankAccount = { + bankCurrency: CONST.CURRENCY.USD, + bankCountry: CONST.COUNTRY.US, + accountData: {bankAccountID: BANK_ACCOUNT_ID, type: CONST.BANK_ACCOUNT.TYPE.BUSINESS, state: CONST.BANK_ACCOUNT.STATE.OPEN, addressName: 'Boulder Development Inc.'}, +}; + +const PRIVATE_PERSONAL_DETAILS: PrivatePersonalDetails = { + legalFirstName: 'Alice', + legalLastName: 'Nguyen', + dob: '1985-04-12', + addresses: [{street: '42 Oak Ave', city: 'Austin', state: 'TX', zip: '78704', country: CONST.COUNTRY.US, current: true}], +}; + +const {saveDraftAnswers: saveDraftAnswersToOnyx} = jest.requireActual<{saveDraftAnswers: typeof saveDraftAnswers}>('@userActions/DynamicForm'); + +const Stack = createPlatformStackNavigator(); + +async function renderPage(bankAccount: BankAccount = ELIGIBLE_BANK_ACCOUNT) { + await Onyx.multiSet({ + [ONYXKEYS.BETAS]: [CONST.BETAS.WISE_REIMBURSEMENTS], + [ONYXKEYS.BANK_ACCOUNT_LIST]: {[BANK_ACCOUNT_ID]: bankAccount}, + [ONYXKEYS.IS_LOADING_PAYMENT_METHODS]: false, + [ONYXKEYS.PRIVATE_PERSONAL_DETAILS]: PRIVATE_PERSONAL_DETAILS, + }); + render( + + + + + + + , + ); + await waitForBatchedUpdatesWithAct(); +} + +describe('WiseBusinessOnboardingPage', () => { + beforeAll(() => { + Onyx.init({keys: ONYXKEYS}); + }); + + beforeEach(async () => { + jest.clearAllMocks(); + jest.mocked(saveDraftAnswers).mockImplementation(saveDraftAnswersToOnyx); + await Onyx.clear(); + }); + + it('shows a loader until the prefill is in the draft, then the flow', async () => { + // Given a draft that the prefill has not reached yet, since its save is held back + jest.mocked(saveDraftAnswers).mockImplementation(() => {}); + + // When the page opens for an eligible business account + await renderPage(); + + // Then the loader stays while the prefill is only asked for, since the flow's inputs read the draft once when they mount + expect(saveDraftAnswers).toHaveBeenCalledWith(ONYXKEYS.FORMS.WISE_BUSINESS_ONBOARDING_FORM, expect.objectContaining({firstName: 'Alice', companyName: 'Boulder Development Inc.'})); + expect(screen.getByTestId(LOADER_TEST_ID)).toBeOnTheScreen(); + expect(screen.queryByTestId(FLOW_TEST_ID)).not.toBeOnTheScreen(); + + // When the prefill lands in the draft + const prefill = jest.mocked(saveDraftAnswers).mock.lastCall?.[1]; + if (!prefill) { + throw new Error('The page did not ask for a prefill'); + } + act(() => saveDraftAnswersToOnyx(ONYXKEYS.FORMS.WISE_BUSINESS_ONBOARDING_FORM, prefill)); + await waitForBatchedUpdatesWithAct(); + + // Then the flow replaces the loader + expect(screen.getByTestId(FLOW_TEST_ID)).toBeOnTheScreen(); + expect(screen.queryByTestId(LOADER_TEST_ID)).not.toBeOnTheScreen(); + }); + + it('keeps the flow mounted when private details change after the prefill', async () => { + // Given the flow open after the prefill, with no phone number on file + await renderPage(); + expect(screen.getByTestId(FLOW_TEST_ID)).toBeOnTheScreen(); + + // When a phone number is added to the private details during the visit + await act(() => Onyx.merge(ONYXKEYS.PRIVATE_PERSONAL_DETAILS, {phoneNumber: '+15125550199'})); + await waitForBatchedUpdatesWithAct(); + + // Then the flow is not swapped for the loader and remounted, since that would drop an SSN the user is typing + expect(screen.getByTestId(FLOW_TEST_ID)).toBeOnTheScreen(); + expect(mockFlowMount).toHaveBeenCalledTimes(1); + expect(saveDraftAnswers).toHaveBeenCalledTimes(1); + }); + + it('shows not found for a bank account that cannot use global reimbursements', async () => { + // Given a business account in euros, which Wise reimbursements do not cover + const euroBankAccount: BankAccount = {...ELIGIBLE_BANK_ACCOUNT, bankCurrency: CONST.CURRENCY.EUR}; + + // When the page opens for it + await renderPage(euroBankAccount); + + // Then the user sees not found instead of the form + expect(screen.getByTestId(NOT_FOUND_TEST_ID)).toBeOnTheScreen(); + expect(screen.queryByTestId(FLOW_TEST_ID)).not.toBeOnTheScreen(); + }); +}); diff --git a/tests/unit/CountryUtils.test.ts b/tests/unit/CountryUtils.test.ts index 6bc00d2057b9..d48fcca35c1a 100644 --- a/tests/unit/CountryUtils.test.ts +++ b/tests/unit/CountryUtils.test.ts @@ -1,4 +1,4 @@ -import {getCountryCode, normalizeCountryCode} from '@libs/CountryUtils'; +import {getCountryCode, normalizeCountryCode, resolveStateCode} from '@libs/CountryUtils'; import type {Address} from '@src/types/onyx/PrivatePersonalDetails'; @@ -160,4 +160,23 @@ describe('CountryUtils', () => { expect(result).toEqual({street: '789 Test St', city: 'Test City', country: 'MISSING TRANSLATION'}); }); }); + + describe('resolveStateCode', () => { + it('turns a full US state name into its code, whatever the case', () => { + // Given a stored address that names its state in full + // When the state is resolved for the state picker + // Then the picker gets the 2-letter code it lists states by + expect(resolveStateCode('California')).toBe('CA'); + expect(resolveStateCode('new york')).toBe('NY'); + }); + + it('keeps a code, an empty value and a name it does not know as they are', () => { + // Given states that are already codes, missing, or unknown + // When they are resolved + // Then they come back unchanged, so the caller decides what to do with an unknown name + expect(resolveStateCode('TX')).toBe('TX'); + expect(resolveStateCode('')).toBe(''); + expect(resolveStateCode('Ontario')).toBe('Ontario'); + }); + }); }); diff --git a/tests/unit/components/DynamicForm/DynamicFormFieldsTest.tsx b/tests/unit/components/DynamicForm/DynamicFormFieldsTest.tsx index 8b0438eedf0f..65029d149d35 100644 --- a/tests/unit/components/DynamicForm/DynamicFormFieldsTest.tsx +++ b/tests/unit/components/DynamicForm/DynamicFormFieldsTest.tsx @@ -23,6 +23,8 @@ import RadioButtons from '@components/RadioButtons'; import TextInput from '@components/TextInput'; import ValuePicker from '@components/ValuePicker'; +import variables from '@styles/variables'; + import CONST from '@src/CONST'; import type {DynamicFormContentItem, DynamicFormField, DynamicFormFieldType, DynamicFormHeading, DynamicFormSchemaField} from '@src/types/onyx'; @@ -37,6 +39,7 @@ type CapturedInputProps = { forwardedFSClass?: string; hint?: string; inputMode?: string; + maxAutoGrowHeight?: number; items?: Array<{value: string; label: string}>; optionsList?: Record; renamedInputKeys?: Record; @@ -521,6 +524,19 @@ describe('DynamicFormFields', () => { expect(rendered.get('phone')?.inputMode).toBe(CONST.INPUT_MODE.TEL); }); + it('caps the height a multiline text field grows to, and leaves a single-line one uncapped', () => { + // Given a multiline business description next to a single-line name + const businessDescription: DynamicFormField = {key: 'businessDescription', type: 'text', required: true, multiline: true}; + const name: DynamicFormField = {key: 'name', type: 'text', required: true}; + + // When they render + const rendered = renderFields([businessDescription, name]); + + // Then only the multiline field stops growing at the shared limit, so a long answer scrolls inside its input instead of pushing the page down + expect(rendered.get('businessDescription')?.maxAutoGrowHeight).toBe(variables.textInputAutoGrowMaxHeight); + expect(rendered.get('name')?.maxAutoGrowHeight).toBeUndefined(); + }); + it('asks the screen to refetch the schema only when a refreshing field changes', () => { // Given a currency field that changes the requirements, next to one that does not const onRefreshRequirements = jest.fn(); diff --git a/tests/unit/components/DynamicForm/DynamicFormFlowTest.tsx b/tests/unit/components/DynamicForm/DynamicFormFlowTest.tsx index 6bf47853c506..afc4264c939a 100644 --- a/tests/unit/components/DynamicForm/DynamicFormFlowTest.tsx +++ b/tests/unit/components/DynamicForm/DynamicFormFlowTest.tsx @@ -1,4 +1,4 @@ -import {render} from '@testing-library/react-native'; +import {act, render} from '@testing-library/react-native'; import ActivityIndicator from '@components/ActivityIndicator'; import DynamicFormFlow from '@components/DynamicForm'; @@ -35,9 +35,15 @@ const mockPrevPage = jest.fn(); const mockResetToPage = jest.fn(); const mockMoveTo = jest.fn(); let mockOnBackButtonPress: (() => void) | undefined; +let mockOnAndroidBackPress: (() => boolean) | undefined; const mockStepWrapper = jest.fn(() => null); jest.mock('@hooks/useSubPage', () => jest.fn()); +jest.mock('@hooks/useAndroidBackButtonHandler', () => + jest.fn((callback: () => boolean) => { + mockOnAndroidBackPress = callback; + }), +); jest.mock('@hooks/useLocalize', () => jest.fn(() => ({translate: (key: string) => key}))); jest.mock('@userActions/DynamicForm', () => ({ saveDraftAnswers: jest.fn(), @@ -100,6 +106,21 @@ type RenderFlowOptions = { onRefreshRequirements?: (inputID: string, value: FormValue) => void; }; +function mockSubPage(currentPageName: string, pageIndex: number, isRedirecting: boolean) { + jest.mocked(useSubPage).mockReturnValue({ + CurrentPage: mockCurrentPage, + isEditing: false, + currentPageName, + pageIndex, + lastPageIndex: 3, + nextPage: jest.fn(), + prevPage: mockPrevPage, + moveTo: mockMoveTo, + resetToPage: mockResetToPage, + isRedirecting, + }); +} + async function renderFlow({ flowSchema = schema, draft = {}, @@ -116,18 +137,7 @@ async function renderFlow({ }: RenderFlowOptions = {}) { await Onyx.set(`${FORM_ID}Draft`, draft); await Onyx.set(ONYXKEYS.RAM_ONLY_DYNAMIC_FORM_SENSITIVE_ANSWERS, {[FORM_ID]: sensitiveAnswers}); - jest.mocked(useSubPage).mockReturnValue({ - CurrentPage: mockCurrentPage, - isEditing: false, - currentPageName, - pageIndex, - lastPageIndex: 3, - nextPage: jest.fn(), - prevPage: mockPrevPage, - moveTo: mockMoveTo, - resetToPage: mockResetToPage, - isRedirecting, - }); + mockSubPage(currentPageName, pageIndex, isRedirecting); const onSubmit = jest.fn(); const onBack = jest.fn(); const onPageSubmit = jest.fn(); @@ -161,7 +171,15 @@ async function renderFlow({ throw new Error('useSubPage was not called'); } const pageProps = mockCurrentPage.mock.lastCall?.[0]; - return {subPageOptions, setSubmitting, unmount, onSubmit, onBack, onPageSubmit, pageProps: hasDynamicFormProps(pageProps) ? pageProps : undefined}; + const rerenderFlow = () => setSubmitting(isSubmitting); + return {subPageOptions, setSubmitting, rerenderFlow, unmount, onSubmit, onBack, onPageSubmit, pageProps: hasDynamicFormProps(pageProps) ? pageProps : undefined}; +} + +function pressAndroidBack(): boolean { + if (!mockOnAndroidBackPress) { + throw new Error('The flow did not register an Android back handler'); + } + return mockOnAndroidBackPress(); } describe('DynamicFormFlow', () => { @@ -171,6 +189,7 @@ describe('DynamicFormFlow', () => { beforeEach(async () => { jest.clearAllMocks(); + mockOnAndroidBackPress = undefined; await Onyx.clear(); }); @@ -495,6 +514,54 @@ describe('DynamicFormFlow', () => { expect(clearSensitiveAnswers).not.toHaveBeenCalled(); }); + it('takes Android back to the previous page from a later page', async () => { + // Given the second page of a flow on replaced routes, which leaves no page in the stack for the system back to pop + await renderFlow({pageIndex: 1, shouldReplaceRoute: true}); + + // When the user presses Android's back button + const isHandled = pressAndroidBack(); + + // Then the flow handles it like the header's back, so the user lands on the first page instead of leaving the flow + expect(isHandled).toBe(true); + expect(mockPrevPage).toHaveBeenCalled(); + expect(clearSensitiveAnswers).not.toHaveBeenCalled(); + }); + + it('leaves the flow and forgets sensitive answers on Android back from the first page', async () => { + // Given the first page + const {onBack} = await renderFlow({pageIndex: 0, shouldReplaceRoute: true}); + + // When the user presses Android's back button + const isHandled = pressAndroidBack(); + + // Then the screen is left and the SSN is dropped, as the header's back does, so it does not outlive the visit + expect(isHandled).toBe(true); + expect(onBack).toHaveBeenCalled(); + expect(clearSensitiveAnswers).toHaveBeenCalledWith(FORM_ID); + expect(mockPrevPage).not.toHaveBeenCalled(); + }); + + it('waits for the sensitive answers of an earlier visit to be cleared before showing a page', async () => { + // Given an SSN still in memory from a visit left without the flow's own back, such as by a swipe, and a new visit that opens with no page in the URL + const {rerenderFlow} = await renderFlow({draft: {firstName: 'Jane'}, sensitiveAnswers: {ssn: '123456789'}, isRedirecting: true}); + + // When the redirect lands on the first page before the clearing reaches memory + mockSubPage('personal-details', 0, false); + await rerenderFlow(); + + // Then the spinner stays, since the page's inputs read their values once on mount and would keep the old SSN + expect(mockCurrentPage).not.toHaveBeenCalled(); + + // When the earlier answers are cleared + await act(() => Onyx.merge(ONYXKEYS.RAM_ONLY_DYNAMIC_FORM_SENSITIVE_ANSWERS, {[FORM_ID]: null})); + await waitForBatchedUpdatesWithAct(); + + // Then the page opens without the old SSN, and no render of it ever held the SSN + expect(mockCurrentPage).toHaveBeenCalled(); + const pageValues = mockCurrentPage.mock.calls.map(([props]) => (hasDynamicFormProps(props) ? props.values : undefined)); + expect(pageValues.every((values) => values?.ssn === undefined)).toBe(true); + }); + it('passes the file size limit on to the page', async () => { // Given a screen that sets a file size limit // When the flow renders diff --git a/tests/unit/components/DynamicForm/formatDynamicFieldValueTest.ts b/tests/unit/components/DynamicForm/formatDynamicFieldValueTest.ts new file mode 100644 index 000000000000..8597260d5773 --- /dev/null +++ b/tests/unit/components/DynamicForm/formatDynamicFieldValueTest.ts @@ -0,0 +1,28 @@ +import formatDynamicFieldValue from '@components/DynamicForm/utils/formatDynamicFieldValue'; + +import type {DynamicFormField} from '@src/types/onyx'; + +import {translateLocal} from '../../../utils/TestHelper'; + +const description: DynamicFormField = {key: 'description', type: 'text', required: true, multiline: true}; +const name: DynamicFormField = {key: 'name', type: 'text', required: true}; + +describe('formatDynamicFieldValue', () => { + it.each(['A\nB', 'A \r\n B'])('joins the lines of a multiline answer %j into one', (answer) => { + // Given a multiline answer typed on two lines, with or without spaces and a Windows line break around the break + // When it is shown on a confirmation or readonly row + const shown = formatDynamicFieldValue(description, {description: answer}, translateLocal); + + // Then it reads as one line, since a row shows one line and cuts a longer answer with an ellipsis + expect(shown).toBe('A B'); + }); + + it('shows a single-line answer as it was typed', () => { + // Given a single-line text field whose answer holds a line break, as a pasted value would + // When it is shown on a row + const shown = formatDynamicFieldValue(name, {name: 'A\nB'}, translateLocal); + + // Then it is not changed, since only multiline fields are joined + expect(shown).toBe('A\nB'); + }); +}); diff --git a/tests/unit/pages/settings/Wallet/EnableGlobalReimbursements/getWiseBusinessOnboardingPrefillTest.ts b/tests/unit/pages/settings/Wallet/EnableGlobalReimbursements/getWiseBusinessOnboardingPrefillTest.ts new file mode 100644 index 000000000000..8bcc30d95acd --- /dev/null +++ b/tests/unit/pages/settings/Wallet/EnableGlobalReimbursements/getWiseBusinessOnboardingPrefillTest.ts @@ -0,0 +1,132 @@ +import getAddressInputKeys from '@components/DynamicForm/utils/getAddressInputKeys'; + +import getWiseBusinessOnboardingPrefill, {getMissingPrefill} from '@pages/settings/Wallet/EnableGlobalReimbursements/Wise/getWiseBusinessOnboardingPrefill'; + +import CONST from '@src/CONST'; +import type {BankAccount, PrivatePersonalDetails} from '@src/types/onyx'; + +const ADDRESS_KEYS = getAddressInputKeys('address'); + +const BANK_ACCOUNT: BankAccount = { + bankCurrency: CONST.CURRENCY.USD, + bankCountry: CONST.COUNTRY.US, + accountData: {bankAccountID: 1, addressName: 'Boulder Development Inc.'}, +}; + +const PRIVATE_PERSONAL_DETAILS: PrivatePersonalDetails = { + legalFirstName: 'Alice', + legalLastName: 'Nguyen', + phoneNumber: '+15125550199', + dob: '1985-04-12', + addresses: [ + {street: '1 Old Rd', city: 'Dallas', state: 'TX', zip: '75201', country: CONST.COUNTRY.US}, + {street: '42 Oak Ave\nApt 3', city: 'Austin', state: 'TX', zip: '78704', country: CONST.COUNTRY.US, current: true}, + ], +}; + +describe('getWiseBusinessOnboardingPrefill', () => { + it('fills the representative from private details and the business name from the bank account', () => { + // Given a user with private details on file and a business bank account + + // When the onboarding builds its starting answers + const prefill = getWiseBusinessOnboardingPrefill(BANK_ACCOUNT, PRIVATE_PERSONAL_DETAILS); + + // Then the representative comes from the current address, with both street lines on the one street input the form has + expect(prefill).toEqual({ + firstName: 'Alice', + lastName: 'Nguyen', + phoneNumber: '+15125550199', + dateOfBirth: '1985-04-12', + [ADDRESS_KEYS.street]: '42 Oak Ave, Apt 3', + [ADDRESS_KEYS.city]: 'Austin', + [ADDRESS_KEYS.state]: 'TX', + [ADDRESS_KEYS.zipCode]: '78704', + [ADDRESS_KEYS.country]: CONST.COUNTRY.US, + companyName: 'Boulder Development Inc.', + }); + }); + + it('turns country and state names from older addresses into the codes the pickers take', () => { + // Given an address saved with full names + // @ts-expect-error - Legacy addresses can contain country names before normalization. + const details: PrivatePersonalDetails = {addresses: [{street: '1 Main St', city: 'Fresno', state: 'California', zip: '93650', country: 'United States'}]}; + + // When the onboarding builds its starting answers + const prefill = getWiseBusinessOnboardingPrefill(BANK_ACCOUNT, details); + + // Then the pickers get codes they can show + expect(prefill).toMatchObject({[ADDRESS_KEYS.country]: CONST.COUNTRY.US, [ADDRESS_KEYS.state]: 'CA'}); + }); + + it('leaves a country or state that does not resolve for the user to pick', () => { + // Given an address whose country and state match nothing the pickers know + const details: PrivatePersonalDetails = {addresses: [{street: '1 Main St', city: 'Springfield', state: 'Nowhere', zip: '12345', country: CONST.COUNTRY.US}]}; + + // When the onboarding builds its starting answers + const prefill = getWiseBusinessOnboardingPrefill(BANK_ACCOUNT, details); + + // Then the unknown state is not prefilled, so the user picks it instead of carrying a value the picker cannot show + expect(prefill[ADDRESS_KEYS.state]).toBeUndefined(); + expect(prefill[ADDRESS_KEYS.country]).toBe(CONST.COUNTRY.US); + }); + + it('leaves out what is not on file', () => { + // Given a user with no private details yet + + // When the onboarding builds its starting answers + const prefill = getWiseBusinessOnboardingPrefill(BANK_ACCOUNT, undefined); + + // Then nothing is made up, so getMissingPrefill writes only the business name + expect(getMissingPrefill(prefill, {})).toEqual({companyName: 'Boulder Development Inc.'}); + }); +}); + +describe('getMissingPrefill', () => { + it('keeps what the user typed, even an emptied field', () => { + // Given a draft where the user changed the first name and cleared the phone number + const prefill = getWiseBusinessOnboardingPrefill(BANK_ACCOUNT, PRIVATE_PERSONAL_DETAILS); + const draft = {firstName: 'Alicia', phoneNumber: ''}; + + // When the onboarding decides what to prefill + const missing = getMissingPrefill(prefill, draft); + + // Then the user's answers stay, and only the untouched fields are filled + expect(missing).not.toHaveProperty('firstName'); + expect(missing).not.toHaveProperty('phoneNumber'); + expect(missing).toMatchObject({lastName: 'Nguyen', dateOfBirth: '1985-04-12'}); + }); + + it('updates the business name, since it is a read-only row that follows the bank account', () => { + // Given a draft holding an older business name + const prefill = getWiseBusinessOnboardingPrefill(BANK_ACCOUNT, undefined); + + // When the onboarding decides what to prefill + const missing = getMissingPrefill(prefill, {companyName: 'Old Name LLC'}); + + // Then the bank account's name replaces it + expect(missing).toEqual({companyName: 'Boulder Development Inc.'}); + }); + + it('empties the business name when the bank account has none, so the name of another account does not stay', () => { + // Given a draft holding another account's name and a bank account without a name + const prefill = getWiseBusinessOnboardingPrefill({...BANK_ACCOUNT, accountData: {bankAccountID: 2}}, undefined); + + // When the onboarding decides what to prefill + const missing = getMissingPrefill(prefill, {companyName: 'Old Name LLC'}); + + // Then the read-only row is emptied, and once the draft holds that nothing is left to write + expect(missing).toEqual({companyName: ''}); + expect(getMissingPrefill(prefill, missing)).toEqual({}); + }); + + it('writes nothing once the draft holds every prefill answer', () => { + // Given a draft the prefill already landed in + const prefill = getWiseBusinessOnboardingPrefill(BANK_ACCOUNT, PRIVATE_PERSONAL_DETAILS); + + // When the onboarding decides what to prefill again + const missing = getMissingPrefill(prefill, prefill); + + // Then there is nothing left to write, so the page stops waiting and renders the flow + expect(missing).toEqual({}); + }); +});