@@ -46,6 +46,33 @@ import {
4646 assertDrawerState ,
4747 verifySidePanelConversation ,
4848} from './utils/sidebar' ;
49+ import {
50+ openChatContextMenu ,
51+ openChatContextMenuByName ,
52+ verifyChatContextMenuOptions ,
53+ selectRenameAction ,
54+ verifyRenameChatForm ,
55+ submitChatRename ,
56+ verifyChatRenamed ,
57+ verifyEmptyPinnedChatsMessage ,
58+ verifyPinnedChatsNotEmpty ,
59+ selectPinAction ,
60+ verifyChatPinned ,
61+ verifyPinActionAvailable ,
62+ selectDeleteAction ,
63+ verifyDeleteConfirmation ,
64+ cancelChatDeletion ,
65+ confirmChatDeletion ,
66+ verifyChatDeleted ,
67+ openChatbotSettings ,
68+ verifyChatbotSettingsVisible ,
69+ verifyPinnedSectionVisible ,
70+ verifyPinnedSectionHidden ,
71+ verifyDisablePinnedChatsOption ,
72+ verifyEnablePinnedChatsOption ,
73+ selectDisablePinnedChats ,
74+ selectEnablePinnedChats ,
75+ } from './utils/chatManagement' ;
4976import { login } from './utils/login' ;
5077import {
5178 mockChatHistory ,
@@ -146,13 +173,13 @@ test.describe('Lightspeed tests', () => {
146173 } ) ;
147174
148175 await test . step ( 'Close the sidebar and verify elements are hidden' , async ( ) => {
149- await closeChatDrawer ( sharedPage ) ;
176+ await closeChatDrawer ( sharedPage , translations ) ;
150177 await runAccessibilityTests ( sharedPage , testInfo ) ;
151178 await assertDrawerState ( sharedPage , 'closed' , translations ) ;
152179 } ) ;
153180
154181 await test . step ( 'Reopen the sidebar and verify elements are visible again' , async ( ) => {
155- await openChatDrawer ( sharedPage ) ;
182+ await openChatDrawer ( sharedPage , translations ) ;
156183 await assertDrawerState ( sharedPage , 'open' , translations ) ;
157184 } ) ;
158185 } ) ;
@@ -288,10 +315,10 @@ test.describe('Lightspeed tests', () => {
288315 await sendMessage ( message , sharedPage , translations , false ) ;
289316
290317 const jumpTopButton = sharedPage . getByRole ( 'button' , {
291- name : 'Back to top' ,
318+ name : translations [ 'aria.scroll.up' ] ,
292319 } ) ;
293320 const jumpBottomButton = sharedPage . getByRole ( 'button' , {
294- name : 'Back to bottom' ,
321+ name : translations [ 'aria.scroll.down' ] ,
295322 } ) ;
296323
297324 await runAccessibilityTests ( sharedPage , testInfo ) ;
@@ -327,7 +354,7 @@ test.describe('Lightspeed tests', () => {
327354
328355 const chats = sidePanel . locator ( 'li.pf-chatbot__menu-item' ) ;
329356 if ( devMode ) {
330- await expect ( chats ) . toHaveCount ( 2 ) ;
357+ await expect ( chats ) . toHaveCount ( 3 ) ;
331358 } else {
332359 expect ( await chats . count ( ) ) . toBeGreaterThanOrEqual ( 1 ) ;
333360 await sharedPage
@@ -344,10 +371,21 @@ test.describe('Lightspeed tests', () => {
344371 translations [ 'chatbox.search.placeholder' ] ,
345372 ) ;
346373 await searchBox . fill ( devMode ? 'new' : 'Backstage' ) ;
347- for ( const chat of await chats . all ( ) ) {
348- expect ( chat ) . toContainText ( searchText ) ;
374+ const validChat = sidePanel
375+ . locator ( 'li.pf-chatbot__menu-item' )
376+ . filter ( { hasText : searchText } )
377+ . first ( ) ;
378+
379+ const chatItems = await chats . all ( ) ;
380+ for ( const chat of chatItems ) {
381+ const text = await chat . textContent ( ) ;
382+ // Skip empty state messages (e.g., "No pinned chats")
383+ if ( text ?. includes ( translations [ 'chatbox.emptyState.noPinnedChats' ] ) ) {
384+ continue ;
385+ }
386+ await expect ( chat ) . toContainText ( searchText ) ;
349387 }
350- await chats . first ( ) . click ( ) ;
388+ await validChat . click ( ) ;
351389
352390 const userMessage = sharedPage . locator ( '.pf-chatbot__message--user' ) ;
353391 const botMessage = sharedPage . locator ( '.pf-chatbot__message--bot' ) ;
@@ -359,5 +397,72 @@ test.describe('Lightspeed tests', () => {
359397 devMode ? contents [ 0 ] . messages [ 1 ] . content : 'Backstage' ,
360398 ) ;
361399 } ) ;
400+
401+ test . describe ( 'Chat Management' , ( ) => {
402+ const testChatName = 'Test Rename' ;
403+
404+ test ( 'Verify chat actions menu' , async ( ) => {
405+ await sharedPage . reload ( ) ;
406+ await sharedPage . waitForTimeout ( 3000 ) ;
407+ await openChatContextMenu ( sharedPage ) ;
408+ await verifyChatContextMenuOptions ( sharedPage , translations ) ;
409+ } ) ;
410+
411+ test ( 'Verify Rename chat and its actions' , async ( ) => {
412+ await selectRenameAction ( sharedPage , translations ) ;
413+ await verifyRenameChatForm ( sharedPage , translations ) ;
414+ await submitChatRename ( sharedPage , testChatName , translations ) ;
415+ await verifyChatRenamed ( sharedPage , testChatName ) ;
416+ } ) ;
417+
418+ test ( 'Verify pin chat and its actions' , async ( ) => {
419+ await verifyEmptyPinnedChatsMessage ( sharedPage , translations ) ;
420+ await openChatContextMenu ( sharedPage ) ;
421+ await verifyPinActionAvailable ( sharedPage , translations ) ;
422+ await selectPinAction ( sharedPage , translations ) ;
423+ await verifyChatPinned ( sharedPage , testChatName ) ;
424+ await verifyPinnedChatsNotEmpty ( sharedPage , translations ) ;
425+ } ) ;
426+
427+ test ( 'Verify delete chat and its actions' , async ( ) => {
428+ await verifyChatRenamed ( sharedPage , testChatName ) ;
429+ await openChatContextMenuByName ( sharedPage , testChatName , translations ) ;
430+ await selectDeleteAction ( sharedPage , translations ) ;
431+ await verifyDeleteConfirmation ( sharedPage , translations ) ;
432+ await cancelChatDeletion ( sharedPage , translations ) ;
433+ await verifyChatRenamed ( sharedPage , testChatName ) ;
434+
435+ await openChatContextMenuByName ( sharedPage , testChatName , translations ) ;
436+ await selectDeleteAction ( sharedPage , translations ) ;
437+ await confirmChatDeletion ( sharedPage , translations ) ;
438+ await verifyChatDeleted ( sharedPage , testChatName ) ;
439+ } ) ;
440+
441+ test ( 'Verify disable pinned chats' , async ( ) => {
442+ await verifyPinnedSectionVisible ( sharedPage , translations ) ;
443+ await verifyEmptyPinnedChatsMessage ( sharedPage , translations ) ;
444+ await verifyChatbotSettingsVisible ( sharedPage , translations ) ;
445+ await openChatbotSettings ( sharedPage , translations ) ;
446+ await verifyDisablePinnedChatsOption ( sharedPage , translations ) ;
447+ await selectDisablePinnedChats ( sharedPage , translations ) ;
448+ await verifyPinnedSectionHidden ( sharedPage , translations ) ;
449+ await verifyPinnedChatsNotEmpty ( sharedPage , translations ) ;
450+ } ) ;
451+
452+ test ( 'Verify enable pinned chats' , async ( ) => {
453+ await verifyPinnedSectionHidden ( sharedPage , translations ) ;
454+ await verifyPinnedChatsNotEmpty ( sharedPage , translations ) ;
455+ await openChatbotSettings ( sharedPage , translations ) ;
456+ await verifyEnablePinnedChatsOption ( sharedPage , translations ) ;
457+ await selectEnablePinnedChats ( sharedPage , translations ) ;
458+ await verifyPinnedSectionVisible ( sharedPage , translations ) ;
459+ await verifyEmptyPinnedChatsMessage ( sharedPage , translations ) ;
460+ } ) ;
461+ /**
462+ * TODO (after persistence is implemented):
463+ * - Verify pinned chat is visible after page refresh
464+ * - Add test to verify unpin actions
465+ */
466+ } ) ;
362467 } ) ;
363468} ) ;
0 commit comments