Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/components/OnboardingMergingAccountBlockedView.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import React from 'react';
import useLocalize from '@hooks/useLocalize';
import useOnyx from '@hooks/useOnyx';
Comment thread
blimpich marked this conversation as resolved.
Resolved
import useThemeStyles from '@hooks/useThemeStyles';
import Navigation from '@libs/Navigation/Navigation';
import variables from '@styles/variables';
import {setOnboardingErrorMessage} from '@userActions/Welcome';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import BlockingView from './BlockingViews/BlockingView';
import Button from './Button';
Expand All @@ -20,14 +22,24 @@ type OnboardingMergingAccountBlockedViewProps = {
function OnboardingMergingAccountBlockedView({workEmail, isVsb}: OnboardingMergingAccountBlockedViewProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
const [onboardingErrorMessage] = useOnyx(ONYXKEYS.ONBOARDING_ERROR_MESSAGE, {canBeMissing: true});

const getErrorSubtitle = () => {
Comment thread
blimpich marked this conversation as resolved.
Resolved
if (onboardingErrorMessage) {
return onboardingErrorMessage;
}
// Fallback to generic error message
return translate('onboarding.mergeBlockScreen.subtitle', {workEmail});
};

return (
<>
<BlockingView
icon={ToddBehindCloud}
iconWidth={variables.modalTopIconWidth}
iconHeight={variables.modalTopIconHeight}
title={translate('onboarding.mergeBlockScreen.title')}
subtitle={translate('onboarding.mergeBlockScreen.subtitle', {workEmail})}
subtitle={getErrorSubtitle()}
Comment thread
blimpich marked this conversation as resolved.
Resolved
Comment thread
blimpich marked this conversation as resolved.
Resolved
subtitleStyle={[styles.colorMuted]}
/>
<Button
Expand Down
55 changes: 55 additions & 0 deletions tests/ui/WorkEmailOnboarding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -572,4 +572,59 @@ describe('OnboardingWorkEmailValidation Page', () => {
unmount();
await waitForBatchedUpdatesWithAct();
});

it('should display specific error message when ONBOARDING_ERROR_MESSAGE is set', async () => {
await TestHelper.signInWithTestUser();

const specificErrorMessage = 'some extraordinarily specific error has occurred!';

await act(async () => {
await Onyx.merge(ONYXKEYS.NVP_ONBOARDING, {
hasCompletedGuidedSetupFlow: false,
shouldValidate: true,
isMergingAccountBlocked: true,
});
await Onyx.merge(ONYXKEYS.FORMS.ONBOARDING_WORK_EMAIL_FORM, {
onboardingWorkEmail: 'test@company.com',
});
await Onyx.merge(ONYXKEYS.ONBOARDING_ERROR_MESSAGE, specificErrorMessage);
});

const {unmount} = renderOnboardingWorkEmailValidationPage(SCREENS.ONBOARDING.WORK_EMAIL_VALIDATION, {backTo: ''});

await waitForBatchedUpdatesWithAct();

await waitFor(() => {
expect(screen.getByText(specificErrorMessage)).toBeOnTheScreen();
});

unmount();
await waitForBatchedUpdatesWithAct();
});

it('should fallback to generic error message when ONBOARDING_ERROR_MESSAGE is not set', async () => {
await TestHelper.signInWithTestUser();

await act(async () => {
await Onyx.merge(ONYXKEYS.NVP_ONBOARDING, {
hasCompletedGuidedSetupFlow: false,
shouldValidate: true,
isMergingAccountBlocked: true,
});
await Onyx.merge(ONYXKEYS.FORMS.ONBOARDING_WORK_EMAIL_FORM, {
onboardingWorkEmail: workEmail,
});
});

const {unmount} = renderOnboardingWorkEmailValidationPage(SCREENS.ONBOARDING.WORK_EMAIL_VALIDATION, {backTo: ''});

await waitForBatchedUpdatesWithAct();

await waitFor(() => {
expect(screen.getByText(translateLocal('onboarding.mergeBlockScreen.subtitle', {workEmail}))).toBeOnTheScreen();
});

unmount();
await waitForBatchedUpdatesWithAct();
});
});