Skip to content

Commit fe50183

Browse files
committed
added test files to circular dep check exception, updated some helpers per pr feedback
1 parent 80c634d commit fe50183

File tree

7 files changed

+284
-279
lines changed

7 files changed

+284
-279
lines changed

x-pack/legacy/plugins/siem/dev_tools/circular_deps/run_check_circular_deps_cli.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ run(
1717
[resolve(__dirname, '../../public'), resolve(__dirname, '../../common')],
1818
{
1919
fileExtensions: ['ts', 'js', 'tsx'],
20+
excludeRegExp: [
21+
'test.ts$',
22+
'test.tsx$',
23+
'containers/detection_engine/rules/types.ts$',
24+
'core/public/chrome/chrome_service.tsx$',
25+
'src/core/server/types.ts$',
26+
'src/core/server/saved_objects/types.ts$',
27+
'src/core/public/overlays/banners/banners_service.tsx$',
28+
'src/core/public/saved_objects/saved_objects_client.ts$',
29+
],
2030
}
2131
);
2232

x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/description_step/helpers.test.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ describe('helpers', () => {
382382
});
383383

384384
describe('buildNoteDescription', () => {
385-
test('returns ListItem with passed in label and SeverityBadge component', () => {
385+
test('returns ListItem with passed in label and note content', () => {
386386
const noteSample =
387387
'Cras mattism. [Pellentesque](https://elastic.co). ### Malesuada adipiscing tristique';
388388
const result: ListItems[] = buildNoteDescription('Test label', noteSample);
@@ -393,5 +393,11 @@ describe('helpers', () => {
393393
expect(noteElement.exists()).toBeTruthy();
394394
expect(noteElement.text()).toEqual(noteSample);
395395
});
396+
397+
test('returns empty array if passed in note is empty string', () => {
398+
const result: ListItems[] = buildNoteDescription('Test label', '');
399+
400+
expect(result).toHaveLength(0);
401+
});
396402
});
397403
});

x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/description_step/helpers.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ export const buildUrlsDescription = (label: string, values: string[]): ListItems
233233
<ul>
234234
{values
235235
.filter(v => !isEmpty(v))
236-
.map((val: string, index: number) => (
236+
.map((val, index) => (
237237
<li data-test-subj="urlsDescriptionReferenceLinkItem" key={`${index}-${val}`}>
238238
<EuiLink href={val} external target="_blank">
239239
{val}
@@ -250,7 +250,7 @@ export const buildUrlsDescription = (label: string, values: string[]): ListItems
250250
};
251251

252252
export const buildNoteDescription = (label: string, note: string): ListItems[] => {
253-
if (note) {
253+
if (note.trim() !== '') {
254254
return [
255255
{
256256
title: label,

x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/step_about_rule_details/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const FlexGroupFullHeight = styled(EuiFlexGroup)`
3434
`;
3535

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

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

7474
const onResize = (e: { height: number; width: number }) => {
7575
setAboutPanelHeight(e.height);
@@ -87,7 +87,7 @@ const StepAboutRuleToggleDetailsComponent: React.FC<StepPanelProps> = ({
8787
<FlexGroupFullHeight gutterSize="xs" direction="column">
8888
<EuiFlexItem grow={1}>
8989
<HeaderSection title={i18n.ABOUT_TEXT}>
90-
{!isEmpty(stepDataDetails.note) && (
90+
{!isEmpty(stepDataDetails.note) && stepDataDetails.note.trim() !== '' && (
9191
<EuiButtonGroup
9292
options={toggleOptions}
9393
idSelected={selectedToggleOption}

x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/details/index.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ import * as detectionI18n from '../../translations';
5353
import { ReadOnlyCallOut } from '../components/read_only_callout';
5454
import { RuleSwitch } from '../components/rule_switch';
5555
import { StepPanel } from '../components/step_panel';
56-
import { getStepsDataDetails, redirectToDetections } from '../helpers';
56+
import { getStepsData, redirectToDetections } from '../helpers';
5757
import * as ruleI18n from '../translations';
5858
import * as i18n from './translations';
5959
import { GlobalTime } from '../../../../containers/global_time';
@@ -105,12 +105,12 @@ const RuleDetailsPageComponent: FC<PropsFromRedux> = ({
105105
// This is used to re-trigger api rule status when user de/activate rule
106106
const [ruleEnabled, setRuleEnabled] = useState<boolean | null>(null);
107107
const [ruleDetailTab, setRuleDetailTab] = useState(RuleDetailTabs.signals);
108-
const { aboutRuleData, aboutRuleDataDetails, defineRuleData, scheduleRuleData } =
108+
const { aboutRuleData, modifiedAboutRuleDetailsData, defineRuleData, scheduleRuleData } =
109109
rule != null
110-
? getStepsDataDetails(rule)
110+
? getStepsData({ rule, detailsView: true })
111111
: {
112112
aboutRuleData: null,
113-
aboutRuleDataDetails: null,
113+
modifiedAboutRuleDetailsData: null,
114114
defineRuleData: null,
115115
scheduleRuleData: null,
116116
};
@@ -299,7 +299,7 @@ const RuleDetailsPageComponent: FC<PropsFromRedux> = ({
299299
<StepAboutRuleToggleDetails
300300
loading={isLoading}
301301
stepData={aboutRuleData}
302-
stepDataDetails={aboutRuleDataDetails}
302+
stepDataDetails={modifiedAboutRuleDetailsData}
303303
/>
304304
</EuiFlexItem>
305305

0 commit comments

Comments
 (0)