Skip to content

Commit

Permalink
revert tetst / remove PageTitleContentForAnomaly story
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwizp committed Sep 27, 2024
1 parent bb7e9e9 commit e7ba815
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { Subset } from '../../typings';
import { useKibana } from '../../utils/kibana_react';
import { kibanaStartMock } from '../../utils/kibana_react.mock';
import { render } from '../../utils/test_helper';
import { AlertDetails } from './alert_details';
import { AlertDetails, getPageTitle } from './alert_details';
import { alertDetail, alertWithNoData } from './mock/alert';

jest.mock('react-router-dom', () => ({
Expand Down Expand Up @@ -128,6 +128,34 @@ describe('Alert details', () => {
config
);

describe('getPageTitle', () => {
const renderPageTitle = (ruleCategory: string) =>
render(
<IntlProvider locale="en">
<span data-test-subj="title">{getPageTitle(ruleCategory)}</span>
</IntlProvider>,
config
);

it('should display Log threshold title', () => {
const { getByTestId } = renderPageTitle('Log threshold');

expect(getByTestId('title').textContent).toContain('Log threshold breached');
});

it('should display Anomaly title', () => {
const { getByTestId } = renderPageTitle('Anomaly');

expect(getByTestId('title').textContent).toContain('Anomaly detected');
});

it('should display Inventory title', () => {
const { getByTestId } = renderPageTitle('Inventory');

expect(getByTestId('title').textContent).toContain('Inventory threshold breached');
});
});

it('should show the alert detail page with all necessary components', async () => {
useFetchAlertDetailMock.mockReturnValue([false, alertDetail]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const RELATED_ALERTS_TAB_ID = 'related_alerts';
const ALERT_DETAILS_TAB_URL_STORAGE_KEY = 'tabId';
type TabId = typeof OVERVIEW_TAB_ID | typeof METADATA_TAB_ID | typeof RELATED_ALERTS_TAB_ID;

const getPageTitle = (ruleCategory: string) => {
export const getPageTitle = (ruleCategory: string) => {
return i18n.translate('xpack.observability.pages.alertDetails.pageTitle.title', {
defaultMessage:
'{ruleCategory} {ruleCategory, select, Anomaly {detected} Inventory {threshold breached} other {breached}}',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import React from 'react';
import { ComponentStory } from '@storybook/react';
import { EuiPageTemplate } from '@elastic/eui';
import { ALERT_RULE_CATEGORY } from '@kbn/rule-data-utils';

import { PageTitleContent as Component, PageTitleContentProps } from './page_title_content';
import { alert } from '../mock/alert';
Expand Down Expand Up @@ -38,19 +37,6 @@ const defaultProps = {
export const PageTitleContent = Template.bind({});
PageTitleContent.args = defaultProps;

export const PageTitleContentForAnomaly = Template.bind({});
PageTitleContentForAnomaly.args = {
...{
alert: {
...defaultProps.alert,
fields: {
...defaultProps.alert.fields,
[ALERT_RULE_CATEGORY]: 'Anomaly',
},
},
},
};

export const PageTitleUsedWithinPageTemplate = TemplateWithPageTemplate.bind({});
PageTitleUsedWithinPageTemplate.args = {
...defaultProps,
Expand Down

0 comments on commit e7ba815

Please sign in to comment.