Skip to content

Commit baae86a

Browse files
authored
Remove param based onboarding navigation (#2233)
* Remove onboarding finish navigation from next param * Remove param in test
1 parent 4393139 commit baae86a

File tree

4 files changed

+6
-48
lines changed

4 files changed

+6
-48
lines changed

authentication/views.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from django.contrib.auth import logout
66
from django.shortcuts import redirect
7-
from django.utils.http import url_has_allowed_host_and_scheme, urlencode
7+
from django.utils.http import url_has_allowed_host_and_scheme
88
from django.views import View
99

1010
from main import settings
@@ -80,8 +80,7 @@ def get(
8080
not profile.completed_onboarding
8181
and request.GET.get("skip_onboarding", "0") == "0"
8282
):
83-
params = urlencode({"next": redirect_url})
84-
redirect_url = f"{settings.MITOL_NEW_USER_LOGIN_URL}?{params}"
83+
redirect_url = settings.MITOL_NEW_USER_LOGIN_URL
8584
profile.completed_onboarding = True
8685
profile.save()
8786
return redirect(redirect_url)

authentication/views_test.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,14 @@ def test_custom_login_view_authenticated_user_with_onboarding(mocker):
120120
request.user = MagicMock(is_anonymous=False)
121121
request.user.profile = MagicMock(completed_onboarding=False)
122122
mocker.patch("authentication.views.get_redirect_url", return_value="/dashboard")
123-
mocker.patch("authentication.views.urlencode", return_value="next=/dashboard")
124123
mocker.patch(
125124
"authentication.views.settings.MITOL_NEW_USER_LOGIN_URL", "/onboarding"
126125
)
127126

128127
response = CustomLoginView().get(request)
129128

130129
assert response.status_code == 302
131-
assert response.url == "/onboarding?next=/dashboard"
130+
assert response.url == "/onboarding"
132131

133132

134133
def test_custom_login_view_authenticated_user_skip_onboarding(mocker):

frontends/main/src/app-pages/OnboardingPage/OnboardingPage.test.tsx

Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { merge, times } from "lodash"
44
import {
55
renderWithProviders,
66
screen,
7+
waitFor,
78
setMockResponse,
89
user,
910
} from "../../test-utils"
@@ -18,32 +19,8 @@ import {
1819
type Profile,
1920
} from "api/v0"
2021

21-
import { waitFor } from "@testing-library/react"
22-
2322
import OnboardingPage from "./OnboardingPage"
2423

25-
const oldWindowLocation = window.location
26-
27-
beforeAll(() => {
28-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
29-
delete (window as any).location
30-
31-
window.location = Object.defineProperties(
32-
{} as unknown as string & Location,
33-
{
34-
...Object.getOwnPropertyDescriptors(oldWindowLocation),
35-
assign: {
36-
configurable: true,
37-
value: jest.fn(),
38-
},
39-
},
40-
)
41-
})
42-
43-
afterAll(() => {
44-
window.location = oldWindowLocation as unknown as string & Location
45-
})
46-
4724
const STEPS_DATA: Partial<Profile>[] = [
4825
{
4926
topic_interests: [factories.learningResources.topic()],
@@ -91,9 +68,7 @@ const setup = async (profile: Profile) => {
9168
...req,
9269
}))
9370

94-
renderWithProviders(<OnboardingPage />, {
95-
url: "/onboarding?next=http%3A%2F%2Flearn.mit.edu",
96-
})
71+
renderWithProviders(<OnboardingPage />)
9772
}
9873

9974
// this function sets up the test and progresses the UI to the designated step
@@ -132,15 +107,8 @@ describe("OnboardingPage", () => {
132107
const nextStep = step + 1
133108
await setupAndProgressToStep(step)
134109
if (step === STEP_TITLES.length - 1) {
135-
const finishButton = await findFinishButton()
136-
110+
await findFinishButton()
137111
expect(queryBackButton()).not.toBeNil()
138-
139-
await user.click(finishButton)
140-
await waitFor(() => {
141-
expect(window.location).toBe("http://learn.mit.edu")
142-
})
143-
144112
return
145113
}
146114

frontends/main/src/app-pages/OnboardingPage/OnboardingPage.tsx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ import { DASHBOARD_HOME } from "@/common/urls"
2727
import { useFormik } from "formik"
2828
import { useLearningResourceTopics } from "api/hooks/learningResources"
2929
import { useUserMe } from "api/hooks/user"
30-
31-
import { useSearchParams } from "next/navigation"
3230
import {
3331
CERTIFICATE_CHOICES,
3432
EDUCATION_LEVEL_OPTIONS,
@@ -158,8 +156,6 @@ const OnboardingPage: React.FC = () => {
158156
const { isLoading: userLoading, data: user } = useUserMe()
159157
const [activeStep, setActiveStep] = React.useState<number>(0)
160158
const router = useRouter()
161-
const searchParams = useSearchParams()
162-
const nextUrl = searchParams.get("next")
163159

164160
const formik = useFormik({
165161
enableReinitialize: true,
@@ -175,10 +171,6 @@ const OnboardingPage: React.FC = () => {
175171
if (activeStep < NUM_STEPS - 1) {
176172
setActiveStep((prevActiveStep) => prevActiveStep + 1)
177173
} else {
178-
if (nextUrl) {
179-
;(window as Window).location = nextUrl
180-
return null
181-
}
182174
router.push(DASHBOARD_HOME)
183175
}
184176
},

0 commit comments

Comments
 (0)