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

[SIEM] [Cases] Case container unit tests #63376

Merged
merged 11 commits into from
Apr 14, 2020
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
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
122 changes: 122 additions & 0 deletions x-pack/legacy/plugins/siem/public/containers/case/__mocks__/api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import {
ActionLicense,
AllCases,
BulkUpdateStatus,
Case,
CasesStatus,
CaseUserActions,
FetchCasesProps,
SortFieldCase,
} from '../types';
import {
actionLicenses,
allCases,
basicCase,
basicCaseCommentPatch,
basicCasePost,
casesStatus,
caseUserActions,
pushedCase,
respReporters,
serviceConnector,
tags,
} from '../mock';
import {
CaseExternalServiceRequest,
CasePatchRequest,
CasePostRequest,
CommentRequest,
ServiceConnectorCaseParams,
ServiceConnectorCaseResponse,
User,
} from '../../../../../../../plugins/case/common/api';

export const getCase = async (
caseId: string,
includeComments: boolean = true,
signal: AbortSignal
): Promise<Case> => {
return Promise.resolve(basicCase);
};

export const getCasesStatus = async (signal: AbortSignal): Promise<CasesStatus> =>
Promise.resolve(casesStatus);

export const getTags = async (signal: AbortSignal): Promise<string[]> => Promise.resolve(tags);

export const getReporters = async (signal: AbortSignal): Promise<User[]> =>
Promise.resolve(respReporters);

export const getCaseUserActions = async (
caseId: string,
signal: AbortSignal
): Promise<CaseUserActions[]> => Promise.resolve(caseUserActions);

export const getCases = async ({
filterOptions = {
search: '',
reporters: [],
status: 'open',
tags: [],
},
queryParams = {
page: 1,
perPage: 5,
sortField: SortFieldCase.createdAt,
sortOrder: 'desc',
},
signal,
}: FetchCasesProps): Promise<AllCases> => Promise.resolve(allCases);

export const postCase = async (newCase: CasePostRequest, signal: AbortSignal): Promise<Case> =>
Promise.resolve(basicCasePost);

export const patchCase = async (
caseId: string,
updatedCase: Pick<CasePatchRequest, 'description' | 'status' | 'tags' | 'title'>,
version: string,
signal: AbortSignal
): Promise<Case[]> => Promise.resolve([basicCase]);

export const patchCasesStatus = async (
cases: BulkUpdateStatus[],
signal: AbortSignal
): Promise<Case[]> => Promise.resolve(allCases.cases);

export const postComment = async (
newComment: CommentRequest,
caseId: string,
signal: AbortSignal
): Promise<Case> => Promise.resolve(basicCase);

export const patchComment = async (
caseId: string,
commentId: string,
commentUpdate: string,
version: string,
signal: AbortSignal
): Promise<Case> => Promise.resolve(basicCaseCommentPatch);

export const deleteCases = async (caseIds: string[], signal: AbortSignal): Promise<boolean> =>
Promise.resolve(true);

export const pushCase = async (
caseId: string,
push: CaseExternalServiceRequest,
signal: AbortSignal
): Promise<Case> => Promise.resolve(pushedCase);

export const pushToService = async (
connectorId: string,
casePushParams: ServiceConnectorCaseParams,
signal: AbortSignal
): Promise<ServiceConnectorCaseResponse> => Promise.resolve(serviceConnector);

export const getActionLicense = async (signal: AbortSignal): Promise<ActionLicense[]> =>
Promise.resolve(actionLicenses);
Loading