[BD-29] [TNL-7266] Learning MFE data integration tests

Description

This PR adds integration tests for Learning MFE data layer, as well as `rosie` factories for various platform API responses.

Code covered:

  • `src/courseware/data`

  • `src/courseware/course/bookmark/data`

  • `src/course-home/data`

  • `src/model-store`

  • `src/data`

*JIRA tickets*:

*Discussions*: None

*Dependencies*: None

*Merge deadline*: None

*Testing instructions*:

Travis CI already runs tests from this PR, so no local testing required.

*Author notes and concerns*:

Take a look on this thunk:
```js
export function saveSequencePosition(courseId, sequenceId, position) {
return async (dispatch, getState) => {
const { models } = getState();
const initialPosition = models.sequences[sequenceId].position;
// Optimistically update the position.
dispatch(updateModel({
modelType: 'sequences',
model: {
id: sequenceId,
position,
},
}));
try {
await updateSequencePosition(courseId, sequenceId, position);
// Update again under the assumption that the above call succeeded, since it doesn't return a
// meaningful response.
dispatch(updateModel({
modelType: 'sequences',
model: {
id: sequenceId,
position,
},
}));
} catch (error) {
logError(error);
dispatch(updateModel({
modelType: 'sequences',
model: {
id: sequenceId,
position: initialPosition,
},
}));
}
};
}
```

After `updateSequencePosition` call it updates `position` field of sequence model. However, `normalizeSequenceMetadata` normalizer doesn't store `position` field, so after sequence metadata fetch position is undefined until it's saved.

```diff
diff --git a/src/data/api.js b/src/data/api.js
index 0f48325..b67f717 100644
— a/src/data/api.js
+++ b/src/data/api.js
@@ -144,6 +144,7 @@ function normalizeSequenceMetadata(sequence) {
title: sequence.display_name,
gatedContent: camelCaseObject(sequence.gated_content),
isTimeLimited: sequence.is_time_limited,
+ position: sequence.position || 0,
// Position comes back from the server 1-indexed. Adjust here.
activeUnitIndex: sequence.position ? sequence.position - 1 : 0,
saveUnitPosition: sequence.save_position,
```

I'm not sure if this behavior is correct.

*Reviewers*

  • [ ] @Agrendalath

  • [ ] edX reviewer[s] TBD

Assignee

Unassigned

Reporter

Open Source Pull Request Bot

Labels

Github Latest Action by edX

Yes

Github PR Last Updated At

Jul 06, 2020, 8:58 PM

Github PR Last Updated By

natabene

Github Organization

None

Customer

PR Number

95

Repo

edx/frontend-app-learning

Contributor Name

Demid Avramenko

Github Latest Action

issue_comment: created

Platform Map Area (Levels 1 & 2)

Developer Experiences

Platform Map Area (Levels 3 & 4)

None

Blended Project Status Page

None

Story Points

1

Sprint

None

Priority

Unset
Configure