[Infra UI] Hosts view test: fix apm services link (#162147)

Closes https://github.com/elastic/kibana/issues/162051
Closes #159368
## Summary

This PR aims to make the APM services link test more stable. For some
reason, some of the query parameters are not present in the URL the
moment we navigate but we can see in the screenshot that the correct
dates are applied (it could be that the moment we load APM the URL is
not updated - when checking locally those parameters exist in the URL)
<img width="1612" alt="image"
src="2363108a-329e-4f28-a0d8-9f177d01d4ef">

---------

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
jennypavlova 2023-07-19 10:30:43 +02:00 committed by GitHub
parent 0a6b5e92b8
commit e98abd0fb5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -150,6 +150,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
const returnTo = async (path: string, timeout = 2000) =>
retry.waitForWithTimeout('returned to hosts view', timeout, async () => {
await browser.goBack();
await pageObjects.header.waitUntilLoadingHasFinished();
const currentUrl = await browser.getCurrentUrl();
return !!currentUrl.match(path);
});
@ -245,9 +246,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
});
});
// FLAKY: https://github.com/elastic/kibana/issues/162051
// FLAKY: https://github.com/elastic/kibana/issues/159368
describe.skip('#Single host Flyout', () => {
describe('#Single host Flyout', () => {
before(async () => {
await setHostViewEnabled(true);
await pageObjects.common.navigateToApp(HOSTS_VIEW_PATH);
@ -419,22 +418,18 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
});
});
it('should navigate to APM services after click', async () => {
await pageObjects.infraHostsView.clickFlyoutApmServicesLink();
const url = parse(await browser.getCurrentUrl());
describe('Flyout links', () => {
it('should navigate to APM services after click', async () => {
await pageObjects.infraHostsView.clickFlyoutApmServicesLink();
const url = parse(await browser.getCurrentUrl());
const query = decodeURIComponent(url.query ?? '');
const kuery = 'kuery=host.hostname:"Jennys-MBP.fritz.box"';
const query = decodeURIComponent(url.query ?? '');
expect(url.pathname).to.eql('/app/apm/services');
expect(query).to.contain(kuery);
const kuery = 'kuery=host.hostname:"Jennys-MBP.fritz.box"';
const rangeFrom = 'rangeFrom=2023-03-28T18:20:00.000Z';
const rangeTo = 'rangeTo=2023-03-28T18:21:00.000Z';
expect(url.pathname).to.eql('/app/apm/services');
expect(query).to.contain(kuery);
expect(query).to.contain(rangeFrom);
expect(query).to.contain(rangeTo);
await returnTo(HOSTS_VIEW_PATH);
await returnTo(HOSTS_VIEW_PATH);
});
});
});