Repository navigation
refactor: port the modules the outline tab shares to frontend-base - #2251
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## frontend-base #2251 +/- ##
=================================================
+ Coverage 96.77% 96.81% +0.03%
=================================================
Files 478 485 +7
Lines 7382 7469 +87
Branches 1769 1780 +11
=================================================
+ Hits 7144 7231 +87
Misses 223 223
Partials 15 15
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:
|
d09cf17 to
47f5333
Compare
29a67cf to
5cdad42
Compare
arbrandes
left a comment
There was a problem hiding this comment.
Approved with two suggestions.
|
|
||
| const showAccountActivationAlert = Cookies.get('show-account-activation-popup'); | ||
| if (showAccountActivationAlert !== undefined) { | ||
| Cookies.remove('show-account-activation-popup', { path: '/', domain: getAppConfig(appId).SESSION_COOKIE_DOMAIN }); |
There was a problem hiding this comment.
We should probably add SESSION_COOKIE_DOMAIN: null to the app's default config (frontend-base/src/app.ts:9-15). It's the only key the package reads that isn't listed there, and that list is the closest thing an operator has to documentation of what can be set.
It matters a bit more than the others: when the LMS sets the cookie on a parent domain and the operator hasn't set this key, the cookie is never removed and the activation alert silently never opens.
Behavior doesn't change with a null default: the new test already resets the key to null and passes.
There was a problem hiding this comment.
| it('gives today as the start date when the course metadata is gone from the cache', () => { | ||
| const { container } = render(<CourseStartMasqueradeBanner payload={{ courseId }} />); | ||
|
|
||
| const today = new Intl.DateTimeFormat('en').format(new Date()); | ||
| expect(container).toHaveTextContent(`The course starts on ${today}.`); | ||
| }); |
There was a problem hiding this comment.
I'm not sure this case is worth pinning (optional). I'd drop the ?? {} and this case together, as the PR already does for the course start alert. The case asserts that staff are told the course starts today, which is wrong, and the banner only shows once the metadata says someone is masquerading, so it can't be reached without metadata anyway.
Fine to leave if you'd rather keep master's line as it is.
There was a problem hiding this comment.
755ccb6 to
5b93f6e
Compare
shared/effort-estimate, alerts/course-start-alert and the account activation alert (alerts/logistration-alert/AccountActivationAlert.jsx, messages.ts) move to the same paths under frontend-base/src, with manifest lines. Nothing renders them on a route yet. The account activation alert's request comes with it: courseware/data/ api.js gains sendActivationEmail, and courseware/data/index.js ports exporting that one name; getResumeBlock and getSequenceForUnitDeprecated stay commented out there until #2195. The alert reads the cookie domain from the app config's SESSION_COOKIE_DOMAIN, which app.ts lists at null, where master read process.env, and the site name from the site config. The package declares js-cookie. course-start-alert ports whole: the outline tab reads the alert, and the masquerade banner has no caller until #2194. Both components drop the ?? {} after their metadata read. Without metadata the alert throws either way, so its default only moved the throw. The banner's showed today's date as the start date, and the banner is only shown once that metadata says the requester is masquerading. EffortEstimate drops its defaultProps, a null class name that classNames skips as it does an absent one. For the package's lint, the masquerade banner's multi-line date value gains parentheses and the activities message gains a description. master covers these modules only through the suites of the outline and progress tabs. Here each gets a test of its own: EffortEstimate.test.tsx, course-start-alert/hooks.test.tsx for both hooks and both components, and AccountActivationAlert.test.tsx, which sets the cookie on the document and lets js-cookie read and remove it. The setup file's pattern for Paragon's own defaultProps warnings (openedx/paragon#3043) gains the four modal components the account activation alert mounts. Part of #2191. Co-Authored-By: Claude <noreply@anthropic.com>
5b93f6e to
c020c52
Compare
Summary
The modules Learning's outline tab shares with other pages now live in the frontend-base package: the effort estimate (
shared/effort-estimate/), the course start alert and its masquerade banner (alerts/course-start-alert/), and the account activation alert with the request it sends. No user-facing change: no route renders any of it until the outline tab ports in the next layer of this stack, and the legacy tree undersrc/is untouched.Part of #1905. Part of #2191. Stacked above #2249; the outline tab follows as the layer above this one.
Note
For reviewers: the ported files are added under
frontend-base/src/as new files, 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:course-start-alert/hooks.js,course-start-alert/index.jsandeffort-estimate/index.js.What changed
masterremoves theshow-account-activation-popupcookie onprocess.env.SESSION_COOKIE_DOMAIN. Here the domain isgetAppConfig(appId).SESSION_COOKIE_DOMAIN, an app config key thatapp.tslists atnull: an operator who sets nothing gets the cookie removed on the serving host, asmasterdoes with the variable unset. The continue button's site name isgetSiteConfig().siteName.sendActivationEmailand the courseware data index. The alert imports its request fromcourseware/data, socourseware/data/api.jsgainssendActivationEmailandcourseware/data/index.jsports exporting that one name. The other two names the index re-exports onmaster,getResumeBlockandgetSequenceForUnitDeprecated, are commented out under Port the courseware container and redirects to frontend-base #2195's URL until the courseware container ports them.useCourseStartAlertandCourseStartAlert.jsx.useCourseStartMasqueradeBannerandCourseStartMasqueradeBanner.jsxcome with them and have no caller until the instructor toolbar ports (Wire up the frontend-base masquerade bar #2194). Both components drop the?? {}after their metadata read: without metadata the alert throws either way, and the banner is only shown once that metadata is loaded (decision log entry 9).EffortEstimatedrops itsdefaultProps. React warns about them on a function component. The one default was anullclass name, whichclassNamesskips the same way it skips an absent one.FormattedDatevalue gains parentheses, and the effort estimate'sactivitiesmessage gains adescription; its id and default message are untouched.js-cookieis declared at^3.0.8, the versionmasterinstalls. The lock gains that one package entry.defaultPropswarnings gains four names.AlertModal,ModalDialogBody,ModalDialogFooterandModalDialogTitleare function components declared in Paragon'ssrc/Modal/, each settingdefaultPropsthere, so they join the pattern under Support for defaultProps will be removed from function components in a future major release. paragon#3043. The pattern for react-bootstrap's components (Deprecation warnings from react-bootstrap 1.x components that Paragon wraps paragon#4523) is untouched.Testing
In
frontend-base/: lint, the tests,buildandbuild:cipass. 39 suites, 430 tests passed and 7 skipped (cases kept asit.skipunder the issues that port what they render). Lint ran with the package's.jsxfiles included (openedx/frontend-base#327).New tests.
masterhas no test file for any of these modules; it covers them through the outline and progress tab suites. Each gets one here, since no route in this layer renders them:EffortEstimate.test.tsx: the time in whole minutes, abbreviated on screen and spelled out for screen readers; the activity count; both together; nothing for a block with neither; the class name it is given.course-start-alert/hooks.test.tsx: the alert's full sentence for a course more than a day away and less than a day away, in the learner's time zone and without one, and nothing for a learner who is not enrolled or a course that has started; the masquerade banner on the progress tab, and nothing on another tab or without masquerading.AccountActivationAlert.test.tsx: the alert opens when the cookie is set and removes it; stays closed without it; removes it on the domain the app config names; closes on the continue button and stays open on Escape; resends the activation email, with a spinner until the request settles and a check after. The cases set the cookie on the document and letjs-cookieread and remove it, wheremaster's outline suite replaces the library's functions with mocks.Coverage. The package is at 100% of lines at this layer, against its 96.15% bar, and every file this layer adds is at 100% of lines. Codecov's first report on this PR showed two partially covered lines, the
?? {}after the metadata read inCourseStartAlert.jsxandCourseStartMasqueradeBanner.jsx; both defaults are dropped (decision log entry 9).Manual testing. None: no route renders these modules yet. The outline tab layer carries the manual pass.
Decisions
What was decided while building this layer; the scope and the import and config mapping are in #2191.
Full decision log
Decisions: the modules the outline tab shares (#2251)
Decisions made while building this layer of #2191. The scope and the
import and config mapping are in #2191's plan and are not repeated.
The outline tab ports as two layers; this is the bottom one.
The effort estimate, the course start alert, the account activation
alert with its request, and the
js-cookiedependency, in 13 sourceand test files. Accepted cost: nothing here renders on a route, so
there is no manual pass, and each module gets a test
masterdoesnot have, since this layer's CI meets the line threshold alone.
courseware/data/index.jsports with one of its three names.AccountActivationAlert.jsximportssendActivationEmailfrom thedirectory, so the index ports and
api.jsgains the function. Theother two names it re-exports on
master,getResumeBlockandgetSequenceForUnitDeprecated, are commented out under Port the courseware container and redirects to frontend-base #2195's URL,as the factory indexes carry their unported imports.
The cookie domain is read from the app config, and
app.tsliststhe key at
null.masterreadsprocess.env.SESSION_COOKIE_DOMAINwhen it removes the
show-account-activation-popupcookie; here it isgetAppConfig(appId).SESSION_COOKIE_DOMAIN. An operator who setsnothing gets a cookie removed on the serving host, as
masterdoeswith the variable unset. The site name in the continue button is
getSiteConfig().siteName.following authn, whose
src/app.tsdoes not list it. arbrandes's review comment
(refactor: port the modules the outline tab shares to frontend-base #2251 (comment))
pointed out that it was the only key the package reads that
defaultConfigdoes not list, and that the list is the nearestthing an operator has to documentation of what can be set. Brian
agreed (2026-11-18).
nullchanges no behavior.js-cookieleaves a null attribute outas it does an absent one (entry 7).
getAppConfigmergesdefaultConfigbelow the site'scommonAppConfigand the app'sconfig, so a site sets the key as before.null, is thedefaultConfigrule Port the dates tab to frontend-base #2189 set for this app. authn lists only itsreal defaults and documents this key in its README; this package
has no such table.
EffortEstimateloses itsdefaultProps. React warns about themon a function component and the suite fails on console output. The
one default was
className: null, whichclassNamesskips the sameway it skips an absent one, so no default parameter takes its place.
Lint.
CourseStartMasqueradeBanner.jsx's multi-lineFormattedDatevalue gains parentheses (the autofixer's change).shared/effort-estimate/messages.ts'sactivitiesmessage gains thedescriptionthe package's lint requires; its id and defaultmessage are untouched.
Paragon's own modal
defaultPropswarnings are silenced by exactpattern. The account activation alert mounts
AlertModal, whoseparts (
AlertModal,ModalDialogBody,ModalDialogFooter,ModalDialogTitle) setdefaultPropson function components. Theirnames join the setup file's pattern under Support for defaultProps will be removed from function components in a future major release. paragon#3043, the
issue for
defaultPropson Paragon's own components.The account activation test uses the document's cookie, not a
mock of
js-cookie.mastercovers the alert through the outlinesuite, which replaces
Cookies.getandCookies.removewith mockfunctions. Here the cases set the cookie on jsdom's document and let
the library read and remove it.
SESSION_COOKIE_DOMAINto a domain that isnot the test page's. jsdom refuses that write, so the cookie
remains and the alert stays closed, which is the guard
masterwrote against re-rendering forever; the case asserts the string
written to
document.cookiecarries the configured domain.mergeAppConfigcannot remove a key (it merges, and a merge skipsan undefined value), so the cases restore the key to
null;js-cookieleaves a null attribute out as it does an unset one.onClose, which does nothing onmasterand here.The course start alert's cases compute dates from the current
time. The alert's text depends on the distance to the start date,
so each case sets a start relative to now (7 days and an hour, 2
hours and a minute) and gives the metadata
userTimezone: 'UTC', sothe expected date string does not depend on the machine's time zone.
No test in the package pins the clock, and none does here.
Both
?? {}after the metadata read are dropped. Both run onlyif the component renders with no course metadata in the cache, and
the first push of this layer left both branches untaken, which
codecov showed as two partially covered lines. Each was rendered
alone without metadata to see what its default does.
CourseStartAlert.jsxthrows either way: with the default thestart date is undefined, the distance is
NaN, andFormattedRelativeTimeraises React's "Too many re-renders";without it the destructure throws. The default only moved the
throw, so it is dropped, as refactor: port the dates tab to frontend-base #2234 did in
TimelineandUpgradeToCompleteAlertand refactor: port the modules the progress tab shares to frontend-base #2246 inGetCourseExitNavigation.CourseStartMasqueradeBanner.jsxrenders the banner with today'sdate as the start date, since
FormattedDateformats the currenttime for an undefined value. The layer first kept that default and
added a case asserting the text. arbrandes's review comment
(refactor: port the modules the outline tab shares to frontend-base #2251 (comment))
asked for both to go: the case asserts that staff are told the
course starts today, which is wrong, and the banner cannot render
without metadata, since
useCourseStartMasqueradeBanner, its onlycaller, shows it only when that metadata says the requester is
masquerading. Brian agreed (2026-11-18).
converted
useModel('courseHomeMeta', courseId), which returned{}for a model that was not loaded, to the query read. Without ita banner rendered without metadata throws, as the alert does.
js-cookieis declared at^3.0.8,master's3.0.8with acaret, as the dates tab layer declared its dependencies. The lock
gains the one package entry.
Checks at the layer's commit (2026-11-12).
npm run lintclean, with the package's
.jsxfiles included(
openedx lintdoes not lint.jsxfiles frontend-base#327).npm test: 39 suites, 433 passed, 7 skipped; lines 100,statements 99.64, branches 97.65, functions 98.15 for the package.
Each file this layer adds is at 100 lines, and
alerts/course-start-alert/at 100 branches.npm run buildandnpm run build:cipass;dist/holds the new modules.clean;
npm test, 39 suites, 430 passed, 7 skipped, 100% of lines;CourseStartAlert.jsxandCourseStartMasqueradeBanner.jsxat 100%of branches;
npm run buildandnpm run build:cipass.🤖 Generated with Claude Code