Skip to content

[Actionable observability] Add tests for alert search bar #145259

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

Merged

Conversation

maryam-saeidi
Copy link
Member

Closes #143641

Summary

As a follow-up to this PR #145067, in this PR I've added tests to make sure the same issue will not happen in the future.

Checklist

@maryam-saeidi maryam-saeidi added chore 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" labels Nov 15, 2022
@maryam-saeidi maryam-saeidi requested a review from a team as a code owner November 15, 2022 15:17
@maryam-saeidi maryam-saeidi self-assigned this Nov 15, 2022
@elasticmachine
Copy link
Contributor

Pinging @elastic/actionable-observability (Team: Actionable Observability)

@@ -85,6 +85,13 @@ export default ({ getService }: FtrProviderContext) => {
await testSubjects.existOrFail('autocompleteSuggestion-field-kibana.alert.status-');
});

it('Invalid input should not break the page', async () => {
Copy link
Member Author

Choose a reason for hiding this comment

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

💬 This is the main test related to the bug. When testing locally, by disabling my fix, this test was failing.

Copy link
Contributor

@kdelemme kdelemme left a comment

Choose a reason for hiding this comment

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

Nice tests 👍🏻 !

I wonder if there is an easy way to test the fix without doing a functional test, but instantiating the component with a badly formatted query, and asserting on the toasts.addError being called or something. I'm not suggesting to write such test, I'm just thinking out loud :) The functional test works fine 👍🏻
Good job 👏🏻

@maryam-saeidi
Copy link
Member Author

maryam-saeidi commented Nov 16, 2022

I wonder if there is an easy way to test the fix without doing a functional test, but instantiating the component with a badly formatted query, and asserting on the toasts.addError being called or something.

I wanted to do the same and because of that I have started with unit tests in this PR 🙂 But since I mocked the whole SearchBar from TriggersActionsUI, I wasn't able to select the input and fill it with invalid input. If you have other suggestions, I will be happy to improve this part in a future PR.

Btw, for the bugs that make the page blank, I think a functional test is more suitable because in unit tests, we mock a lot of things and the test is more about what we think fixes the issue rather than testing what user will see on the page.

@@ -21,10 +21,10 @@ interface AlertSearchBarContainerState {
}

interface AlertSearchBarStateTransitions {
setRangeFrom: (rangeFrom: string) => AlertSearchBarContainerState;
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting that this made it in in the first place

Copy link
Contributor

@CoenWarmer CoenWarmer left a comment

Choose a reason for hiding this comment

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

LGTM!

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Unknown metric groups

ESLint disabled in files

id before after diff
osquery 1 2 +1

ESLint disabled line counts

id before after diff
enterpriseSearch 19 21 +2
fleet 59 65 +6
osquery 108 113 +5
securitySolution 441 447 +6
total +19

Total ESLint disabled count

id before after diff
enterpriseSearch 20 22 +2
fleet 67 73 +6
osquery 109 115 +6
securitySolution 518 524 +6
total +20

History

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

cc @maryam-saeidi

@maryam-saeidi maryam-saeidi merged commit 1566897 into elastic:main Nov 16, 2022
@kibanamachine kibanamachine added v8.6.0 backport:skip This commit does not require backporting labels Nov 16, 2022
@maryam-saeidi maryam-saeidi deleted the 143641-fix-alert-search-bar-tests branch December 19, 2022 10:29
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 chore 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.6.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Actionable observability] Alerts page - Fix page goes blank with invalid query input
6 participants