refactor login page check, turn off telemetry (#17435) (#20722)

* refactor login page check, turn off telemetry

* significant refactor of navigateTo

* replace slashes with _ in test failure output html files

* re-do out of date PR
This commit is contained in:
Lee Drengenberg 2018-07-12 11:57:47 -05:00 committed by GitHub
parent 988784188c
commit 885eb1039e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 15 deletions

View file

@ -48,7 +48,7 @@ export function CommonPageProvider({ getService, getPageObjects }) {
* @param {string} appName As defined in the apps config
* @param {string} subUrl The route after the hash (#)
*/
navigateToUrl(appName, subUrl) {
async navigateToUrl(appName, subUrl) {
const appConfig = {
...config.get(['apps', appName]),
// Overwrite the default hash with the URL we really want.
@ -56,9 +56,32 @@ export function CommonPageProvider({ getService, getPageObjects }) {
};
const appUrl = getUrl.noAuth(config.get('servers.kibana'), appConfig);
return remote.get(appUrl);
await remote.get(appUrl);
await this.loginIfPrompted(appUrl);
}
async loginIfPrompted(appUrl) {
let currentUrl = await remote.getCurrentUrl();
log.debug(`currentUrl = ${currentUrl}\n appUrl = ${appUrl}`);
await remote.setFindTimeout(defaultTryTimeout * 2).findByCssSelector('[data-test-subj="kibanaChrome"]');
const loginPage = currentUrl.includes('/login');
const wantedLoginPage = appUrl.includes('/login') || appUrl.includes('/logout');
if (loginPage && !wantedLoginPage) {
log.debug(`Found login page. Logging in with username = ${config.get('servers.kibana.username')}`);
await PageObjects.shield.login(
config.get('servers.kibana.username'),
config.get('servers.kibana.password')
);
await remote.setFindTimeout(20000).findByCssSelector('[data-test-subj="kibanaChrome"] nav:not(.ng-hide)');
currentUrl = await remote.getCurrentUrl();
log.debug(`Finished login process currentUrl = ${currentUrl}`);
}
return currentUrl;
}
navigateToApp(appName) {
const self = this;
const appUrl = getUrl.noAuth(config.get('servers.kibana'), config.get(['apps', appName]));
@ -78,7 +101,8 @@ export function CommonPageProvider({ getService, getPageObjects }) {
log.debug(' >>>>>>>> Setting defaultIndex to "logstash-*""');
return kibanaServer.uiSettings.update({
'dateFormat:tz': 'UTC',
'defaultIndex': 'logstash-*'
'defaultIndex': 'logstash-*',
'telemetry:optIn': false
});
}
}
@ -95,17 +119,7 @@ export function CommonPageProvider({ getService, getPageObjects }) {
return remote.refresh();
})
.then(async function () {
const currentUrl = await remote.getCurrentUrl();
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')}`);
await PageObjects.shield.login(
config.get('servers.kibana.username'),
config.get('servers.kibana.password')
);
}
const currentUrl = await self.loginIfPrompted(appUrl);
if (currentUrl.includes('app/kibana')) {
await testSubjects.find('kibanaChrome');

View file

@ -50,7 +50,7 @@ export async function FailureDebuggingProvider({ getService }) {
async function onFailure(error, test) {
// Replace characters in test names which can't be used in filenames, like *
const name = test.fullTitle().replace(/([^ a-zA-Z0-9/-]+)/g, '_');
const name = test.fullTitle().replace(/([^ a-zA-Z0-9-]+)/g, '_');
await Promise.all([
screenshots.takeForFailure(name),