Skip to content

Commit ecd294e

Browse files
committed
fix: navigate to concierge chat after onboarding on test account
1 parent a8b8229 commit ecd294e

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

src/libs/navigateAfterOnboarding.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,21 @@ const navigateAfterOnboarding = (
99
onboardingPolicyID?: string,
1010
activeWorkspaceID?: string,
1111
onboardingAdminsChatReportID?: string,
12+
shouldOpenAdminRoom?: boolean,
1213
) => {
1314
Navigation.dismissModal();
1415

1516
// When hasCompletedGuidedSetupFlow is true, OnboardingModalNavigator in AuthScreen is removed from the navigation stack.
1617
// On small screens, this removal redirects navigation to HOME. Dismissing the modal doesn't work properly,
1718
// so we need to specifically navigate to the last accessed report.
1819
if (!isSmallScreenWidth) {
19-
if (onboardingAdminsChatReportID) {
20+
if (onboardingAdminsChatReportID && shouldOpenAdminRoom) {
2021
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(onboardingAdminsChatReportID));
2122
}
2223
return;
2324
}
2425

25-
const lastAccessedReport = findLastAccessedReport(!canUseDefaultRooms, shouldOpenOnAdminRoom(), activeWorkspaceID);
26+
const lastAccessedReport = findLastAccessedReport(!canUseDefaultRooms, shouldOpenOnAdminRoom() && shouldOpenAdminRoom, activeWorkspaceID);
2627
const lastAccessedReportID = lastAccessedReport?.reportID;
2728
// we don't want to navigate to newly created workspaces after onboarding is completed.
2829
if (!lastAccessedReportID || lastAccessedReport.policyID === onboardingPolicyID || isConciergeChatReport(lastAccessedReport)) {

src/pages/OnboardingAccounting/BaseOnboardingAccounting.tsx

+8-1
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,14 @@ function BaseOnboardingAccounting({shouldUseNativeStyles}: BaseOnboardingAccount
188188
setOnboardingAdminsChatReportID();
189189
setOnboardingPolicyID();
190190
});
191-
navigateAfterOnboarding(isSmallScreenWidth, canUseDefaultRooms, onboardingPolicyID, activeWorkspaceID, onboardingAdminsChatReportID);
191+
navigateAfterOnboarding(
192+
isSmallScreenWidth,
193+
canUseDefaultRooms,
194+
onboardingPolicyID,
195+
activeWorkspaceID,
196+
onboardingAdminsChatReportID,
197+
!(session?.email ?? '').includes('+'),
198+
);
192199
}}
193200
pressOnEnter
194201
/>

tests/unit/navigateAfterOnboardingTest.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ describe('navigateAfterOnboarding', () => {
5555

5656
it('should navigate to the admin room report if onboardingAdminsChatReportID is provided', () => {
5757
const navigate = jest.spyOn(Navigation, 'navigate');
58+
const testSession = {email: 'realaccount@gmail.com'};
5859

59-
navigateAfterOnboarding(false, true, undefined, undefined, ONBOARDING_ADMINS_CHAT_REPORT_ID);
60+
navigateAfterOnboarding(false, true, undefined, undefined, ONBOARDING_ADMINS_CHAT_REPORT_ID, !(testSession?.email ?? '').includes('+'));
6061
expect(navigate).toHaveBeenCalledWith(ROUTES.REPORT_WITH_ID.getRoute(ONBOARDING_ADMINS_CHAT_REPORT_ID));
6162
});
6263

@@ -102,4 +103,15 @@ describe('navigateAfterOnboarding', () => {
102103
navigateAfterOnboarding(true, true, ONBOARDING_POLICY_ID, ACTIVE_WORKSPACE_ID, ONBOARDING_ADMINS_CHAT_REPORT_ID);
103104
expect(navigate).toHaveBeenCalledWith(ROUTES.REPORT_WITH_ID.getRoute(REPORT_ID));
104105
});
106+
107+
it('should navigate to Concierge room if user uses a test email', () => {
108+
const navigate = jest.spyOn(Navigation, 'navigate');
109+
const lastAccessedReport = {reportID: REPORT_ID};
110+
mockFindLastAccessedReport.mockReturnValue(lastAccessedReport);
111+
mockShouldOpenOnAdminRoom.mockReturnValue(true);
112+
const testSession = {email: 'test+account@gmail.com'};
113+
114+
navigateAfterOnboarding(true, true, ONBOARDING_POLICY_ID, ACTIVE_WORKSPACE_ID, ONBOARDING_ADMINS_CHAT_REPORT_ID, !(testSession?.email ?? '').includes('+'));
115+
expect(navigate).toHaveBeenCalledWith(ROUTES.REPORT_WITH_ID.getRoute(REPORT_ID));
116+
});
105117
});

0 commit comments

Comments
 (0)