Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,9 @@ describe('helpers', () => {
});
const wrapper = shallow<React.ReactElement>(result[0].description as React.ReactElement);
expect(result[0].title).toEqual('Mitre Attack');
expect(wrapper.find('[data-test-subj="threatTacticLink"]').text()).toEqual('');
expect(wrapper.find('[data-test-subj="threatTacticLink"]').text()).toEqual(
'Collection (TA000999)'
);
expect(wrapper.find('[data-test-subj="threatTechniqueLink"]').text()).toEqual(
'Audio Capture (T1123)'
);
Expand All @@ -234,7 +236,9 @@ describe('helpers', () => {
expect(wrapper.find('[data-test-subj="threatTacticLink"]').text()).toEqual(
'Collection (TA0009)'
);
expect(wrapper.find('[data-test-subj="threatTechniqueLink"]').text()).toEqual('');
expect(wrapper.find('[data-test-subj="threatTechniqueLink"]').text()).toEqual(
'Audio Capture (T1123456)'
);
});

test('returns empty technique link if no corresponding subtechnique id found', () => {
Expand Down Expand Up @@ -265,7 +269,9 @@ describe('helpers', () => {
expect(wrapper.find('[data-test-subj="threatTechniqueLink"]').text()).toEqual(
'Audio Capture (T1123)'
);
expect(wrapper.find('[data-test-subj="threatSubtechniqueLink"]').text()).toEqual('');
expect(wrapper.find('[data-test-subj="threatSubtechniqueLink"]').text()).toEqual(
'Audio Capture Data (T1123.000123)'
);
});

test('returns with corresponding tactic, technique, and subtechnique link text', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ export const buildThreatDescription = ({ label, threat }: BuildThreatDescription
href={singleThreat.tactic.reference}
target="_blank"
>
{tactic != null ? tactic.text : ''}
{tactic != null
? tactic.text
: `${singleThreat.tactic.name} (${singleThreat.tactic.id})`}
Comment on lines +154 to +156
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to change or anything, but just noting that instead of a ternary you could use optional chaining + nullish coalescing to pair this down a bit if you'd like.

e.g.

{tactic?.text ?? `${singleThreat.tactic.name} (${singleThreat.tactic.id})`}

</EuiLink>
<EuiFlexGroup gutterSize="none" alignItems="flexStart" direction="column">
{singleThreat.technique.map((technique, techniqueIndex) => {
Expand All @@ -165,7 +167,9 @@ export const buildThreatDescription = ({ label, threat }: BuildThreatDescription
iconType={ListTreeIcon}
size="xs"
>
{myTechnique != null ? myTechnique.label : ''}
{myTechnique != null
? myTechnique.label
: `${technique.name} (${technique.id})`}
</TechniqueLinkItem>
<EuiFlexGroup gutterSize="none" alignItems="flexStart" direction="column">
{technique.subtechnique != null &&
Expand All @@ -184,7 +188,9 @@ export const buildThreatDescription = ({ label, threat }: BuildThreatDescription
iconType={ListTreeIcon}
size="xs"
>
{mySubtechnique != null ? mySubtechnique.label : ''}
{mySubtechnique != null
? mySubtechnique.label
: `${subtechnique.name} (${subtechnique.id})`}
</TechniqueLinkItem>
</SubtechniqueFlexItem>
);
Expand Down