[Search] enable fun-ctional tests (#97398)

* only fun-ctional

* fix functional tests

* tests

* Type
This commit is contained in:
Liza Katz 2021-04-19 12:21:50 +03:00 committed by GitHub
parent 1bc7e5462f
commit 4c45ae0645
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 57 additions and 16 deletions

View file

@ -195,7 +195,7 @@ export const SearchExamplesApp = ({
});
};
const doSearchSourceSearch = async () => {
const doSearchSourceSearch = async (otherBucket: boolean) => {
if (!indexPattern) return;
const query = data.query.queryString.getQuery();
@ -221,7 +221,7 @@ export const SearchExamplesApp = ({
aggDef.push({
type: 'terms',
schema: 'split',
params: { field: selectedBucketField.name, size: 2, otherBucket: true },
params: { field: selectedBucketField.name, size: 2, otherBucket },
});
}
if (selectedNumericField) {
@ -280,8 +280,8 @@ export const SearchExamplesApp = ({
}
};
const onSearchSourceClickHandler = () => {
doSearchSourceSearch();
const onSearchSourceClickHandler = (withOtherBucket: boolean) => {
doSearchSourceSearch(withOtherBucket);
};
const reqTabs = [
@ -367,6 +367,7 @@ export const SearchExamplesApp = ({
setIndexPattern(newIndexPattern);
}}
isClearable={false}
data-test-subj="indexPatternSelector"
/>
</EuiFlexItem>
<EuiFlexItem>
@ -449,7 +450,7 @@ export const SearchExamplesApp = ({
</EuiText>
<EuiButtonEmpty
size="xs"
onClick={onSearchSourceClickHandler}
onClick={() => onSearchSourceClickHandler(true)}
iconType="play"
data-test-subj="searchSourceWithOther"
>
@ -464,6 +465,23 @@ export const SearchExamplesApp = ({
defaultMessage="Bucket and metrics aggregations with other bucket."
/>
</EuiText>
<EuiButtonEmpty
size="xs"
onClick={() => onSearchSourceClickHandler(false)}
iconType="play"
data-test-subj="searchSourceWithoutOther"
>
<FormattedMessage
id="searchExamples.searchSource.buttonText"
defaultMessage="Request from high-level client (data.search.searchSource)"
/>
</EuiButtonEmpty>
<EuiText size="xs" color="subdued" className="searchExampleStepDsc">
<FormattedMessage
id="searchExamples.buttonText"
defaultMessage="Bucket and metrics aggregations without other bucket."
/>
</EuiText>
</EuiText>
<EuiSpacer />
<EuiTitle size="s">

View file

@ -12,26 +12,45 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const testSubjects = getService('testSubjects');
const PageObjects = getPageObjects(['common', 'timePicker']);
const retry = getService('retry');
const comboBox = getService('comboBox');
describe.skip('Search session example', () => {
describe('Search session example', () => {
const appId = 'searchExamples';
before(async function () {
await PageObjects.common.navigateToApp(appId, { insertTimestamp: false });
await comboBox.set('indexPatternSelector', 'logstash-*');
await comboBox.set('searchBucketField', 'geo.src');
await comboBox.set('searchMetricField', 'memory');
await PageObjects.timePicker.setAbsoluteRange(
'Mar 1, 2015 @ 00:00:00.000',
'Nov 1, 2015 @ 00:00:00.000'
);
});
it('should have an other bucket', async () => {
await PageObjects.timePicker.setAbsoluteRange(
'Jan 1, 2014 @ 00:00:00.000',
'Jan 1, 2016 @ 00:00:00.000'
);
await testSubjects.click('searchSourceWithOther');
await retry.waitFor('has other bucket', async () => {
await testSubjects.click('responseTab');
const codeBlock = await testSubjects.find('responseCodeBlock');
await testSubjects.click('responseTab');
const codeBlock = await testSubjects.find('responseCodeBlock');
await retry.waitFor('get code block', async () => {
const visibleText = await codeBlock.getVisibleText();
return visibleText.indexOf('__other__') > -1;
const parsedResponse = JSON.parse(visibleText);
const buckets = parsedResponse.aggregations[1].buckets;
return (
buckets.length === 3 && buckets[2].key === '__other__' && buckets[2].doc_count === 9039
);
});
});
it('should not have an other bucket', async () => {
await testSubjects.click('searchSourceWithoutOther');
await testSubjects.click('responseTab');
const codeBlock = await testSubjects.find('responseCodeBlock');
await retry.waitFor('get code block', async () => {
const visibleText = await codeBlock.getVisibleText();
const parsedResponse = JSON.parse(visibleText);
const buckets = parsedResponse.aggregations[1].buckets;
return buckets.length === 2;
});
});
});

View file

@ -14,6 +14,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const PageObjects = getPageObjects(['common']);
const toasts = getService('toasts');
const retry = getService('retry');
const comboBox = getService('comboBox');
async function getExecutedAt() {
const toast = await toasts.getToastElement(1);
@ -26,11 +27,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
return text;
}
describe.skip('Search session client side cache', () => {
describe('Search session client side cache', () => {
const appId = 'searchExamples';
before(async function () {
await PageObjects.common.navigateToApp(appId, { insertTimestamp: false });
await comboBox.set('indexPatternSelector', 'logstash-*');
await comboBox.set('searchBucketField', 'extension.raw');
await comboBox.set('searchMetricField', 'phpmemory');
});
it('should cache responses by search session id', async () => {