Skip to content

Commit 58e26ba

Browse files
debsmita1HusneShabbir
andauthored
Lightspeed chat history management (#1804)
* feat(lightspeed): chat history management * feat(lightspeed): chat history management * add tests for chat management * update the search empty state and add tests --------- Co-authored-by: HusneShabbir <husneshabbir447@gmail.com>
1 parent 221e215 commit 58e26ba

31 files changed

Lines changed: 2071 additions & 291 deletions
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
'@red-hat-developer-hub/backstage-plugin-lightspeed-common': patch
3+
'@red-hat-developer-hub/backstage-plugin-lightspeed': patch
4+
---
5+
6+
'@red-hat-developer-hub/backstage-plugin-lightspeed' :
7+
8+
- Added missing translations for untranslated labels across the Lightspeed chat UI.
9+
- Added lightspeed settings kebab menu
10+
- Added a new “Pinned” section. The section is conditionally visible only when pinning chats are enabled in Lightspeed settings. It shows an empty state when no chats are pinned.
11+
- Added Kebab menu actions to each chat item with actions: Rename, Pin, Unpin
12+
- Implemented logic to move chats between Pinned and Recent sections based on the selected action (“Pin” / “Unpin”).
13+
- Updated search behavior to show results under both Pinned and Recent groups (when enabled), including appropriate empty search messaging.
14+
- The Rename action opens a dialog with an editable text field and confirm/cancel actions.
15+
- Replaced the patternfly components with MUI to match the Figma designs [Design 1](https://www.figma.com/design/urwU8VqRvHfbxMqxeVknrv/RHDH-Lightspeed---AI-Assistant?node-id=1523-1670&t=CqnUYsxar0PtjAjZ-0)
16+
[Design 2](https://www.figma.com/design/urwU8VqRvHfbxMqxeVknrv/RHDH-Lightspeed---AI-Assistant?node-id=2514-5415&t=PphIEOl5Yzmgv5tI-0)
17+
18+
'@red-hat-developer-hub/backstage-plugin-lightspeed-common':
19+
20+
Added the Update api client

workspaces/lightspeed/packages/app/e2e-tests/lightspeed.test.ts

Lines changed: 113 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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';
4976
import { login } from './utils/login';
5077
import {
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

Comments
 (0)