initial api integration test for DFA map api (#86225)

This commit is contained in:
Melissa Alvarez 2020-12-17 12:35:50 -05:00 committed by GitHub
parent 8c5f64f07e
commit 5d2014dec5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -235,5 +235,42 @@ export default ({ getService }: FtrProviderContext) => {
expect(body.message).to.eql('Forbidden');
});
});
describe('GetDataFrameAnalyticsIdMap', () => {
it('should return a map of objects leading up to analytics job id', async () => {
const { body } = await supertest
.get(`/api/ml/data_frame/analytics/map/${jobId}_1`)
.auth(USER.ML_VIEWER, ml.securityCommon.getPasswordForUser(USER.ML_VIEWER))
.set(COMMON_REQUEST_HEADERS)
.expect(200);
expect(body).to.have.keys('elements', 'details', 'error');
// Index node, 2 job nodes (with same source index), and 2 edge nodes to connect them
expect(body.elements.length).to.eql(5);
for (const detailsId in body.details) {
if (detailsId.includes('analytics')) {
expect(body.details[detailsId]).to.have.keys('id', 'source', 'dest');
} else if (detailsId.includes('index')) {
const indexId = detailsId.replace('-index', '');
expect(body.details[detailsId][indexId]).to.have.keys('aliases', 'mappings');
}
}
});
it('should return empty results and an error message if the job does not exist', async () => {
const { body } = await supertest
.get(`/api/ml/data_frame/analytics/map/${jobId}_fake`)
.auth(USER.ML_VIEWER, ml.securityCommon.getPasswordForUser(USER.ML_VIEWER))
.set(COMMON_REQUEST_HEADERS)
.expect(200);
expect(body.elements.length).to.eql(0);
expect(body.details).to.eql({});
expect(body.error).to.eql(`No known job with id '${jobId}_fake'`);
expect(body).to.have.keys('elements', 'details', 'error');
});
});
});
};