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

Unit Tests for new o11y rules page #128576

Merged
merged 23 commits into from
Apr 20, 2022
Merged

Unit Tests for new o11y rules page #128576

merged 23 commits into from
Apr 20, 2022

Conversation

mgiota
Copy link
Contributor

@mgiota mgiota commented Mar 28, 2022

Fixes #127440

Covers following basic scenarios:

  • empty RulesPage
  • empty RulesPage with show only capability
  • RulesPage with items
  • RulesPage with items and show only capability

Note: These tests are a starting point and can be extended to cover more scenarios

@mgiota mgiota changed the title Tests Unit Tests for new o11y rules page Apr 7, 2022
@mgiota
Copy link
Contributor Author

mgiota commented Apr 12, 2022

@elasticmachine merge upstream

@mgiota mgiota marked this pull request as ready for review April 14, 2022 05:18
@mgiota mgiota requested a review from a team as a code owner April 14, 2022 05:18
@mgiota mgiota self-assigned this Apr 14, 2022
@mgiota mgiota added Team: Actionable Observability - DEPRECATED For Observability Alerting and SLOs use "Team:obs-ux-management", for AIops "Team:obs-knowledge" release_note:skip Skip the PR/issue when compiling release notes labels Apr 14, 2022
@mgiota
Copy link
Contributor Author

mgiota commented Apr 14, 2022

@elasticmachine merge upstream

@mgiota mgiota added the auto-backport Deprecated - use backport:version if exact versions are needed label Apr 14, 2022
Copy link
Contributor

@fkanout fkanout left a comment

Choose a reason for hiding this comment

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

A good tests suite!
There is one question, and need to add mention types to better get the context.

describe('empty RulesPage with show only capability', () => {
let wrapper: ReactWrapper<any>;
async function setup() {
const rulesState = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

describe('empty RulesPage', () => {
let wrapper: ReactWrapper<any>;
async function setup() {
const rulesState = {
Copy link
Contributor

Choose a reason for hiding this comment

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

},
];

const rulesState = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

await nextTick();
wrapper.update();
});
expect(wrapper.find(RulesTable)).toHaveLength(0);
Copy link
Contributor

Choose a reason for hiding this comment

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

What does toHaveLength(0) mean for the Rules Table? it seems to be checking of existence why not use .exists() for example?

Don't we need a kind of selector to do so?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@fkanout I can do expect(wrapper.find(RulesTable).exists()).toBe(false);

@mgiota
Copy link
Contributor Author

mgiota commented Apr 20, 2022

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

merge conflict between base and head

@mgiota mgiota requested a review from fkanout April 20, 2022 08:46
@mgiota mgiota enabled auto-merge (squash) April 20, 2022 08:47
@mgiota mgiota merged commit 9d6aa99 into elastic:main Apr 20, 2022
@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
observability 427.3KB 427.4KB +75.0B

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @mgiota

@kibanamachine
Copy link
Contributor

💔 All backports failed

Status Branch Result
8.2 Backport failed because of merge conflicts

Manual backport

To create the backport manually run:

node scripts/backport --pr 128576

Questions ?

Please refer to the Backport tool documentation

@mgiota mgiota removed auto-backport Deprecated - use backport:version if exact versions are needed v8.2.0 labels Apr 20, 2022
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Apr 20, 2022
kertal pushed a commit to kertal/kibana that referenced this pull request May 24, 2022
* tests for rules page

* mock useKibana and useBreadcrubms

* mock useFetchRules

* rules page scenarios

* temp

* mock usePluginContext and useLoadRuleTypes

* fix typescript errors

* fix Jest did not exit one second after the test run has completed warning

* add more tests to the empty rules page scenario

* fix typescript error

* render documentation link

* empty RulesPage with show only capability

* rules page with items

* RulesPage with items and show only capability

* remove disabled items (I need to implement it later on)

* refactoring

* update documentation link

* add types to the ruleState

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team: Actionable Observability - DEPRECATED For Observability Alerting and SLOs use "Team:obs-ux-management", for AIops "Team:obs-knowledge" v8.3.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add unit tests for new o11y Rule page
4 participants