Skip to content

Commit

Permalink
add API tests for filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
Esteban Beltran committed May 6, 2022
1 parent f18427e commit b342e20
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
1 change: 1 addition & 0 deletions x-pack/test/cases_api_integration/common/lib/mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const postCaseReq: CasePostRequest = {
description: 'This is a brand new case of a bad meanie defacing data',
title: 'Super Bad Security Issue',
tags: ['defacement'],
severity: CaseSeverity.LOW,
connector: {
id: 'none',
name: 'none',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@

import expect from '@kbn/expect';
import { CASES_URL } from '@kbn/cases-plugin/common/constants';
import { CaseResponse, CaseStatuses, CommentType } from '@kbn/cases-plugin/common/api';
import {
CaseResponse,
CaseSeverity,
CaseStatuses,
CommentType,
} from '@kbn/cases-plugin/common/api';
import { FtrProviderContext } from '../../../../common/ftr_provider_context';

import {
Expand Down Expand Up @@ -117,6 +122,45 @@ export default ({ getService }: FtrProviderContext): void => {
});
});

it('filters by severity', async () => {
await createCase(supertest, postCaseReq);
const theCase = await createCase(supertest, postCaseReq);
const patchedCase = await updateCase({
supertest,
params: {
cases: [
{
id: theCase.id,
version: theCase.version,
severity: CaseSeverity.HIGH,
},
],
},
});

const cases = await findCases({ supertest, query: { severity: CaseSeverity.HIGH } });

expect(cases).to.eql({
...findCasesResp,
total: 1,
cases: [patchedCase[0]],
count_open_cases: 1,
});
});

it('filters by severity (none found)', async () => {
await createCase(supertest, postCaseReq);
await createCase(supertest, postCaseReq);

const cases = await findCases({ supertest, query: { severity: CaseSeverity.CRITICAL } });

expect(cases).to.eql({
...findCasesResp,
total: 0,
cases: [],
});
});

it('filters by reporters', async () => {
const postedCase = await createCase(supertest, postCaseReq);
const cases = await findCases({ supertest, query: { reporters: 'elastic' } });
Expand Down

0 comments on commit b342e20

Please sign in to comment.