Fix visualize app chart type test (#47807)

* Add method to detect oss in settings pages

- if it's not OSS, than 'Maps' is added to the expected chart types

Co-authored-by: liza-mae <liza-mae@users.noreply.github.com>
This commit is contained in:
Matthias Wilhelm 2019-10-14 09:37:05 +02:00 committed by GitHub
parent 7bcc7634ec
commit 83b4b4568c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 6 deletions

View file

@ -18,18 +18,22 @@
*/
import expect from '@kbn/expect';
import { FtrProviderContext } from '../../ftr_provider_context';
export default function ({ getService, getPageObjects }) {
// eslint-disable-next-line import/no-default-export
export default function({ getService, getPageObjects }: FtrProviderContext) {
const log = getService('log');
const PageObjects = getPageObjects(['common', 'visualize']);
let isOss = true;
describe('chart types', function () {
before(function () {
describe('chart types', function() {
before(async function() {
log.debug('navigateToApp visualize');
return PageObjects.visualize.navigateToNewVisualization();
isOss = await PageObjects.common.isOss();
await PageObjects.visualize.navigateToNewVisualization();
});
it('should show the correct chart types', async function () {
it('should show the correct chart types', async function() {
const expectedChartTypes = [
'Area',
'Controls',
@ -50,6 +54,11 @@ export default function ({ getService, getPageObjects }) {
'Vega',
'Vertical Bar',
];
if (!isOss) {
expectedChartTypes.push('Maps');
expectedChartTypes.sort();
}
log.debug('oss= ' + isOss);
// find all the chart types and make sure there all there
const chartTypes = await PageObjects.visualize.getChartTypes();

View file

@ -19,7 +19,7 @@
import { delay } from 'bluebird';
import expect from '@kbn/expect';
import fetch from 'node-fetch';
import getUrl from '../../../src/test_utils/get_url';
export function CommonPageProvider({ getService, getPageObjects }) {
@ -405,6 +405,24 @@ export function CommonPageProvider({ getService, getPageObjects }) {
return await jsonElement.getVisibleText();
}
}
/**
* Helper to detect an OSS licensed Kibana
* Useful for functional testing in cloud environment
*/
async isOss() {
const baseUrl = this.getEsHostPort();
const username = config.get('servers.elasticsearch.username');
const password = config.get('servers.elasticsearch.password');
const response = await fetch(baseUrl + '/_xpack', {
method: 'get',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Basic ' + Buffer.from(username + ':' + password).toString('base64')
},
});
return response.status !== 200;
}
}
return new CommonPage();