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

[SecuritySolution] Unskip fields browser timeline tests #174597

Conversation

janmonschke
Copy link
Contributor

@janmonschke janmonschke commented Jan 10, 2024

Summary

Unskips the fields browser tests.

The fields browser tests have been skipped because of issues during the population of the timeline (as described in #169363, #169271, #169197). As investigated in previous PRs (e.g. #174593) that flakiness has been removed in #173413 so it is safe to unskip the tests now.

In addition to that, unnecessary timeline population was removed, force clicks/checks/unchecks cleaned up. Also, parts of the acceptance test have been moved to the unit test.

Flaky test runner (200/200)

fixes #169197
fixes #169271
fixes #169363

@janmonschke janmonschke added release_note:skip Skip the PR/issue when compiling release notes Team:Threat Hunting:Investigations Security Solution Investigations Team labels Jan 10, 2024
@janmonschke janmonschke self-assigned this Jan 10, 2024
@janmonschke janmonschke marked this pull request as ready for review January 10, 2024 17:30
@janmonschke janmonschke requested review from a team as code owners January 10, 2024 17:30
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-threat-hunting-investigations (Team:Threat Hunting:Investigations)

@janmonschke janmonschke added the Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) label Jan 10, 2024
@elasticmachine
Copy link
Contributor

Pinging @elastic/response-ops (Team:ResponseOps)

@janmonschke
Copy link
Contributor Author

/ci

Copy link
Contributor

@PhilippeOberti PhilippeOberti left a comment

Choose a reason for hiding this comment

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

left a few comments on some cleanup and potential merge of tests to reduce run time :)

@@ -369,7 +369,7 @@ export const markAsFavorite = () => {
};

export const openTimelineFieldsBrowser = () => {
cy.get(TIMELINE_FIELDS_BUTTON).first().click({ force: true });
cy.get(TIMELINE_FIELDS_BUTTON).first().click();
Copy link
Contributor

Choose a reason for hiding this comment

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

I just want to note that the first() here is pretty dangerous/brittle. I was trying to remove it and realized that we have 3 instances of the FieldBrowserComponent which contains the EuiButtonEmpty that has the data-test-subj="show-field-browser" property.
It happens that in the DOM the first one is the one that we mostly want, but that could change.

I don't think this PR is the right place to do it, so this is just a note, but we should at some point modify the FieldBrowserComponent to take the `data-test-subj- as a prop so we can guarantee the uniqueness.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, first() often is a source of flakiness/trouble in the future. I wouldn't want to touch it in this PR. Also, it seems like the component is owned by ResponseOps and not us...

it('displays "view all" option by default', () => {
cy.get(FIELDS_BROWSER_VIEW_BUTTON).should('contain.text', 'View: all');
});

it('displays the expected count of categories that match the filter input', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

what do you think about merging some of the tests below?

I can see the first (displays the expected count of categories that match the filter input) and second (displays a search results label with the expected count of fields matching the filter input) together. They have the same input and only check a small UI element each...

I can also see the last 3 (or 2) in this describe merged together, under a title that would say something like should correctly create and search category or something more descriptive. A few cy.log in the test would clarify what exactly happens in each step.

The whole test suite would run much faster

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, nice catch. I'll merge them.

beforeEach(() => {
login();
visitWithTimeRange(hostsUrl('allHosts'));
openTimelineUsingToggle();
populateTimeline();
openTimelineFieldsBrowser();
});

Copy link
Contributor

Choose a reason for hiding this comment

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

same comment here, I feel like the first 3 tests could easily be merged into a single one that would test add, remove and reset fields.

Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

actually even the fourth one (restores focus to the Customize Columns button when Reset Fields is clicked) can easily be merged with the other 3. Just check the focus after you've reset. It would just be a this single line added at the end

cy.get(TIMELINE_FIELDS_BUTTON).should('have.focus');

It doesn't really make sense to have a whole test that verifies just that

@janmonschke
Copy link
Contributor Author

@PhilippeOberti Thanks for looking into how to simplify these tests. I consolidated a bunch of them into combined tests now. However, I didn't merge them all as that would have created super long tests that, even with cy.log, would become quite hard to follow. In total we're now down to 5 tests. This is considerably less than before. Let me know if you think we should consolidate them further.

Copy link
Contributor

@PhilippeOberti PhilippeOberti left a comment

Choose a reason for hiding this comment

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

looks super clean, thank you!!

@PhilippeOberti
Copy link
Contributor

@PhilippeOberti Thanks for looking into how to simplify these tests. I consolidated a bunch of them into combined tests now. However, I didn't merge them all as that would have created super long tests that, even with cy.log, would become quite hard to follow. In total we're now down to 5 tests. This is considerably less than before. Let me know if you think we should consolidate them further.

it looks awesome. I took the liberty to push a commit that just changes the name of 2 tests to use should a the beginning

@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

✅ unchanged

History

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

cc @janmonschke

@PhilippeOberti PhilippeOberti merged commit a8d3173 into elastic:main Jan 12, 2024
38 checks passed
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Jan 12, 2024
semd pushed a commit to semd/kibana that referenced this pull request Jan 12, 2024
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:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) Team:Threat Hunting:Investigations Security Solution Investigations Team v8.13.0
Projects
None yet
6 participants