Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cnasikas committed Apr 20, 2022
1 parent c621b3a commit 197f4f4
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 29 deletions.
29 changes: 2 additions & 27 deletions x-pack/plugins/cases/common/ui/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

import type { SavedObjectsResolveResponse } from '@kbn/core/public';
import {
CaseAttributes,
CaseConnector,
CasePatchRequest,
CaseStatuses,
User,
Expand All @@ -17,6 +15,7 @@ import {
CaseUserActionResponse,
CaseMetricsResponse,
CommentResponse,
CaseResponse,
CommentResponseAlertsType,
} from '../api';
import { SnakeToCamelCase } from '../types';
Expand Down Expand Up @@ -61,31 +60,7 @@ export type Comment = SnakeToCamelCase<CommentResponse>;
export type AlertComment = SnakeToCamelCase<CommentResponseAlertsType>;
export type CaseUserActions = SnakeToCamelCase<CaseUserActionResponse>;
export type CaseExternalService = SnakeToCamelCase<CaseExternalServiceBasic>;

interface BasicCase {
id: string;
owner: string;
closedAt: string | null;
closedBy: ElasticUser | null;
comments: Comment[];
createdAt: string;
createdBy: ElasticUser;
status: CaseStatuses;
title: string;
totalAlerts: number;
totalComment: number;
updatedAt: string | null;
updatedBy: ElasticUser | null;
version: string;
}

export interface Case extends BasicCase {
connector: CaseConnector;
description: string;
externalService: CaseExternalService | null;
settings: CaseAttributes['settings'];
tags: string[];
}
export type Case = Omit<SnakeToCamelCase<CaseResponse>, 'comments'> & { comments: Comment[] };

export interface ResolvedCase {
case: Case;
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/cases/public/containers/mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ export const basicCase: Case = {
fields: null,
},
description: 'Security banana Issue',
duration: null,
externalService: null,
status: CaseStatuses.open,
tags,
Expand Down Expand Up @@ -245,6 +246,7 @@ export const mockCase: Case = {
type: ConnectorTypes.none,
fields: null,
},
duration: null,
description: 'Security banana Issue',
externalService: null,
status: CaseStatuses.open,
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/cases/server/client/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ describe('utils', () => {
"username": "elastic",
},
"description": "A description",
"duration": null,
"external_service": null,
"owner": "securitySolution",
"settings": Object {
Expand Down
8 changes: 8 additions & 0 deletions x-pack/plugins/cases/server/common/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ describe('common utils', () => {
"username": "elastic",
},
"description": "This is a brand new case of a bad meanie defacing data",
"duration": null,
"external_service": null,
"id": "mock-id-1",
"owner": "securitySolution",
Expand Down Expand Up @@ -141,6 +142,7 @@ describe('common utils', () => {
"username": "elastic",
},
"description": "Oh no, a bad meanie destroying data!",
"duration": null,
"external_service": null,
"id": "mock-id-2",
"owner": "securitySolution",
Expand Down Expand Up @@ -183,6 +185,7 @@ describe('common utils', () => {
"username": "elastic",
},
"description": "Oh no, a bad meanie going LOLBins all over the place!",
"duration": null,
"external_service": null,
"id": "mock-id-3",
"owner": "securitySolution",
Expand Down Expand Up @@ -229,6 +232,7 @@ describe('common utils', () => {
"username": "elastic",
},
"description": "Oh no, a bad meanie going LOLBins all over the place!",
"duration": null,
"external_service": null,
"id": "mock-id-4",
"owner": "securitySolution",
Expand Down Expand Up @@ -292,6 +296,7 @@ describe('common utils', () => {
"username": "elastic",
},
"description": "Oh no, a bad meanie going LOLBins all over the place!",
"duration": null,
"external_service": null,
"id": "mock-id-3",
"owner": "securitySolution",
Expand Down Expand Up @@ -346,6 +351,7 @@ describe('common utils', () => {
"username": "elastic",
},
"description": "Oh no, a bad meanie going LOLBins all over the place!",
"duration": null,
"external_service": null,
"id": "mock-id-3",
"owner": "securitySolution",
Expand Down Expand Up @@ -423,6 +429,7 @@ describe('common utils', () => {
"username": "elastic",
},
"description": "Oh no, a bad meanie going LOLBins all over the place!",
"duration": null,
"external_service": null,
"id": "mock-id-3",
"owner": "securitySolution",
Expand Down Expand Up @@ -475,6 +482,7 @@ describe('common utils', () => {
"username": "elastic",
},
"description": "This is a brand new case of a bad meanie defacing data",
"duration": null,
"external_service": null,
"id": "mock-id-1",
"owner": "securitySolution",
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/cases/server/services/cases/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ describe('CasesService', () => {
"username": "elastic",
},
"description": "This is a brand new case of a bad meanie defacing data",
"duration": null,
"owner": "securitySolution",
"settings": Object {
"syncAlerts": true,
Expand Down Expand Up @@ -500,6 +501,7 @@ describe('CasesService', () => {
"username": "elastic",
},
"description": "This is a brand new case of a bad meanie defacing data",
"duration": null,
"external_service": Object {
"connector_name": ".jira",
"external_id": "100",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,11 @@ export default ({ getService }: FtrProviderContext): void => {
const userActions = await getCaseUserActions({ supertest, caseID: postedCase.id });
const statusUserAction = removeServerGeneratedPropertiesFromUserAction(userActions[1]);
const data = removeServerGeneratedPropertiesFromCase(patchedCases[0]);
const { duration, ...dataWithoutDuration } = data;
const { duration: resDuration, ...resWithoutDuration } = postCaseResp();

expect(data).to.eql({
...postCaseResp(),
expect(dataWithoutDuration).to.eql({
...resWithoutDuration,
status: CaseStatuses.closed,
closed_by: defaultUser,
updated_by: defaultUser,
Expand Down

0 comments on commit 197f4f4

Please sign in to comment.