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

feat: Add redirect to enterprise learner dashboard #1251

Merged
merged 1 commit into from
Dec 15, 2023

Conversation

pwnage101
Copy link
Contributor

@pwnage101 pwnage101 commented Dec 11, 2023

When a learner tries to load the B2C course page for a course that starts in the future (error_code="course_not_started"), normally the learning MFE automatically redirects to the B2C dashboard. This change supports an alternate error_code "course_not_started_enterprise_learner" to trigger an alternative redirect to the B2B (enterprise) learner dashboard.

This does two main things:

  1. When the course metadata API response indicates course_access.error_code = "course_not_started_enterprise_learner" then redirect to "/redirect/enterprise-learner-dashboard".
  2. When the top-level router matches path "/redirect/enterprise-learner-dashboard" then redirec to to the value of config ENTERPRISE_LEARNER_PORTAL_URL.

ENT-8078

Companion PR to create the new course_not_started_enterprise_learner error code: openedx/edx-platform#33913

@pwnage101 pwnage101 marked this pull request as draft December 11, 2023 23:52
@pwnage101 pwnage101 force-pushed the pwnage101/ENT-8078 branch 2 times, most recently from dab267e to 7166020 Compare December 12, 2023 21:06
When a learner tries to load the B2C course page for a course that
starts in the future (error_code="course_not_started"), normally the
learning MFE automatically redirects to the B2C dashboard.  This change
supports an alternate error_code "course_not_started_enterprise_learner"
to trigger an alternative redirect to the B2B (enterprise) learner
dashboard.

This does two main things:

1. When the course metadata API response indicates
   course_access.error_code = "course_not_started_enterprise_learner"
   then redirect to "/redirect/enterprise-learner-dashboard".
2. When the top-level router matches path "/redirect/enterprise-learner-dashboard"
   then redirec to to the value of config `ENTERPRISE_LEARNER_PORTAL_URL`.

ENT-8078
@pwnage101 pwnage101 marked this pull request as ready for review December 14, 2023 00:08
Comment on lines +1 to +4
// Force all tests to run in UTC to prevent tests from being sensitive to host timezone.
module.exports = async () => {
process.env.TZ = 'UTC';
};
Copy link
Contributor Author

@pwnage101 pwnage101 Dec 14, 2023

Choose a reason for hiding this comment

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

Spent 25 minutes scratching my head on a failing js test until I realized it was sensitive to the time zone of the host machine, and running TZ=UTC npm run test fixed it. This addition causes all tests to always run in UTC, regardless of host TZ.

Copy link
Member

Choose a reason for hiding this comment

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

Out of curiosity, does setting process.env.TZ in the existing setupTest.js file work (in an attempt to avoid needing to setup the globalSetup config).

Copy link
Contributor Author

@pwnage101 pwnage101 Dec 14, 2023

Choose a reason for hiding this comment

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

yes, it would have! I figured just do it for the whole project but happy to revert back to just doing it for one test class if you feel like it's too heavy-handed. This was the failing test (date off by one day):

https://github.com/openedx/frontend-app-learning/pull/1251/files#diff-729c9dcf69224055c50e2364be6ba2387aada65cd0929bf928271c8b3e1c561aR511

Copy link

codecov bot commented Dec 14, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (e004ead) 87.97% compared to head (d0d63df) 87.98%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1251      +/-   ##
==========================================
+ Coverage   87.97%   87.98%   +0.01%     
==========================================
  Files         276      276              
  Lines        4739     4745       +6     
  Branches     1194     1196       +2     
==========================================
+ Hits         4169     4175       +6     
  Misses        554      554              
  Partials       16       16              

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

@pwnage101 pwnage101 changed the title feat: strawman for ENT-8078 feat: Add redirect to enterprise learner dashboard Dec 14, 2023
@pwnage101 pwnage101 requested a review from jansenk December 14, 2023 01:57
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.

These changes LGTM (with 1 non-blocking question). Defer to any of Jansen's feedback, if any; otherwise, ✅

Comment on lines +1 to +4
// Force all tests to run in UTC to prevent tests from being sensitive to host timezone.
module.exports = async () => {
process.env.TZ = 'UTC';
};
Copy link
Member

Choose a reason for hiding this comment

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

Out of curiosity, does setting process.env.TZ in the existing setupTest.js file work (in an attempt to avoid needing to setup the globalSetup config).

@macdiesel macdiesel merged commit 7957533 into master Dec 15, 2023
6 checks passed
@macdiesel macdiesel deleted the pwnage101/ENT-8078 branch December 15, 2023 12:45
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