Skip to content

Commit

Permalink
test: add integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
mbondyra committed Mar 4, 2020
1 parent 6b692ab commit f2aca43
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 4 deletions.
49 changes: 45 additions & 4 deletions x-pack/test/api_integration/apis/lens/existing_fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,54 @@ export default ({ getService }: FtrProviderContext) => {
expect(body.existingFieldNames.sort()).to.eql(metricBeatData.sort());
});

it('should throw a 404 for a non-existent index', async () => {
await supertest
it('should return fields filtered by query and filters', async () => {
const expectedFieldNames = [
'@message',
'@message.raw',
'@tags',
'@tags.raw',
'@timestamp',
'agent',
'agent.raw',
'bytes',
'clientip',
'extension',
'extension.raw',
'headings',
'headings.raw',
'host',
'host.raw',
'index',
'index.raw',
'referer',
'request',
'request.raw',
'response',
'response.raw',
'spaces',
'spaces.raw',
'type',
'url',
'url.raw',
'utc_time',
'xss',
'xss.raw',
];

const dslQueryFiltered = JSON.stringify({
bool: {
filter: [{ match: { referer: 'https://www.taylorswift.com/' } }],
},
});
const { body } = await supertest
.get(
`/api/lens/existing_fields/nadachance?fromDate=${TEST_START_TIME}&toDate=${TEST_END_TIME}&dslQuery=${DSL_QUERY}`
`/api/lens/existing_fields/${encodeURIComponent(
'logstash-*'
)}?fromDate=${TEST_START_TIME}&toDate=${TEST_END_TIME}&dslQuery=${dslQueryFiltered}`
)
.set(COMMON_HEADERS)
.expect(404);
.expect(200);
expect(body.existingFieldNames.sort()).to.eql(expectedFieldNames.sort());
});
});
});
Expand Down
Binary file not shown.

0 comments on commit f2aca43

Please sign in to comment.