Skip to content

Commit

Permalink
[tests/functional] automatically opt-out of getting started page on n…
Browse files Browse the repository at this point in the history
…avigation
  • Loading branch information
spalger committed May 17, 2017
1 parent e7d5fc7 commit 9b4e19b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="kuiViewContent gettingStartedContent">
<div class="kuiViewContent gettingStartedContent" data-test-subj="gettingStartedContainer">

<div
ng-if="!gettingStarted.hasOptedOut()"
Expand Down
2 changes: 0 additions & 2 deletions test/functional/apps/console/_console.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ export default function ({ getService, getPageObjects }) {
describe('console app', function describeIndexTests() {
before(async function () {
log.debug('navigateTo console');
await PageObjects.common.navigateToUrl('settings', 'kibana/getting_started');
await PageObjects.gettingStarted.clickOptOutLink();
return PageObjects.common.navigateToApp('console');
});

Expand Down
18 changes: 13 additions & 5 deletions test/functional/page_objects/common_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function CommonPageProvider({ getService, getPageObjects }) {
const retry = getService('retry');
const testSubjects = getService('testSubjects');
const kibanaServer = getService('kibanaServer');
const PageObjects = getPageObjects(['shield']);
const PageObjects = getPageObjects(['shield', 'gettingStarted']);

const defaultTryTimeout = config.get('timeouts.try');
const defaultFindTimeout = config.get('timeouts.find');
Expand Down Expand Up @@ -78,18 +78,26 @@ export function CommonPageProvider({ getService, getPageObjects }) {
.then(function (currentUrl) {
const loginPage = currentUrl.includes('/login');
const wantedLoginPage = appUrl.includes('/login') || appUrl.includes('/logout');

if (loginPage && !wantedLoginPage) {
log.debug('Found loginPage username = '
+ config.get('servers.kibana.username'));
return PageObjects.shield.login(config.get('servers.kibana.username'),
config.get('servers.kibana.password'))
log.debug(`Found loginPage username = ${config.get('servers.kibana.username')}`);
return PageObjects.shield.login(
config.get('servers.kibana.username'),
config.get('servers.kibana.password')
)
.then(function () {
return remote.getCurrentUrl();
});
} else {
return currentUrl;
}
})
.then(async function (currentUrl) {
if (await PageObjects.gettingStarted.doesContainerExist()) {
await PageObjects.gettingStarted.outOut();
}
return currentUrl;
})
.then(function (currentUrl) {
currentUrl = currentUrl.replace(/\/\/\w+:\w+@/, '//');
const maxAdditionalLengthOnNavUrl = 230;
Expand Down
14 changes: 12 additions & 2 deletions test/functional/page_objects/getting_started_page.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
export function GettingStartedPageProvider({ getService }) {

const log = getService('log');
const retry = getService('retry');
const testSubjects = getService('testSubjects');

class GettingStartedPage {
async clickOptOutLink() {
async doesContainerExist() {
return await testSubjects.exists('gettingStartedContainer');
}

async outOut() {
log.debug('Clicking opt-out link');
await testSubjects.click('lnkGettingStartedOptOut');
await retry.try(async () => {
if (await this.doesContainerExist()) {
throw new Error('Still on getting started page');
}
});
}
}

return new GettingStartedPage();
}
}

0 comments on commit 9b4e19b

Please sign in to comment.