Skip to content
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

Merged
merged 3 commits into from
Jun 17, 2024

Conversation

amandasavluchinske
Copy link
Contributor

Closes: #78

Examples:
image
image

Base automatically changed from fix/rename-hooks to main June 17, 2024 14:20
Copy link
Member

@fjsj fjsj left a 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.

@amandasavluchinske
Copy link
Contributor Author

Sure, yeah!

@amandasavluchinske amandasavluchinske requested a review from fjsj June 17, 2024 14:45
@amandasavluchinske amandasavluchinske merged commit e7c1061 into main Jun 17, 2024
6 checks passed
@amandasavluchinske amandasavluchinske deleted the feat/show-assistant-name-in-window branch June 17, 2024 14:55
Comment on lines +24 to +44
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);
});
Copy link
Collaborator

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?

Suggested change
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);
});

Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Show assistant true name in frontend
3 participants