1- import { renderWithContext , screen , waitFor , fireEvent , act , logRoles } from '../../test/test.utils' ;
1+ import { renderWithContext , screen , waitFor , fireEvent , act } from '../../test/test.utils' ;
22import { Answer } from './Answer'
3- import { AppStateContext } from '../../state/AppProvider'
43import { AskResponse , Citation , Feedback , historyMessageFeedback } from '../../api' ;
54//import { Feedback, AskResponse, Citation } from '../../api/models'
65import { cloneDeep } from 'lodash'
76import userEvent from '@testing-library/user-event' ;
8- import { CitationPanel } from '../../pages/chat/Components/CitationPanel' ;
97
108// Mock required modules and functions
119jest . mock ( '../../api/api' , ( ) => ( {
@@ -27,9 +25,6 @@ jest.mock('remark-gfm', () => jest.fn());
2725jest . mock ( 'rehype-raw' , ( ) => jest . fn ( ) ) ;
2826jest . mock ( 'remark-supersub' , ( ) => jest . fn ( ) ) ;
2927
30- const mockDispatch = jest . fn ( ) ;
31- const mockOnCitationClicked = jest . fn ( ) ;
32-
3328// Mock context provider values
3429let mockAppState = {
3530 frontendSettings : { feedback_enabled : true , sanitize_answer : true } ,
@@ -360,15 +355,14 @@ describe('Answer Component', () => {
360355 it ( 'should open and submit negative feedback dialog' , async ( ) => {
361356 userEvent . setup ( ) ;
362357 renderComponent ( ) ;
363- const handleChange = jest . fn ( ) ;
364358 const dislikeButton = screen . getByLabelText ( 'Dislike this response' ) ;
365359
366360 // Click dislike to open dialog
367361 await fireEvent . click ( dislikeButton ) ;
368362 expect ( screen . getByText ( "Why wasn't this response helpful?" ) ) . toBeInTheDocument ( ) ;
369363
370364 // Select feedback and submit
371- const checkboxEle = await screen . findByLabelText ( / C i t a t i o n s a r e w r o n g / i)
365+ const checkboxEle = await screen . findByLabelText ( / C i t a t i o n s a r e w r o n g / i) ;
372366 //logRoles(checkboxEle)
373367 await waitFor ( ( ) => {
374368 userEvent . click ( checkboxEle ) ;
@@ -382,12 +376,8 @@ describe('Answer Component', () => {
382376
383377 it ( 'calls resetFeedbackDialog and setFeedbackState with Feedback.Neutral on dialog dismiss' , async ( ) => {
384378
385- const resetFeedbackDialogMock = jest . fn ( ) ;
386- const setFeedbackStateMock = jest . fn ( ) ;
387-
388379 userEvent . setup ( ) ;
389380 renderComponent ( ) ;
390- const handleChange = jest . fn ( ) ;
391381 const dislikeButton = screen . getByLabelText ( 'Dislike this response' ) ;
392382
393383 // Click dislike to open dialog
@@ -410,7 +400,6 @@ describe('Answer Component', () => {
410400 it ( 'Dialog Options should be able to select and unSelect' , async ( ) => {
411401 userEvent . setup ( ) ;
412402 renderComponent ( ) ;
413- const handleChange = jest . fn ( ) ;
414403 const dislikeButton = screen . getByLabelText ( 'Dislike this response' ) ;
415404
416405 // Click dislike to open dialog
@@ -419,15 +408,15 @@ describe('Answer Component', () => {
419408 expect ( screen . getByText ( "Why wasn't this response helpful?" ) ) . toBeInTheDocument ( ) ;
420409
421410 // Select feedback and submit
422- const checkboxEle = await screen . findByLabelText ( / C i t a t i o n s a r e w r o n g / i)
411+ const checkboxEle = await screen . findByLabelText ( / C i t a t i o n s a r e w r o n g / i) ;
423412 expect ( checkboxEle ) . not . toBeChecked ( ) ;
424413
425414 await userEvent . click ( checkboxEle ) ;
426415 await waitFor ( ( ) => {
427416 expect ( checkboxEle ) . toBeChecked ( ) ;
428417 } ) ;
429418
430- const checkboxEle1 = await screen . findByLabelText ( / C i t a t i o n s a r e w r o n g / i)
419+ const checkboxEle1 = await screen . findByLabelText ( / C i t a t i o n s a r e w r o n g / i) ;
431420
432421 await userEvent . click ( checkboxEle1 ) ;
433422 await waitFor ( ( ) => {
@@ -439,7 +428,6 @@ describe('Answer Component', () => {
439428 it ( 'Should able to show ReportInappropriateFeedbackContent form while click on "InappropriateFeedback" button ' , async ( ) => {
440429 userEvent . setup ( ) ;
441430 renderComponent ( ) ;
442- const handleChange = jest . fn ( ) ;
443431 const dislikeButton = screen . getByLabelText ( 'Dislike this response' ) ;
444432
445433 // Click dislike to open dialog
@@ -514,7 +502,6 @@ describe('Answer Component', () => {
514502 feedbackState : { '123' : Feedback . OtherHarmful } ,
515503 }
516504 renderComponent ( answerWithMissingFeedback , extraMockState ) ;
517- const handleChange = jest . fn ( ) ;
518505 const dislikeButton = screen . getByLabelText ( 'Dislike this response' ) ;
519506
520507 // Click dislike to open dialog
@@ -529,10 +516,6 @@ describe('Answer Component', () => {
529516
530517 tempMockCitation [ 0 ] . filepath = '' ;
531518 tempMockCitation [ 0 ] . reindex_id = '' ;
532- const answerWithMissingFeedback = {
533- ...mockAnswerProps ,
534- CitationPanel : [ ...tempMockCitation ]
535- }
536519
537520 renderComponent ( ) ;
538521
0 commit comments