Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ignore failed outline API call when learner has no access #1259

Merged
merged 1 commit into from
Jan 22, 2024

Conversation

pwnage101
Copy link
Contributor

@pwnage101 pwnage101 commented Dec 21, 2023

If the learner doesn't even have access to the course (e.g. because the course starts in the future), don't worry about a 404 fetching the course outline since we're not planning to use it anyway.

ENT-8078

matrix

  • [current behavior] if the learner has access to the course and tab data is available: stay on course home page.
  • [current behavior] if the learner has access to the course but the tab data is not available, display error page.
  • [current behavior] if the learner does not have access to the course, but the tab data is available, dispatch to enterprise redirect logic.
  • [NEW BEHAVIOR] if the learner does not have access to the course, but the tab data is not available, dispatch to enterprise redirect logic (WAS: display error page).

A combination of factors contribute to this specific scenario with new behavior, but the vast majority of hits on this page won't trigger this scenario. It just so happens that it's likely to happen while testing on stage, which gets in the way of testing other features which rely on dispatching to fetchTabDenied.

@pwnage101 pwnage101 force-pushed the pwnage101/ENT-8078-2 branch from 8dd60f1 to ccdd37d Compare December 21, 2023 23:31
Copy link

codecov bot commented Dec 21, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (4928f50) 88.29% compared to head (1cea8cd) 88.33%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1259      +/-   ##
==========================================
+ Coverage   88.29%   88.33%   +0.03%     
==========================================
  Files         291      291              
  Lines        4923     4930       +7     
  Branches     1239     1242       +3     
==========================================
+ Hits         4347     4355       +8     
+ Misses        562      561       -1     
  Partials       14       14              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines 67 to 78
if (courseHomeCourseMetadataResult.status === 'rejected') {
throw courseHomeCourseMetadataResult.reason;
} else if (!courseHomeCourseMetadataResult.value.courseAccess.hasAccess) {
dispatch(fetchTabDenied({ courseId }));
} else if (tabDataResult || !getTabData) {
} else if (tabDataResult && tabDataResult.status === 'rejected') {
throw tabDataResult.reason;
} else {
dispatch(fetchTabSuccess({
courseId,
targetUserId,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Notable changes:

  • There's now a default case; one of [fetchTabDenied, fetchTabSuccess, fetchTabFailure] is always dispatched.
  • A non-accessible course is now handled using fetchTabDenied regardless of the tab data query results.

Copy link
Member

@adamstankiewicz adamstankiewicz left a comment

Choose a reason for hiding this comment

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

LGTM (with a couple nits), deferring to any owning squad's review feedback.

Comment on lines 71 to 75
} else if (tabDataResult && tabDataResult.status === 'rejected') {
throw tabDataResult.reason;
} else {
Copy link
Member

Choose a reason for hiding this comment

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

nit: I wonder if it'd make sense to co-locate the conditions that result in throwing an exception?

if (courseHomeCourseMetadataResult.status === 'rejected') {
  throw courseHomeCourseMetadataResult.reason;
} else if (tabDataResult?.status === 'rejected') {
  throw tabDataResult.reason;
} else if (!courseHomeCourseMetadataResult.value.courseAccess.hasAccess) {
 dispatch(fetchTabDenied({ courseId }));
} else {
  dispatch(fetchTabSuccess({
    courseId,
    targetUserId,
  }));
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm, I'm pretty sure I want to dispatch fetchTabDenied as soon as possible, which is why the conditional is ordered like that. I added a comment to clarify this.

src/course-home/data/thunks.js Outdated Show resolved Hide resolved
src/course-home/data/thunks.js Outdated Show resolved Hide resolved
@pwnage101 pwnage101 force-pushed the pwnage101/ENT-8078-2 branch from ccdd37d to 997a524 Compare January 11, 2024 02:43
If the learner doesn't even have access to the course (e.g. because the
course starts in the future), don't worry about a 404 fetching the
course outline since we're not planning to use it anyway.

ENT-8078
@pwnage101 pwnage101 force-pushed the pwnage101/ENT-8078-2 branch from 997a524 to 1cea8cd Compare January 19, 2024 21:14
@pwnage101 pwnage101 merged commit ab87167 into master Jan 22, 2024
6 checks passed
@pwnage101 pwnage101 deleted the pwnage101/ENT-8078-2 branch January 22, 2024 20:49
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.

3 participants