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
[Security Solution] Refactor Cypress tests navigation utilities #166201
Conversation
7fe7738
to
5fd6a47
Compare
5fd6a47
to
c3e7dc4
Compare
Pinging @elastic/security-detections-response (Team:Detections and Resp) |
Pinging @elastic/security-solution (Team: SecuritySolution) |
91a3a3b
to
6afa689
Compare
4f58527
to
0468999
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Security changes LGTM. Thanks for the refactor, it looks much better 👏
Files by Code Ownerelastic/security-detection-engine
elastic/security-detection-rule-management
elastic/security-threat-hunting-explore
elastic/security-threat-hunting-investigations
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM for the Threat Hunting Investigations team
69f07df
to
36a45d0
Compare
711fa6f
to
86fd68a
Compare
942a764
to
59662ea
Compare
💔 Build FailedFailed CI StepsTest Failures
Metrics [docs]
History
To update your PR or re-run it, just comment with: cc @maximpn |
…tic#166201) **Relates to:** elastic#153645 ## Summary This PR makes refactoring of navigation utilities and constants to make it transparent and be able to specify correct ownership later on. ## Motivation Engineers need to add new tests and maintain the older ones. Base building blocks of this are constants and utility functions in particular URL constants and `visit()` and `visitWithoutDataRange()` functions. It turned out a simple `visit()` helper function also passes `timerange` as a query param while only some tests need it. Having it as a base utility function (as the name suggests) it also gets used in the new code while `visitWithoutDateRange()` should be preferred. On top of that URL constants are combined in one file without clear ownership and contain a mix of legacy and new urls with some parts looking outdated as navigating to the url causes redirecting to a specific page. Having only relevant URL constants in a common file will help to reduce confusion. As the next step constants should be split into files/folders with clear ownership. Also having `visit()` adding no extra params (besides common for ALL the tests) will make the intention clear. Whenever a time range is needed `visitWithTimeRange()` can be used (ideally accepting a time range defined in a test). And the same stays true for any other pages, e.g. rule details page can have a utility `visitRuleDetailsPage(id: string)` containing some general waiting logic so the following actions operate on a loaded page. ## Details As a step towards clearness and transparent ownership this PR performs refactoring of `x-pack/test/security_solution_cypress/cypress/urls/navigation.ts` and `x-pack/test/security_solution_cypress/cypress/tasks/login.ts` files. The following has been done - all url constants in `x-pack/test/security_solution_cypress/cypress/urls/navigation.ts` were checked and updated to remove duplications, avoid redirections and grouped - legacy urls were moved to the only one test using them to test compatibility (`x-pack/test/security_solution_cypress/cypress/e2e/urls/compatibility.cy.ts`) - `visit()` was renamed to `visitWithTimeRange()` - `visitWithoutDateRange()` was renamed to `visit()` - `visit()` was refactored to accept a query string ## Next steps It's expected teams decompose `x-pack/test/security_solution_cypress/cypress/urls/navigation.ts` into feature specific file(s)/folder(s) with assigned owners. There is no 100% chance a generic wait for a page to be loaded helper function meet requirements for each page. It makes sense to consider adding per feature `visitFeatureAPage()` helper function containing assertions for the page to be loaded. `visitRuleDetailsPage(id: string)` was added for this purpose while waiting for page to be loaded functionality is omitted in this PR to reduce a number of changes.
Relates to: #153645
Summary
This PR makes refactoring of navigation utilities and constants to make it transparent and be able to specify correct ownership later on.
Motivation
Engineers need to add new tests and maintain the older ones. Base building blocks of this are constants and utility functions in particular URL constants and
visit()
andvisitWithoutDataRange()
functions. It turned out a simplevisit()
helper function also passestimerange
as a query param while only some tests need it. Having it as a base utility function (as the name suggests) it also gets used in the new code whilevisitWithoutDateRange()
should be preferred. On top of that URL constants are combined in one file without clear ownership and contain a mix of legacy and new urls with some parts looking outdated as navigating to the url causes redirecting to a specific page.Having only relevant URL constants in a common file will help to reduce confusion. As the next step constants should be split into files/folders with clear ownership.
Also having
visit()
adding no extra params (besides common for ALL the tests) will make the intention clear. Whenever a time range is neededvisitWithTimeRange()
can be used (ideally accepting a time range defined in a test). And the same stays true for any other pages, e.g. rule details page can have a utilityvisitRuleDetailsPage(id: string)
containing some general waiting logic so the following actions operate on a loaded page.Details
As a step towards clearness and transparent ownership this PR performs refactoring of
x-pack/test/security_solution_cypress/cypress/urls/navigation.ts
andx-pack/test/security_solution_cypress/cypress/tasks/login.ts
files. The following has been donex-pack/test/security_solution_cypress/cypress/urls/navigation.ts
were checked and updated to remove duplications, avoid redirections and groupedx-pack/test/security_solution_cypress/cypress/e2e/urls/compatibility.cy.ts
)visit()
was renamed tovisitWithTimeRange()
visitWithoutDateRange()
was renamed tovisit()
visit()
was refactored to accept a query stringNext steps
It's expected teams decompose
x-pack/test/security_solution_cypress/cypress/urls/navigation.ts
into feature specific file(s)/folder(s) with assigned owners.There is no 100% chance a generic wait for a page to be loaded helper function meet requirements for each page. It makes sense to consider adding per feature
visitFeatureAPage()
helper function containing assertions for the page to be loaded.visitRuleDetailsPage(id: string)
was added for this purpose while waiting for page to be loaded functionality is omitted in this PR to reduce a number of changes.