@@ -43,7 +43,6 @@ import {
4343import {
4444 createNewCourseXBlock ,
4545 deleteUnitItemQuery ,
46- editCourseUnitVisibilityAndData ,
4746 fetchCourseSectionVerticalData ,
4847 fetchCourseVerticalChildrenData ,
4948 getCourseOutlineInfoQuery ,
@@ -373,7 +372,8 @@ describe('<CourseUnit />', () => {
373372 published_by : userName ,
374373 } ,
375374 } ) ;
376- await executeThunk ( editCourseUnitVisibilityAndData ( blockId , PUBLISH_TYPES . makePublic , true ) , store . dispatch ) ;
375+ const publishBtn = await screen . findByRole ( 'button' , { name : / P u b l i s h / } ) ;
376+ await user . click ( publishBtn ) ;
377377
378378 // check if the sidebar status is Published and Live
379379 expect ( await screen . findByText (
@@ -415,7 +415,7 @@ describe('<CourseUnit />', () => {
415415 axiosMock
416416 . onGet ( getCourseSectionVerticalApiUrl ( blockId ) )
417417 . reply ( 200 , courseSectionVerticalMock ) ;
418- await executeThunk ( editCourseUnitVisibilityAndData ( blockId , PUBLISH_TYPES . makePublic , true ) , store . dispatch ) ;
418+ await user . click ( publishBtn ) ;
419419
420420 expect ( await screen . findByTitle (
421421 xblockContainerIframeMessages . xblockIframeTitle . defaultMessage ,
@@ -540,7 +540,8 @@ describe('<CourseUnit />', () => {
540540 published_by : userName ,
541541 } ,
542542 } ) ;
543- await executeThunk ( editCourseUnitVisibilityAndData ( blockId , PUBLISH_TYPES . makePublic , true ) , store . dispatch ) ;
543+ const publishBtn = await screen . findByRole ( 'button' , { name : / P u b l i s h / } ) ;
544+ await user . click ( publishBtn ) ;
544545
545546 await waitFor ( ( ) => {
546547 // check if the sidebar status is Published and Live
@@ -557,7 +558,7 @@ describe('<CourseUnit />', () => {
557558 axiosMock
558559 . onGet ( getCourseSectionVerticalApiUrl ( blockId ) )
559560 . reply ( 200 , courseSectionVerticalMock ) ;
560- await executeThunk ( editCourseUnitVisibilityAndData ( blockId , PUBLISH_TYPES . makePublic , true ) , store . dispatch ) ;
561+ await user . click ( publishBtn ) ;
561562
562563 const xblockIframe = await screen . findByTitle ( xblockContainerIframeMessages . xblockIframeTitle . defaultMessage ) ;
563564 expect ( xblockIframe ) . toHaveAttribute (
@@ -711,7 +712,8 @@ describe('<CourseUnit />', () => {
711712 } ,
712713 } ) ;
713714
714- await executeThunk ( editCourseUnitVisibilityAndData ( blockId , PUBLISH_TYPES . makePublic , true ) , store . dispatch ) ;
715+ const publishBtn = await screen . findByRole ( 'button' , { name : / P u b l i s h / } ) ;
716+ await user . click ( publishBtn ) ;
715717
716718 await waitFor ( async ( ) => {
717719 const problemButton = screen . getByRole ( 'button' , {
@@ -726,7 +728,7 @@ describe('<CourseUnit />', () => {
726728 . onGet ( getCourseSectionVerticalApiUrl ( blockId ) )
727729 . reply ( 200 , courseSectionVerticalMock ) ;
728730
729- await executeThunk ( editCourseUnitVisibilityAndData ( blockId , PUBLISH_TYPES . makePublic , true ) , store . dispatch ) ;
731+ await user . click ( publishBtn ) ;
730732
731733 // after creating problem xblock, the sidebar status changes to Draft (unpublished changes)
732734 expect ( screen . getByText (
@@ -895,7 +897,7 @@ describe('<CourseUnit />', () => {
895897 } ,
896898 } ) ;
897899
898- await executeThunk ( editCourseUnitVisibilityAndData ( blockId , PUBLISH_TYPES . makePublic , true ) , store . dispatch ) ;
900+ await user . click ( publishButton ) ;
899901
900902 await waitFor ( ( ) => {
901903 // check if the sidebar status is Published and Live
@@ -920,7 +922,7 @@ describe('<CourseUnit />', () => {
920922 . onGet ( getCourseSectionVerticalApiUrl ( blockId ) )
921923 . reply ( 200 , courseSectionVerticalMock ) ;
922924
923- await executeThunk ( editCourseUnitVisibilityAndData ( blockId , PUBLISH_TYPES . makePublic , true ) , store . dispatch ) ;
925+ await user . click ( publishButton ) ;
924926
925927 // after creating video xblock, the sidebar status changes to Draft (unpublished changes)
926928 expect ( screen . getByText (
@@ -974,7 +976,8 @@ describe('<CourseUnit />', () => {
974976 } ,
975977 } ) ;
976978
977- await executeThunk ( editCourseUnitVisibilityAndData ( blockId , PUBLISH_TYPES . makePublic , true ) , store . dispatch ) ;
979+ const publishButton = await screen . findByRole ( 'button' , { name : legacySidebarMessages . actionButtonPublishTitle . defaultMessage } ) ;
980+ await user . click ( publishButton ) ;
978981
979982 await waitFor ( async ( ) => {
980983 // check if the sidebar status is Published and Live
@@ -1004,7 +1007,7 @@ describe('<CourseUnit />', () => {
10041007 . onGet ( getCourseSectionVerticalApiUrl ( blockId ) )
10051008 . reply ( 200 , courseSectionVerticalMock ) ;
10061009
1007- await executeThunk ( editCourseUnitVisibilityAndData ( blockId , PUBLISH_TYPES . makePublic , true ) , store . dispatch ) ;
1010+ await user . click ( publishButton ) ;
10081011
10091012 // after creating video xblock, the sidebar status changes to Draft (unpublished changes)
10101013 expect ( screen . getByText (
@@ -1138,7 +1141,8 @@ describe('<CourseUnit />', () => {
11381141 } ,
11391142 } ) ;
11401143
1141- await executeThunk ( editCourseUnitVisibilityAndData ( blockId , PUBLISH_TYPES . republish , true ) , store . dispatch ) ;
1144+ const publishButton = await screen . findByRole ( 'button' , { name : legacySidebarMessages . actionButtonPublishTitle . defaultMessage } ) ;
1145+ await user . click ( publishButton ) ;
11421146
11431147 await waitFor ( async ( ) => {
11441148 expect ( visibilityCheckbox ) . toBeChecked ( ) ;
@@ -1174,7 +1178,7 @@ describe('<CourseUnit />', () => {
11741178 . onGet ( getCourseSectionVerticalApiUrl ( blockId ) )
11751179 . reply ( 200 , courseSectionVerticalMock ) ;
11761180
1177- await executeThunk ( editCourseUnitVisibilityAndData ( blockId , PUBLISH_TYPES . republish , null ) , store . dispatch ) ;
1181+ await user . click ( publishButton ) ;
11781182
11791183 expect ( visibilityCheckbox ) . not . toBeChecked ( ) ;
11801184 expect ( draftUnpublishedChangesHeading ) . toBeInTheDocument ( ) ;
@@ -1211,7 +1215,8 @@ describe('<CourseUnit />', () => {
12111215 } ,
12121216 } ) ;
12131217
1214- await executeThunk ( editCourseUnitVisibilityAndData ( blockId , PUBLISH_TYPES . makePublic , true ) , store . dispatch ) ;
1218+ const publishButton = await screen . findByRole ( 'button' , { name : legacySidebarMessages . actionButtonPublishTitle . defaultMessage } ) ;
1219+ await user . click ( publishButton ) ;
12151220
12161221 expect ( within ( courseUnitSidebar )
12171222 . getByText ( legacySidebarMessages . sidebarTitlePublishedAndLive . defaultMessage ) ) . toBeInTheDocument ( ) ;
@@ -1271,11 +1276,8 @@ describe('<CourseUnit />', () => {
12711276 } ,
12721277 } ) ;
12731278
1274- await executeThunk ( editCourseUnitVisibilityAndData (
1275- blockId ,
1276- PUBLISH_TYPES . discardChanges ,
1277- true ,
1278- ) , store . dispatch ) ;
1279+ const publishButton = await screen . findByRole ( 'button' , { name : legacySidebarMessages . actionButtonPublishTitle . defaultMessage } ) ;
1280+ await user . click ( publishButton ) ;
12791281
12801282 expect ( within ( courseUnitSidebar )
12811283 . getByText ( legacySidebarMessages . sidebarTitlePublishedNotYetReleased . defaultMessage ) ) . toBeInTheDocument ( ) ;
@@ -2430,7 +2432,8 @@ describe('<CourseUnit />', () => {
24302432 } ,
24312433 } ) ;
24322434
2433- await executeThunk ( editCourseUnitVisibilityAndData ( blockId , PUBLISH_TYPES . republish , true ) , store . dispatch ) ;
2435+ const publishButton = await screen . findByRole ( 'button' , { name : legacySidebarMessages . actionButtonPublishTitle . defaultMessage } ) ;
2436+ await user . click ( publishButton ) ;
24342437 // Move to Details
24352438 const detailsTab = screen . getByRole ( 'tab' , { name : / d e t a i l s / i } ) ;
24362439 await user . click ( detailsTab ) ;
@@ -2461,7 +2464,7 @@ describe('<CourseUnit />', () => {
24612464 } ,
24622465 } ) ;
24632466
2464- await executeThunk ( editCourseUnitVisibilityAndData ( blockId , PUBLISH_TYPES . republish , false ) , store . dispatch ) ;
2467+ await user . click ( publishButton ) ;
24652468
24662469 // Move to Details
24672470 await user . click ( detailsTab ) ;
@@ -2538,13 +2541,8 @@ describe('<CourseUnit />', () => {
25382541 } ,
25392542 } ) ;
25402543
2541- await executeThunk ( editCourseUnitVisibilityAndData (
2542- blockId ,
2543- PUBLISH_TYPES . republish ,
2544- false ,
2545- null ,
2546- false ,
2547- ) , store . dispatch ) ;
2544+ const publishButton = await screen . findByRole ( 'button' , { name : legacySidebarMessages . actionButtonPublishTitle . defaultMessage } ) ;
2545+ await user . click ( publishButton ) ;
25482546
25492547 expect ( discussionButton ) . not . toBeChecked ( ) ;
25502548 } ) ;
0 commit comments