Skip to content

Commit a15ce4f

Browse files
Merge pull request microsoft#315 from microsoft/psl-bug-16106
fix: resolved DocGen- After hovering over the chat history, no tooltip is displayed
2 parents c6feddc + bce6caf commit a15ce4f

File tree

5 files changed

+49
-26
lines changed

5 files changed

+49
-26
lines changed

package-lock.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/frontend/src/components/ChatHistory/ChatHistoryList.test.tsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -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

src/frontend/src/components/ChatHistory/ChatHistoryListItem.tsx

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,17 @@ import {
77
DialogType,
88
IconButton,
99
ITextField,
10+
ITooltipHostStyles,
1011
List,
1112
PrimaryButton,
1213
Separator,
1314
Spinner,
1415
SpinnerSize,
1516
Stack,
1617
Text,
17-
TextField
18+
TextField,
19+
TooltipHost,
20+
DirectionalHint,
1821
} from '@fluentui/react'
1922
import { useBoolean } from '@fluentui/react-hooks'
2023

@@ -77,6 +80,10 @@ export const ChatHistoryListItemCell: React.FC<ChatHistoryListItemCellProps> = (
7780
isBlocking: true,
7881
styles: { main: { maxWidth: 450 } }
7982
}
83+
84+
const tooltipStyles: Partial<ITooltipHostStyles> = {
85+
root: { display: 'inline-block', maxWidth: '80%' }
86+
};
8087

8188
if (!item) {
8289
return null
@@ -145,7 +152,7 @@ export const ChatHistoryListItemCell: React.FC<ChatHistoryListItemCellProps> = (
145152
}
146153
}
147154

148-
const truncatedTitle = item?.title?.length > 28 ? `${item.title.substring(0, 28)} ...` : item.title
155+
const truncatedTitle = item?.title?.length > 24 ? `${item.title.substring(0, 24)} ...` : item.title
149156

150157
const handleSaveEdit = async (e: any) => {
151158
e.preventDefault()
@@ -285,9 +292,17 @@ export const ChatHistoryListItemCell: React.FC<ChatHistoryListItemCellProps> = (
285292
) : (
286293
<>
287294
<Stack horizontal verticalAlign={'center'} style={{ width: '100%' }}>
288-
<div className={styles.chatTitle}>{truncatedTitle}</div>
295+
<Stack.Item grow>
296+
<TooltipHost
297+
content={item.title}
298+
directionalHint={DirectionalHint.bottomCenter}
299+
>
300+
<div className={styles.chatTitle}>{truncatedTitle}</div>
301+
</TooltipHost>
302+
</Stack.Item>
303+
{/* <div className={styles.chatTitle}>{truncatedTitle}</div> */}
289304
{(isSelected || isHovered) && (
290-
<Stack horizontal horizontalAlign="end">
305+
<Stack horizontal horizontalAlign="end" styles={{ root: { marginLeft: 'auto' } }}>
291306
<IconButton
292307
className={styles.itemButton}
293308
iconProps={{ iconName: 'Delete' }}

src/frontend/src/components/ChatHistory/chatHistoryListItem.test.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,14 @@ describe('ChatHistoryListItemGroups', () => {
7575
});
7676
});
7777

78-
test('renders grouped chat history correctly', () => {
78+
test('renders grouped chat history correctly', async () => {
7979
renderWithContext(<ChatHistoryListItemGroups groupedChatHistory={mockGroupedChatHistory} />)
8080

8181
// Check if group month and titles are rendered
82-
expect(screen.getByText('2024-11')).toBeInTheDocument()
83-
expect(screen.getByText('Chat 1')).toBeInTheDocument()
82+
await waitFor(() => {
83+
expect(screen.getByText('2024-11')).toBeInTheDocument();
84+
expect(screen.getAllByText('Chat 1').length).toBeGreaterThan(1);
85+
});
8486
})
8587

8688
test('displays a spinner when fetching history', async () => {
@@ -162,8 +164,8 @@ describe('ChatHistoryListItemCell', () => {
162164
test('renders the chat history item', () => {
163165
renderWithContext(<ChatHistoryListItemCell item={conversation} onSelect={mockOnSelect} />, mockAppState)
164166

165-
const titleElement = screen.getByText(/Test Chat/i)
166-
expect(titleElement).toBeInTheDocument()
167+
const titleElement = screen.getAllByText(/Test Chat/i)
168+
expect(titleElement.length).toBeGreaterThan(1)
167169
})
168170
// test('calls onSelect when a chat history item is clicked', async () => {
169171
// renderWithContext(<ChatHistoryListItemCell item={conversation} onSelect={mockOnSelect} />, mockAppState)
@@ -192,7 +194,7 @@ describe('ChatHistoryListItemCell', () => {
192194

193195
renderWithContext(<ChatHistoryListItemCell item={conversation} onSelect={mockOnSelect} />, mockAppState);
194196

195-
fireEvent.click(screen.getByText(/Test Chat/i));
197+
fireEvent.click(screen.getAllByText(/Test Chat/i)[0]);
196198

197199
await waitFor(() => {
198200
expect(mockOnSelect).toHaveBeenCalledWith({ ...conversation, messages: mockMessages });
@@ -202,12 +204,12 @@ describe('ChatHistoryListItemCell', () => {
202204
test('truncates long title', () => {
203205
const longTitleConversation = {
204206
...conversation,
205-
title: 'A very long title that should be truncated after 28 characters'
207+
title: 'A very long title that should be truncated after 24 characters'
206208
}
207209

208210
renderWithContext(<ChatHistoryListItemCell item={longTitleConversation} onSelect={mockOnSelect} />, mockAppState)
209211

210-
const truncatedTitle = screen.getByText(/A very long title that shoul .../i)
212+
const truncatedTitle = screen.getByText(/A very long title that s .../i)
211213
expect(truncatedTitle).toBeInTheDocument()
212214
})
213215

src/start.cmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set NODE_OPTIONS=--max_old_space_size=8192
55
echo.
66
echo Restoring backend python packages
77
echo.
8-
call python -m pip install -r src/requirements.txt
8+
call python -m pip install -r requirements.txt
99
if "%errorlevel%" neq "0" (
1010
echo Failed to restore backend python packages
1111
exit /B %errorlevel%
@@ -14,7 +14,7 @@ if "%errorlevel%" neq "0" (
1414
echo.
1515
echo Restoring frontend npm packages
1616
echo.
17-
cd src/frontend
17+
cd frontend
1818
call npm install
1919
if "%errorlevel%" neq "0" (
2020
echo Failed to restore frontend npm packages

0 commit comments

Comments
 (0)