@@ -131,3 +131,69 @@ test.describe('Error Handling', () => {
131131 await expect ( page . getByText ( / A n e r r o r o c c u r r e d / i) ) . toBeVisible ( ) ;
132132 } ) ;
133133} ) ;
134+
135+ test . describe ( 'Chat History' , ( ) => {
136+ test ( 'can view chat history after creating conversations' , async ( { page } ) => {
137+ const { aiPlugin } = await setupTestPage ( page ) ;
138+ await aiPlugin . openRHS ( ) ;
139+
140+ // Create first conversation
141+ await openAIMock . addCompletionMock ( responseTest ) ;
142+ await aiPlugin . sendMessage ( 'First conversation message' ) ;
143+ await aiPlugin . waitForBotResponse ( responseTestText ) ;
144+
145+ // Create second conversation by starting new chat
146+ await page . getByTestId ( 'new-chat' ) . click ( ) ;
147+ await openAIMock . addCompletionMock ( responseTest2 ) ;
148+ await aiPlugin . sendMessage ( 'Second conversation message' ) ;
149+ await aiPlugin . waitForBotResponse ( responseTest2Text ) ;
150+
151+ // Open chat history
152+ await aiPlugin . openChatHistory ( ) ;
153+ await aiPlugin . expectChatHistoryVisible ( ) ;
154+
155+ // Verify we can see conversation entries
156+ await expect ( aiPlugin . threadsListContainer . locator ( 'div' ) . first ( ) ) . toBeVisible ( ) ;
157+ } ) ;
158+
159+ test ( 'can click on chat history items without errors' , async ( { page } ) => {
160+ const { aiPlugin } = await setupTestPage ( page ) ;
161+ await aiPlugin . openRHS ( ) ;
162+
163+ // Create a conversation first
164+ await openAIMock . addCompletionMock ( responseTest ) ;
165+ await aiPlugin . sendMessage ( 'Test conversation' ) ;
166+ await aiPlugin . waitForBotResponse ( responseTestText ) ;
167+
168+ // Open chat history
169+ await aiPlugin . openChatHistory ( ) ;
170+ await aiPlugin . expectChatHistoryVisible ( ) ;
171+
172+ // Click on the first history item
173+ await aiPlugin . clickChatHistoryItem ( 0 ) ;
174+
175+ // Verify we can see the conversation content we created
176+ await expect ( page . getByText ( 'Test conversation' ) ) . toBeVisible ( ) ;
177+ await expect ( page . getByText ( responseTestText ) ) . toBeVisible ( ) ;
178+ } ) ;
179+
180+ test ( 'chat history button is visible and functional' , async ( { page } ) => {
181+ const { aiPlugin } = await setupTestPage ( page ) ;
182+ await aiPlugin . openRHS ( ) ;
183+
184+ // Create a conversation first so we have content in the history
185+ await openAIMock . addCompletionMock ( responseTest ) ;
186+ await aiPlugin . sendMessage ( 'Test for history button' ) ;
187+ await aiPlugin . waitForBotResponse ( responseTestText ) ;
188+
189+ // Chat history button should be visible
190+ await expect ( aiPlugin . chatHistoryButton ) . toBeVisible ( ) ;
191+
192+ // Should be clickable
193+ await aiPlugin . chatHistoryButton . click ( ) ;
194+
195+ // Should show threads list with content
196+ await expect ( aiPlugin . threadsListContainer ) . toBeVisible ( ) ;
197+ await expect ( aiPlugin . threadsListContainer . locator ( 'div' ) . first ( ) ) . toBeVisible ( ) ;
198+ } ) ;
199+ } ) ;
0 commit comments