-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shows the assistant name in the window instead of the assistant id #85
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall LGTM! But could you please add tests? Similar to frontend/tests/useAssistantList.test.ts
. Please make a new file.
Sure, yeah! |
it("should fetch assistant and update state correctly", async () => { | ||
const mockAssistants = [ | ||
{ id: 'weather_assistant', name: "Assistant 1" }, | ||
{ id: 'movies_assistant', name: "Assistant 2" }, | ||
]; | ||
(djangoAiAssistantViewsGetAssistant as jest.Mock).mockResolvedValue( | ||
mockAssistants | ||
); | ||
|
||
const { result } = renderHook(() => useAssistant({ assistantId: 'weather_assistant' })); | ||
|
||
expect(result.current.assistant).toBeNull(); | ||
expect(result.current.loadingFetchAssistant).toBe(false); | ||
|
||
await act(async () => { | ||
await result.current.fetchAssistant(); | ||
}); | ||
|
||
expect(result.current.assistant).toEqual(mockAssistants); | ||
expect(result.current.loadingFetchAssistant).toBe(false); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should return a single assistant rather than a list, right?
it("should fetch assistant and update state correctly", async () => { | |
const mockAssistants = [ | |
{ id: 'weather_assistant', name: "Assistant 1" }, | |
{ id: 'movies_assistant', name: "Assistant 2" }, | |
]; | |
(djangoAiAssistantViewsGetAssistant as jest.Mock).mockResolvedValue( | |
mockAssistants | |
); | |
const { result } = renderHook(() => useAssistant({ assistantId: 'weather_assistant' })); | |
expect(result.current.assistant).toBeNull(); | |
expect(result.current.loadingFetchAssistant).toBe(false); | |
await act(async () => { | |
await result.current.fetchAssistant(); | |
}); | |
expect(result.current.assistant).toEqual(mockAssistants); | |
expect(result.current.loadingFetchAssistant).toBe(false); | |
}); | |
it("should fetch assistant and update state correctly", async () => { | |
const mockAssistant = { id: 'weather_assistant', name: "Assistant 1" }; | |
(djangoAiAssistantViewsGetAssistant as jest.Mock).mockResolvedValue( | |
mockAssistant | |
); | |
const { result } = renderHook(() => useAssistant({ assistantId: 'weather_assistant' })); | |
expect(result.current.assistant).toBeNull(); | |
expect(result.current.loadingFetchAssistant).toBe(false); | |
await act(async () => { | |
await result.current.fetchAssistant(); | |
}); | |
expect(result.current.assistant).toEqual(mockAssistant); | |
expect(result.current.loadingFetchAssistant).toBe(false); | |
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, you're right. Adjusting this.
Closes: #78
Examples: