Skip to content

Commit

Permalink
[ftr] fix url check by excluding port (elastic#168112)
Browse files Browse the repository at this point in the history
## Summary

Addressing MKI `commonPage.navigateToUrl()` failures when `actualUrl`
contains port value.

```
✖ fail: Serverless Common UI - Management Data View Management disables scripted fields Scripted fields tab is missing
--
  | │      Error: retry.try timeout: Error: expected https://bk-serverless-ftr-185-elasticsearch-e79c7a.kb.eu-west-1.aws.qa.elastic.cloud/app/management/kibana/dataViews.includes(https://bk-serverless-ftr-185-elasticsearch-e79c7a.kb.eu-west-1.aws.qa.elastic.cloud:443/app/management/kibana/dataViews)
```

Works both on MKI and local serverless run.

(cherry picked from commit 6301dc8)
  • Loading branch information
dmlemeshko committed Oct 5, 2023
1 parent 5aee3c4 commit 793b096
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions test/functional/page_objects/common_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ export class CommonPageObject extends FtrService {
private readonly defaultTryTimeout = this.config.get('timeouts.try');
private readonly defaultFindTimeout = this.config.get('timeouts.find');

private getUrlWithoutPort(urlStr: string) {
const url = new URL(urlStr);
url.port = '';
return url.toString();
}

/**
* Logins to Kibana as default user and navigates to provided app
* @param appUrl Kibana URL
Expand Down Expand Up @@ -121,8 +127,13 @@ export class CommonPageObject extends FtrService {
throw new Error(msg);
}

if (ensureCurrentUrl && !currentUrl.includes(appUrl)) {
throw new Error(`expected ${currentUrl}.includes(${appUrl})`);
if (ensureCurrentUrl) {
const actualUrl = this.getUrlWithoutPort(currentUrl);
const expectedUrl = this.getUrlWithoutPort(appUrl);

if (!actualUrl.includes(expectedUrl)) {
throw new Error(`expected ${actualUrl}.includes(${expectedUrl})`);
}
}
});
}
Expand Down

0 comments on commit 793b096

Please sign in to comment.