Skip to content

Commit

Permalink
fix faling tests
Browse files Browse the repository at this point in the history
  • Loading branch information
allgandalf committed Dec 27, 2024
1 parent 0196179 commit f131cfe
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 57 deletions.
3 changes: 1 addition & 2 deletions src/hooks/useOnboardingFlow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ function useOnboardingFlowRouter() {

const {canUsePrivateDomainOnboardingCheck} = usePermissions();

const [allBetas, allBetasMetadata] = useOnyx(ONYXKEYS.BETAS);

useEffect(() => {
// This should delay opening the onboarding modal so it does not interfere with the ongoing ReportScreen params changes
InteractionManager.runAfterInteractions(() => {
Expand Down Expand Up @@ -89,6 +87,7 @@ function useOnboardingFlowRouter() {
dismissedProductTraining?.migratedUserWelcomeModal,
dismissedProductTraining,
isPrivateDomain,
canUsePrivateDomainOnboardingCheck,
]);

return {isOnboardingCompleted, isHybridAppOnboardingCompleted};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function OnboardingModalNavigator() {
const styles = useThemeStyles();
const {onboardingIsMediumOrLargerScreenWidth} = useResponsiveLayout();
const outerViewRef = React.useRef<View>(null);
const [accountID] = useOnyx(ONYXKEYS.SESSION, {selector: (session) => session?.accountID ?? 0});
const [accountID] = useOnyx(ONYXKEYS.SESSION, {selector: (session) => session?.accountID ?? CONST.DEFAULT_NUMBER_ID});

// Publish a sign_up event when we start the onboarding flow. This should track basic sign ups
// as well as Google and Apple SSO.
Expand Down
1 change: 0 additions & 1 deletion src/libs/actions/Welcome/OnboardingFlow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ Onyx.connect({
* Start a new onboarding flow or continue from the last visited onboarding page.
*/
function startOnboardingFlow(isPrivateDomain?: boolean, canUsePrivateDomainOnboardingCheck?: boolean) {
console.log('canUsePrivateDomainOnboardingCheck', canUsePrivateDomainOnboardingCheck);
const currentRoute = navigationRef.getCurrentRoute();
const {adaptedState} = getAdaptedStateFromPath(getOnboardingInitialPath(isPrivateDomain, canUsePrivateDomainOnboardingCheck), linkingConfig.config, false);
const focusedRoute = findFocusedRoute(adaptedState as PartialState<NavigationState<RootStackParamList>>);
Expand Down
98 changes: 45 additions & 53 deletions src/pages/OnboardingWorkEmail/BaseOnboardingWorkEmail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,46 +23,49 @@ import Navigation from '@libs/Navigation/Navigation';
import * as Session from '@userActions/Session';
import * as Welcome from '@userActions/Welcome';
import CONST from '@src/CONST';
import {TranslationPaths} from '@src/languages/types';
import type {TranslationPaths} from '@src/languages/types';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import INPUT_IDS from '@src/types/form/OnboardingWorkEmailForm';
import IconAsset from '@src/types/utils/IconAsset';
import type IconAsset from '@src/types/utils/IconAsset';
import type {BaseOnboardingWorkEmailProps} from './types';

function BaseOnboardingWorkEmail({shouldUseNativeStyles, route}: BaseOnboardingWorkEmailProps) {
function BaseOnboardingWorkEmail({shouldUseNativeStyles}: BaseOnboardingWorkEmailProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
const [onboardingValues] = useOnyx(ONYXKEYS.NVP_ONBOARDING);
const [formValue] = useOnyx(ONYXKEYS.FORMS.ONBOARDING_WORK_EMAIL_FORM);
const workEmail = formValue?.[INPUT_IDS.ONBOARDING_WORK_EMAIL];
console.log('workEmailworkEmail', workEmail);
const isVsb = onboardingValues && 'signupQualifier' in onboardingValues && onboardingValues.signupQualifier === CONST.ONBOARDING_SIGNUP_QUALIFIERS.VSB;
// We need to use isSmallScreenWidth, see navigateAfterOnboarding function comment
// eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth
const {onboardingIsMediumOrLargerScreenWidth, isSmallScreenWidth, shouldUseNarrowLayout} = useResponsiveLayout();

Check failure on line 42 in src/pages/OnboardingWorkEmail/BaseOnboardingWorkEmail.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

'shouldUseNarrowLayout' is assigned a value but never used

Check failure on line 42 in src/pages/OnboardingWorkEmail/BaseOnboardingWorkEmail.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

'shouldUseNarrowLayout' is assigned a value but never used
const {inputCallbackRef} = useAutoFocusInput();
const [shouldValidateOnChange, setShouldValidateOnChange] = useState(false);
const {isOffline} = useNetwork();
const ICON_SIZE = 48;

useEffect(() => {
Welcome.setOnboardingErrorMessage('');
}, []);

const validatePrivateDomain = useCallback((values: FormOnyxValues<'onboardingWorkEmailForm'>) => {
Session.AddWorkEmail(values[INPUT_IDS.ONBOARDING_WORK_EMAIL]);
const validatePrivateDomain = useCallback(
(values: FormOnyxValues<'onboardingWorkEmailForm'>) => {
Session.AddWorkEmail(values[INPUT_IDS.ONBOARDING_WORK_EMAIL]);

if (onboardingValues && 'shouldValidate' in onboardingValues && onboardingValues.shouldValidate) {
return;
}
if (onboardingValues && 'shouldValidate' in onboardingValues && onboardingValues.shouldValidate) {
return;
}

if (isVsb) {
Navigation.navigate(ROUTES.ONBOARDING_ACCOUNTING.getRoute());
return;
}
if (isVsb) {
Navigation.navigate(ROUTES.ONBOARDING_ACCOUNTING.getRoute());
return;
}

Navigation.navigate(ROUTES.ONBOARDING_PURPOSE.getRoute());
}, []);
Navigation.navigate(ROUTES.ONBOARDING_PURPOSE.getRoute());
},
[isVsb, onboardingValues],
);

const validate = (values: FormOnyxValues<'onboardingWorkEmailForm'>) => {
if (!shouldValidateOnChange) {
Expand Down Expand Up @@ -96,26 +99,24 @@ function BaseOnboardingWorkEmail({shouldUseNativeStyles, route}: BaseOnboardingW
items: Item[];
};

const section: SectionObject[] = [
{
titleTranslationKey: 'onboarding.workEmail.title',
subtitleTranslationKey: 'onboarding.workEmail.subtitle',
items: [
{
icon: Illustrations.EnvelopeReceipt,
titleTranslationKey: 'onboarding.workEmail.explanationModal.descriptionOne',
},
{
icon: Illustrations.Profile,
titleTranslationKey: 'onboarding.workEmail.explanationModal.descriptionTwo',
},
{
icon: Illustrations.Gears,
titleTranslationKey: 'onboarding.workEmail.explanationModal.descriptionThree',
},
],
},
];
const section: SectionObject = {
titleTranslationKey: 'onboarding.workEmail.title',
subtitleTranslationKey: 'onboarding.workEmail.subtitle',
items: [
{
icon: Illustrations.EnvelopeReceipt,
titleTranslationKey: 'onboarding.workEmail.explanationModal.descriptionOne',
},
{
icon: Illustrations.Profile,
titleTranslationKey: 'onboarding.workEmail.explanationModal.descriptionTwo',
},
{
icon: Illustrations.Gears,
titleTranslationKey: 'onboarding.workEmail.explanationModal.descriptionThree',
},
],
};

const renderItem = useCallback(
(item: Item) => (
Expand All @@ -139,23 +140,6 @@ function BaseOnboardingWorkEmail({shouldUseNativeStyles, route}: BaseOnboardingW
[styles, translate],
);

const renderSection = useCallback(
(section: SectionObject) => (
<View>
<View style={[onboardingIsMediumOrLargerScreenWidth ? styles.flexRow : styles.flexColumn, styles.mb3]}>
<Text style={styles.textHeadlineH1}>{translate('onboarding.workEmail.title')}</Text>
</View>
<View style={styles.mb2}>
<Text style={[styles.textNormal, styles.colorMuted]}>{translate('onboarding.workEmail.subtitle')}</Text>
</View>
<View>{section.items.map(renderItem)}</View>
</View>
),
[shouldUseNarrowLayout, styles, renderItem, translate, onboardingIsMediumOrLargerScreenWidth],
);

const ICON_SIZE = 48;

return (
<ScreenWrapper
shouldEnableMaxHeight
Expand Down Expand Up @@ -197,7 +181,15 @@ function BaseOnboardingWorkEmail({shouldUseNativeStyles, route}: BaseOnboardingW
}
shouldRenderFooterAboveSubmit
>
{section.map(renderSection)}
<View>
<View style={[onboardingIsMediumOrLargerScreenWidth ? styles.flexRow : styles.flexColumn, styles.mb3]}>
<Text style={styles.textHeadlineH1}>{translate('onboarding.workEmail.title')}</Text>
</View>
<View style={styles.mb2}>
<Text style={[styles.textNormal, styles.colorMuted]}>{translate('onboarding.workEmail.subtitle')}</Text>
</View>
<View>{section.items.map(renderItem)}</View>
</View>

<View style={[styles.mb4, styles.pt3]}>
<InputWrapper
Expand Down

0 comments on commit f131cfe

Please sign in to comment.