Skip to content
Snippets Groups Projects
Commit 5dfd5213 authored by Harry Rein's avatar Harry Rein
Browse files

Ensure entitlement session select initializes to enrolled session.

LEARNER-3827
parent c2094d43
No related merge requests found
......@@ -10,6 +10,7 @@ define([
describe('Course Entitlement View', function() {
var view = null,
setupView,
sessionIndex,
selectOptions,
entitlementAvailableSessions,
initialSessionId,
......@@ -18,17 +19,18 @@ define([
entitlementUUID = 'a9aiuw76a4ijs43u18',
testSessionIds = ['test_session_id_1', 'test_session_id_2'];
setupView = function(isAlreadyEnrolled, hasAvailableSessions) {
setupView = function(isAlreadyEnrolled, hasAvailableSessions, specificSessionIndex) {
setFixtures('<div class="course-entitlement-selection-container"></div>');
alreadyEnrolled = (typeof isAlreadyEnrolled !== 'undefined') ? isAlreadyEnrolled : true;
hasSessions = (typeof hasAvailableSessions !== 'undefined') ? hasAvailableSessions : true;
sessionIndex = (typeof specificSessionIndex !== 'undefined') ? specificSessionIndex : 0;
initialSessionId = alreadyEnrolled ? testSessionIds[0] : '';
initialSessionId = alreadyEnrolled ? testSessionIds[sessionIndex] : '';
entitlementAvailableSessions = [];
if (hasSessions) {
entitlementAvailableSessions = [{
enrollment_end: null,
start: '2019-02-05T05:00:00+00:00',
start: '2016-02-05T05:00:00+00:00',
pacing_type: 'instructor_paced',
session_id: testSessionIds[0],
end: null
......@@ -141,6 +143,17 @@ define([
});
});
describe('Available Sessions Select - Fulfilled Entitlement (session in the future)', function() {
beforeEach(function() {
setupView(true, true, 1);
});
it('Currently selected session should initialize to selected in the dropdown options.', function() {
var selectedOption = view.$('.session-select').find('option:selected');
expect(selectedOption.data('session_id')).toEqual(testSessionIds[1]);
});
});
describe('Select Session Action Button and popover behavior - Unfulfilled Entitlement', function() {
beforeEach(function() {
setupView(false);
......
......@@ -14,7 +14,7 @@
<div class="action-controls">
<select class="session-select" aria-label="<%- StringUtils.interpolate( gettext('Session Selection Dropdown for {courseName}'), { courseName: courseName }) %>">
<% _.each(availableSessions, function(session) { %>
<option data-session_id="<%- session.session_id || session.key %>">
<option data-session_id="<%- session.session_id || session.key %>" <% if ((session.session_id || session.key) === currentSessionId) { %> selected<% } %> >
<% if ((session.session_id || session.key) === currentSessionId) { %>
<%- StringUtils.interpolate( gettext('{sessionDates} - Currently Selected'), {sessionDates: session.session_dates}) %>
<% } else if (session.enrollment_end){ %>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment