From 6518d713873f02108bfa1555a7ab5b5641399d0c Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Thu, 5 Oct 2023 13:44:26 -0400 Subject: [PATCH] [8.11] [ftr] fix url check by excluding port (#168112) (#168128) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Backport This will backport the following commits from `main` to `8.11`: - [[ftr] fix url check by excluding port (#168112)](https://github.com/elastic/kibana/pull/168112) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) Co-authored-by: Dzmitry Lemechko --- test/functional/page_objects/common_page.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/test/functional/page_objects/common_page.ts b/test/functional/page_objects/common_page.ts index 61297aea12e4e..9e48ac1ea7e36 100644 --- a/test/functional/page_objects/common_page.ts +++ b/test/functional/page_objects/common_page.ts @@ -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 @@ -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})`); + } } }); }