The new version of Paragon includes a “dialogClassName” property on Modal which lets us set the modal width to ‘modal-lg’ or ‘modal-sm’ - we’re using the former here.
* Updating Dropdown and Button.
* Fixing broken tests and test warnings.
* Remove comment block.
* Using variant=“link” on the Tabs Dropdown.Toggle.
* Fixing some merge conflicts.
* Bumping axios-mock-adapter version
Thought there was a feature in 1.18.2 that I needed - turns out the feature hasn’t been released yet. Still fine to bump the dependency, though.
* Hiding some warnings about console logging.
* Fixes bugs in CoursewareContainer
Fixes a few bugs in the courseware container:
- Position was not being saved because we weren’t reading “saveUnitPosition” correctly.
- We weren’t calling checkContentRedirect with the right arguments - it was using a non-existent unitId instead of the routeUnitId, meaning we would redirect to the active unit even if a unit was specified in the URL.
Adds tests in CoursewareContainer for various URL and data states.
Now explicitly tests:
- Exam redirects
- The resume block method when it has, and doesn’t have, a block to resume.
- The content redirect when a unit isn’t present on the URL (uses sequence.position)
- Loading a specific unit (not the first of a sequence!) by URL.
Updated some of the factories to be more flexible/allow multiple units.
* fix: Use reselect’s defaultMemoize instead of lodash.memoize
Lodash memoize doesn’t examine all parameters when deciding to memoize, apparently, meaning it doesn’t re-call the function if any parameter except the first changes.
More here: https://dev.to/nioufe/you-should-not-use-lodash-for-memoization-3441
* Fixing test setup. Improper use of sequenceMetadata factory!
Two problems:
One, we weren’t properly passing the courseId into our sequenceMetadata factories, so it was differing than the one defined in courseMetadata. This didn’t manifest until now because we weren’t using the one from sequenceMetadata until this memoization fix!
Two, I’d updated the options for sequenceMetadata to have a “unitBlocks” option, but didn’t update all the usages of the old “unitBlock” option. This meant it was manually creating its own unit instead of inheriting the one from courseBlocks, resulting in a different ID.
I find it much more legible this way.
Some thoughts… as part of refactoring it, I made some of the redux selectors more formal, and made use of reselect more thoroughly. this resulted in a reduction in re-renders from 16 to 12 on your average page load. It’s also a bit more verbose, accounting for some of the increased line count.
I hadn’t tried it before, but found the memoize method of comparing previous props/state to current props/state to be very, very nice. Much easier than manually comparing props, and much clearer to me than using react hooks’ dependency arrays.
The lack of dependency arrays feels really freeing in general to me. They’ve been such a source of hard-to-track-down bugs, and the hooks linter does not always suggest the right solution for what belongs in and out of the array.
Function names are nice. We had a ton of custom hooks in there so that we could put names to otherwise anonymous bits of functionality.
Also note: this component has a test suite. It passed without any changes. 🥳
* Adding testing-library dependencies, and bumping frontend-build to be compatible with them.
* Adding a function to initialize the redux store
We need to use it in a few places. Seems worth not-repeating, since they can easily get out of sync. In general, tests should only test the parts of the store they care about, as well.
* Adding function to initialize a mock application.
Ultimately I’d like to move this to frontend-platform as an alternative to ‘initialize’ for tests. ‘initialize’ is an async function which complicates matters.
* Using more explicit assertions for courseware reducer fields.
This removes the need for the snapshot file, and ensures our test is more resilient to unrelated changes in the store.
Also added a few more stages of assertions to some of the tests, showing that they have the right values over time.
* Adding a helper to build a simple course blocks response.
We can use this in the courseware data tests, and shortly in the tests for CoursewareContainer.
* Modifying sequenceMetadata factory to allow multiple units.
This will help us test sequence navigation’s behavior more fully by having multiple units in a sequence.
* A little linting and cleanup.
* Adding first round of tests for CoursewareContainer.
Tests loading, sequence navigation/unit rendering, and ‘denied’ states.
Subsequent tests will add tests for handlers.
* Add test for fetchCourse
* Add tests for fetchDatesTab, fetchOutlineTab, fetchSequence and resetDeadlines
* Implement fetch tabs tests
* Add fail test case for fetchSequence
* Add success test for fetchSequence
* Add test for resetDeadlines
* Update test group name
* Add empty tests for courseware and bookmarks
* Fix wrong field in saveSequencePosition thunk
* Add tests for courseware data layer
* Temporary commit
* Split tests after rebase
* Revert "Fix wrong field in saveSequencePosition thunk"
This reverts commit 4394d363c58ad929f81e587ce4da2241528494b5.
* Fix test for position
* Move executeThunk into utils
* Add test for all reducers
* Add expect statements for logs
* Remove redundant snapshot tests and add some specific checks
* Polishing
* Remove redundant checks
* Fix bug in normalizer and update test
* Upgrade @edx/frontend-platform dependency
* Utilize MockAuthService instead of manual auth package mocking
* Update tests after breaking changes in master
* Remove redundant snapshot check
* BB-2569: Use faVideo instead of faFilm for video units; Set page title based on section, sequence, and course titles
* Add CourseLicense component with styling
* Reorder the pageTitleBreadCrumbs that are used for setting the page title
* Revert "Add CourseLicense component with styling"
This reverts commit 8d154998de.
* Fix package-lock.json so that only new changes for react-helmet are included
* build: bumping version of frontend-platform
We’re going to need to use the new getLoginRedirectUrl helper.
* Adding custom alerts for anonymous and unenrolled users.
- Anonymous users are prompted to sign in or register.
- Unenrolled users are prompted to enroll.
The alerts themselves are lazy-loaded as necessary, like the ContentLock component.
This PR also adds `customAlerts` to the AlertList, allowing an application to specify custom components to be shown as Alerts for a given alert code.
* refactor: Renaming enrollmentIsActive to isEnrolled
As per review feedback that the former wasn’t clear.