Repository navigation
refactor: port the courseware data module to frontend-base - #2260
Draft
brian-smith-tcril wants to merge 1 commit into
Draft
brian-smith-tcril wants to merge 1 commit into
brian-smith-tcril wants to merge 1 commit into
Conversation
The rest of courseware/data moves to the same path under
frontend-base/src: api.js and apiHooks.ts in full, at the paths where
their metadata slice already was, and the three normalizers,
courseNavigationOutline.ts, minimalCourseOutline.ts and
sequenceMetadata.ts. useMinimalCourseOutline is the real query in place
of its stub, and courseware/data/index.js exports getResumeBlock and
getSequenceForUnitDeprecated again. Nothing renders on a route yet; the
hooks the navigation sidebar, the unit and the discussions widget read
come with the file and their cases.
Platform imports become @openedx/frontend-base ones and LMS_BASE_URL
reads become getSiteConfig().lmsBaseUrl. Every query spreads
queryDefaults; sequenceMetadataQuery keeps its own retry: false after
the spread.
useIsPreview compares the pathname with the learning role's URL followed
by /preview. master tests startsWith('/preview') on a pathname its
router has already stripped of /learning; under the shell learning is a
route, and the pathname starts with it.
master's apiHooks.test.tsx joins the cases already here, with the
preview case rendered under /learning/preview. New cases for what the
port changes: each query carries the query defaults, and useIsPreview on
the preview path, the course path and master's unprefixed path.
More new cases run lines master reaches only through suites that port
later: the resume lookup; the parent sequence lookup with its request
parameters, a unit no sequence holds, and no signed-in user; a sequence
with a saved position; a sidebar outline whose section and sequence
have no children; a unit completed in a sequence that has another; a
sidebar toggles response without the flag; and a loaded course whose
outline has no sections.
The learningSequencesOutline and sequenceMetadata factories and
buildSimpleCourseBlocks come with these tests.
buildSimpleCourseAndSequenceMetadata, which only master's course request
harness calls, is commented out under the issue that brings the harness
(#2196). The courseRecommendations and discussionTopics imports stay
commented out, now under the issues whose suites build them (#2202,
#2199). The sequenceMetadata factory declares its course id as an
option with no default, which rosie requires a value for. master gives
it a default that returns its argument or throws, and rosie passes that
default no argument, so it only ever threw. The Pact consumer test is
dropped in the manifest, as the course-home one was: nothing publishes
or verifies its contract.
Part of #2195.
Co-Authored-By: Claude <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## bsmith/outline-tab #2260 +/- ##
======================================================
+ Coverage 97.07% 97.15% +0.08%
======================================================
Files 520 525 +5
Lines 7990 8221 +231
Branches 1884 1914 +30
======================================================
+ Hits 7756 7987 +231
Misses 222 222
Partials 12 12
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This was referenced Nov 18, 2026
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.
Summary
The rest of Learning's courseware data module now lives in the frontend-base package:
courseware/data/api.jsandapiHooks.tsin full, the three normalizers behind them, and the factories their tests build. No user-facing change: no route renders any of it until the courseware container ports two layers up (#2262), and the legacy tree undersrc/is untouched.Part of #1905. Part of #2195. Stacked above #2252; the route wrappers (#2261) and the container with its redirects (#2262) follow.
Note
For reviewers: the ported files are added or filled in under
frontend-base/src/, so this diff cannot show what changed frommaster. Theport-diffscript in #2234's description prints that diff, fromfrontend-base/manifest.tsv. Three of the ported files are identical tomaster's:courseware/data/index.js,minimalCourseOutline.tsandminimalCourseOutline.test.ts. Three more differ in one import line:courseNavigationOutline.ts,sequenceMetadata.tsandlearningSequencesOutline.factory.js.What changed
api.jsandapiHooks.tsport in full, at the paths where their metadata slice already was. Platform imports become@openedx/frontend-baseones and the twelvegetConfig().LMS_BASE_URLreads becomegetSiteConfig().lmsBaseUrl. Each of the eight queries spreadsqueryDefaults, as every ported query has since Port the dates tab to frontend-base #2189;sequenceMetadataQuerykeeps its ownretry: falseafter the spread.useIsPreviewcompares the pathname with the learning role's URL followed by/preview.mastertestsstartsWith('/preview')on a pathname its router has stripped of/learning; under the shelllearningis a route, and the pathname starts with it.useMinimalCourseOutlineis the real query in place of its stub, andcourseware/data/index.jsexportsgetResumeBlockandgetSequenceForUnitDeprecatedagain, so the index ismaster's.courseNavigationOutline.ts,minimalCourseOutline.tsandsequenceMetadata.ts.learningSequencesOutline,sequenceMetadataandbuildSimpleCourseBlockscome with the hook tests that build them.buildSimpleCourseAndSequenceMetadata, which onlymaster's course-request harness calls, is commented out under Port the courseware sequence and unit to frontend-base #2196's URL. ThecourseRecommendationsanddiscussionTopicsimports stay commented out, now under the issues whose suites build them (Port the course exit page to frontend-base #2202, Port the auxiliary sidebar to frontend-base #2199).sequenceMetadatafactory declares its course id as an option with no default, which rosie requires a value for.mastergives the option a default that returns its argument or throws; rosie passes that default no argument, so it only ever threw, behind a branch no input reaches (decision log entry 9).droppedin the manifest, as the course-home one was in refactor: port the dates tab to frontend-base #2234: nothing publishes or verifies the contract it writes.Testing
In
frontend-base/: lint, the tests,buildandbuild:cipass. 43 suites, 643 tests passed and 11 skipped (all skipped in earlier layers, under the issues that port what they render). Lint ran with the package's.jsxfiles included (openedx/frontend-base#327).master's tests.minimalCourseOutline.test.tsismaster's file.master'sapiHooks.test.tsxjoins the cases #2249 wrote in the same file; its cases change in their imports, the mock logging service and the preview case's path, which is under/learning/preview.New cases, for what the port changes: each query carries the query defaults, and
sequenceMetadataQuerykeeps itsretry: false;useIsPreviewon the preview path, the course path andmaster's unprefixed/preview/…path, which is no longer a preview.New cases, for lines
masterruns only through suites that port later (the container's and the course component's), since each layer's patch is covered by its own tests: the resume lookup; the parent-sequence lookup with its request parameters, for a unit no sequence holds, and with no signed-in user; a sequence with a saved position; a sidebar outline whose section and sequence have no children; a unit completed in a sequence that holds another; a sidebar toggles response without the flag; a loaded course whose outline has no sections; and thesequenceMetadatafactory built without a course id.Coverage. The package is at 100% of lines at this layer, against its 96.15% bar. Counted as codecov counts a patch, against #2252's head, the layer adds 238 lines with none missed and none partly covered.
Manual testing. None: no route renders this module yet. The two layers above carry the manual passes.
Decisions
What was decided while building this layer; the scope and the import mapping are in #2195.
Full decision log
Decisions: the courseware data module (#2260)
Decisions made while building this layer of #2195. The scope and the
import mapping are in #2195's plan and are not repeated.
The bottom layer of three, one commit. The rest of
courseware/data/ports whole; the two route wrappers (refactor: port the route wrappers to frontend-base as layout routes #2261) andthe container with its redirects (refactor: port the courseware container and redirects to frontend-base #2262) are the layers above.
Nothing renders on a route in this layer.
api.jsandapiHooks.tsaremaster's files with three kindsof change. Platform imports become
@openedx/frontend-baseones;getConfig().LMS_BASE_URLbecomesgetSiteConfig().lmsBaseUrl(twelve reads, all in
api.js); each of the eightqueryOptionscalls spreads
queryDefaultsfirst, sosequenceMetadataQuery'sown
retry: falsestill wins. The eleven non-null assertionsmaster'sapiHooks.tscarries port as they are; the port addsnone.
useIsPreviewcompares against the learning role's URL. It ispathname.startsWith(${getUrlByRouteRole(learningRole)}/preview).master'sstartsWith('/preview')reads a pathname its router hasstripped of
/learning; under the shell the pathname starts withit. Three cases pin it: the preview path, the course path, and
master's unprefixed/preview/...path, which is no longer apreview.
The spread stays on each query. Eight
...queryDefaultsin onefile read as repetition, and a helper that wraps
queryOptionsandadds the defaults was weighed on review. Not taken: the queries
ported before this layer carry the spread too (seven in
course-home/data/apiHooks.ts, one in this file since fix: read the entrance exam status on the progress tab #2249), so ahelper would touch all fifteen definitions in both files to save a
line in each, which is more machinery than the repetition costs.
openedx/frontend-app-gradebook has such a wrapper, on the hook:
useGradebookQueryspreadsgradebookQueryOptionsinsrc/data/query.ts.Tests.
master'sapiHooks.test.tsxis merged into the filefix: read the entrance exam status on the progress tab #2249 created: that file's describe block stays first, and
master's eleven follow. Changed inmaster's cases: the imports,the mock logging service read from
getLoggingService(), and thepreview case's path. Added for what the port changes:
sequenceMetadataQuerykeeps itsretry: false;useIsPreviewon the three paths of entry 3.Lines
masterreaches only through later suites get caseshere. Each layer's patch is covered by tests in that layer (the
coverage rule in Port the courseware container and redirects to frontend-base #2195). Counted as codecov counts a patch, the
port with only the cases of entry 5 left 14 lines missed and 5
partly covered, all of them lines
masterruns through thecontainer's suite or the course component's. Added to
apiHooks.test.tsx:resumeBlockQuery: the resume response in camel case;parentSequenceQuery: the parent of a unit, with the request'sfour parameters; a unit no sequence holds; an empty
usernamewith no signed-in user (
getSequenceForUnitDeprecatedUrl's otherbranch, which an anonymous visitor to a public course takes);
activeUnitIndex);children;sequence stays incomplete;
|| falsebranch no
mastercase takes;(
buildEmptyOutline, which nothing onmastercalls).Factories.
learningSequencesOutline,sequenceMetadataandbuildSimpleCourseBlocksare built by the hook tests and come here.buildBinaryCourseBlockswaits for the container suite (refactor: port the courseware container and redirects to frontend-base #2262). Nosuite of Port the courseware container and redirects to frontend-base #2195 builds
courseRecommendationsordiscussionTopics:masterbuilds them inCourseExit.test.jsxand in the discussionswidget's two tests, so their commented imports now name Port the course exit page to frontend-base #2202 and
Port the auxiliary sidebar to frontend-base #2199. The two factories lose
master'seslint-disable-line import/no-extraneous-dependencies, a rule thepackage's lint does not define.
buildSimpleCourseAndSequenceMetadatais commented out underPort the courseware sequence and unit to frontend-base #2196's URL, with its import, as
courseBlocks.factory.jscarriedits two builders until Port the courseware container and redirects to frontend-base #2195. Only
master's course-requestharness (
mockCourseRequestsinsetupTest.js) calls it, and theharness arrives with the first suite that uses it.
The
sequenceMetadatafactory's course id is an option with nodefault.
masterhas.option('courseId', (courseId) => { if (courseId) { return courseId; } throw … }). rosie calls anoption's generator only when the caller gave no value, and passes
it the option's declared dependencies: its README, under
instance.option,says "This list of
dependencieswill match the parameters thatare passed to the
generator_function". This option declaresnone, so
courseIdis always undefined in the generator and theifnever passes: one missed and one partly covered line that noinput reaches.
as confusing on review.
default must be given a value, or the build throws
option `courseId` has no default value and none was provided(
src/rosie.js). The factory is.option('courseId').master's message goes; a case inapiHooks.test.tsxassertsrosie's.
The Pact consumer test is
dropped.courseware/data/pact-tests/lmsPact.test.jsxgets adroppedmanifest line, as the course-home one did in refactor: port the dates tab to frontend-base #2234: nothing
publishes or verifies the contract it writes.
The comment in
course-exit/utils.test.tssaid the outlinequery was a stub until Port the courseware container and redirects to frontend-base #2195. It now says nothing there fetches
the metadata or the outline, which is why the cases supply both.
Checks (2026-11-17).
npm run lintclean, with the package's.jsxfiles included (openedx lintdoes not lint.jsxfiles frontend-base#327);npm test, 43suites, 643 passed, 11 skipped (all from earlier layers); 100% of
lines for the package.
npm run buildandnpm run build:cipass. Counted as codecov counts a patch, against refactor: port the outline tab to frontend-base #2252's head: 238
added lines, none missed and none partly covered.
🤖 Generated with Claude Code