Skip to content

Commit

Permalink
fix links for rule monitoring table (#104473)
Browse files Browse the repository at this point in the history
  • Loading branch information
angorayc authored Jul 6, 2021
1 parent 8564b3a commit d5ca242
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { newRule } from '../../objects/rule';
import { RULES_MONIROTING_TABLE, RULE_NAME } from '../../screens/alerts_detection_rules';
import { goToManageAlertsDetectionRules, waitForAlertsIndexToBeCreated } from '../../tasks/alerts';
import { createCustomRuleActivated } from '../../tasks/api_calls/rules';
import { cleanKibana, reload } from '../../tasks/common';
import { loginAndWaitForPageWithoutDateRange } from '../../tasks/login';
import { ALERTS_URL } from '../../urls/navigation';

describe('Rules talbes links', () => {
beforeEach(() => {
cleanKibana();
loginAndWaitForPageWithoutDateRange(ALERTS_URL);
goToManageAlertsDetectionRules();
waitForAlertsIndexToBeCreated();
createCustomRuleActivated(newRule, 'rule1');

reload();
});

it('should render correct link for rule name - rules', () => {
cy.get(RULE_NAME).first().click();
cy.url().should('contain', 'rules/id/');
});

it('should render correct link for rule name - rule monitoring', () => {
cy.get(RULES_MONIROTING_TABLE).first().click();
cy.get(RULE_NAME).first().click();
cy.url().should('contain', 'rules/id/');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ export const RULES_TABLE = '[data-test-subj="rules-table"]';

export const RULES_ROW = '.euiTableRow';

export const RULES_MONIROTING_TABLE = '[data-test-subj="allRulesTableTab-monitoring"]';

export const SEVENTH_RULE = 6;

export const SEVERITY = '[data-test-subj="severity"]';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ export const getColumns = ({
};

export const getMonitoringColumns = (
history: H.History,
navigateToApp: (appId: string, options?: NavigateToAppOptions | undefined) => Promise<void>,
formatUrl: FormatUrl
): RulesStatusesColumns[] => {
const cols: RulesStatusesColumns[] = [
Expand All @@ -326,7 +326,10 @@ export const getMonitoringColumns = (
data-test-subj="ruleName"
onClick={(ev: { preventDefault: () => void }) => {
ev.preventDefault();
history.push(getRuleDetailsUrl(item.id));
navigateToApp(APP_ID, {
deepLinkId: SecurityPageName.rules,
path: getRuleDetailsUrl(item.id),
});
}}
href={formatUrl(getRuleDetailsUrl(item.id))}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,8 @@ export const RulesTables = React.memo<RulesTableProps>(
reFetchRules,
]);

const monitoringColumns = useMemo(() => getMonitoringColumns(history, formatUrl), [
history,
const monitoringColumns = useMemo(() => getMonitoringColumns(navigateToApp, formatUrl), [
navigateToApp,
formatUrl,
]);

Expand Down

0 comments on commit d5ca242

Please sign in to comment.