-
Notifications
You must be signed in to change notification settings - Fork 23
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
add unit tests for chat window header #63
add unit tests for chat window header #63
Conversation
Signed-off-by: Lin Wang <wonglam@amazon.com>
Signed-off-by: Lin Wang <wonglam@amazon.com>
Signed-off-by: Lin Wang <wonglam@amazon.com>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## feature/agent-framework #63 +/- ##
============================================================
+ Coverage 48.75% 60.69% +11.93%
============================================================
Files 46 46
Lines 1087 1089 +2
Branches 250 252 +2
============================================================
+ Hits 530 661 +131
+ Misses 548 419 -129
Partials 9 9 ☔ View full report in Codecov by Sentry. |
setSelectedTabId: jest.fn(), | ||
setFlyoutComponent: jest.fn(), | ||
}; | ||
jest.spyOn(chatContextExports, 'useChatContext').mockReturnValue(useChatContextMock); |
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.
I am thinking if we should add two files: chat_context.mock.ts and use_chat_state.mock.ts, in which we can mock the output and export the mocked methods. I've seen over 3 PRs have this spyOn function to hijack useChatContext.
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.
I think we can provide a general mocks for chat_context
and use_chat_state
. But we may still need to customized the mock in some specific PRs. Can be refactor in the next PRs.
expect(queryByText('Experimental')).not.toBeInTheDocument(); | ||
fireEvent.click(getByRole('button')); | ||
expect(getByText('Experimental')).toBeInTheDocument(); | ||
}); |
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.
not sure snapshot match assertion is needed here, we could have one.
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.
I think snapshot match would be too heavy. Match Experimental
title is enough here.
|
||
await waitFor(() => { | ||
expect(renderResult.queryByText('OpenSearch Assistant')).not.toBeInTheDocument(); | ||
}); |
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.
test seems not match the description should show "OpenSearch Assistant" when sessionId is not defined
@@ -3,7 +3,7 @@ | |||
* SPDX-License-Identifier: Apache-2.0 | |||
*/ | |||
|
|||
import React, { useState } from 'react'; | |||
import React, { useEffect, useState } from 'react'; |
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.
useEffect
seems not used in this file
Signed-off-by: Lin Wang <wonglam@amazon.com>
540bdb7
into
opensearch-project:feature/agent-framework
* test: add unit tests for chat window header Signed-off-by: Lin Wang <wonglam@amazon.com> * test: add ut for chat window header title Signed-off-by: Lin Wang <wonglam@amazon.com> * test: add unit tests for chat experimental badge Signed-off-by: Lin Wang <wonglam@amazon.com> * Address PR comments Signed-off-by: Lin Wang <wonglam@amazon.com> --------- Signed-off-by: Lin Wang <wonglam@amazon.com>
Description
Add unit tests for chat window header
Issues Resolved
List any issues this PR will resolve, e.g. Closes [...].
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.