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] Update button text according to status #80389

Merged
merged 8 commits into from
Oct 15, 2020

Conversation

angorayc
Copy link
Contributor

@angorayc angorayc commented Oct 13, 2020

Summary

This PR fixes https:/elastic/security-team/issues/36

load-rules-templates

Problem:

Before this PR, the button for loading rules and templates in Manage Detection Rules button always display Load pre-built Elastic Rules and Timeline Templates even if the templates have already been loaded.

Steps to Verify

  1. Go to x-pack/plugins/security_solution/server/lib/detection_engine/scripts, and run ./timelines/delete_all_timelines.sh to delete all the existing timelines and templates.
  2. Click on Detection tab (Make sure you haven't landed on timelines page)
  3. Click on Manage Detection Rules button
  4. Confirm the text on the button to load elastic rule & Template is Load pre-built Elastic Rules and Timeline Templates
  5. Go to timelines page, and click on template. Wait for templates to load
  6. Go back to Manage Detection Rules page, the button text should become Load pre-built Elastic Rules

Checklist

Delete any items that are not applicable to this PR.

@angorayc angorayc added release_note:skip Skip the PR/issue when compiling release notes v7.10.0 Team:Threat Hunting Security Solution Threat Hunting Team labels Oct 13, 2020
@angorayc angorayc requested review from a team as code owners October 13, 2020 17:55
expect(wrapper.find('[data-test-subj="all-rules"]').exists()).toEqual(true);
});

it('renders correct button with correct text - Load Elastic prebuilt rules and timeline templates', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

could you please refactor all of your tests to use waitFor instead of act? Whenever you see that act error on a test, you should resolve it using waitFor with enzyme mount and act with renderHook You can follow the waitFor pattern in edit_connector/index.test.tsx. I'll show you an example on this test:

import { waitFor } from '@testing-library/react';

  it('renders correct button with correct text - Load Elastic prebuilt rules and timeline templates', async () => {
    (getPrePackagedRulesStatus as jest.Mock).mockResolvedValue({
      rules_not_installed: 3,
      rules_installed: 0,
      rules_not_updated: 0,
      timelines_not_installed: 3,
      timelines_installed: 0,
      timelines_not_updated: 0,
    });

    const wrapper = mount(
      <TestProviders>
        <RulesPage />
      </TestProviders>
    );
    await waitFor(() => {
      wrapper.update();
      expect(wrapper.find('[data-test-subj="loadPrebuiltRulesBtn"]').exists()).toEqual(true);
      expect(wrapper.find('[data-test-subj="loadPrebuiltRulesBtn"]').last().text()).toEqual(
        'Load Elastic prebuilt rules and timeline templates'
      );
    });
  });

Copy link
Contributor

Choose a reason for hiding this comment

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

if you get stuck and want to zoom let me know!

Copy link
Contributor

@stephmilovic stephmilovic left a comment

Choose a reason for hiding this comment

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

Nice work here! Code looks good, great job on test coverage, manual testing is good. The only change for me is the test update I requested in my comment. Once you have that ping me for a LGTM!

Copy link
Contributor

@stephmilovic stephmilovic 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 updating those tests. This PR is ready to rock 🎸 LGTM!!

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

async chunks size

id before after diff
securitySolution 10.9MB 10.9MB +6.7KB

History

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

@angorayc angorayc merged commit 6b8e8a5 into elastic:master Oct 15, 2020
angorayc added a commit to angorayc/kibana that referenced this pull request Oct 15, 2020
…0389)

* update button text according to status

* remove unused translations

* fix functional test

* fixup

* fix unit test

* update unit tests

* update unit test
angorayc added a commit to angorayc/kibana that referenced this pull request Oct 15, 2020
…0389)

* update button text according to status

* remove unused translations

* fix functional test

* fixup

* fix unit test

* update unit tests

* update unit test
angorayc added a commit that referenced this pull request Oct 15, 2020
…80714)

* update button text according to status

* remove unused translations

* fix functional test

* fixup

* fix unit test

* update unit tests

* update unit test
angorayc added a commit that referenced this pull request Oct 15, 2020
…80715)

* update button text according to status

* remove unused translations

* fix functional test

* fixup

* fix unit test

* update unit tests

* update unit test
gmmorris added a commit to gmmorris/kibana that referenced this pull request Oct 16, 2020
* master: (115 commits)
  [ML] Transforms/DF Analytics: Fix data grid column sorting. (elastic#80618)
  added brace import to vis editor (elastic#80652)
  Fix error rate sorting in services list (elastic#80764)
  Emit info log when using custom registry URL (elastic#80768)
  [Reporting] Config Schema Validation for rules[N].protocol strings (elastic#80766)
  Add Storybook a11y addon (elastic#80069)
  Fix anomaly alert selection text (elastic#80746)
  [Security Solution] [Maps] Kibana index pattern, comma bug fix (elastic#80208)
  [kbn/optimizer] tweak split chunks options (elastic#80444)
  update template to use the new team label (elastic#80748)
  [Security Solution] Fix the Field dropdown in Timeline data providers resets when scrolled (elastic#80718)
  Adjusts observability alerting perms to require "all" (elastic#79896)
  [Security Solutions][Detection Engine] Fixes pre-packaged rules which contain exception lists to not overwrite user defined lists   (elastic#80592)
  [data.ui] Fix flaky test & lazy loading rendering artifacts. (elastic#80612)
  Licensed feature usage for connectors (elastic#77679)
  [Security Solution] Cypress template creation (elastic#80180)
  [APM] Hide service if only data is from ML (elastic#80145)
  Fix role mappings test for ESS (elastic#80604)
  [Maps] Add support for envelope (elastic#80614)
  [Security Solution] Update button text according to status (elastic#80389)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:skip Skip the PR/issue when compiling release notes Team:Threat Hunting Security Solution Threat Hunting Team v7.10.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants