Skip to content

Post React Query migration improvements#802

Closed
arbrandes wants to merge 23 commits intoopenedx:frontend-basefrom
arbrandes:frontend-base-master-ports-improvements
Closed

Post React Query migration improvements#802
arbrandes wants to merge 23 commits intoopenedx:frontend-basefrom
arbrandes:frontend-base-master-ports-improvements

Conversation

@arbrandes
Copy link
Contributor

@arbrandes arbrandes commented Mar 5, 2026

Description

Follow-up improvements to the ports from master (including but not limited to the big React Query migration) in #801:

  • Transform course data once in the queryFn instead of per card render
  • Replace BackedDataProvider with direct React Query cache lookups
  • Use explicit query key for initializeBase invalidation
  • Add smart retry that skips 4xx errors but retries server/network errors
  • Separate mutation keys from query keys
  • Replace useReducer with useState in context providers
  • Add normal user happy path test for useInitializeLearnerHome
  • Fix lint errors in queryHooks test

NoyanAziz and others added 7 commits March 4, 2026 16:07
Co-authored-by: Adolfo R. Brandes <adolfo@axim.org>
Co-authored-by: Deborah Kaplan <deborahgu@users.noreply.github.com>
Co-authored-by: Adolfo R. Brandes <adolfo@axim.org>
…extra repositories (openedx#752)

Co-authored-by: Adolfo R. Brandes <adolfo@axim.org>
Co-authored-by: Adolfo R. Brandes <adolfo@axim.org>
Co-authored-by: Adolfo R. Brandes <adolfo@axim.org>
Co-authored-by: Adolfo R. Brandes <adolfo@axim.org>
Use 'test' string literal instead of EnvironmentTypes.TEST and
import only the type to avoid circular dependency when mocking
@openedx/frontend-base itself.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@codecov
Copy link

codecov bot commented Mar 5, 2026

Codecov Report

❌ Patch coverage is 95.29412% with 24 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (frontend-base@0632525). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...gets/LearnerDashboardHeader/MasqueradeBar/hooks.js 0.00% 9 Missing and 5 partials ⚠️
...components/CourseCardBanners/CertificateBanner.jsx 82.35% 3 Missing ⚠️
...Card/components/CourseCardBanners/CourseBanner.jsx 71.42% 2 Missing ⚠️
...ners/CourseFilterControls/CourseFilterControls.jsx 88.23% 2 Missing ⚠️
...components/CourseCardBanners/CreditBanner/hooks.js 90.00% 1 Missing ⚠️
...ners/CourseCard/components/CourseCardMenu/hooks.js 94.11% 1 Missing ⚠️
src/containers/CoursesPanel/index.jsx 91.66% 1 Missing ⚠️
Additional details and impacted files
@@               Coverage Diff                @@
##             frontend-base     #802   +/-   ##
================================================
  Coverage                 ?   90.33%           
================================================
  Files                    ?      152           
  Lines                    ?     1283           
  Branches                 ?      266           
================================================
  Hits                     ?     1159           
  Misses                   ?      119           
  Partials                 ?        5           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@arbrandes arbrandes changed the title React Query migration improvements Post React Query migration improvements Mar 5, 2026
arbrandes and others added 11 commits March 5, 2026 11:57
Remove all Redux files and packages. Add React Query hooks, Context
providers, typed API layer, data transformers, and tests. Migrate all
components including CourseCard, CourseCardBanners, CourseFilterControls,
CoursesPanel, Dashboard, modals, and remaining widgets. Reconcile
masquerade implementations with frontend-base providers.ts architecture.

Co-Authored-By: Jacobo Dominguez <jacobo.dominguez@wgu.edu>
Co-Authored-By: Claude <noreply@anthropic.com>
useInitializeLearnerHome() is consumed by 15+ components, and with
staleTime defaulting to 0, every mount and window focus triggered a
redundant background refetch. Set staleTime to 5 minutes since
dashboard data rarely changes while the user is viewing it.

Co-Authored-By: Claude <noreply@anthropic.com>
The useUnenrollFromCourse mutation already calls invalidateQueries on
success, which triggers a refetch automatically. The manual refetch()
call in closeAndRefresh caused the API to be called twice.

Co-Authored-By: Claude <noreply@anthropic.com>
The fallback enrollment date was frozen when the module first loaded.
If the app stayed open across midnight, courses with null lastEnrolled
would get a stale timestamp.

Co-Authored-By: Claude <noreply@anthropic.com>
Previously, modals closed immediately after firing mutations via
mutate(), giving no feedback on failure. Now the close action is
passed as an onSuccess callback so the modal stays open if the
mutation fails.

Co-Authored-By: Claude <noreply@anthropic.com>
Auto-fixed stylistic issues (indentation, semicolons, brace style,
type→interface, Array<T>→T[]) and manually fixed display-name errors
(named wrapper functions), @ts-ignore@ts-expect-error, and
Function→explicit signature.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Convert GlobalDataContext.jsx to .tsx with proper interface so
setEmailConfirmation and setPlatformSettings are typed as
Dispatch<SetStateAction<T>> | null instead of literal null.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The tsconfig declares "types": ["jest"] but @types/jest was not
installed, so TypeScript treated jest as a namespace rather than a
value.  Adding the matching type definitions lets the webpack
type-checker process test files without errors.

Also bump frontend-base to fix the @src alias in jest config.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Previously, each useCourseData(cardId) call independently transformed
the full course list via getTransformedCourseDataList just to find one
item. With N course cards, this ran N times per render cycle.

Now the transformation runs once in the queryFn, stored as
coursesByCardId on the cached data. useCourseData does an O(1) lookup
and CoursesPanel reads directly from the pre-transformed data.

Co-Authored-By: Claude <noreply@anthropic.com>
The masquerade fallback data was maintained in a separate context
provider, duplicating what React Query already caches. Now when
masquerading fails, the normal user's data is read directly from the
query cache via queryClient.getQueryData(). This eliminates
BackedDataProvider and its associated useEffect sync.

Co-Authored-By: Claude <noreply@anthropic.com>
Mutations were invalidating with initialize() which produces a key
with trailing undefined, relying on React Query implementation details
for prefix matching. Added initializeBase() that produces a clean
prefix key ['learner-dashboard', 'initialize'] for unambiguous
invalidation of all initialize queries regardless of masquerade user.

Co-Authored-By: Claude <noreply@anthropic.com>
@arbrandes arbrandes force-pushed the frontend-base-master-ports-improvements branch from 769494c to 276b45f Compare March 5, 2026 16:25
arbrandes and others added 5 commits March 5, 2026 13:35
… errors

Client errors (4xx) won't resolve on retry, so skip them. Server errors
(5xx) and network failures get up to 3 retries with React Query's
default exponential backoff.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Split learnerDashboardQueryKeys into distinct query and mutation key
factories for clearer semantics. Mutation keys now live in
learnerDashboardMutationKeys while query invalidation still uses
learnerDashboardQueryKeys.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
MasqueradeProvider and FiltersProvider used useReducer with action
type enums for what are simple value states. Replaced with useState
for less boilerplate while preserving the same public API.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Verifies the basic flow: API is called without masquerade user,
data is returned with coursesByCardId transformation applied.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@arbrandes arbrandes force-pushed the frontend-base-master-ports-improvements branch from 276b45f to 1f109e1 Compare March 5, 2026 16:41
@arbrandes arbrandes closed this Mar 6, 2026
@arbrandes arbrandes deleted the frontend-base-master-ports-improvements branch March 6, 2026 22:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

6 participants