diff --git a/lms/static/js/spec/student_account/finish_auth_spec.js b/lms/static/js/spec/student_account/finish_auth_spec.js index 53565ef157..9ae30c400b 100644 --- a/lms/static/js/spec/student_account/finish_auth_spec.js +++ b/lms/static/js/spec/student_account/finish_auth_spec.js @@ -95,6 +95,24 @@ ); }); + it('sends the user to the course mode selection flow with bulk purchase workflow', function() { + // Simulate providing enrollment query string params + setFakeQueryParams({ + '?enrollment_action': 'enroll', + '?course_id': COURSE_KEY, + '?purchase_workflow': 'bulk' + }); + + ajaxSpyAndInitialize(this); + + // Expect that the view redirected to the course + // mode select flow with the purchase_workflow parameter + expect( EnrollmentInterface.enroll ).toHaveBeenCalledWith( + COURSE_KEY, + '/course_modes/choose/' + COURSE_KEY + '/?purchase_workflow=bulk' + ); + }); + it('sends the user to the payment flow for a paid course mode', function() { // Simulate providing enrollment query string params // AND specifying a course mode. @@ -114,6 +132,28 @@ ); }); + it('sends the user to the payment flow for a paid course mode with bulk purchase workflow', function() { + // Simulate providing enrollment query string params + // AND specifying a course mode + // AND purchase workflow type. + setFakeQueryParams({ + '?enrollment_action': 'enroll', + '?course_id': COURSE_KEY, + '?course_mode': 'professional-no-id', + '?purchase_workflow': 'bulk' + }); + + ajaxSpyAndInitialize(this); + + // Expect that the view tried to auto-enroll the student + // with a redirect into the payment flow including the + // purchase_workflow parameter. + expect( EnrollmentInterface.enroll ).toHaveBeenCalledWith( + COURSE_KEY, + '/verify_student/start-flow/' + COURSE_KEY + '/?purchase_workflow=bulk' + ); + }); + it('sends the user to the student dashboard for an unpaid course mode', function() { // Simulate providing enrollment query string params // AND specifying a course mode. diff --git a/lms/static/js/student_account/views/FinishAuthView.js b/lms/static/js/student_account/views/FinishAuthView.js index 8e5c3955da..bef5aa4f2b 100644 --- a/lms/static/js/student_account/views/FinishAuthView.js +++ b/lms/static/js/student_account/views/FinishAuthView.js @@ -89,6 +89,15 @@ console.log(desc); }, + appendPurchaseWorkflow: function(redirectUrl) { + if (this.purchaseWorkflow) { + // Append the purchase_workflow parameter to indicate + // whether this is a bulk purchase or a single seat purchase + redirectUrl += '?purchase_workflow=' + this.purchaseWorkflow; + } + return redirectUrl; + }, + /** * Step 1: * Update the user's email preferences and then proceed to the next step @@ -125,7 +134,7 @@ The track selection page would allow the user to select the course mode ("verified", "honor", etc.) -- or, if the only course mode was "honor", it would redirect the user to the dashboard. */ - redirectUrl = this.urls.trackSelection + courseId + '/'; + redirectUrl = this.appendPurchaseWorkflow(this.urls.trackSelection + courseId + '/'); } else if ( this.courseMode === 'honor' || this.courseMode === 'audit' ) { /* The newer version of the course details page allows the user to specify which course mode to enroll as. If the student has @@ -135,7 +144,7 @@ } else { /* If the user selected any other kind of course mode, send them to the payment/verification flow. */ - redirectUrl = this.urls.payment + courseId + '/'; + redirectUrl = this.appendPurchaseWorkflow(this.urls.payment + courseId + '/'); } /* Attempt to auto-enroll the user in a free mode of the course,