feat: handle courseware paths more liberally (#395)

Valid courseware URLs currently include:
* /course/:courseId
* /course/:courseId/:sequenceId
* /course/:courseId/:sequenceId/:unitId

In this commit we add support for:
* /course/:courseId/:sectionId
* /course/:courseId/:sectionId/:unitId
* /course/:courseId/:unitId

All URL forms still redirect to:
  /course/:courseId/:sequenceId/:unitId

See ADR #8 for more context.

All changes:
* refactor: allow courseBlocks factory to build multiple sections
* refactor: make CoursewareContainer tests less brittle & stateful
* feat: handle courseware paths more liberally
* refactor: reorder, rename, & comment redirection functions

TNL-7796
This commit is contained in:
Kyle McCormick
2021-04-01 09:10:00 -04:00
committed by GitHub
parent 6a376b20c7
commit 353964e75c
12 changed files with 621 additions and 237 deletions

View File

@@ -132,7 +132,7 @@ export async function initializeTestStore(options = {}, overrideStore = true) {
axiosMock.reset();
const {
courseBlocks, sequenceBlock, courseMetadata, sequenceMetadata,
courseBlocks, sequenceBlocks, courseMetadata, sequenceMetadata,
} = buildSimpleCourseAndSequenceMetadata(options);
let forbiddenCourseUrl = `${getConfig().LMS_BASE_URL}/api/courseware/course/${courseMetadata.id}`;
@@ -153,7 +153,7 @@ export async function initializeTestStore(options = {}, overrideStore = true) {
!options.excludeFetchCourse && await executeThunk(fetchCourse(courseMetadata.id), store.dispatch);
if (!options.excludeFetchSequence) {
await Promise.all(sequenceBlock
await Promise.all(sequenceBlocks
.map(block => executeThunk(fetchSequence(block.id), store.dispatch)));
}