From 8a4b95b0d4305415bebfd1cf8e135cab8b2a9e2f Mon Sep 17 00:00:00 2001 From: Jatin Kathuria Date: Wed, 14 Aug 2024 15:11:22 +0200 Subject: [PATCH] chore: better namings --- .../use_investigate_in_timeline.test.tsx | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/x-pack/plugins/security_solution/public/detections/components/alerts_table/timeline_actions/use_investigate_in_timeline.test.tsx b/x-pack/plugins/security_solution/public/detections/components/alerts_table/timeline_actions/use_investigate_in_timeline.test.tsx index 45b8b9f66961d..6d20ef3973337 100644 --- a/x-pack/plugins/security_solution/public/detections/components/alerts_table/timeline_actions/use_investigate_in_timeline.test.tsx +++ b/x-pack/plugins/security_solution/public/detections/components/alerts_table/timeline_actions/use_investigate_in_timeline.test.tsx @@ -84,7 +84,7 @@ const getEcsDataWithRuleTypeAndTimelineTemplate = (ruleType: string, ecsData: Ec } as Ecs; }; -const getNonEcsDataWithRuleType = ( +const getNonEcsDataWithRuleTypeAndTimelineTemplate = ( ruleType: string, nonEcsData: TimelineEventsDetailsItem[] = nonECSRowData ) => { @@ -135,7 +135,7 @@ const mockTimelineTemplateResponse = { { and: [], enabled: true, - id: 'event-field-default-timeline-1-host_name-0-jatins-macbook-pro_local', + id: 'some-random-id', name: 'host.name', excluded: false, kqlQuery: '', @@ -233,9 +233,9 @@ const RULE_TYPES_TO_BE_TESTED = [ 'query', 'esql', 'eql', + 'machine_learning', /* TODO: Complete test suites for below rule types */ // 'new_terms', - // 'machine_learning', // 'eql', // 'threshold', // 'threat_match', @@ -258,7 +258,9 @@ const renderContextMenu = (items: AlertTableContextMenuItem[]) => { describe('useInvestigateInTimeline', () => { let mockSearchStrategyClient = { - search: jest.fn().mockReturnValue(of({ data: getNonEcsDataWithRuleType('query') })), + search: jest + .fn() + .mockReturnValue(of({ data: getNonEcsDataWithRuleTypeAndTimelineTemplate('query') })), }; beforeEach(() => { (getTimelineTemplate as jest.Mock).mockResolvedValue(mockTimelineTemplateResponse); @@ -275,7 +277,7 @@ describe('useInvestigateInTimeline', () => { afterEach(() => { jest.clearAllMocks(); }); - test('it creates a component and click handler', () => { + test('creates a component and click handler', () => { const { result } = renderHook(() => useInvestigateInTimeline(props), { wrapper: TestProviders, }); @@ -300,9 +302,11 @@ describe('useInvestigateInTimeline', () => { describe('investigate an alert with timeline template', () => { describe.each(RULE_TYPES_TO_BE_TESTED)('Rule type : %s', (ruleType: string) => { - it('should copy columns over from template', async () => { + test('should copy columns over from template', async () => { mockSearchStrategyClient = { - search: jest.fn().mockReturnValue(of({ data: getNonEcsDataWithRuleType(ruleType) })), + search: jest + .fn() + .mockReturnValue(of({ data: getNonEcsDataWithRuleTypeAndTimelineTemplate(ruleType) })), }; const ecsData = getEcsDataWithRuleTypeAndTimelineTemplate(ruleType); const { result } = renderHook( @@ -345,9 +349,11 @@ describe('useInvestigateInTimeline', () => { ); }); }); - it('should copy dataProviders over from template', async () => { + test('should copy dataProviders over from template', async () => { mockSearchStrategyClient = { - search: jest.fn().mockReturnValue(of({ data: getNonEcsDataWithRuleType(ruleType) })), + search: jest + .fn() + .mockReturnValue(of({ data: getNonEcsDataWithRuleTypeAndTimelineTemplate(ruleType) })), }; const ecsData: Ecs = getEcsDataWithRuleTypeAndTimelineTemplate(ruleType); const { result } = renderHook( @@ -361,7 +367,7 @@ describe('useInvestigateInTimeline', () => { { and: [], enabled: true, - id: 'event-field-default-timeline-1-host_name-0-jatins-macbook-pro_local', + id: 'some-random-id', name: 'some host name', excluded: false, kqlQuery: '',