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

[Security Solution][Detections] Adds exception modal tests #74596

Merged
merged 8 commits into from
Aug 18, 2020

Conversation

dplumlee
Copy link
Contributor

@dplumlee dplumlee commented Aug 6, 2020

Summary

Adds jest tests for the add and edit exception modals to cover all current state variations based on props

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@dplumlee dplumlee force-pushed the exceptions-modal-tests branch 2 times, most recently from 7ebdf20 to 4b54bdb Compare August 10, 2020 18:19
@dplumlee dplumlee added Feature:Detection Rules Security Solution rules and Detection Engine release_note:skip Skip the PR/issue when compiling release notes Team:SIEM v7.10.0 v8.0.0 labels Aug 14, 2020
@dplumlee dplumlee marked this pull request as ready for review August 14, 2020 19:28
@dplumlee dplumlee requested review from a team as code owners August 14, 2020 19:28
@elasticmachine
Copy link
Contributor

Pinging @elastic/siem (Team:SIEM)

@dplumlee dplumlee force-pushed the exceptions-modal-tests branch from 9c1524b to 2346c39 Compare August 14, 2020 19:29
@@ -259,7 +259,8 @@ export const EditExceptionModal = memo(function EditExceptionModal({
<ModalBodySection>
<EuiFormRow fullWidth>
<EuiCheckbox
id="close-alert-on-add-add-exception-checkbox"
data-test-subj="close-alert-on-add-edit-exception-checkbox"
id="close-alert-on-add-edit-exception-checkbox"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need this id here do you? Looks like above you're using data-test-subj successfully?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i believe the id is a required field for the EuiCheckbox, would spit out a console warning and potentially cause usage problems if not there.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah looking at the docs and searching around this looks like it is required.

ruleIndices={['filebeat-*']}
ruleName={ruleName}
exceptionListType={'endpoint'}
onCancel={() => {}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: If you search through the code base most of the time people across the plugins and code base do this when stubbing out no operations:

jest.fn()

Makes it easier as a stub that it won't blow up later on as it's more accepting of what can call it, etc...

For example:

onCancel={jest.fn()}

wrapper.find('button[data-test-subj="add-exception-confirm-button"]').getDOMNode()
).not.toBeDisabled();
});

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Seems weird to have a new line break here but not between the describe blocks or other it blocks?

I would change the newlines you have to be consistent. The new lines between test/it/describe blocks seem to be what most people do everywhere across plugins. Some people don't though (which is not a biggie to me which way to choose as long as consistency within a single file is maintained.

For a "science based reason" if I was going to make the argument of using new line blocks between it blocks and it/describe blocks is that spacing is a "pre-attentive attribute" meaning that when reading blocks of code we will naturally group things based on spacial distance between things before having to think consciously so it makes it easier to read them. Several posts about this and the other preattentive attributes is out there and good reads IMHO.

http://daydreamingnumbers.com/blog/preattentive-attributes-example/

makes kind of sense when you think about how the IDE adds color in some aspects to make things stand out.

@@ -112,7 +112,7 @@ export const AddExceptionComments = memo(function AddExceptionComments({
<EuiFlexItem grow={1}>
<EuiTextArea
placeholder={i18n.ADD_COMMENT_PLACEHOLDER}
aria-label="Use aria labels when no actual label is in use"
aria-label="Comment Input"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch! 👍

@dplumlee dplumlee force-pushed the exceptions-modal-tests branch from 94f0ca3 to 4cf0023 Compare August 17, 2020 16:20
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Build metrics

async chunks size

id value diff baseline
securitySolution 7.2MB +439.0B 7.2MB

History

  • 💚 Build #68254 succeeded 94f0ca3c0d4175f355eaa27d362f8ac956d03df8
  • 💔 Build #68247 failed 16956993cf2addbb9d2a9211417e7e8724e41058
  • 💚 Build #68229 succeeded 2346c392ac1765fbfd7f6a04c39bcd72382b94a5
  • 💚 Build #68021 succeeded 3a57767fe8a4f20b87051f0f51e7b4b14c5ded47
  • 💚 Build #67813 succeeded 4452cd7184a7f529c5e9c53beabfd55a7e432251

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

Copy link
Contributor

@FrankHassanabad FrankHassanabad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the good catches on aria-label, explanations on the id, and the unit tests

Copy link
Contributor

@peluja1012 peluja1012 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this coverage!

@dplumlee dplumlee merged commit bfdaacd into elastic:master Aug 18, 2020
@dplumlee dplumlee deleted the exceptions-modal-tests branch August 18, 2020 15:20
dplumlee added a commit to dplumlee/kibana that referenced this pull request Aug 18, 2020
gmmorris added a commit to gmmorris/kibana that referenced this pull request Aug 18, 2020
* master:
  Skip failing test in CI (elastic#75266)
  [Task Manager] time out work when it overruns in poller (elastic#74980)
  [Drilldowns] misc improvements & fixes (elastic#75276)
  Small README note on bumping memory for builds (elastic#75247)
  [Security Solution][Detections] Adds exception modal tests (elastic#74596)
  [Dashboard] Sample data link does not work (elastic#75262)
  [Dashboard First] Unlink from Library Action With ReferenceOrValueEmbeddable (elastic#74905)
  [Form lib] Fix issue where serializer on fields are called on every change (elastic#75166)
  convert processor labels to sentence case (elastic#75278)
  [Monaco] Refactor the way XJSON grammar checker gets registered (elastic#75160)
  Clarify no documents error message when filtering by is_training (elastic#75227)
  [Lens] Fix crash when two layers xychart  switches to pie (elastic#75267)
  [Observability Homepage] Fix console error because of side effect (elastic#75258)
  [Usage Collection] Add `legacy=true` option to the /api/stats request in the docs (elastic#75146)
  [ML] Functional tests - re-activate DFA test suites (elastic#75257)
  GS providers improvements (elastic#75174)
  [Visualize] First version of by-value visualize editor (elastic#72256)
gmmorris added a commit to gmmorris/kibana that referenced this pull request Aug 19, 2020
…emove-header

* saved-objects/version-on-create: (59 commits)
  remove version when loading sample data
  omit version from SO import/export
  Skip failing test in CI (elastic#75266)
  [Task Manager] time out work when it overruns in poller (elastic#74980)
  [Drilldowns] misc improvements & fixes (elastic#75276)
  Small README note on bumping memory for builds (elastic#75247)
  [Security Solution][Detections] Adds exception modal tests (elastic#74596)
  Revert "Revert "added missing core docs""
  Revert "Revert "added version to saved object bulk creation""
  [Dashboard] Sample data link does not work (elastic#75262)
  [Dashboard First] Unlink from Library Action With ReferenceOrValueEmbeddable (elastic#74905)
  [Form lib] Fix issue where serializer on fields are called on every change (elastic#75166)
  convert processor labels to sentence case (elastic#75278)
  [Monaco] Refactor the way XJSON grammar checker gets registered (elastic#75160)
  Clarify no documents error message when filtering by is_training (elastic#75227)
  [Lens] Fix crash when two layers xychart  switches to pie (elastic#75267)
  [Observability Homepage] Fix console error because of side effect (elastic#75258)
  [Usage Collection] Add `legacy=true` option to the /api/stats request in the docs (elastic#75146)
  [ML] Functional tests - re-activate DFA test suites (elastic#75257)
  GS providers improvements (elastic#75174)
  ...
@MindyRS MindyRS added the Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. label Sep 23, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-solution (Team: SecuritySolution)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Detection Rules Security Solution rules and Detection Engine release_note:skip Skip the PR/issue when compiling release notes Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. Team:SIEM v7.10.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants