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

[OSCI][ADD] More tests for overview #5418

Merged

Conversation

thanhinhchtom
Copy link
Contributor

Description

Add some tests for other complications of overview part

Issues Resolved

fixes #4693

Screenshot

image

Testing the changes

  1. Run command yarn test:jest src/plugins/opensearch_dashboards_overview/public/components/overview/overview.test.tsx

Check List

  • All tests pass
    • yarn test:jest
    • yarn test:jest_integration
  • New functionality includes testing.
  • New functionality has been documented.
  • Update CHANGELOG.md
  • Commits are signed per the DCO using --signoff

Copy link

codecov bot commented Nov 7, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (5fabb73) 66.97% compared to head (70dde91) 55.68%.
Report is 3 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #5418       +/-   ##
===========================================
- Coverage   66.97%   55.68%   -11.30%     
===========================================
  Files        3293     3005      -288     
  Lines       63289    59323     -3966     
  Branches    10065     9453      -612     
===========================================
- Hits        42390    33032     -9358     
- Misses      18458    24235     +5777     
+ Partials     2441     2056      -385     
Flag Coverage Δ
Linux_1 ?
Linux_2 ?
Linux_3 ?
Linux_4 ?
Windows_1 35.27% <ø> (ø)
Windows_2 ?
Windows_3 43.80% <ø> (ø)
Windows_4 35.34% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

Copy link
Contributor

@CMDWillYang CMDWillYang left a comment

Choose a reason for hiding this comment

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

LGTM!

joshuarrrr
joshuarrrr previously approved these changes Nov 13, 2023
Copy link
Member

@joshuarrrr joshuarrrr left a comment

Choose a reason for hiding this comment

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

@thanhinhchtom Thanks for adding these test cases to increase our coverage in this plugin - it's certainly better to have snapshot tests rather than no tests at all. But in a follow-up issue/PR, I think we can continue to improve these tests by actually validating/asserting the intended behavior instead of just capturing snapshots.

While snapshot tests are by far the easiest to write, they have a couple disadvantages compared to making more specific assertions:

  1. They're brittle, because they often capture the specific implementation of the component, not just its business logic. That means that almost any change to the component code will generate a snapshot diff, which then has to be analyzed by the contributor and reviewers manually to verify that all the changes are intended/desired.
  2. They don't tell you what the desired/important behavior is - in fact, they don't even guarantee that the current implementation works as intended.

newsFetchResult: null,
};
const component = shallowWithIntl(<Overview {...props} />);
expect(component).toMatchSnapshot();
Copy link
Member

Choose a reason for hiding this comment

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

If we were to re-write as a unit test, we'd want to assert that:

  1. The <NewsFeed> component is not rendered
  2. The .osdOverviewMore section is rendered (solutions)
  3. The .osdOverviewData section is not rendered (solutions)

Copy link
Member

Choose a reason for hiding this comment

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

Is it worth repurposing this to ensure that newsfeed is not returned? or just delete in the same line as the tutorials.

I think originally we left it in because we could have re-used it. But now it just feels like bloat.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@joshuarrrr So should I rewrite those tests to finish this issue or this one will be merged as it is now and I will create a new one and fix it later

Copy link
Member

Choose a reason for hiding this comment

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

@thanhinhchtom From my perspective, this is an iterative improvement, and I'd be in favor of merging as-is with the follow-up improvements tracked in a separate issue (and subsequent PR). But other maintainers may have other perspectives.

@ananzh ananzh merged commit 9ba5cf5 into opensearch-project:main Dec 13, 2023
79 of 80 checks passed
@opensearch-trigger-bot
Copy link
Contributor

The backport to 1.3 failed:

The process '/usr/bin/git' failed with exit code 128

To backport manually, run these commands in your terminal:

# Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/OpenSearch-Dashboards/backport-1.3 1.3
# Navigate to the new working tree
pushd ../.worktrees/OpenSearch-Dashboards/backport-1.3
# Create a new branch
git switch --create backport/backport-5418-to-1.3
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 9ba5cf54576724f48afde224c90d83ba504608ea
# Push it to GitHub
git push --set-upstream origin backport/backport-5418-to-1.3
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/OpenSearch-Dashboards/backport-1.3

Then, create a pull request where the base branch is 1.3 and the compare/head branch is backport/backport-5418-to-1.3.

@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.x failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/OpenSearch-Dashboards/backport-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/OpenSearch-Dashboards/backport-2.x
# Create a new branch
git switch --create backport/backport-5418-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 9ba5cf54576724f48afde224c90d83ba504608ea
# Push it to GitHub
git push --set-upstream origin backport/backport-5418-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/OpenSearch-Dashboards/backport-2.x

Then, create a pull request where the base branch is 2.x and the compare/head branch is backport/backport-5418-to-2.x.

manasvinibs pushed a commit to manasvinibs/OpenSearch-Dashboards that referenced this pull request Jan 31, 2024
* add more tests for overview
* add more tests for overview
* add to CHANGELOG
* change log

---------

Signed-off-by: Thanh Le <[email protected]>
Signed-off-by: Josh Romero <[email protected]>
Co-authored-by: Josh Romero <[email protected]>
(cherry picked from commit 9ba5cf5)
manasvinibs pushed a commit to manasvinibs/OpenSearch-Dashboards that referenced this pull request Jan 31, 2024
* add more tests for overview
* add more tests for overview
* add to CHANGELOG
* change log

---------

Signed-off-by: Thanh Le <[email protected]>
Signed-off-by: Josh Romero <[email protected]>
Co-authored-by: Josh Romero <[email protected]>
(cherry picked from commit 9ba5cf5)
@manasvinibs
Copy link
Member

Manual backport for 2.x - #5769

ashwin-pc pushed a commit that referenced this pull request Feb 5, 2024
* add more tests for overview
* add more tests for overview
* add to CHANGELOG
* change log

---------

Signed-off-by: Thanh Le <[email protected]>
Signed-off-by: Josh Romero <[email protected]>
Co-authored-by: Josh Romero <[email protected]>
(cherry picked from commit 9ba5cf5)

Co-authored-by: Thanh Le <[email protected]>
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.

Overview units tests are insufficient
7 participants