fix: dashboard card courserun association#3365
Open
gumaerc wants to merge 1 commit into
Open
Conversation
OpenAPI ChangesNo changes detected Unexpected changes? Ensure your branch is up-to-date with |
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a dashboard regression where a learner could appear unenrolled (and lose completion/certificate context) after a newer course run supplanted the run they were actually enrolled in, by updating the legacy dashboard enrollment-selection logic to match enrollments to courses by course id (with run-id matching retained as a fallback).
Changes:
- Add a helper (
enrollmentBelongsToCourse) that associates an enrollment to a course bycourse.idfirst, falling back to legacy run-id matching. - Update
pickDisplayedEnrollmentForLegacyDashboardto use the new course-matching helper. - Add a regression test covering the “older enrolled run, newer run only in course payload” scenario.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| frontends/main/src/app-pages/DashboardPage/CoursewareDisplay/model/dashboardViewModel.ts | Adjusts legacy enrollment-to-course matching to prefer course-id association, avoiding false “unenrolled” display when runs are supplanted. |
| frontends/main/src/app-pages/DashboardPage/CoursewareDisplay/model/dashboardViewModel.test.ts | Adds focused regression coverage ensuring older enrolled runs are still selected when the course payload only includes the newer run. |
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.
What are the relevant tickets?
Closes https://github.com/mitodl/hq/issues/11387
Description (What does it do?)
This fixes a dashboard regression where a learner could appear unenrolled from a course after a newer run supplanted the run they were actually enrolled in.
The dashboard card selection logic was only treating an enrollment as relevant when its run id was still present in the course's current
courserunspayload. In the B2B contract case from the linked issue, that meant older enrolled runs could be dropped from the card context once a newer run became the current/default run, which also hid certificate/completion context.This change updates the legacy dashboard enrollment selection logic to associate enrollments to a course by course id first, with the existing run-id match kept as a fallback. That allows the dashboard to continue surfacing a learner's real enrolled run even when the course payload only lists a newer run.
A regression test was added for the exact failure mode: an older enrolled run should still be selected when the course payload only contains the newer supplanting run.
How can this be tested?
Automated testing:
docker compose exec watch yarn test frontends/main/src/app-pages/DashboardPage/CoursewareDisplay/model/dashboardViewModel.test.tsManual testing:
mainand verify that you can reproduce the original bugReviewer validation:
dashboardViewModel.ts.dashboardViewModel.test.ts.