@@ -2541,6 +2541,87 @@ describe('<CourseUnit />', () => {
25412541 expect ( discussionButton ) . not . toBeChecked ( ) ;
25422542 } ) ;
25432543
2544+ it ( 'should update the group access in the unit sidebar' , async ( ) => {
2545+ const user = userEvent . setup ( ) ;
2546+
2547+ setConfig ( {
2548+ ...getConfig ( ) ,
2549+ ENABLE_UNIT_PAGE_NEW_DESIGN : 'true' ,
2550+ } ) ;
2551+ render ( < RootWrapper /> ) ;
2552+
2553+ axiosMock
2554+ . onGet ( getCourseSectionVerticalApiUrl ( courseId ) )
2555+ . reply ( 200 , {
2556+ ...courseSectionVerticalMock ,
2557+ } ) ;
2558+ axiosMock
2559+ . onPost ( getXBlockBaseApiUrl ( courseSectionVerticalMock . xblock_info . id ) )
2560+ . reply ( 200 , {
2561+ ...courseSectionVerticalMock ,
2562+ } ) ;
2563+ axiosMock
2564+ . onGet ( getCourseSectionVerticalApiUrl ( blockId ) )
2565+ . reply ( 200 , {
2566+ ...courseSectionVerticalMock ,
2567+ xblock_info : {
2568+ ...courseSectionVerticalMock . xblock_info ,
2569+ user_partition_info : {
2570+ selected_partition_index : 0 ,
2571+ selected_groups_label : 'Group A' ,
2572+ selectable_partitions : [ {
2573+ id : 10 ,
2574+ name : 'Content Groups' ,
2575+ scheme : 'cohort' ,
2576+ groups : [
2577+ {
2578+ deleted : false ,
2579+ id : 1 ,
2580+ name : 'Group A' ,
2581+ selected : true ,
2582+ } ,
2583+ {
2584+ deleted : false ,
2585+ id : 2 ,
2586+ name : 'Group B' ,
2587+ selected : false ,
2588+ } ,
2589+ {
2590+ deleted : false ,
2591+ id : 3 ,
2592+ name : 'Group C' ,
2593+ selected : false ,
2594+ } ,
2595+ ] ,
2596+ } ] ,
2597+ } ,
2598+ } ,
2599+ } ) ;
2600+ await executeThunk ( fetchCourseSectionVerticalData ( courseId ) , store . dispatch ) ;
2601+ await executeThunk ( fetchCourseSectionVerticalData ( blockId , courseId ) , store . dispatch ) ;
2602+
2603+ // Move to settings
2604+ expect ( await screen . findByRole ( 'heading' , { name : / d r a f t \( u n p u b l i s h e d c h a n g e s \) / i } ) ) . toBeInTheDocument ( ) ;
2605+ const settingsTab = screen . getByRole ( 'tab' , { name : / s e t t i n g s / i } ) ;
2606+ expect ( settingsTab ) . toBeInTheDocument ( ) ;
2607+ await user . click ( settingsTab ) ;
2608+
2609+ // Select groub
2610+ const groupCombobox = screen . getByTestId ( 'group-type-select' ) ;
2611+ await user . selectOptions ( groupCombobox , 'Content Groups' ) ;
2612+ await user . click ( screen . getByRole ( 'checkbox' , { name : / G r o u p A / i } ) ) ;
2613+ await user . click ( screen . getByRole ( 'checkbox' , { name : / G r o u p B / i } ) ) ;
2614+ await user . click ( screen . getByRole ( 'button' , { name : / S a v e c h a n g e s / i } ) ) ;
2615+
2616+ // Check that the group access is being updated
2617+ await waitFor ( ( ) => {
2618+ expect ( axiosMock . history . post . length ) . toBeGreaterThan ( 0 ) ;
2619+ } ) ;
2620+
2621+ expect ( axiosMock . history . post [ 0 ] . url ) . toBe ( getXBlockBaseApiUrl ( courseSectionVerticalMock . xblock_info . id ) ) ;
2622+ expect ( axiosMock . history . post [ 0 ] . data ) . toMatch ( / " g r o u p _ a c c e s s " : \{ " 1 0 " : \[ 1 , 2 \] \} / ) ;
2623+ } ) ;
2624+
25442625 it ( 'should one group in the visibility field in the unit sidebar' , async ( ) => {
25452626 setConfig ( {
25462627 ...getConfig ( ) ,
0 commit comments