From 793b0964c92da4428bcef03da2df4b444b572b8f Mon Sep 17 00:00:00 2001 From: Dzmitry Lemechko Date: Thu, 5 Oct 2023 18:28:46 +0200 Subject: [PATCH] [ftr] fix url check by excluding port (#168112) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 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 6301dc83843d2fad546a02edcef68ad9a6715937) --- 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})`); + } } }); }