@@ -103,7 +103,7 @@ async function getThreadAPIResponse(attr = null) {
103103 await executeThunk ( fetchThread ( discussionPostId ) , store . dispatch , store . getState ) ;
104104}
105105
106- async function setupCourseConfig ( ) {
106+ async function setupCourseConfig ( isEmailVerified = true , onlyVerifiedUsersCanPost = false ) {
107107 axiosMock . onGet ( `${ courseConfigApiUrl } ${ courseId } /` ) . reply ( 200 , {
108108 has_moderation_privileges : true ,
109109 isPostingEnabled : true ,
@@ -115,7 +115,8 @@ async function setupCourseConfig() {
115115 { code : 'reason-1' , label : 'reason 1' } ,
116116 { code : 'reason-2' , label : 'reason 2' } ,
117117 ] ,
118- isEmailVerified : true ,
118+ isEmailVerified,
119+ onlyVerifiedUsersCanPost,
119120 } ) ;
120121 axiosMock . onGet ( `${ courseSettingsApiUrl } ${ courseId } /settings` ) . reply ( 200 , { } ) ;
121122 await executeThunk ( fetchCourseConfig ( courseId ) , store . dispatch , store . getState ) ;
@@ -310,6 +311,29 @@ describe('ThreadView', () => {
310311 expect ( screen . queryByTestId ( 'tinymce-editor' ) ) . not . toBeInTheDocument ( ) ;
311312 } ) ;
312313
314+ it ( 'should open the confirmation link dialogue box by clicking on add comment button.' , async ( ) => {
315+ await setupCourseConfig ( false , true ) ;
316+ await waitFor ( ( ) => renderComponent ( discussionPostId ) ) ;
317+
318+ const comment = await waitFor ( ( ) => screen . findByTestId ( 'comment-comment-1' ) ) ;
319+ const hoverCard = within ( comment ) . getByTestId ( 'hover-card-comment-1' ) ;
320+ await act ( async ( ) => { fireEvent . click ( within ( hoverCard ) . getByRole ( 'button' , { name : / A d d c o m m e n t / i } ) ) ; } ) ;
321+
322+ expect ( screen . queryByText ( 'Send confirmation link' ) ) . toBeInTheDocument ( ) ;
323+ } ) ;
324+
325+ it ( 'should open the confirmation link dialogue box by clicking on add response.' , async ( ) => {
326+ await setupCourseConfig ( false , true ) ;
327+ await waitFor ( ( ) => renderComponent ( discussionPostId ) ) ;
328+
329+ const post = await screen . findByTestId ( 'post-thread-1' ) ;
330+ const hoverCard = within ( post ) . getByTestId ( 'hover-card-thread-1' ) ;
331+ const addResponseButton = within ( hoverCard ) . getByRole ( 'button' , { name : / A d d r e s p o n s e / i } ) ;
332+ await act ( async ( ) => { fireEvent . click ( addResponseButton ) ; } ) ;
333+
334+ expect ( screen . queryByText ( 'Send confirmation link' ) ) . toBeInTheDocument ( ) ;
335+ } ) ;
336+
313337 it ( 'should allow posting a comment with CAPTCHA' , async ( ) => {
314338 await setupCourseConfig ( ) ;
315339 await waitFor ( ( ) => renderComponent ( discussionPostId ) ) ;
@@ -1061,6 +1085,17 @@ describe('ThreadView', () => {
10611085 expect ( responseSortTour ( ) . enabled ) . toBeFalsy ( ) ;
10621086 } ) ;
10631087 } ) ;
1088+
1089+ it ( 'should open the confirmation link dialogue box on add response button.' , async ( ) => {
1090+ await setupCourseConfig ( false , true ) ;
1091+ await waitFor ( ( ) => renderComponent ( discussionPostId ) ) ;
1092+
1093+ const addResponseButton = screen . getByTestId ( 'add-response' ) ;
1094+
1095+ await act ( async ( ) => { fireEvent . click ( addResponseButton ) ; } ) ;
1096+
1097+ expect ( screen . queryByText ( 'Send confirmation link' ) ) . toBeInTheDocument ( ) ;
1098+ } ) ;
10641099} ) ;
10651100
10661101describe ( 'MockReCAPTCHA' , ( ) => {
0 commit comments