diff --git a/examples/search_examples/public/search/app.tsx b/examples/search_examples/public/search/app.tsx index b2a4991d0717b..65d939088515a 100644 --- a/examples/search_examples/public/search/app.tsx +++ b/examples/search_examples/public/search/app.tsx @@ -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" /> @@ -449,7 +450,7 @@ export const SearchExamplesApp = ({ onSearchSourceClickHandler(true)} iconType="play" data-test-subj="searchSourceWithOther" > @@ -464,6 +465,23 @@ export const SearchExamplesApp = ({ defaultMessage="Bucket and metrics aggregations with other bucket." /> + onSearchSourceClickHandler(false)} + iconType="play" + data-test-subj="searchSourceWithoutOther" + > + + + + + diff --git a/x-pack/test/examples/search_examples/search_example.ts b/x-pack/test/examples/search_examples/search_example.ts index 19a9535ebb951..c841b595ed119 100644 --- a/x-pack/test/examples/search_examples/search_example.ts +++ b/x-pack/test/examples/search_examples/search_example.ts @@ -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 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 === 3 && buckets[2].key === '__other__' && buckets[2].doc_count === 9039 + ); + }); + }); - await retry.waitFor('has other bucket', async () => { - await testSubjects.click('responseTab'); - const codeBlock = await testSubjects.find('responseCodeBlock'); + 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(); - return visibleText.indexOf('__other__') > -1; + const parsedResponse = JSON.parse(visibleText); + const buckets = parsedResponse.aggregations[1].buckets; + return buckets.length === 2; }); }); }); diff --git a/x-pack/test/examples/search_examples/search_sessions_cache.ts b/x-pack/test/examples/search_examples/search_sessions_cache.ts index 57b2d1665d901..7e52849ed2a7e 100644 --- a/x-pack/test/examples/search_examples/search_sessions_cache.ts +++ b/x-pack/test/examples/search_examples/search_sessions_cache.ts @@ -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 () => {