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

Add unit test for useFetchAgentFrameworkTraces Hook #77

Merged
merged 3 commits into from
Dec 18, 2023

Conversation

Hailong-am
Copy link
Collaborator

Description

Add unit test for useFetchAgentFrameworkTraces

Issues Resolved

[List any issues this PR will resolve]

Check List

  • New functionality includes testing.
    • All tests pass, including unit test, integration test and doctest
  • New functionality has been documented.
    • New functionality has javadoc added
    • New functionality has user manual doc added
  • Commits are signed per the DCO using --signoff

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.

@Hailong-am Hailong-am changed the title Add unit test for useFetchAgentFrameworkTraces Add unit test for useFetchAgentFrameworkTraces Hook Dec 15, 2023
Copy link

codecov bot commented Dec 15, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (dd0c13e) 75.39% compared to head (79af35d) 83.52%.
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #77      +/-   ##
==========================================
+ Coverage   75.39%   83.52%   +8.13%     
==========================================
  Files          43       43              
  Lines        1024     1026       +2     
  Branches      238      239       +1     
==========================================
+ Hits          772      857      +85     
+ Misses        251      168      -83     
  Partials        1        1              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -33,7 +33,7 @@ export const useFetchAgentFrameworkTraces = (traceId: string) => {
.catch((error) => dispatch({ type: 'failure', error }));

return () => abortController.abort();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we add one test case for assert this abort method has been called after unmount.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, case added.

Signed-off-by: Hailong Cui <ihailong@amazon.com>
Signed-off-by: Hailong Cui <ihailong@amazon.com>
})
);

waitFor(() => {
Copy link
Member

@ruanyl ruanyl Dec 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line seems problematic, if I put await waitFor, the test will failed, and also I see a console error on this test

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a condition check for unmount to remediate console log error about [Can't perform a React state update on an unmounted component]

.catch((error) => {
  if (error.name === 'AbortError') return;
    dispatch({ type: 'failure', error });
  });

Signed-off-by: Hailong Cui <ihailong@amazon.com>
@Hailong-am Hailong-am merged commit 66292ce into opensearch-project:main Dec 18, 2023
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants