Fix blank profile after registration#2923
Merged
Merged
Conversation
|
Frontend test coverage: 72.59% (+0.09% compared to 72.5% on base) |
The profile page rendered empty right after sign-up: no first/last name,
gender unselected, and "Год рождения: NaN" / invalid-date.
Root cause is a navigation-vs-task race in registration-form. The shared
loginTask called router.transitionTo('index') the moment the session
authenticated — in the middle of registrationTask. That navigation tears down
the registration-form component, and ember-concurrency auto-cancels the still
running registrationTask before patchUserInfo() and the refreshing
loadCurrentUser() complete. So userData.userModel kept the empty pre-patch stub
(loadCurrentUser otherwise only runs in application.beforeModel at boot), and a
missing bornYear made fromLatestUserDto emit the literal string "NaN".
Fixes:
- registration-form: remove the redirect from loginTask and move it to the end
of registrationTask, after patchUserInfo + loadCurrentUser. The redirect now
fires whenever the session is authenticated, even if the profile PATCH fails,
so a fully-registered user is never trapped on the form (re-submitting would
re-run registerUser and fail with "user already exists"); they can finish
their profile on the profile page, which patches each field on input.
- network: fromLatestUserDto now yields an empty birthday string instead of
"NaN" when bornYear is missing/invalid, and drops the vestigial Date
round-trip.
Tests:
- network: birthday parsed from bornYear; missing bornYear -> '' (fails on old).
- registration-form: redirect happens only after the profile is patched and
reloaded (fails on old ordering); and the user is still redirected when the
profile patch fails after auth.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
98d6ff9 to
8a04fa4
Compare
|
Frontend test coverage: 72.61% (+0.14% compared to 72.47% on base) |
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Problem
Right after a user registers, their profile page renders blank — empty first/last name, gender unselected, and Год рождения: NaN with an "invalid date" error.
![symptom: blank profile after registration]
Root cause
A navigation-vs-task race in
registration-form.registrationTaskruns:registerUser→await loginTask.perform()→patchUserInfo()(saves name/bornYear/gender) →loadCurrentUser()(refreshes the trackeduserModelthe profile reads).The shared
loginTaskcalledrouter.transitionTo('index')the moment the session authenticated — in the middle ofregistrationTask. That navigation tears down theregistration-formcomponent, and ember-concurrency auto-cancels the still-runningregistrationTaskbeforepatchUserInfo+ the refreshingloadCurrentUsercomplete. SouserData.userModelkeeps the empty pre-patch stub (it otherwise only repopulates inapplication.beforeModelat app boot), and a missingbornYearmadefromLatestUserDtoemit the literal string"NaN".Tellingly, the existing integration test mocked
session.isAuthenticated = false, so thetransitionTopath — the buggy one — was never exercised.Fix
registration-form/index.gts— remove the redirect fromloginTask; move it to the end ofregistrationTask, afterpatchUserInfo+loadCurrentUser. The redirect now fires whenever the session is authenticated, even if the profile PATCH fails, so a fully-registered, authenticated user is never trapped on the form (re-submitting would re-runregisterUser→ "user already exists" dead-end, andloginInProgresswould leave a stuck spinner). They can finish their profile on the profile page, which patches each field on input.services/network.ts—fromLatestUserDtonow yields an emptybirthdaystring instead of"NaN"whenbornYearis missing/invalid, and drops the vestigialnew Date()round-trip.Tests
network-test.js—birthdayparsed frombornYear; missingbornYear→''(fails on old code, which produced"NaN").registration-formcomponent test — redirect happens only after the profile is patched and reloaded (fails on the old ordering); and the user is still redirected when the profile patch fails after auth.Verification
pnpm run lint:types(ember-tsc), ESLint, and ember-template-lint all pass on the changed files.ember testrunner does not boot on this repo (pre-existing globalCould not find module ./packageerror, reproduces on a cleanmaster), so the new tests are traced-by-hand to fail-on-old / pass-on-new rather than executed locally. CI will run them.🤖 Generated with Claude Code