* Add some functional tests for query language switching
This commit is contained in:
parent
1e4d4c7753
commit
2521f83285
|
@ -55,6 +55,7 @@
|
|||
ng-model="queryBar.localQuery.language"
|
||||
ng-change="queryBar.selectLanguage()"
|
||||
ng-if="queryBar.showLanguageSwitcher"
|
||||
data-test-subj="queryBarLanguageSwitcher"
|
||||
>
|
||||
</select>
|
||||
|
||||
|
|
|
@ -7,7 +7,13 @@ export default function ({ getService, getPageObjects }) {
|
|||
const remote = getService('remote');
|
||||
const kibanaServer = getService('kibanaServer');
|
||||
const screenshots = getService('screenshots');
|
||||
const queryBar = getService('queryBar');
|
||||
const filterBar = getService('filterBar');
|
||||
const PageObjects = getPageObjects(['common', 'discover', 'header']);
|
||||
const defaultSettings = {
|
||||
'dateFormat:tz': 'UTC',
|
||||
'defaultIndex': 'logstash-*'
|
||||
};
|
||||
|
||||
describe('discover app', function describeIndexTests() {
|
||||
const fromTime = '2015-09-19 06:31:44.000';
|
||||
|
@ -17,10 +23,7 @@ export default function ({ getService, getPageObjects }) {
|
|||
|
||||
before(async function () {
|
||||
// delete .kibana index and update configDoc
|
||||
await kibanaServer.uiSettings.replace({
|
||||
'dateFormat:tz':'UTC',
|
||||
'defaultIndex':'logstash-*'
|
||||
});
|
||||
await kibanaServer.uiSettings.replace(defaultSettings);
|
||||
|
||||
log.debug('load kibana index with default index pattern');
|
||||
await esArchiver.load('discover');
|
||||
|
@ -229,6 +232,77 @@ export default function ({ getService, getPageObjects }) {
|
|||
});
|
||||
});
|
||||
|
||||
describe('query language switching', function () {
|
||||
|
||||
after(async function () {
|
||||
await kibanaServer.uiSettings.replace(defaultSettings);
|
||||
|
||||
log.debug('discover');
|
||||
await PageObjects.common.navigateToApp('discover');
|
||||
});
|
||||
|
||||
it('should not show a language switcher by default', async function () {
|
||||
const languageSwitcherExists = await queryBar.hasLanguageSwitcher();
|
||||
expect(languageSwitcherExists).to.be(false);
|
||||
});
|
||||
|
||||
it('should show a language switcher after it has been enabled in the advanced settings', async function () {
|
||||
await kibanaServer.uiSettings.update({
|
||||
'search:queryLanguage:switcher:enable': true
|
||||
});
|
||||
await PageObjects.common.navigateToApp('discover');
|
||||
const languageSwitcherExists = await queryBar.hasLanguageSwitcher();
|
||||
expect(languageSwitcherExists).to.be(true);
|
||||
});
|
||||
|
||||
it('should use lucene by default', async function () {
|
||||
const currentLanguage = await queryBar.getCurrentLanguage();
|
||||
expect(currentLanguage).to.be('lucene');
|
||||
});
|
||||
|
||||
it('should allow changing the default language in advanced settings', async function () {
|
||||
await kibanaServer.uiSettings.update({
|
||||
'search:queryLanguage': 'kuery'
|
||||
});
|
||||
await PageObjects.common.navigateToApp('discover');
|
||||
|
||||
const languageSwitcherExists = await queryBar.hasLanguageSwitcher();
|
||||
expect(languageSwitcherExists).to.be(true);
|
||||
|
||||
const currentLanguage = await queryBar.getCurrentLanguage();
|
||||
expect(currentLanguage).to.be('kuery');
|
||||
});
|
||||
|
||||
it('should reset the query and filters when the language is switched', async function () {
|
||||
await PageObjects.header.setAbsoluteRange(fromTime, toTime);
|
||||
await PageObjects.discover.clickFieldListItem('response');
|
||||
await PageObjects.discover.clickFieldListPlusFilter('response', 200);
|
||||
await PageObjects.header.waitUntilLoadingHasFinished();
|
||||
|
||||
let queryString = await queryBar.getQueryString();
|
||||
expect(queryString).to.not.be.empty();
|
||||
|
||||
await queryBar.setLanguage('lucene');
|
||||
await PageObjects.header.waitUntilLoadingHasFinished();
|
||||
queryString = await queryBar.getQueryString();
|
||||
expect(queryString).to.be.empty();
|
||||
expect(await filterBar.hasFilter('response', 200)).to.be(false);
|
||||
|
||||
await PageObjects.discover.clickFieldListPlusFilter('response', 200);
|
||||
await PageObjects.header.waitUntilLoadingHasFinished();
|
||||
queryString = await queryBar.getQueryString();
|
||||
expect(queryString).to.be.empty();
|
||||
expect(await filterBar.hasFilter('response', 200)).to.be(true);
|
||||
|
||||
await queryBar.setLanguage('kuery');
|
||||
await PageObjects.header.waitUntilLoadingHasFinished();
|
||||
queryString = await queryBar.getQueryString();
|
||||
expect(queryString).to.be.empty();
|
||||
expect(await filterBar.hasFilter('response', 200)).to.be(false);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('data-shared-item', function () {
|
||||
it('should have correct data-shared-item title and description', async () => {
|
||||
const expected = {
|
||||
|
|
|
@ -15,6 +15,7 @@ import {
|
|||
import {
|
||||
RemoteProvider,
|
||||
FilterBarProvider,
|
||||
QueryBarProvider,
|
||||
FindProvider,
|
||||
TestSubjectsProvider,
|
||||
DocTableProvider,
|
||||
|
@ -56,6 +57,7 @@ export default async function ({ readConfigFile }) {
|
|||
retry: commonConfig.get('services.retry'),
|
||||
remote: RemoteProvider,
|
||||
filterBar: FilterBarProvider,
|
||||
queryBar: QueryBarProvider,
|
||||
find: FindProvider,
|
||||
testSubjects: TestSubjectsProvider,
|
||||
docTable: DocTableProvider,
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
export { QueryBarProvider } from './query_bar';
|
||||
export { FilterBarProvider } from './filter_bar';
|
||||
export { FindProvider } from './find';
|
||||
export { TestSubjectsProvider } from './test_subjects';
|
||||
|
|
37
test/functional/services/query_bar.js
Normal file
37
test/functional/services/query_bar.js
Normal file
|
@ -0,0 +1,37 @@
|
|||
export function QueryBarProvider({ getService }) {
|
||||
const testSubjects = getService('testSubjects');
|
||||
const find = getService('find');
|
||||
|
||||
class QueryBar {
|
||||
|
||||
async getQueryString() {
|
||||
const queryInput = await testSubjects.find('queryInput');
|
||||
return await queryInput.getProperty('value');
|
||||
}
|
||||
|
||||
async hasLanguageSwitcher() {
|
||||
return await testSubjects.exists('queryBarLanguageSwitcher');
|
||||
}
|
||||
|
||||
async getLanguageSwitcher() {
|
||||
return await testSubjects.find('queryBarLanguageSwitcher');
|
||||
}
|
||||
|
||||
async getCurrentLanguage() {
|
||||
const languageSwitcher = await this.getLanguageSwitcher();
|
||||
const selectedOption = await languageSwitcher.findByCssSelector('option[selected="selected"]');
|
||||
return await selectedOption.getVisibleText();
|
||||
}
|
||||
|
||||
async setLanguage(language) {
|
||||
const languageSwitcher = await this.getLanguageSwitcher();
|
||||
await languageSwitcher.click();
|
||||
|
||||
const requestedOption = await find.byCssSelector(`option[label="${language}"]`);
|
||||
await requestedOption.click();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return new QueryBar();
|
||||
}
|
Loading…
Reference in a new issue