Skip to content

Commit

Permalink
added test files to circular dep check exception, updated some helper…
Browse files Browse the repository at this point in the history
…s per pr feedback
  • Loading branch information
yctercero committed Mar 17, 2020
1 parent 80c634d commit fe50183
Show file tree
Hide file tree
Showing 7 changed files with 284 additions and 279 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ run(
[resolve(__dirname, '../../public'), resolve(__dirname, '../../common')],
{
fileExtensions: ['ts', 'js', 'tsx'],
excludeRegExp: [
'test.ts$',
'test.tsx$',
'containers/detection_engine/rules/types.ts$',
'core/public/chrome/chrome_service.tsx$',
'src/core/server/types.ts$',
'src/core/server/saved_objects/types.ts$',
'src/core/public/overlays/banners/banners_service.tsx$',
'src/core/public/saved_objects/saved_objects_client.ts$',
],
}
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ describe('helpers', () => {
});

describe('buildNoteDescription', () => {
test('returns ListItem with passed in label and SeverityBadge component', () => {
test('returns ListItem with passed in label and note content', () => {
const noteSample =
'Cras mattism. [Pellentesque](https://elastic.co). ### Malesuada adipiscing tristique';
const result: ListItems[] = buildNoteDescription('Test label', noteSample);
Expand All @@ -393,5 +393,11 @@ describe('helpers', () => {
expect(noteElement.exists()).toBeTruthy();
expect(noteElement.text()).toEqual(noteSample);
});

test('returns empty array if passed in note is empty string', () => {
const result: ListItems[] = buildNoteDescription('Test label', '');

expect(result).toHaveLength(0);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ export const buildUrlsDescription = (label: string, values: string[]): ListItems
<ul>
{values
.filter(v => !isEmpty(v))
.map((val: string, index: number) => (
.map((val, index) => (
<li data-test-subj="urlsDescriptionReferenceLinkItem" key={`${index}-${val}`}>
<EuiLink href={val} external target="_blank">
{val}
Expand All @@ -250,7 +250,7 @@ export const buildUrlsDescription = (label: string, values: string[]): ListItems
};

export const buildNoteDescription = (label: string, note: string): ListItems[] => {
if (note) {
if (note.trim() !== '') {
return [
{
title: label,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const FlexGroupFullHeight = styled(EuiFlexGroup)`
`;

const VerticalOverflowContainer = styled.div((props: { maxHeight: number }) => ({
'max-height': `${props.maxHeight ?? '200'}px`,
'max-height': `${props.maxHeight}px`,
'overflow-y': 'hidden',
}));

Expand Down Expand Up @@ -69,7 +69,7 @@ const StepAboutRuleToggleDetailsComponent: React.FC<StepPanelProps> = ({
loading,
}) => {
const [selectedToggleOption, setToggleOption] = useState('details');
const [aboutPanelHeight, setAboutPanelHeight] = useState();
const [aboutPanelHeight, setAboutPanelHeight] = useState(0);

const onResize = (e: { height: number; width: number }) => {
setAboutPanelHeight(e.height);
Expand All @@ -87,7 +87,7 @@ const StepAboutRuleToggleDetailsComponent: React.FC<StepPanelProps> = ({
<FlexGroupFullHeight gutterSize="xs" direction="column">
<EuiFlexItem grow={1}>
<HeaderSection title={i18n.ABOUT_TEXT}>
{!isEmpty(stepDataDetails.note) && (
{!isEmpty(stepDataDetails.note) && stepDataDetails.note.trim() !== '' && (
<EuiButtonGroup
options={toggleOptions}
idSelected={selectedToggleOption}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ import * as detectionI18n from '../../translations';
import { ReadOnlyCallOut } from '../components/read_only_callout';
import { RuleSwitch } from '../components/rule_switch';
import { StepPanel } from '../components/step_panel';
import { getStepsDataDetails, redirectToDetections } from '../helpers';
import { getStepsData, redirectToDetections } from '../helpers';
import * as ruleI18n from '../translations';
import * as i18n from './translations';
import { GlobalTime } from '../../../../containers/global_time';
Expand Down Expand Up @@ -105,12 +105,12 @@ const RuleDetailsPageComponent: FC<PropsFromRedux> = ({
// This is used to re-trigger api rule status when user de/activate rule
const [ruleEnabled, setRuleEnabled] = useState<boolean | null>(null);
const [ruleDetailTab, setRuleDetailTab] = useState(RuleDetailTabs.signals);
const { aboutRuleData, aboutRuleDataDetails, defineRuleData, scheduleRuleData } =
const { aboutRuleData, modifiedAboutRuleDetailsData, defineRuleData, scheduleRuleData } =
rule != null
? getStepsDataDetails(rule)
? getStepsData({ rule, detailsView: true })
: {
aboutRuleData: null,
aboutRuleDataDetails: null,
modifiedAboutRuleDetailsData: null,
defineRuleData: null,
scheduleRuleData: null,
};
Expand Down Expand Up @@ -299,7 +299,7 @@ const RuleDetailsPageComponent: FC<PropsFromRedux> = ({
<StepAboutRuleToggleDetails
loading={isLoading}
stepData={aboutRuleData}
stepDataDetails={aboutRuleDataDetails}
stepDataDetails={modifiedAboutRuleDetailsData}
/>
</EuiFlexItem>

Expand Down
Loading

0 comments on commit fe50183

Please sign in to comment.