Add messaging when verified track content MVP is enabled.
TNL-4393
This commit is contained in:
@@ -13,12 +13,14 @@ define(['backbone', 'jquery', 'common/js/spec_helpers/ajax_helpers', 'common/js/
|
||||
describe("Cohorts View", function () {
|
||||
var catLoversInitialCount = 123, dogLoversInitialCount = 456, unknownUserMessage,
|
||||
createMockCohort, createMockCohorts, createMockContentGroups, createMockCohortSettingsJson,
|
||||
createCohortsView, cohortsView, requests, respondToRefresh, verifyMessage, verifyNoMessage,
|
||||
verifyDetailedMessage, verifyHeader, expectCohortAddRequest, getAddModal, selectContentGroup,
|
||||
clearContentGroup, saveFormAndExpectErrors, createMockCohortSettings, MOCK_COHORTED_USER_PARTITION_ID,
|
||||
createMockVerifiedTrackCohortsJson, flushVerifiedTrackCohortRequests, createCohortsView,
|
||||
cohortsView, requests, respondToRefresh, verifyMessage, verifyNoMessage, verifyDetailedMessage,
|
||||
verifyHeader, verifyVerifiedTrackMessage, verifyVerifiedTrackUIUpdates, expectCohortAddRequest,
|
||||
getAddModal, selectContentGroup, clearContentGroup,
|
||||
saveFormAndExpectErrors, createMockCohortSettings, MOCK_COHORTED_USER_PARTITION_ID,
|
||||
MOCK_UPLOAD_COHORTS_CSV_URL, MOCK_STUDIO_ADVANCED_SETTINGS_URL, MOCK_STUDIO_GROUP_CONFIGURATIONS_URL,
|
||||
MOCK_MANUAL_ASSIGNMENT, MOCK_RANDOM_ASSIGNMENT, createMockCohortDiscussionsJson,
|
||||
createMockCohortDiscussions, showAndAssertDiscussionTopics;
|
||||
MOCK_VERIFIED_TRACK_COHORTING_URL, MOCK_MANUAL_ASSIGNMENT, MOCK_RANDOM_ASSIGNMENT,
|
||||
createMockCohortDiscussionsJson, createMockCohortDiscussions, showAndAssertDiscussionTopics;
|
||||
|
||||
// Selectors
|
||||
var discussionsToggle ='.toggle-cohort-management-discussions',
|
||||
@@ -34,6 +36,7 @@ define(['backbone', 'jquery', 'common/js/spec_helpers/ajax_helpers', 'common/js/
|
||||
MOCK_UPLOAD_COHORTS_CSV_URL = 'http://upload-csv-file-url/';
|
||||
MOCK_STUDIO_ADVANCED_SETTINGS_URL = 'http://studio/settings/advanced';
|
||||
MOCK_STUDIO_GROUP_CONFIGURATIONS_URL = 'http://studio/group_configurations';
|
||||
MOCK_VERIFIED_TRACK_COHORTING_URL = 'http://courses/foo/verified_track_content/settings';
|
||||
|
||||
createMockCohort = function (name, id, userCount, groupId, userPartitionId, assignmentType) {
|
||||
return {
|
||||
@@ -129,6 +132,18 @@ define(['backbone', 'jquery', 'common/js/spec_helpers/ajax_helpers', 'common/js/
|
||||
);
|
||||
};
|
||||
|
||||
createMockVerifiedTrackCohortsJson = function (enabled) {
|
||||
if (enabled) {
|
||||
return {
|
||||
enabled: true,
|
||||
verified_cohort_name: "Verified Track"
|
||||
};
|
||||
}
|
||||
else {
|
||||
return { enabled: false };
|
||||
}
|
||||
};
|
||||
|
||||
createCohortsView = function (test, options) {
|
||||
var cohortsJson, cohorts, contentGroups, cohortSettings, cohortDiscussions;
|
||||
options = options || {};
|
||||
@@ -151,7 +166,8 @@ define(['backbone', 'jquery', 'common/js/spec_helpers/ajax_helpers', 'common/js/
|
||||
discussionTopicsSettingsModel: cohortDiscussions,
|
||||
uploadCohortsCsvUrl: MOCK_UPLOAD_COHORTS_CSV_URL,
|
||||
studioAdvancedSettingsUrl: MOCK_STUDIO_ADVANCED_SETTINGS_URL,
|
||||
studioGroupConfigurationsUrl: MOCK_STUDIO_GROUP_CONFIGURATIONS_URL
|
||||
studioGroupConfigurationsUrl: MOCK_STUDIO_GROUP_CONFIGURATIONS_URL,
|
||||
verifiedTrackCohortingUrl: MOCK_VERIFIED_TRACK_COHORTING_URL
|
||||
}
|
||||
});
|
||||
|
||||
@@ -159,6 +175,21 @@ define(['backbone', 'jquery', 'common/js/spec_helpers/ajax_helpers', 'common/js/
|
||||
if (options && options.selectCohort) {
|
||||
cohortsView.$('.cohort-select').val(options.selectCohort.toString()).change();
|
||||
}
|
||||
|
||||
flushVerifiedTrackCohortRequests(options.enableVerifiedTrackCohorting);
|
||||
};
|
||||
|
||||
// Flush out all requests to get verified track cohort information.
|
||||
// The order relative to other requests is not important to encode,
|
||||
// and for pre-existing test cases, we don't care about these additional requests.
|
||||
flushVerifiedTrackCohortRequests = function (enableVerifiedTrackCohorting) {
|
||||
for (var i = requests.length-1; i >= 0 ; i--) {
|
||||
if (requests[i].url === MOCK_VERIFIED_TRACK_COHORTING_URL) {
|
||||
AjaxHelpers.respondWithJson(
|
||||
requests, createMockVerifiedTrackCohortsJson(enableVerifiedTrackCohorting), i
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
respondToRefresh = function(catCount, dogCount) {
|
||||
@@ -213,6 +244,27 @@ define(['backbone', 'jquery', 'common/js/spec_helpers/ajax_helpers', 'common/js/
|
||||
expect(cohortsView.$('.message').length).toBe(0);
|
||||
};
|
||||
|
||||
verifyVerifiedTrackMessage = function(type, expectedText) {
|
||||
if (type) {
|
||||
expect($('.message').length).toBe(1);
|
||||
expect($('.message-' + type).length).toBe(1);
|
||||
expect($('.message-title').text()).toContain(expectedText);
|
||||
}
|
||||
else {
|
||||
expect($('.message').length).toBe(0);
|
||||
}
|
||||
};
|
||||
|
||||
verifyVerifiedTrackUIUpdates = function(enableCohortsCheckbox, disableCohortNameField) {
|
||||
expect(cohortsView.$('.cohorts-state').prop('disabled')).toBe(enableCohortsCheckbox);
|
||||
// Select settings tab
|
||||
if (disableCohortNameField !== undefined) {
|
||||
cohortsView.$('.cohort-select').val('1').change();
|
||||
cohortsView.$('.tab-settings a').click();
|
||||
expect(cohortsView.$('.cohort-name').prop('readonly')).toBe(disableCohortNameField);
|
||||
}
|
||||
};
|
||||
|
||||
verifyDetailedMessage = function(expectedTitle, expectedMessageType, expectedDetails, expectedAction) {
|
||||
var numDetails = cohortsView.$('.summary-items').children().length;
|
||||
verifyMessage(expectedTitle, expectedMessageType, expectedAction, true);
|
||||
@@ -243,7 +295,7 @@ define(['backbone', 'jquery', 'common/js/spec_helpers/ajax_helpers', 'common/js/
|
||||
var manualMessage = "Learners are added to this cohort only when you provide their email addresses " +
|
||||
"or usernames on this page.";
|
||||
var randomMessage = "Learners are added to this cohort automatically.";
|
||||
var message = (assignmentType == MOCK_MANUAL_ASSIGNMENT) ? manualMessage : randomMessage;
|
||||
var message = (assignmentType === MOCK_MANUAL_ASSIGNMENT) ? manualMessage : randomMessage;
|
||||
expect(header.find('.cohort-management-group-setup .setup-value').text().trim().split('\n')[0]).toBe(message);
|
||||
};
|
||||
|
||||
@@ -301,7 +353,9 @@ define(['backbone', 'jquery', 'common/js/spec_helpers/ajax_helpers', 'common/js/
|
||||
};
|
||||
|
||||
beforeEach(function () {
|
||||
setFixtures('<ul class="instructor-nav"><li class="nav-item"><<a href data-section="cohort_management" class="active-section">Cohort Management</a></li></ul><div></div><div class="cohort-state-message"></div>');
|
||||
setFixtures('<ul class="instructor-nav"><li class="nav-item"><<a href data-section=' +
|
||||
'"cohort_management" class="active-section">Cohort Management</a></li></ul><div></div>' +
|
||||
'<div class="cohort-management"><div class="cohort-state-message"></div></div>');
|
||||
TemplateHelpers.installTemplate('templates/instructor/instructor_dashboard_2/cohorts');
|
||||
TemplateHelpers.installTemplate('templates/instructor/instructor_dashboard_2/cohort-form');
|
||||
TemplateHelpers.installTemplate('templates/instructor/instructor_dashboard_2/cohort-selector');
|
||||
@@ -390,6 +444,53 @@ define(['backbone', 'jquery', 'common/js/spec_helpers/ajax_helpers', 'common/js/
|
||||
});
|
||||
});
|
||||
|
||||
describe("Verified Track Cohorting Settings View", function () {
|
||||
it('displays no message if the feature is disabled', function () {
|
||||
createCohortsView(this);
|
||||
verifyVerifiedTrackMessage(false);
|
||||
verifyVerifiedTrackUIUpdates(false, false);
|
||||
});
|
||||
|
||||
it('displays a confirmation if the feature is enabled and a verified track cohort exists', function () {
|
||||
var cohortName = "Verified Track";
|
||||
createCohortsView(this, {
|
||||
cohorts: [
|
||||
{
|
||||
id: 1,
|
||||
name: cohortName,
|
||||
assignment_type: MOCK_MANUAL_ASSIGNMENT,
|
||||
group_id: 111,
|
||||
user_partition_id: MOCK_COHORTED_USER_PARTITION_ID
|
||||
}
|
||||
],
|
||||
enableVerifiedTrackCohorting: true
|
||||
});
|
||||
verifyVerifiedTrackMessage(
|
||||
"confirmation", "automatic cohorting for verified track learners. You cannot disable cohorts"
|
||||
);
|
||||
verifyVerifiedTrackUIUpdates(true, true);
|
||||
});
|
||||
|
||||
it('displays an error if no verified track cohort exists', function () {
|
||||
createCohortsView(this, {enableVerifiedTrackCohorting: true});
|
||||
verifyVerifiedTrackMessage(
|
||||
"error", "cohorting enabled for verified track learners, but the required cohort does not exist"
|
||||
);
|
||||
verifyVerifiedTrackUIUpdates(true, false);
|
||||
});
|
||||
|
||||
it('displays an error if cohorting is disabled', function () {
|
||||
createCohortsView(this, {
|
||||
cohortSettings: createMockCohortSettings(false),
|
||||
enableVerifiedTrackCohorting: true
|
||||
});
|
||||
verifyVerifiedTrackMessage(
|
||||
"error", "automatic cohorting enabled for verified track learners, but cohorts are disabled"
|
||||
);
|
||||
verifyVerifiedTrackUIUpdates(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Course Cohort Settings", function () {
|
||||
it('can enable and disable cohorting', function () {
|
||||
createCohortsView(this, {cohortSettings: createMockCohortSettings(false)});
|
||||
@@ -441,7 +542,7 @@ define(['backbone', 'jquery', 'common/js/spec_helpers/ajax_helpers', 'common/js/
|
||||
expect(cohortsView.$('.cohorts-state').prop('checked')).toBeFalsy();
|
||||
cohortsView.$('.cohorts-state').prop('checked', true).change();
|
||||
AjaxHelpers.respondWithError(requests, 500);
|
||||
var expectedTitle = "We've encountered an error. Refresh your browser and then try again."
|
||||
var expectedTitle = "We've encountered an error. Refresh your browser and then try again.";
|
||||
expect(cohortsView.$('.message-title').text().trim()).toBe(expectedTitle);
|
||||
});
|
||||
});
|
||||
@@ -456,7 +557,7 @@ define(['backbone', 'jquery', 'common/js/spec_helpers/ajax_helpers', 'common/js/
|
||||
assignment_type: assignment_type,
|
||||
group_id: null,
|
||||
user_partition_id: null
|
||||
}
|
||||
};
|
||||
};
|
||||
createCohortsView(this, {
|
||||
cohorts: [
|
||||
@@ -520,8 +621,7 @@ define(['backbone', 'jquery', 'common/js/spec_helpers/ajax_helpers', 'common/js/
|
||||
var assignmentType = 'random';
|
||||
|
||||
it("can add a cohort", function() {
|
||||
var contentGroupId = 0,
|
||||
contentGroupUserPartitionId = 0;
|
||||
var contentGroupId = 0;
|
||||
createCohortsView(this, {cohorts: []});
|
||||
cohortsView.$('.action-create').click();
|
||||
expect(cohortsView.$('.cohort-management-settings-form').length).toBe(1);
|
||||
@@ -989,7 +1089,7 @@ define(['backbone', 'jquery', 'common/js/spec_helpers/ajax_helpers', 'common/js/
|
||||
assignment_type: assignment_type,
|
||||
group_id: null,
|
||||
user_partition_id: null
|
||||
}
|
||||
};
|
||||
};
|
||||
createCohortsView(this, {
|
||||
cohorts: [
|
||||
|
||||
Reference in New Issue
Block a user