Skip to content
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

Merged
merged 3 commits into from
Feb 3, 2025
Merged

SWC-7237 #1549

merged 3 commits into from
Feb 3, 2025

Conversation

nickgros
Copy link
Collaborator

@nickgros nickgros commented Feb 3, 2025

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.

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.
@@ -42,21 +42,20 @@ function LoggedInRedirector() {
const isProviderSearchParam = getSearchParam('provider') !== undefined
const isInSSOFlow = isCodeSearchParam && isProviderSearchParam

const { mayRedirect: mayRedirectToSignToS } =
useMaybeRedirectToSignTermsOfService()
const { mayPromptTermsOfUse } = useMaybeRedirectToSignTermsOfService()
Copy link
Collaborator Author

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.

Comment on lines 141 to 161
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',
)
})
})
Copy link
Collaborator Author

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.

Comment on lines +49 to 52
} else {
setMayPromptTermsOfUse(false)
}
setMayRedirect(false)
}
Copy link
Collaborator Author

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.

Comment on lines +140 to +157
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',
)
})
})
Copy link
Collaborator Author

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.

@nickgros nickgros merged commit 9d3ac14 into Sage-Bionetworks:main Feb 3, 2025
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants