Attempt to fix AlertSummaryWidget flaky test (#212107)

Fixes #198102

## Summary

The check that fails is related to status:All
[here](https://github.com/elastic/kibana/blob/main/x-pack/test/observability_functional/apps/observability/pages/rule_details_page.ts#L191):

```
expect(url.includes('status%3Aall')).to.be(true);
```

It seems the status is active from the previous step:

<img
src="https://github.com/user-attachments/assets/8fa33035-d54a-4bfd-9e06-fff696767598"
width=500 />


This PR adds a retry to accommodate a delay in changing URLs.

Co-authored-by: Dominique Clarke <dominique.clarke@elastic.co>
This commit is contained in:
Maryam Saeidi 2025-02-25 21:13:04 +01:00 committed by GitHub
parent 1ee97c3c8f
commit 3b1c352df9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -168,14 +168,16 @@ export default ({ getService }: FtrProviderContext) => {
await observability.components.alertSummaryWidget.getActiveAlertSelector();
await activeAlerts.click();
const url = await browser.getCurrentUrl();
const from = 'rangeFrom:now-30d';
const to = 'rangeTo:now';
await retry.try(async () => {
const url = await browser.getCurrentUrl();
const from = 'rangeFrom:now-30d';
const to = 'rangeTo:now';
expect(url.includes('tabId=alerts')).to.be(true);
expect(url.includes('status%3Aactive')).to.be(true);
expect(url.includes(from.replaceAll(':', '%3A'))).to.be(true);
expect(url.includes(to.replaceAll(':', '%3A'))).to.be(true);
expect(url.includes('tabId=alerts')).to.be(true);
expect(url.includes('status%3Aactive')).to.be(true);
expect(url.includes(from.replaceAll(':', '%3A'))).to.be(true);
expect(url.includes(to.replaceAll(':', '%3A'))).to.be(true);
});
});
it('handles clicking on total alerts correctly', async () => {
@ -183,14 +185,16 @@ export default ({ getService }: FtrProviderContext) => {
await observability.components.alertSummaryWidget.getTotalAlertSelector();
await totalAlerts.click();
const url = await browser.getCurrentUrl();
const from = 'rangeFrom:now-30d';
const to = 'rangeTo:now';
await retry.try(async () => {
const url = await browser.getCurrentUrl();
const from = 'rangeFrom:now-30d';
const to = 'rangeTo:now';
expect(url.includes('tabId=alerts')).to.be(true);
expect(url.includes('status%3Aall')).to.be(true);
expect(url.includes(from.replaceAll(':', '%3A'))).to.be(true);
expect(url.includes(to.replaceAll(':', '%3A'))).to.be(true);
expect(url.includes('tabId=alerts')).to.be(true);
expect(url.includes('status%3Aall')).to.be(true);
expect(url.includes(from.replaceAll(':', '%3A'))).to.be(true);
expect(url.includes(to.replaceAll(':', '%3A'))).to.be(true);
});
});
});