Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ describe('AddComment ', () => {

await waitFor(() => {
expect(onCommentSaving).toBeCalled();
expect(postComment).toBeCalledWith(sampleData, onCommentPosted);
expect(postComment).toBeCalledWith(addCommentProps.caseId, sampleData, onCommentPosted);
expect(wrapper.find(`[data-test-subj="add-comment"] textarea`).text()).toBe('');
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ interface AddCommentProps {
export const AddComment = React.memo(
forwardRef<AddCommentRefObject, AddCommentProps>(
({ caseId, disabled, showLoading = true, onCommentPosted, onCommentSaving }, ref) => {
const { isLoading, postComment } = usePostComment(caseId);
const { isLoading, postComment } = usePostComment();

const { form } = useForm<AddCommentFormSchema>({
defaultValue: initialCommentValue,
Expand Down Expand Up @@ -79,10 +79,10 @@ export const AddComment = React.memo(
if (onCommentSaving != null) {
onCommentSaving();
}
postComment({ ...data, type: CommentType.user }, onCommentPosted);
postComment(caseId, { ...data, type: CommentType.user }, onCommentPosted);
reset();
}
}, [onCommentPosted, onCommentSaving, postComment, reset, submit]);
}, [onCommentPosted, onCommentSaving, postComment, reset, submit, caseId]);

return (
<span id="add-comment-permLink">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,44 @@ describe('AllCases', () => {
);
await waitFor(() => {
wrapper.find('[data-test-subj="cases-table-row-1"]').first().simulate('click');
expect(onRowClick).toHaveBeenCalledWith('1');
expect(onRowClick).toHaveBeenCalledWith({
closedAt: null,
closedBy: null,
comments: [],
connector: { fields: null, id: '123', name: 'My Connector', type: '.none' },
createdAt: '2020-02-19T23:06:33.798Z',
createdBy: {
email: '[email protected]',
fullName: 'Leslie Knope',
username: 'lknope',
},
description: 'Security banana Issue',
externalService: {
connectorId: '123',
connectorName: 'connector name',
externalId: 'external_id',
externalTitle: 'external title',
externalUrl: 'basicPush.com',
pushedAt: '2020-02-20T15:02:57.995Z',
pushedBy: {
email: '[email protected]',
fullName: 'Leslie Knope',
username: 'lknope',
},
},
id: '1',
status: 'open',
tags: ['coke', 'pepsi'],
title: 'Another horrible breach!!',
totalComment: 0,
updatedAt: '2020-02-20T15:02:57.995Z',
updatedBy: {
email: '[email protected]',
fullName: 'Leslie Knope',
username: 'lknope',
},
version: 'WzQ3LDFd',
});
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const getSortField = (field: string): SortFieldCase => {
};

interface AllCasesProps {
onRowClick?: (id?: string) => void;
onRowClick?: (theCase?: Case) => void;
isModal?: boolean;
userCanCrud: boolean;
}
Expand Down Expand Up @@ -341,9 +341,9 @@ export const AllCases = React.memo<AllCasesProps>(

const onTableRowClick = useMemo(
() =>
memoize<(id: string) => () => void>((id) => () => {
memoize<(theCase: Case) => () => void>((theCase) => () => {
if (onRowClick) {
onRowClick(id);
onRowClick(theCase);
}
}),
[onRowClick]
Expand All @@ -358,7 +358,7 @@ export const AllCases = React.memo<AllCasesProps>(
if (isModal) {
return {
...rowProps,
onClick: onTableRowClick(item.id),
onClick: onTableRowClick(item),
};
}

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading