@@ -57,7 +57,7 @@ describe('ChatHistoryList', () => {
5757 renderChatHistoryList ( { chatHistory } ) ;
5858
5959 expect ( screen . getByText ( 'Recent' ) ) . toBeInTheDocument ( ) ;
60- expect ( screen . getByText ( 'Recent Chat' ) ) . toBeInTheDocument ( ) ;
60+ expect ( screen . getAllByText ( 'Recent Chat' ) . length ) . toBeGreaterThan ( 1 ) ;
6161 } ) ;
6262
6363 it ( 'handles empty chat history group gracefully' , ( ) => {
@@ -71,16 +71,16 @@ describe('ChatHistoryList', () => {
7171 { id : '4' , title : 'Month Old Chat' , date : new Date ( Date . now ( ) - 30 * 24 * 60 * 60 * 1000 ) . toISOString ( ) , messages : [ ] } ,
7272 ] ;
7373 renderChatHistoryList ( { chatHistory } ) ;
74- expect ( screen . getByText ( 'Week Old Chat' ) ) . toBeInTheDocument ( ) ;
75- expect ( screen . getByText ( 'Month Old Chat' ) ) . toBeInTheDocument ( ) ;
74+ expect ( screen . getAllByText ( 'Week Old Chat' ) . length ) . toBeGreaterThan ( 1 ) ;
75+ expect ( screen . getAllByText ( 'Month Old Chat' ) . length ) . toBeGreaterThan ( 1 ) ;
7676 } ) ;
7777
7878 it ( 'groups entries without matching month-year into a new group' , ( ) => {
7979 const chatHistory : Conversation [ ] = [
8080 { id : '5' , title : 'Very Old Chat' , date : new Date ( Date . now ( ) - 365 * 24 * 60 * 60 * 1000 ) . toISOString ( ) , messages : [ ] } ,
8181 ] ;
8282 renderChatHistoryList ( { chatHistory } ) ;
83- expect ( screen . getByText ( 'Very Old Chat' ) ) . toBeInTheDocument ( ) ;
83+ expect ( screen . getAllByText ( 'Very Old Chat' ) . length ) . toBeGreaterThan ( 1 ) ;
8484 // Check that a new group for the year appears if it's far in the past
8585 } ) ;
8686
@@ -90,8 +90,8 @@ describe('ChatHistoryList', () => {
9090 { id : '7' , title : 'Chat 2' , date : new Date ( Date . now ( ) - 20 * 24 * 60 * 60 * 1000 ) . toISOString ( ) , messages : [ ] } ,
9191 ] ;
9292 renderChatHistoryList ( { chatHistory } ) ;
93- expect ( screen . getByText ( 'Chat 1' ) ) . toBeInTheDocument ( ) ;
94- expect ( screen . getByText ( 'Chat 2' ) ) . toBeInTheDocument ( ) ;
93+ expect ( screen . getAllByText ( 'Chat 1' ) . length ) . toBeGreaterThan ( 1 ) ;
94+ expect ( screen . getAllByText ( 'Chat 2' ) . length ) . toBeGreaterThan ( 1 ) ;
9595 // Confirm that both entries are grouped in the same month
9696 } ) ;
9797 it ( 'groups recent and older entries separately' , ( ) => {
@@ -101,7 +101,7 @@ describe('ChatHistoryList', () => {
101101 ] ;
102102 renderChatHistoryList ( { chatHistory } ) ;
103103 expect ( screen . getByText ( 'Recent' ) ) . toBeInTheDocument ( ) ;
104- expect ( screen . getByText ( 'Older Chat' ) ) . toBeInTheDocument ( ) ;
104+ expect ( screen . getAllByText ( 'Older Chat' ) . length ) . toBeGreaterThan ( 1 ) ;
105105 // Ensures "Recent Chat" is grouped separately from older entries
106106 } ) ;
107107 it ( 'groups multiple entries in the same month-year and sorts them' , ( ) => {
@@ -110,8 +110,8 @@ describe('ChatHistoryList', () => {
110110 { id : '11' , title : 'Chat on Day 2' , date : new Date ( Date . now ( ) - 46 * 24 * 60 * 60 * 1000 ) . toISOString ( ) , messages : [ ] } ,
111111 ] ;
112112 renderChatHistoryList ( { chatHistory } ) ;
113- expect ( screen . getByText ( 'Chat on Day 1' ) ) . toBeInTheDocument ( ) ;
114- expect ( screen . getByText ( 'Chat on Day 2' ) ) . toBeInTheDocument ( ) ;
113+ expect ( screen . getAllByText ( 'Chat on Day 1' ) . length ) . toBeGreaterThan ( 1 ) ;
114+ expect ( screen . getAllByText ( 'Chat on Day 2' ) . length ) . toBeGreaterThan ( 1 ) ;
115115 // Confirms entries from the same month-year are grouped and sorted within the group
116116 } ) ;
117117 it ( 'handles empty groups gracefully' , ( ) => {
@@ -130,9 +130,9 @@ describe('ChatHistoryList', () => {
130130 { id : '15' , title : 'Oldest Chat' , date : new Date ( Date . now ( ) - 365 * 24 * 60 * 60 * 1000 ) . toISOString ( ) , messages : [ ] } ,
131131 ] ;
132132 renderChatHistoryList ( { chatHistory } ) ;
133- expect ( screen . getByText ( 'Newest Chat' ) ) . toBeInTheDocument ( ) ;
134- expect ( screen . getByText ( 'Older Chat' ) ) . toBeInTheDocument ( ) ;
135- expect ( screen . getByText ( 'Oldest Chat' ) ) . toBeInTheDocument ( ) ;
133+ expect ( screen . getAllByText ( 'Newest Chat' ) . length ) . toBeGreaterThan ( 1 ) ;
134+ expect ( screen . getAllByText ( 'Older Chat' ) . length ) . toBeGreaterThan ( 1 ) ;
135+ expect ( screen . getAllByText ( 'Oldest Chat' ) . length ) . toBeGreaterThan ( 1 ) ;
136136
137137 } ) ;
138138
0 commit comments