-
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
Verify that we've navigated to Settings by checking the title. #21245
Verify that we've navigated to Settings by checking the title. #21245
Conversation
CC @elastic/kibana-qa |
This looks like it is related to #19743, but doesn't directly address it based on the discussion. |
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.
Code LGTM
💔 Build Failed |
💚 Build Succeeded |
Retest |
💚 Build Succeeded |
Retest |
💚 Build Succeeded |
Retest |
💚 Build Succeeded |
Retest |
💚 Build Succeeded |
Retest |
💚 Build Succeeded |
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 - I didn't test this but Jenkins has multiple times and it looks like a pretty obvious improvement.
The built-in find timeout should wait a few seconds for the managementSettingsTitle to exist which should prevent errors if the next action tried to do something on that page. And if it fails, it will narrow down where the problem was sooner than without it.
@@ -45,7 +45,7 @@ export function SettingsPageProvider({ getService, getPageObjects }) { | |||
|
|||
async clickKibanaSettings() { | |||
await this.clickLinkText('Advanced Settings'); | |||
await PageObjects.header.waitUntilLoadingHasFinished(); | |||
await testSubjects.exists('managementSettingsTitle'); |
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 think there is some confusion about what this function does. It returns true or false, it doesn't assert that that does indeed exist. I think the default time is like 1 second, so this is the equivalent of adding a 1 second sleep. :) If you want to assert that it does exist, use find instead, as that will retry for something like 60 seconds, and fail if it is never found.
The function should probably be renamed getExists
instead of exists
to eliminate that confusion.
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.
Good catch. It does return true or false. And it has a 1 second timeout, but I don't think that means it's like a 1 second sleep. If it does find it it will return as quickly as it can. If it doesn't find it within 1 second it will return false.
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.
Well, in the latter case, if it doesn't find it, it's like adding a 1 second sleep. In the former case, it's like adding a variable sleep, up to 1 seconds, possibly quicker. I'm wondering if that's why the tests appear more stable.
|
||
// Verify navigation is successful, or else fail the test consuming this. | ||
expect(isSettingsLoaded).to.be(true); | ||
return isSettingsLoaded; |
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.
Why return the value here? Looks like it's not used anywhere, and the name of the function doesn't really indicate it.
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.
An async
method expects a promise as a return value or if a promise isn't returned then it wraps the return value in Promise.resolve
. I don't really know whether that means it's OK to return undefined or not, but resolving undefined feels unexpected to me. I don't have a strong feeling on this so if you feel like something else would make more sense, I'll roll with 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.
Resolve to undefined makes more sense to me then resolving to true, as it would take looking into the function to understand what the value of true indicated. It doesn't even really mean anything because it always returns true, or fails. When I think of a function resolving to true
, I think it can also resolve to false
. Not that the option is resolve(true)
or reject()
. Anyway, most clickX
functions don't return anything, so for the sake of consistency, I think we should follow suit.
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.
Works for me, I'll change it. Thanks!
@stacey-gammon Done. |
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.
reviewed code, will leave the testing up to ci. :)
@LeeDr @stacey-gammon I added a |
@@ -37,6 +38,14 @@ export function TestSubjectsProvider({ getService }) { | |||
return await find.existsByDisplayedByCssSelector(testSubjSelector(selector), timeout); | |||
} | |||
|
|||
async existOrFail(selector, timeout = 1000) { | |||
log.debug(`TestSubjects.existOrFail(${selector})`); | |||
const doesExist = await find.existsByDisplayedByCssSelector(testSubjSelector(selector), timeout); |
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.
why not just do const doesExist = await this.exists(selector, timeout);
?
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.
Good point, fixed!
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!
async existOrFail(selector, timeout = 1000) { | ||
log.debug(`TestSubjects.existOrFail(${selector})`); | ||
const doesExist = await this.exists(selector, timeout); | ||
// Verify element exists, or else fail the test consuming this. |
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.
nit: comment seems unnecessary. But up to you!
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 normally would agree with you but I think the intention behind most of this test code becomes easily obscured so I've been erring on the side of caution with my comments.
@@ -53,6 +53,6 @@ export default function ({ getService, loadTestFile }) { | |||
loadTestFile(require.resolve('./_histogram_request_start')); | |||
loadTestFile(require.resolve('./_vega_chart')); | |||
loadTestFile(require.resolve('./_lab_mode')); | |||
loadTestFile(require.resolve('./_linked_saved_searches.js')); | |||
// loadTestFile(require.resolve('./_linked_saved_searches.js')); |
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.
Oh don't forget to uncomment this
@@ -37,6 +38,13 @@ export function TestSubjectsProvider({ getService }) { | |||
return await find.existsByDisplayedByCssSelector(testSubjSelector(selector), timeout); | |||
} | |||
|
|||
async existOrFail(selector, timeout = 1000) { |
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 kind of like the name expectExists
. But up to you.
💔 Build Failed |
💚 Build Succeeded |
Retest |
💚 Build Succeeded |
Retest |
💔 Build Failed |
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 - I ran the lab mode test in a loop and had failures but they had a different cause and tracked in a diff PR.
Just got some unrelated failures. I believe these are the same ones @LeeDr saw.
|
Retest |
💚 Build Succeeded |
Retest |
💚 Build Succeeded |
…ic#21245) * Fail the consuming test if navigation to settings is unsuccessful. * Add testSubjects.existOrFail helper.
… (#21321) * Fail the consuming test if navigation to settings is unsuccessful. * Add testSubjects.existOrFail helper.
Addresses flaky
afterAll
:We should make this the canonical way of verifying navigation. Users look for titles to verify their location, and so should our functional tests.