Skip to content

Fixes saving unit position and unit redirection bugs - #128

Merged
davidjoy merged 3 commits into
masterfrom
djoy/position_and_redirect_bugs
Jul 29, 2020
Merged

Fixes saving unit position and unit redirection bugs#128
davidjoy merged 3 commits into
masterfrom
djoy/position_and_redirect_bugs

Conversation

@davidjoy

Copy link
Copy Markdown
Contributor

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.

David Joy added 3 commits July 29, 2020 09:17
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.
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.
@davidjoy
davidjoy requested a review from stvstnfrd July 29, 2020 13:27
@codecov

codecov Bot commented Jul 29, 2020

Copy link
Copy Markdown

Codecov Report

Merging #128 into master will increase coverage by 0.76%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #128      +/-   ##
==========================================
+ Coverage   51.51%   52.27%   +0.76%     
==========================================
  Files         119      119              
  Lines        1355     1360       +5     
  Branches      279      279              
==========================================
+ Hits          698      711      +13     
+ Misses        635      627       -8     
  Partials       22       22              
Impacted Files Coverage Δ
...tor-toolbar/masquerade-widget/MasqueradeWidget.jsx 5.55% <ø> (ø)
...-home/data/__factories__/outlineTabData.factory.js 100.00% <100.00%> (ø)
src/courseware/CoursewareContainer.jsx 81.66% <100.00%> (+4.35%) ⬆️
...rseware/data/__factories__/courseBlocks.factory.js 100.00% <100.00%> (ø)
...equence/sequence-navigation/SequenceNavigation.jsx 92.30% <0.00%> (+7.69%) ⬆️
...eware/course/sequence/sequence-navigation/hooks.js 100.00% <0.00%> (+8.33%) ⬆️
src/courseware/course/sequence/SequenceContent.jsx 91.66% <0.00%> (+8.33%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 71482f1...b411385. Read the comment docs.

@stvstnfrd stvstnfrd left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and love the tests! Just a question or two, but tentative +1

const forbiddenCourseBlocks = Factory.build('courseBlocks', {
courseId: forbiddenCourseMetadata.id,
});
const { courseBlocks: forbiddenCourseBlocks } = buildSimpleCourseBlocks(forbiddenCourseMetadata.id, null);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Do we need to pass null? Or is that already the implied default behavior?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I guess I could have just left the parameter out and it'd be undefined, but I figure it's better to obey the method signature. It just needs to be falsy so that the default behavior happens, in this case. ideally there'd be an options parameter here instead of this. Once #97 merges, I think we can use options for this stuff.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the only reason it jumped out to me is that we're not passing in the title in all invocations ;)


// This is an important line that ensures the spinner has been removed - and thus our main
// content has been loaded - prior to proceeding with our expectations.
await waitForElementToBeRemoved(screen.getByRole('status'));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a thought, is it worth extracting this into a helper?
I know it's just a single line of code, but the longer comment is useful and we seem to repeating this pattern a few times. I could imagine it being a bit easier to read if we were invoking, ensureMainContentLoaded(screen).

Not a big deal if it's a wonky refactor though.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not a bad thought.

It's funny, I always find when I come into a test suite that has a lot of things extracted to helpers I find it very hard to find my way around, but when I'm writing a test suite I want to do it... hard to know when to bother. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants