Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phase 1 of search services #46742

Merged
merged 26 commits into from
Oct 10, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
e9d62d2
Phase 1 of search services
stacey-gammon Sep 26, 2019
1da04ee
First review feedback
lukasolson Oct 1, 2019
d2c6787
Merge pull request #11 from lukasolson/np-search-api
stacey-gammon Oct 1, 2019
c0d3070
Start on tests
stacey-gammon Oct 1, 2019
6c9a09a
Add functional tests for search explorer
stacey-gammon Oct 2, 2019
83806cc
Add unload and fix ts error
stacey-gammon Oct 2, 2019
606dcc0
Merge branch 'master' of github.com:elastic/kibana into 2019-09-25-np…
stacey-gammon Oct 2, 2019
00a22d6
Add index.test.ts files for coverage completeness
stacey-gammon Oct 2, 2019
ba50e95
Adding unit tests
lukasolson Oct 2, 2019
83eab32
Merge pull request #12 from lukasolson/np-search-api
stacey-gammon Oct 3, 2019
d75b3e9
use internal route terminology. No reason this should be a public rou…
stacey-gammon Oct 3, 2019
1617ffa
Move search service into data plugin
stacey-gammon Oct 3, 2019
95bde79
Merge branch 'master' of github.com:elastic/kibana into 2019-09-25-np…
stacey-gammon Oct 3, 2019
ce571b5
App mount search context needs to be optional
stacey-gammon Oct 3, 2019
e5ea60e
Merge branch 'master' of github.com:elastic/kibana into 2019-09-25-np…
stacey-gammon Oct 3, 2019
64de132
Add more unit tests for server stuff
lukasolson Oct 3, 2019
2c6c96f
Merge pull request #13 from lukasolson/np-search-api
stacey-gammon Oct 4, 2019
88e73f6
wip types fix
stacey-gammon Oct 7, 2019
e9e75ef
Merge branch 'master' of github.com:elastic/kibana into 2019-09-25-np…
stacey-gammon Oct 7, 2019
83aa47a
fix types for new context container stuff
stacey-gammon Oct 7, 2019
2c9b24c
put back all jest test coverage paths
stacey-gammon Oct 7, 2019
25ec030
address review comments
stacey-gammon Oct 8, 2019
82db4e7
Merge branch 'master' of github.com:elastic/kibana into 2019-09-25-np…
stacey-gammon Oct 8, 2019
8621708
delete the two test files that just tested the instantiation of the s…
stacey-gammon Oct 8, 2019
1678aec
expose search fn on StartContract... tested locally only
stacey-gammon Oct 9, 2019
ce0a93f
update mocks to account for new startcontract
stacey-gammon Oct 9, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions test/functional/services/find.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,17 @@ export async function FindProvider({ getService }: FtrProviderContext) {
return await this.filterElementIsDisplayed(allElements);
}

public async allDescendantDisplayedByTagName(
tagName: string,
parentElement: WebElementWrapper
): Promise<WebElementWrapper[]> {
log.debug(`Find.allDescendantDisplayedByTagName('${tagName}')`);
const allElements = await wrapAll(
await parentElement._webElement.findElements(By.tagName(tagName))
);
return await this.filterElementIsDisplayed(allElements);
}

public async displayedByLinkText(
linkText: string,
timeout: number = defaultFindTimeout
Expand Down
21 changes: 21 additions & 0 deletions test/functional/services/test_subjects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,27 @@ export function TestSubjectsProvider({ getService }: FtrProviderContext) {
: find.waitForDeletedByCssSelector(testSubjSelector(selector), timeout));
}

async stringExistsInCodeBlockOrFail(codeBlockSelector: string, stringToFind: string) {
await retry.try(async () => {
const responseCodeBlock = await this.find(codeBlockSelector);
const spans = await find.allDescendantDisplayedByTagName('span', responseCodeBlock);
const foundInSpans = await Promise.all(
spans.map(async span => {
const text = await span.getVisibleText();
if (text === stringToFind) {
log.debug(`"${text}" matched "${stringToFind}"!`);
return true;
} else {
log.debug(`"${text}" did not match "${stringToFind}"`);
}
})
);
if (!foundInSpans.find(foundInSpan => foundInSpan)) {
throw new Error('String not found. Trying again.');
}
});
}

public async append(selector: string, text: string): Promise<void> {
return await retry.try(async () => {
log.debug(`TestSubjects.append(${selector}, ${text})`);
Expand Down
1 change: 1 addition & 0 deletions test/plugin_functional/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export default async function ({ readConfigFile }) {
require.resolve('./test_suites/custom_visualizations'),
require.resolve('./test_suites/embedding_visualizations'),
require.resolve('./test_suites/panel_actions'),
require.resolve('./test_suites/search'),

/**
* @todo Work on re-enabling this test suite after this is merged. These tests pass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ const SearchApp = ({ basename, context }: { basename: string; context: AppMountC
},
{
title: 'ES search strategy',
id: 'defaultSearch',
id: 'esSearch',
component: <EsSearchTest search={context.search!.search} />,
},
{
title: 'Demo search strategy',
id: 'fakeSearch',
id: 'demoSearch',
component: <DemoStrategy search={context.search!.search} />,
},
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ export class DoSearch extends React.Component<Props, State> {
<React.Fragment>
<EuiFlexGroup>
<EuiFlexItem grow={false}>
<EuiButton onClick={this.search}>Search</EuiButton>
<EuiButton data-test-subj="doSearch" onClick={this.search}>
Search
</EuiButton>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButton disabled={!this.state.searching} onClick={this.cancel}>
Expand Down Expand Up @@ -122,7 +124,13 @@ ${requestStr}
value={(this.state.response && this.state.response.percentComplete) || 0}
max={100}
/>
<EuiCodeBlock language="json" fontSize="m" paddingSize="m" color="dark">
<EuiCodeBlock
language="json"
fontSize="m"
paddingSize="m"
color="dark"
data-test-subj="response"
>
{responseStr}
</EuiCodeBlock>
</EuiFlexItem>
Expand Down
36 changes: 36 additions & 0 deletions test/plugin_functional/test_suites/search/demo_data.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { FtrProviderContext } from 'test/functional/ftr_provider_context';

// eslint-disable-next-line import/no-default-export
export default function({ getService }: FtrProviderContext) {
const testSubjects = getService('testSubjects');

describe('demo search strategy', () => {
before(async () => {
await testSubjects.click('demoSearch');
});

it('data is returned', async () => {
await testSubjects.click('doSearch');
await testSubjects.stringExistsInCodeBlockOrFail('response', '"Lovely to meet you, Molly"');
});
});
}
35 changes: 35 additions & 0 deletions test/plugin_functional/test_suites/search/es_search.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import { FtrProviderContext } from 'test/functional/ftr_provider_context';

// eslint-disable-next-line import/no-default-export
export default function({ getService }: FtrProviderContext) {
const testSubjects = getService('testSubjects');

describe('es search strategy', () => {
before(async () => {
await testSubjects.click('esSearch');
});

it('data is returned', async () => {
await testSubjects.click('doSearch');
await testSubjects.stringExistsInCodeBlockOrFail('response', '"animal weights"');
});
});
}
46 changes: 46 additions & 0 deletions test/plugin_functional/test_suites/search/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { FtrProviderContext } from 'test/functional/ftr_provider_context';

// eslint-disable-next-line import/no-default-export
export default function({ getService, getPageObjects, loadTestFile }: FtrProviderContext) {
const browser = getService('browser');
const appsMenu = getService('appsMenu');
const esArchiver = getService('esArchiver');
const kibanaServer = getService('kibanaServer');
const PageObjects = getPageObjects(['common', 'header']);

describe('search services', function() {
before(async () => {
await esArchiver.loadIfNeeded('../functional/fixtures/es_archiver/dashboard/current/data');
await esArchiver.load('../functional/fixtures/es_archiver/dashboard/current/kibana');
await kibanaServer.uiSettings.replace({
'dateFormat:tz': 'Australia/North',
defaultIndex: 'logstash-*',
});
Comment on lines +32 to +37
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to revert these in an after?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yuuupppp, added another commit (and fixed the ts error that was killing ci)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually I reverted the data that was loaded. I don't think we need to change anything with the uiSettings, haven't seen that being "undone" before. Most tests set it explicitly.

await browser.setWindowSize(1300, 900);
await PageObjects.common.navigateToApp('settings');
await appsMenu.clickLink('Search Explorer');
});

loadTestFile(require.resolve('./demo_data'));
loadTestFile(require.resolve('./es_search'));
});
}