Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
[Cases] Add guardrails for add and update comment API #161200
[Cases] Add guardrails for add and update comment API #161200
Changes from 3 commits
dd10222
f87deb5
c719484
74868c0
a3795f6
28004e9
480adef
75eb73a
3ca8625
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add some tests for the
CommentRequestRt
to verify the validation. In general, I think it is nice if we created a strong linked chain of tests. For example, we test theCommentRequestRt
with all possible testing scenarios. Then we test theaddComment
andbulkCreate
but there there is no need to check all possible testing scenarios (unless there is new logic on top of it). One is enough to ensure the integration between the function and the schema. The chain now isaddComment
->CommentRequestRt
. If the tests inCommentRequestRt
pass we are sure thataddComment
will work correctly because we have at least one test that tests the integration between the two. Lastly, with integration tests, we check the integration between theaddComment
and the route.This article explains the concept in detail: https://www.jamesshore.com/v2/projects/nullables/testing-without-mocks#sociable-tests
cc @adcoelho
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wondered about this but we need to guarantee somehow that (in this case)
CommentRequestRt
is being used byaddComment
andbulkCreate
.Is this what you mean with
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh okay, so just checking if I understood it correctly,
long comment, empty string
etc should be part ofCommentRequestRt
tests inx-pack/plugins/cases/common/api/cases/comment/index.test.ts
addComment, update and bulk create
just tests the integration withCommentRequestRt
with one testroute
andpost_comment, patch_comment, bulk_create_attachments
integration with one test?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the difference between
updateComment
andactionComment
?Edit: I know it is the type 😅 but more specifically, how are they different in practice?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think @cnasikas can answer it 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a user isolates a host from the alerts flyout the security solution team adds a comment to a case + some information about the host etc. At the time we did not have the attachment framework so this became a core attachment type.