@@ -20,42 +20,41 @@ describe('ChatWidget', () => {
2020 } ) ;
2121 } ) ;
2222
23- test ( 'should send a message and display bot response' , async ( ) => {
24- submitQueryMock . mockResolvedValueOnce ( { response : 'Bot response' } ) ;
23+ test ( 'should send a message and display bot response' , async ( ) => {
24+ submitQueryMock . mockResolvedValueOnce ( { response : 'Bot response' } ) ;
2525
26- render ( < ChatWidget /> ) ;
27- fireEvent . click ( screen . getByLabelText ( / o p e n c h a t / i) ) ;
26+ render ( < ChatWidget /> ) ;
2827
29- const input = screen . getByLabelText ( / c h a t i n p u t / i) ;
30- const sendButton = screen . getByLabelText ( / s e n d m e s s a g e / i) ;
28+ const input = screen . getByLabelText ( / c h a t i n p u t / i) ;
29+ const sendButton = screen . getByLabelText ( / s e n d m e s s a g e / i) ;
3130
32- fireEvent . change ( input , { target : { value : 'Hello' } } ) ;
33- expect ( sendButton ) . not . toBeDisabled ( ) ;
31+ fireEvent . change ( input , { target : { value : 'Hello' } } ) ;
32+ expect ( sendButton ) . not . toBeDisabled ( ) ;
3433
35- fireEvent . click ( sendButton ) ;
34+ fireEvent . click ( sendButton ) ;
3635
37- const dots = await screen . findAllByText ( '.' , { selector : '.dot' } ) ;
38- expect ( dots . length ) . toBeGreaterThan ( 0 ) ;
39- const responseText = await screen . findByText ( 'Bot response' ) ;
40- expect ( responseText ) . toBeInTheDocument ( ) ;
41- } ) ;
36+ const dots = await screen . findAllByText ( '.' , { selector : '.dot' } ) ;
37+ expect ( dots . length ) . toBeGreaterThan ( 0 ) ;
4238
43- test ( 'should handle submitQuery failure gracefully' , async ( ) => {
44- submitQueryMock . mockRejectedValueOnce ( new Error ( 'Failed to load response' ) ) ;
39+ const responseText = await screen . findByText ( 'Bot response' ) ;
40+ expect ( responseText ) . toBeInTheDocument ( ) ;
41+ } ) ;
4542
46- render ( < ChatWidget /> ) ;
47- fireEvent . click ( screen . getByLabelText ( / o p e n c h a t / i ) ) ;
43+ test ( 'should handle submitQuery failure gracefully' , async ( ) => {
44+ submitQueryMock . mockRejectedValueOnce ( new Error ( 'Failed to load response' ) ) ;
4845
49- const input = screen . getByLabelText ( / c h a t i n p u t / i) ;
50- const sendButton = screen . getByLabelText ( / s e n d m e s s a g e / i) ;
46+ render ( < ChatWidget /> ) ;
5147
52- fireEvent . change ( input , { target : { value : 'Hi' } } ) ;
53- fireEvent . click ( sendButton ) ;
48+ const input = screen . getByLabelText ( / c h a t i n p u t / i ) ;
49+ const sendButton = screen . getByLabelText ( / s e n d m e s s a g e / i ) ;
5450
55- const dots = await screen . findAllByText ( '.' , { selector : '.dot' } ) ;
56- expect ( dots . length ) . toBeGreaterThan ( 0 ) ;
51+ fireEvent . change ( input , { target : { value : 'Hi' } } ) ;
52+ fireEvent . click ( sendButton ) ;
5753
58- const errorText = await screen . findByText ( 'Failed to load response' ) ;
59- expect ( errorText ) . toBeInTheDocument ( ) ;
60- } ) ;
54+ const dots = await screen . findAllByText ( '.' , { selector : '.dot' } ) ;
55+ expect ( dots . length ) . toBeGreaterThan ( 0 ) ;
56+
57+ const errorText = await screen . findByText ( 'Failed to load response' ) ;
58+ expect ( errorText ) . toBeInTheDocument ( ) ;
59+ } ) ;
6160} ) ;
0 commit comments