Skip to content

Commit

Permalink
fix unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
dplumlee committed Jan 4, 2024
1 parent 2cfc275 commit 4b13726
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export * from './prebuilt_rules/create_prebuilt_rule_saved_objects';
export * from './prebuilt_rules/install_prebuilt_rules_and_timelines';
export * from './get_simple_rule_update';
export * from './get_simple_ml_rule_update';
export * from './create_non_security_rule';
export * from './get_simple_rule_as_ndjson';
export * from './rule_to_ndjson';
export * from './delete_rule';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import {
COVERAGE_OVERVIEW_ENABLE_ALL_DISABLED_BUTTON,
COVERAGE_OVERVIEW_POPOVER_DISABLED_RULES,
COVERAGE_OVERVIEW_POPOVER_ENABLED_RULES,
COVERAGE_OVERVIEW_TACTIC_DISABLED_STATS,
COVERAGE_OVERVIEW_TACTIC_ENABLED_STATS,
COVERAGE_OVERVIEW_TACTIC_PANEL,
COVERAGE_OVERVIEW_TECHNIQUE_TITLE,
} from '../../../../screens/rules_coverage_overview';
import { createRule } from '../../../../tasks/api_calls/rules';
Expand Down Expand Up @@ -368,32 +371,59 @@ describe('Coverage overview', { tags: ['@ess', '@serverless'] }, () => {
getNewRule({
rule_id: 'duplicate_technique_rule_2',
name: 'Rule with tactic 2',
enabled: true,
enabled: false,
threat: [MockCustomRuleDuplicateTechniqueThreat2],
})
);
visit(RULES_COVERAGE_OVERVIEW_URL);
});

it('technique panel renders rule data when the same technique exists in multiple tactics', () => {
it('technique panels render unique rule data', () => {
selectCoverageOverviewActivityFilterOption('Disabled rules');

// Open duplicated technique panel under first tactic
cy.get(COVERAGE_OVERVIEW_TECHNIQUE_TITLE(DuplicateTechniqueMitreData1.technique.id))
.first()
.click();
cy.get(COVERAGE_OVERVIEW_POPOVER_ENABLED_RULES)
.contains('Rule with tactic 1')
.should('not.exist');

cy.get(COVERAGE_OVERVIEW_POPOVER_ENABLED_RULES).contains('Rule with tactic 2');
cy.get(COVERAGE_OVERVIEW_POPOVER_DISABLED_RULES).contains('Rule with tactic 2');

// Open duplicated technique panel under second tactic
cy.get(COVERAGE_OVERVIEW_TECHNIQUE_TITLE(DuplicateTechniqueMitreData2.technique.id))
.last()
.click();
cy.get(COVERAGE_OVERVIEW_POPOVER_ENABLED_RULES).contains('Rule with tactic 1');
cy.get(COVERAGE_OVERVIEW_POPOVER_ENABLED_RULES)
cy.get(COVERAGE_OVERVIEW_POPOVER_DISABLED_RULES)
.contains('Rule with tactic 2')
.should('not.exist');
});

it('tactic panels render correct rule stats', () => {
selectCoverageOverviewActivityFilterOption('Disabled rules');

// Validate rule count stats for first tactic
cy.get(COVERAGE_OVERVIEW_TACTIC_PANEL)
.contains(DuplicateTechniqueMitreData1.tactic.name)
.get(COVERAGE_OVERVIEW_TACTIC_ENABLED_STATS)
.contains('0');

cy.get(COVERAGE_OVERVIEW_TACTIC_PANEL)
.contains(DuplicateTechniqueMitreData1.tactic.name)
.get(COVERAGE_OVERVIEW_TACTIC_DISABLED_STATS)
.contains('1');

// Validate rule count stats for second tactic
cy.get(COVERAGE_OVERVIEW_TACTIC_PANEL)
.contains(DuplicateTechniqueMitreData2.tactic.name)
.get(COVERAGE_OVERVIEW_TACTIC_ENABLED_STATS)
.contains('1');

cy.get(COVERAGE_OVERVIEW_TACTIC_PANEL)
.contains(DuplicateTechniqueMitreData2.tactic.name)
.get(COVERAGE_OVERVIEW_TACTIC_DISABLED_STATS)
.contains('0');
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,11 @@ export const COVERAGE_OVERVIEW_SOURCE_FILTER_BUTTON =
export const COVERAGE_OVERVIEW_FILTER_LIST = '[data-test-subj="coverageOverviewFilterList"]';

export const COVERAGE_OVERVIEW_SEARCH_BAR = '[data-test-subj="coverageOverviewFilterSearchBar"]';

export const COVERAGE_OVERVIEW_TACTIC_PANEL = '[data-test-subj="coverageOverviewTacticPanel"]';

export const COVERAGE_OVERVIEW_TACTIC_ENABLED_STATS =
'[data-test-subj="ruleStatsEnabledRulesCount"]';

export const COVERAGE_OVERVIEW_TACTIC_DISABLED_STATS =
'[data-test-subj="ruleStatsDisabledRulesCount"]';

0 comments on commit 4b13726

Please sign in to comment.