Skip to content

Commit

Permalink
fix: optional_completion selector
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielVZ96 committed Mar 31, 2024
1 parent de5e579 commit f7745fd
Showing 1 changed file with 5 additions and 21 deletions.
26 changes: 5 additions & 21 deletions cms/static/js/spec/views/pages/course_outline_spec.js
Expand Up @@ -350,12 +350,12 @@ describe('CourseOutlinePage', function() {
])
]);

expectOptionalCompletion = function(checked) {
expect($('#optional-completion').is(':checked')).toBe(checked, "optional completion input was not checked");
expectOptionalCompletion = function(exists) {
expect($('#optional_completion').length).toBe(exists ? 1 : 0, `optional completion existence should be ${exists}`);
};

expectOptionalCompletionDisabled = function(disabled) {
expect($('#optional-completion').is(':disabled')).toBe(disabled, "optional completion input not disabled");
expect($('#optional_completion').is(':disabled')).toBe(disabled, "optional completion input not disabled");
};


Expand Down Expand Up @@ -1052,7 +1052,7 @@ describe('CourseOutlinePage', function() {
setCompletionTracking(true);
var mockCourseJSON = createMockCourseJSON({}, [
createMockSectionJSON({optional_completion: true}, [
createMockSubsectionJSON({}, [])
createMockSubsectionJSON({ancestor_has_optional_completion: true}, [])
])
]);
createCourseOutlinePage(this, mockCourseJSON, false);
Expand All @@ -1066,24 +1066,8 @@ describe('CourseOutlinePage', function() {
console.log("section modal html:", $(".course-outline-modal").html())
expectOptionalCompletion(true);
outlinePage.$('.subsection-header-actions .configure-button').click();
expectOptionalCompletion(true);
expect($('.tip-warning')).toExist()
$('.wrapper-modal-window .action-cancel').click();
outlinePage.$('.unit-header-actions .configure-button').click();
expect($('.tip-warning')).toExist()
});

it('sets optional completion to null instead of false to avoid overriding inheritance', function() {
// if we set false, inheritance mechanism returns false and ignores other ancestors even if they
// are optional. if there's an optional ancestor we want to set the descendant block as optional,
// so in the end what we want is to ignore false values (by setting them to null), and only care about
// true values.
outlinePage.$('.section-header-actions .configure-button').click();
$('.wrapper-modal-window .action-save').click();
AjaxHelpers.expectJsonRequest(requests, 'POST', '/xblock/mock-section', {
metadata: {
optional_completion: null,
}
});
});
});
});
Expand Down

0 comments on commit f7745fd

Please sign in to comment.