[Security Solution][Endpoint] Un-skip response console FTR test and fix intermittent StaleElementReferenceError (#158295)

## Summary

- Fixes an intermittent failure for Stale Element when testing response
console access from timeline
- Un-skips test

Fixes #139260
This commit is contained in:
Paul Tavares 2023-05-26 14:35:41 -04:00 committed by GitHub
parent b2355a9d33
commit 9cd94336bc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 16 deletions

View file

@ -63,6 +63,9 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
let timeline: TimelineResponse;
before(async () => {
log.info(
`Creating timeline for events from host: ${indexedData.hosts[0].host.hostname} (agent id: ${indexedData.hosts[0].agent.id})`
);
timeline = await timelineTestService.createTimelineForEndpointAlerts(
'endpoint in timeline',
{
@ -83,7 +86,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
timeline.data.persistTimeline.timeline.savedObjectId
);
await pageObjects.timeline.setDateRange('Last 1 year');
await pageObjects.timeline.waitForEvents(60_000);
await pageObjects.timeline.waitForEvents(60_000 * 2);
});
after(async () => {

View file

@ -121,8 +121,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
});
});
// FLAKY: https://github.com/elastic/kibana/issues/139260
describe.skip('from timeline', () => {
describe('from timeline', () => {
let timeline: TimelineResponse;
let indexedAlerts: IndexedEndpointRuleAlerts;
@ -178,7 +177,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
timeline.data.persistTimeline.timeline.savedObjectId
);
await pageObjects.timeline.setDateRange('Last 1 year');
await pageObjects.timeline.waitForEvents(60_000);
await pageObjects.timeline.waitForEvents(MAX_WAIT_FOR_ALERTS_TIMEOUT);
// Show event/alert details for the first one in the list
await pageObjects.timeline.showEventDetails();
@ -218,7 +217,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
await pageObjects.detections.navigateToAlerts(
`query=(language:kuery,query:'host.hostname: "${hostname}" ')`
);
await pageObjects.detections.waitForListToHaveAlerts();
await pageObjects.detections.waitForListToHaveAlerts(MAX_WAIT_FOR_ALERTS_TIMEOUT);
await pageObjects.detections.openFirstAlertDetailsForHostName(hostname);
await pageObjects.detections.openResponseConsoleFromAlertDetails();
await performResponderSanityChecks();

View file

@ -206,7 +206,7 @@ export class DetectionsPageObject extends FtrService {
*/
async clickRefresh(): Promise<void> {
await this.ensureOnAlertsPage();
this.testSubjects.click('querySubmitButton');
await this.testSubjects.click('querySubmitButton');
// wait for refresh to complete
await this.retry.waitFor(

View file

@ -31,6 +31,7 @@ export class TimelinePageObject extends FtrService {
private readonly testSubjects = this.ctx.getService('testSubjects');
private readonly retry = this.ctx.getService('retry');
private readonly defaultTimeoutMs = this.ctx.getService('config').get('timeouts.waitFor');
private readonly logger = this.ctx.getService('log');
async navigateToTimelineList(): Promise<void> {
await this.pageObjects.common.navigateToUrlWithBrowserHistory('securitySolutionTimelines');
@ -90,35 +91,49 @@ export class TimelinePageObject extends FtrService {
*/
async clickRefresh(): Promise<void> {
await this.ensureTimelineIsOpen();
await this.pageObjects.header.waitUntilLoadingHasFinished();
await (
await this.testSubjects.findService.byCssSelector(TIMELINE_CSS_SELECTOR.refreshButton)
).isEnabled();
await this.testSubjects.findService.clickByCssSelector(TIMELINE_CSS_SELECTOR.refreshButton);
await this.retry.waitFor(
'Timeline refresh button to be enabled',
async (): Promise<boolean> => {
const refreshButton = await this.testSubjects.findService.byCssSelector(
TIMELINE_CSS_SELECTOR.refreshButton
);
return (await refreshButton.isDisplayed()) && (await refreshButton.isEnabled());
return (
await this.testSubjects.findService.byCssSelector(TIMELINE_CSS_SELECTOR.refreshButton)
).isEnabled();
}
);
}
/**
* Check to see if the timeline has events in the list
*/
async hasEvents(): Promise<boolean> {
const eventRows = await this.testSubjects.findService.allByCssSelector(
`${testSubjSelector(TIMELINE_MODAL_PAGE_TEST_SUBJ)} ${testSubjSelector('event')}`
);
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
*/
async waitForEvents(timeoutMs?: number): Promise<void> {
if (await this.hasEvents()) {
this.logger.info(`Timeline already has events displayed`);
return;
}
await this.retry.waitForWithTimeout(
'waiting for events to show up on timeline',
timeoutMs ?? this.defaultTimeoutMs,
async (): Promise<boolean> => {
await this.clickRefresh();
const allEventRows = await this.testSubjects.findService.allByCssSelector(
`${testSubjSelector(TIMELINE_MODAL_PAGE_TEST_SUBJ)} ${testSubjSelector('event')}`
);
return Boolean(allEventRows.length);
return this.hasEvents();
}
);
}