Skip to content

Commit

Permalink
Fixing comments type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-buttner committed May 2, 2023
1 parent 82e6df2 commit 9d018cf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@ import { join } from 'path';
import { SavedObject } from '@kbn/core/server';
import supertest from 'supertest';
import {
CASES_URL,
CASE_SAVED_OBJECT,
CASE_USER_ACTION_SAVED_OBJECT,
CASE_COMMENT_SAVED_OBJECT,
} from '@kbn/cases-plugin/common/constants';
import {
AttributesTypeUser,
Comments,
CaseAttributes,
CasePostRequest,
PushedUserAction,
Expand All @@ -39,6 +37,7 @@ import {
createComment,
findCases,
getCaseUserActions,
findAttachments,
} from '../../../../common/lib/api';
import { getPostCaseRequest, postCommentUserReq } from '../../../../common/lib/mock';
import { FtrProviderContext } from '../../../../common/ftr_provider_context';
Expand Down Expand Up @@ -102,10 +101,10 @@ export default ({ getService }: FtrProviderContext): void => {
expect(findResponse.cases[0].title).to.eql('A case to export');
expect(findResponse.cases[0].description).to.eql('a description');

const { body: commentsResponse }: { body: Comments } = await supertestService
.get(`${CASES_URL}/${findResponse.cases[0].id}/comments/_find`)
.send()
.expect(200);
const commentsResponse = await findAttachments({
supertest: supertestService,
caseId: findResponse.cases[0].id,
});

const comment = commentsResponse.comments[0] as unknown as AttributesTypeUser;
expect(comment.comment).to.eql('A comment for my case');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import expect from '@kbn/expect';

import { CASES_URL } from '@kbn/cases-plugin/common/constants';
import { Comments } from '@kbn/cases-plugin/common/api';
import { CommentsFindResponse } from '@kbn/cases-plugin/common/api';
import { FtrProviderContext } from '../../../../common/ftr_provider_context';
import {
getPostCaseRequest,
Expand All @@ -26,6 +26,7 @@ import {
getSpaceUrlPrefix,
createCase,
superUserSpace1Auth,
findAttachments,
} from '../../../../common/lib/api';

import {
Expand Down Expand Up @@ -221,10 +222,11 @@ export default ({ getService }: FtrProviderContext): void => {
caseID: obsCase.id,
},
]) {
const { body: caseComments }: { body: Comments } = await supertestWithoutAuth
.get(`${getSpaceUrlPrefix(space1)}${CASES_URL}/${scenario.caseID}/comments/_find`)
.auth(scenario.user.username, scenario.user.password)
.expect(200);
const caseComments = await findAttachments({
supertest: supertestWithoutAuth,
caseId: scenario.caseID,
auth: { user: scenario.user, space: space1 },
});

ensureSavedObjectIsAuthorized(
caseComments.comments,
Expand Down Expand Up @@ -279,7 +281,7 @@ export default ({ getService }: FtrProviderContext): void => {
caseId: obsCase.id,
});

const { body: res }: { body: Comments } = await supertestWithoutAuth
const { body: res }: { body: CommentsFindResponse } = await supertestWithoutAuth
.get(
`${getSpaceUrlPrefix('space1')}${CASES_URL}/${
obsCase.id
Expand Down

0 comments on commit 9d018cf

Please sign in to comment.