@@ -1065,6 +1065,24 @@ describe('CourseOutlinePage', function() {
10651065 outlinePage . $ ( '.section-header-actions .configure-button' ) . click ( ) ;
10661066 expect ( $ ( '#optional_completion' ) . is ( ':disabled' ) ) . toBe ( true ) ;
10671067 } ) ;
1068+
1069+ it ( 'sets optional completion to null instead of false' , function ( ) {
1070+ var mockCourseJSON = createMockCourseJSON ( { } , [
1071+ createMockSectionJSON ( { optional_completion : true } )
1072+ ] ) ;
1073+ createCourseOutlinePage ( this , mockCourseJSON , false ) ;
1074+ outlinePage . $ ( '.section-header-actions .configure-button' ) . click ( ) ;
1075+ expect ( $ ( '#optional_completion' ) . is ( ':checked' ) ) . toBe ( true ) ;
1076+ $ ( '#optional_completion' ) . click ( )
1077+ expect ( $ ( '#optional_completion' ) . is ( ':checked' ) ) . toBe ( false ) ;
1078+ $ ( '.wrapper-modal-window .action-save' ) . click ( ) ;
1079+ AjaxHelpers . expectJsonRequest ( requests , 'POST' , '/xblock/mock-section' , {
1080+ publish : 'republish' ,
1081+ metadata : {
1082+ optional_completion : null
1083+ }
1084+ } ) ;
1085+ } ) ;
10681086 } ) ;
10691087 } ) ;
10701088
@@ -2386,7 +2404,7 @@ describe('CourseOutlinePage', function() {
23862404 } ) ;
23872405
23882406 it ( 'shows optional completion checkbox checked' , function ( ) {
2389- var mockCourseJSON = createMockCourseJSON ( { } , [
2407+ var mockCourseJSON = createMockCourseJSON ( { } , [
23902408 createMockSectionJSON ( { } , [
23912409 createMockSubsectionJSON ( { optional_completion : true } , [ ] )
23922410 ] )
@@ -2398,14 +2416,42 @@ describe('CourseOutlinePage', function() {
23982416 } ) ;
23992417
24002418 it ( 'disables optional completion checkbox when the parent uses optional completion' , function ( ) {
2401- var mockCourseJSON = createMockCourseJSON ( { } , [
2402- createMockSectionJSON ( { } , [
2403- createMockSubsectionJSON ( { ancestor_has_optional_completion : true } , [ ] )
2404- ] )
2405- ] ) ;
2406- createCourseOutlinePage ( this , mockCourseJSON , false ) ;
2407- outlinePage . $ ( '.outline-subsection .configure-button' ) . click ( ) ;
2408- expect ( $ ( '#optional_completion' ) . is ( ':disabled' ) ) . toBe ( true ) ;
2419+ var mockCourseJSON = createMockCourseJSON ( { } , [
2420+ createMockSectionJSON ( { } , [
2421+ createMockSubsectionJSON ( { ancestor_has_optional_completion : true } , [ ] )
2422+ ] )
2423+ ] ) ;
2424+ createCourseOutlinePage ( this , mockCourseJSON , false ) ;
2425+ outlinePage . $ ( '.outline-subsection .configure-button' ) . click ( ) ;
2426+ expect ( $ ( '#optional_completion' ) . is ( ':disabled' ) ) . toBe ( true ) ;
2427+ } ) ;
2428+
2429+ it ( 'sets optional completion to null instead of false' , function ( ) {
2430+ var mockCourseJSON = createMockCourseJSON ( { } , [
2431+ createMockSectionJSON ( { } , [
2432+ createMockSubsectionJSON ( { optional_completion : true } , [ ] )
2433+ ] )
2434+ ] ) ;
2435+ createCourseOutlinePage ( this , mockCourseJSON , false ) ;
2436+ outlinePage . $ ( '.outline-subsection .configure-button' ) . click ( ) ;
2437+ expect ( $ ( '#optional_completion' ) . is ( ':checked' ) ) . toBe ( true ) ;
2438+ $ ( '#optional_completion' ) . click ( )
2439+ expect ( $ ( '#optional_completion' ) . is ( ':checked' ) ) . toBe ( false ) ;
2440+ $ ( '.wrapper-modal-window .action-save' ) . click ( ) ;
2441+ AjaxHelpers . expectJsonRequest ( requests , 'POST' , '/xblock/mock-subsection' , {
2442+ publish : 'republish' ,
2443+ graderType : 'notgraded' ,
2444+ isPrereq : false ,
2445+ metadata : {
2446+ optional_completion : null ,
2447+ due : null ,
2448+ is_practice_exam : false ,
2449+ is_time_limited : false ,
2450+ is_proctored_enabled : false ,
2451+ default_time_limit_minutes : null ,
2452+ is_onboarding_exam : false ,
2453+ }
2454+ } ) ;
24092455 } ) ;
24102456 } ) ;
24112457 } ) ;
@@ -2551,9 +2597,25 @@ describe('CourseOutlinePage', function() {
25512597 } ) ;
25522598
25532599 it ( 'disables optional completion checkbox when the parent uses optional completion' , function ( ) {
2554- getUnitStatus ( { ancestor_has_optional_completion : true } , { } ) ;
2555- outlinePage . $ ( '.outline-unit .configure-button' ) . click ( ) ;
2556- expect ( $ ( '#optional_completion' ) . is ( ':disabled' ) ) . toBe ( true ) ;
2600+ getUnitStatus ( { ancestor_has_optional_completion : true } , { } ) ;
2601+ outlinePage . $ ( '.outline-unit .configure-button' ) . click ( ) ;
2602+ expect ( $ ( '#optional_completion' ) . is ( ':disabled' ) ) . toBe ( true ) ;
2603+ } ) ;
2604+
2605+ it ( 'sets optional completion to null instead of false' , function ( ) {
2606+ getUnitStatus ( { optional_completion : true } , { } ) ;
2607+ outlinePage . $ ( '.outline-unit .configure-button' ) . click ( ) ;
2608+ expect ( $ ( '#optional_completion' ) . is ( ':checked' ) ) . toBe ( true ) ;
2609+ $ ( '#optional_completion' ) . click ( )
2610+ expect ( $ ( '#optional_completion' ) . is ( ':checked' ) ) . toBe ( false ) ;
2611+ $ ( '.wrapper-modal-window .action-save' ) . click ( ) ;
2612+ AjaxHelpers . expectJsonRequest ( requests , 'POST' , '/xblock/mock-unit' , {
2613+ publish : 'republish' ,
2614+ metadata : {
2615+ visible_to_staff_only : null ,
2616+ optional_completion : null
2617+ }
2618+ } ) ;
25572619 } ) ;
25582620 } ) ;
25592621 } ) ;
0 commit comments