-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Investigations] - Unskip and refactor discover state tests #173308
[Investigations] - Unskip and refactor discover state tests #173308
Conversation
512e901
to
d258f4f
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.
I left a few comments of extra things to potentially cleanup
createNewTimeline, | ||
createTimelineOptionsPopoverBottomBar, |
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.
this method does not exist in this file
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.
Rebase error, fixing
login(); | ||
visitWithTimeRange(ALERTS_URL); | ||
createTimelineOptionsPopoverBottomBar(); | ||
goToEsqlTab(); |
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.
diving into this function, I think we should remove the should('be.visible')
here (Cypress already checks for visibility)
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.
also I'm wondering if we could remove the about the delay 500
? We're not using that delay in the expandable flyout Cypress tests and I don't remember seeing a test fail because of that
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.
Will remove should('be.visible'), and I figure the delay was put there because of how long it can take for the elements in the timeline tabs to load, but if it is necessary, there are definitely better ways of doing it besides an explicit delay time. Will look into it
describe('save/restore', () => { | ||
beforeEach(() => { | ||
handleIntercepts(); | ||
}); | ||
it('should be able create an empty timeline with default discover state', () => { | ||
addNameToTimelineAndSave('Timerange timeline'); | ||
createNewTimeline(); |
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.
diving into this function, we should be able to remove the should('be.visible')
here (Cypress already checks for visibility)
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.
same thing like 123, looking into the addDiscoverEsqlQuery
function, should('be.visible')
from here
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.
also, line 136, looking into the openTimelineFromSettings
function, I think we should be able to delete this line entirely
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.
let's remove it from here as well, and also the force: true
?
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.
Just gonna remove all of them in the timeline related files
export const confirmLeaveUnsavedTimeline = () => { | ||
cy.get(DELETION_CONFIRMATION).click(); | ||
}; | ||
|
||
export const deleteTimeline = () => { | ||
cy.get(TIMELINE_COLLAPSED_ITEMS_BTN).click(); | ||
cy.get(DELETE_TIMELINE_BTN).click(); | ||
cy.get(DELETION_CONFIRMATION).click(); | ||
}; | ||
|
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.
I'm getting errors where these constants are not defined
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.
Rebase error, will address, thanks!
@@ -212,6 +203,7 @@ describe.skip( | |||
cy.wait(`@${TIMELINE_REQ_WITH_SAVED_SEARCH}`); | |||
openKibanaNavigation(); | |||
navigateFromKibanaCollapsibleTo(STACK_MANAGEMENT_PAGE); | |||
confirmLeaveUnsavedTimeline(); | |||
cy.get(LOADING_INDICATOR).should('not.exist'); | |||
goToSavedObjectSettings(); |
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.
there is a chance we could remove line 11 and 12 of this goToSavedObjectSettings no?
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.
Yep, will do
@@ -212,6 +203,7 @@ describe.skip( | |||
cy.wait(`@${TIMELINE_REQ_WITH_SAVED_SEARCH}`); | |||
openKibanaNavigation(); | |||
navigateFromKibanaCollapsibleTo(STACK_MANAGEMENT_PAGE); | |||
confirmLeaveUnsavedTimeline(); | |||
cy.get(LOADING_INDICATOR).should('not.exist'); | |||
goToSavedObjectSettings(); | |||
cy.get(LOADING_INDICATOR).should('not.exist'); |
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.
should we extract the line below into a task function? (cy.get(SAVED_OBJECTS_TAGS_FILTER).trigger('click');
)
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.
what do you think about removing the nested describes (line 105 describe('save/restore', () => {
and line 194 describe('saved search', () => {
)?
With clear text title I don't think the describe are necessary. They both have the same beforeEach
code so that should work. It would make the file a bit easier to read.
Also I wonder if we could move the const handleIntercepts
method above the top describe.
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.
Yea, will move the handle intercepts up, but I lean leaving the nested describe blocks as while all the beforeEach
logic is the same, the context of what each block is testing is different, but I'll rename them to make them clearer
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.
I'm not a fan of using describe
just to separate tests like this but I'm not totally against it either 😄
If we keep these nested describe
, let's update the test titles to not contains the same string then? We probably don't need the repetition
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.
Yep, I had updated the titles in the last commit :)
bd67a22
to
aee88e1
Compare
- The test title only mentions to check for title changes - Description changes seem to be buggy in general and are not important at this point.
… call is in progress
@kqualters-elastic Could you have a look at e770e35? I noticed that with the original fix, it would still sometimes create two saved searches. |
💛 Build succeeded, but was flaky
Failed CI StepsMetrics [docs]Async chunks
History
To update your PR or re-run it, just comment with: |
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.
just one nit about magic value used
@@ -205,6 +205,10 @@ export const useDiscoverInTimelineActions = ( | |||
} else { | |||
// If no saved search exists. Create a new saved search instance and associate it with the timeline. | |||
try { | |||
// Make sure we're not creating a saved search while a previous creation call is in progress | |||
if (status !== 'idle') { |
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.
isnt there some kind of enum we could use here?
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.
@lgestc status
comes from @tanstack/query-core
and is union of string literals:
export type MutationStatus = 'idle' | 'loading' | 'success' | 'error'
So the type is checked, just not as an enum :)
💔 All backports failed
Manual backportTo create the backport manually run:
Questions ?Please refer to the Backport tool documentation |
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…173308) Dependent on: elastic#173015 - fixes elastic#165663 - fixes elastic#165747 [Flaky Tests (100/100)](https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/4870) --------- Co-authored-by: Jan Monschke <[email protected]> (cherry picked from commit 1172c0e) # Conflicts: # x-pack/test/security_solution_cypress/cypress/tasks/common.ts
…173308) (#174914) # Backport This will backport the following commits from `main` to `8.12`: - [[Investigations] - Unskip and refactor discover state tests (#173308)](#173308) <!--- Backport version: 8.9.8 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Michael Olorunnisola","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-01-16T12:18:26Z","message":"[Investigations] - Unskip and refactor discover state tests (#173308)\n\nDependent on: https://github.com/elastic/kibana/pull/173015\r\n\r\n- fixes https://github.com/elastic/kibana/issues/165663\r\n- fixes https://github.com/elastic/kibana/issues/165747\r\n\r\n[Flaky Tests\r\n(100/100)](https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/4870)\r\n\r\n---------\r\n\r\nCo-authored-by: Jan Monschke <[email protected]>","sha":"1172c0ec09eb72f478b7c0cb7afc6016fabdc400","branchLabelMapping":{"^v8.13.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Threat Hunting:Investigations","v8.12.1","v8.13.0"],"number":173308,"url":"https://github.com/elastic/kibana/pull/173308","mergeCommit":{"message":"[Investigations] - Unskip and refactor discover state tests (#173308)\n\nDependent on: https://github.com/elastic/kibana/pull/173015\r\n\r\n- fixes https://github.com/elastic/kibana/issues/165663\r\n- fixes https://github.com/elastic/kibana/issues/165747\r\n\r\n[Flaky Tests\r\n(100/100)](https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/4870)\r\n\r\n---------\r\n\r\nCo-authored-by: Jan Monschke <[email protected]>","sha":"1172c0ec09eb72f478b7c0cb7afc6016fabdc400"}},"sourceBranch":"main","suggestedTargetBranches":["8.12"],"targetPullRequestStates":[{"branch":"8.12","label":"v8.12.1","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.13.0","labelRegex":"^v8.13.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/173308","number":173308,"mergeCommit":{"message":"[Investigations] - Unskip and refactor discover state tests (#173308)\n\nDependent on: https://github.com/elastic/kibana/pull/173015\r\n\r\n- fixes https://github.com/elastic/kibana/issues/165663\r\n- fixes https://github.com/elastic/kibana/issues/165747\r\n\r\n[Flaky Tests\r\n(100/100)](https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/4870)\r\n\r\n---------\r\n\r\nCo-authored-by: Jan Monschke <[email protected]>","sha":"1172c0ec09eb72f478b7c0cb7afc6016fabdc400"}}]}] BACKPORT--> --------- Co-authored-by: Michael Olorunnisola <[email protected]>
Dependent on: #173015
Flaky Tests (100/100)