Skip to content

Commit

Permalink
pr changes 1
Browse files Browse the repository at this point in the history
  • Loading branch information
stephmilovic committed May 8, 2020
1 parent fd8f5c9 commit 4d2c9d0
Show file tree
Hide file tree
Showing 17 changed files with 60 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { deleteCases, deleteCasesUserActions, deleteComments } from '../../../..
// eslint-disable-next-line import/no-default-export
export default ({ getService }: FtrProviderContext): void => {
const supertest = getService('supertest');
const es = getService('legacyEs');
const es = getService('es');

describe('delete_comment', () => {
afterEach(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ import { deleteCases, deleteCasesUserActions, deleteComments } from '../../../..
// eslint-disable-next-line import/no-default-export
export default ({ getService }: FtrProviderContext): void => {
const supertest = getService('supertest');
const es = getService('legacyEs');
const es = getService('es');

describe('find_comments', () => {
afterEach(async () => {
await deleteCases(es);
await deleteComments(es);
await deleteCasesUserActions(es);
// await deleteComments(es);
// await deleteCasesUserActions(es);
});

it('should get all case comment', async () => {
it('should find all case comment', async () => {
const { body: postedCase } = await supertest
.post(CASES_URL)
.set('kbn-xsrf', 'true')
Expand All @@ -47,5 +47,30 @@ export default ({ getService }: FtrProviderContext): void => {

expect(caseComments.comments).to.eql(patchedCase.comments);
});

// it('should filter case comments', async () => {
// const { body: postedCase } = await supertest
// .post(CASES_URL)
// .set('kbn-xsrf', 'true')
// .send(postCaseReq)
// .expect(200);
// // post 2 comments
// await supertest
// .post(`${CASES_URL}/${postedCase.id}/comments`)
// .set('kbn-xsrf', 'true')
// .send(postCommentReq);
//
// const { body: patchedCase } = await supertest
// .post(`${CASES_URL}/${postedCase.id}/comments`)
// .set('kbn-xsrf', 'true')
// .send({ comment: 'unique' });
//
// const { body: caseComments } = await supertest
// .get(`${CASES_URL}/${postedCase.id}/comments/_find?search=unique`)
// .set('kbn-xsrf', 'true')
// .send();
//
// expect(caseComments.comments).to.eql(patchedCase.comments);
// });
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { deleteCases, deleteCasesUserActions, deleteComments } from '../../../..
// eslint-disable-next-line import/no-default-export
export default ({ getService }: FtrProviderContext): void => {
const supertest = getService('supertest');
const es = getService('legacyEs');
const es = getService('es');

describe('get_comment', () => {
afterEach(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { deleteCases, deleteCasesUserActions, deleteComments } from '../../../..
// eslint-disable-next-line import/no-default-export
export default ({ getService }: FtrProviderContext): void => {
const supertest = getService('supertest');
const es = getService('legacyEs');
const es = getService('es');

describe('patch_comment', () => {
afterEach(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { deleteCases, deleteCasesUserActions, deleteComments } from '../../../..
// eslint-disable-next-line import/no-default-export
export default ({ getService }: FtrProviderContext): void => {
const supertest = getService('supertest');
const es = getService('legacyEs');
const es = getService('es');

describe('post_comment', () => {
afterEach(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { deleteCases } from '../../../common/lib/utils';
// eslint-disable-next-line import/no-default-export
export default ({ getService }: FtrProviderContext): void => {
const supertest = getService('supertest');
const es = getService('legacyEs');
const es = getService('es');

describe('delete_cases', () => {
afterEach(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { deleteCases, deleteComments, deleteCasesUserActions } from '../../../co
// eslint-disable-next-line import/no-default-export
export default ({ getService }: FtrProviderContext): void => {
const supertest = getService('supertest');
const es = getService('legacyEs');
const es = getService('es');
describe('find_cases', () => {
afterEach(async () => {
await deleteCases(es);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { deleteCases } from '../../../common/lib/utils';
// eslint-disable-next-line import/no-default-export
export default ({ getService }: FtrProviderContext): void => {
const supertest = getService('supertest');
const es = getService('legacyEs');
const es = getService('es');

describe('get_case', () => {
afterEach(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { deleteCases, deleteCasesUserActions } from '../../../common/lib/utils';
// eslint-disable-next-line import/no-default-export
export default ({ getService }: FtrProviderContext): void => {
const supertest = getService('supertest');
const es = getService('legacyEs');
const es = getService('es');

describe('patch_cases', () => {
afterEach(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { deleteCases } from '../../../common/lib/utils';
// eslint-disable-next-line import/no-default-export
export default ({ getService }: FtrProviderContext): void => {
const supertest = getService('supertest');
const es = getService('legacyEs');
const es = getService('es');

describe('post_case', () => {
afterEach(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
// eslint-disable-next-line import/no-default-export
export default ({ getService }: FtrProviderContext): void => {
const supertest = getService('supertest');
const es = getService('legacyEs');
const es = getService('es');

describe('push_case', () => {
afterEach(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,13 @@ import expect from '@kbn/expect';
import { FtrProviderContext } from '../../../../common/ftr_provider_context';

import { CASES_URL, CASE_REPORTERS_URL } from '../../../../../../plugins/case/common/constants';
import {
defaultUser,
postCaseReq,
removeServerGeneratedPropertiesFromCase,
} from '../../../../common/lib/mock';
import { defaultUser, postCaseReq } from '../../../../common/lib/mock';
import { deleteCases } from '../../../../common/lib/utils';

// eslint-disable-next-line import/no-default-export
export default ({ getService }: FtrProviderContext): void => {
const supertest = getService('supertest');
const es = getService('legacyEs');
const es = getService('es');

describe('get_reporters', () => {
afterEach(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { deleteCases } from '../../../../common/lib/utils';
// eslint-disable-next-line import/no-default-export
export default ({ getService }: FtrProviderContext): void => {
const supertest = getService('supertest');
const es = getService('legacyEs');
const es = getService('es');

describe('get_status', () => {
afterEach(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import { FtrProviderContext } from '../../../../common/ftr_provider_context';

import { CASES_URL, CASE_TAGS_URL } from '../../../../../../plugins/case/common/constants';
import { postCaseReq } from '../../../../common/lib/mock';
import { deleteCases, deleteComments } from '../../../../common/lib/utils';
import { deleteCases } from '../../../../common/lib/utils';

// eslint-disable-next-line import/no-default-export
export default ({ getService }: FtrProviderContext): void => {
const supertest = getService('supertest');
const es = getService('legacyEs');
const es = getService('es');

describe('get_tags', () => {
afterEach(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
import expect from '@kbn/expect';
import { FtrProviderContext } from '../../../../common/ftr_provider_context';

import { CASES_URL, CASE_STATUS_URL } from '../../../../../../plugins/case/common/constants';
import { CASES_URL } from '../../../../../../plugins/case/common/constants';
import { postCaseReq, postCommentReq } from '../../../../common/lib/mock';
import { deleteCases, deleteCasesUserActions, deleteComments } from '../../../../common/lib/utils';

// eslint-disable-next-line import/no-default-export
export default ({ getService }: FtrProviderContext): void => {
const supertest = getService('supertest');
const es = getService('legacyEs');
const es = getService('es');

describe('get_all_user_actions', () => {
afterEach(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
// eslint-disable-next-line import/no-default-export
export default ({ getService }: FtrProviderContext): void => {
const supertest = getService('supertest');
const es = getService('legacyEs');
const es = getService('es');

describe('get_configure', () => {
afterEach(async () => {
Expand Down
25 changes: 13 additions & 12 deletions x-pack/test/case_api_integration/common/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { Client } from '@elastic/elasticsearch';
import { CasesConfigureRequest, CasesConfigureResponse } from '../../../../plugins/case/common/api';

export const getConfiguration = (connector_id: string = 'connector-1'): CasesConfigureRequest => {
Expand All @@ -29,42 +30,42 @@ export const removeServerGeneratedPropertiesFromConfigure = (
return rest;
};

export const deleteCasesUserActions = async (es: any): Promise<void> => {
export const deleteCasesUserActions = async (es: Client): Promise<void> => {
await es.deleteByQuery({
index: '.kibana',
q: 'type:cases-user-actions',
waitForCompletion: true,
refresh: 'wait_for',
wait_for_completion: true,
refresh: true,
body: {},
});
};

export const deleteCases = async (es: any): Promise<void> => {
export const deleteCases = async (es: Client): Promise<void> => {
await es.deleteByQuery({
index: '.kibana',
q: 'type:cases',
waitForCompletion: true,
refresh: 'wait_for',
wait_for_completion: true,
refresh: true,
body: {},
});
};

export const deleteComments = async (es: any): Promise<void> => {
export const deleteComments = async (es: Client): Promise<void> => {
await es.deleteByQuery({
index: '.kibana',
q: 'type:cases-comments',
waitForCompletion: true,
refresh: 'wait_for',
wait_for_completion: true,
refresh: true,
body: {},
});
};

export const deleteConfiguration = async (es: any): Promise<void> => {
export const deleteConfiguration = async (es: Client): Promise<void> => {
await es.deleteByQuery({
index: '.kibana',
q: 'type:cases-configure',
waitForCompletion: true,
refresh: 'wait_for',
wait_for_completion: true,
refresh: true,
body: {},
});
};

0 comments on commit 4d2c9d0

Please sign in to comment.