fix graph ftr test

This commit is contained in:
alex prozorov 2025-04-08 11:47:17 +03:00
parent 9551d840eb
commit 7be44d7d1f
5 changed files with 21 additions and 4 deletions

View file

@ -341,7 +341,7 @@ describe.skip('GraphInvestigation Component', () => {
// Assert
expect(onInvestigateInTimeline).toHaveBeenCalled();
expect(onInvestigateInTimeline.mock.calls[0][QUERY_PARAM_IDX]).toEqual({
query: 'host1',
query: '(host1) OR event.id: "1" OR event.id: "2"',
language: 'kuery',
});
expect(onInvestigateInTimeline.mock.calls[0][FILTERS_PARAM_IDX]).toEqual([]);

View file

@ -141,12 +141,18 @@ export const GraphInvestigation = memo<GraphInvestigationProps>(
let filters = [...searchFilters];
if (query.query.trim() === '' && searchFilters?.length === 0 && originEventIds.length > 0) {
if ((query.query.trim() === '' || searchFilters.length > 0) && originEventIds.length > 0) {
filters = originEventIds.reduce<Filter[]>((acc, { id }) => {
return addFilter(dataView?.id ?? '', acc, EVENT_ID, id);
}, searchFilters);
}
if (query.query.trim() !== '' && searchFilters.length === 0 && originEventIds.length > 0) {
query.query = `(${query.query})${originEventIds
.map(({ id }) => ` OR ${EVENT_ID}: "${id}"`)
.join('')}`;
}
onInvestigateInTimeline?.(query, filters, timeRange);
}, [dataView?.id, onInvestigateInTimeline, originEventIds, kquery, searchFilters, timeRange]);

View file

@ -80,6 +80,17 @@ export class TimelinePageObject extends FtrService {
return eventRows.length > 0;
}
/**
* Check to see if the timeline is empty
*/
async isTimelineEmpty(): Promise<boolean> {
const eventRows = await this.testSubjects.findService.allByCssSelector(
`${testSubjSelector(TIMELINE_MODAL_PAGE_TEST_SUBJ)} [role="row"]`
);
return eventRows.length === 0;
}
/**
* Waits for events to be displayed in the timeline. It will click on the "Refresh" button to trigger a data fetch
* @param timeoutMs

View file

@ -159,7 +159,7 @@ export default function ({ getPageObjects, getService }: SecurityTelemetryFtrPro
await expandedFlyoutGraph.setKqlQuery('cannotFindThis');
await expandedFlyoutGraph.clickOnInvestigateInTimelineButton();
await timelinePage.ensureTimelineIsOpen();
await timelinePage.waitForEvents();
await timelinePage.isTimelineEmpty();
});
});
}

View file

@ -150,7 +150,7 @@ export default function ({ getPageObjects, getService }: SecurityTelemetryFtrPro
await expandedFlyoutGraph.setKqlQuery('cannotFindThis');
await expandedFlyoutGraph.clickOnInvestigateInTimelineButton();
await timelinePage.ensureTimelineIsOpen();
await timelinePage.waitForEvents();
await timelinePage.isTimelineEmpty();
});
});
}