-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SWC-7237 #1549
SWC-7237 #1549
Conversation
@@ -42,21 +42,20 @@ function LoggedInRedirector() { | |||
const isProviderSearchParam = getSearchParam('provider') !== undefined | |||
const isInSSOFlow = isCodeSearchParam && isProviderSearchParam | |||
|
|||
const { mayRedirect: mayRedirectToSignToS } = | |||
useMaybeRedirectToSignTermsOfService() | |||
const { mayPromptTermsOfUse } = useMaybeRedirectToSignTermsOfService() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed the variable for clarity. It still indicates that we may force the user to see the ToU page.
For the case where the user is on the ToU page, this should (and will) be true, but we will not 'redirect' them since they are already there.
apps/SageAccountWeb/src/hooks/useMaybeRedirectToSignTermsOfService.test.ts
Outdated
Show resolved
Hide resolved
it('redirects to signTermsOfUse when user ToS is MUST_AGREE_NOW and has signed ToU', async () => { | ||
mockUseApplicationSessionContext.mockReturnValue({ | ||
hasInitializedSession: true, | ||
refreshSession: vi.fn(), | ||
clearSession: vi.fn(), | ||
isLoadingSSO: false, | ||
termsOfServiceStatus: { | ||
userId: '1234', | ||
userCurrentTermsOfServiceState: TermsOfServiceState.MUST_AGREE_NOW, | ||
lastAgreementDate: new Date().toISOString(), | ||
}, | ||
}) | ||
|
||
const hook = renderHook(() => useMaybeRedirectToSignTermsOfService()) | ||
await waitFor(() => { | ||
expect(hook.result.current.mayPromptTermsOfUse).toBe(true) | ||
expect(mockNavigate).toHaveBeenCalledWith( | ||
'/authenticated/signUpdatedTermsOfUse', | ||
) | ||
}) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This case is closest to the scenario reported by the user. The assertion expect(hook.result.current.mayPromptTermsOfUse).toBe(true)
fails with the old logic and passes with the new logic.
} else { | ||
setMayPromptTermsOfUse(false) | ||
} | ||
setMayRedirect(false) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrapping in else
fixes the bug.
it('redirects to signTermsOfUse when user ToS is MUST_AGREE_NOW and has signed ToU', async () => { | ||
mockUseApplicationSessionContext.mockReturnValue({ | ||
...mockApplicationSessionContext, | ||
termsOfServiceStatus: { | ||
userId: '1234', | ||
userCurrentTermsOfServiceState: TermsOfServiceState.MUST_AGREE_NOW, | ||
lastAgreementDate: new Date().toISOString(), | ||
}, | ||
}) | ||
|
||
const hook = renderHook(() => useMaybeRedirectToSignTermsOfService()) | ||
await waitFor(() => { | ||
expect(hook.result.current.mayPromptTermsOfUse).toBe(true) | ||
expect(mockNavigate).toHaveBeenCalledWith( | ||
'/authenticated/signUpdatedTermsOfUse', | ||
) | ||
}) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This case is closest to the scenario reported by the user. The assertion expect(hook.result.current.mayPromptTermsOfUse).toBe(true)
fails with the old logic and passes with the new logic.
Fix issue where we improperly indicated that we will not force the user to re-accept the ToU after they are redirected to show the ToU.