From 7f69c23a7d9640cd6bffc25aaf7f54b5f4376f1f Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Thu, 5 Oct 2023 13:30:42 -0400 Subject: [PATCH] [8.10] [ftr] fix url check by excluding port (#168112) (#168127) 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.10`: - [[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 1424d952653cd..dbb66351e21d7 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})`); + } } }); }