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

Verify that we've navigated to Settings by checking the title. #21245

Merged
merged 7 commits into from
Jul 27, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ exports[`AdvancedSettings should render normally 1`] = `
<EuiText
grow={true}
>
<h1>
<h1
data-test-subj="managementSettingsTitle"
>
Settings
</h1>
</EuiText>
Expand Down Expand Up @@ -253,7 +255,9 @@ exports[`AdvancedSettings should render specific setting if given setting key 1`
<EuiText
grow={true}
>
<h1>
<h1
data-test-subj="managementSettingsTitle"
>
Settings
</h1>
</EuiText>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export class AdvancedSettings extends Component {
<EuiFlexGroup gutterSize="none">
<EuiFlexItem>
<EuiText>
<h1>Settings</h1>
<h1 data-test-subj="managementSettingsTitle">Settings</h1>
</EuiText>
</EuiFlexItem>
<EuiFlexItem>
Expand Down
7 changes: 6 additions & 1 deletion test/functional/page_objects/settings_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* under the License.
*/

import expect from 'expect.js';
import { map as mapAsync } from 'bluebird';

export function SettingsPageProvider({ getService, getPageObjects }) {
Expand Down Expand Up @@ -45,7 +46,11 @@ export function SettingsPageProvider({ getService, getPageObjects }) {

async clickKibanaSettings() {
await this.clickLinkText('Advanced Settings');
await PageObjects.header.waitUntilLoadingHasFinished();
const isSettingsLoaded = await testSubjects.exists('managementSettingsTitle');

// Verify navigation is successful, or else fail the test consuming this.
expect(isSettingsLoaded).to.be(true);
return isSettingsLoaded;
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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!

}

async clickKibanaSavedObjects() {
Expand Down