Skip to content

Commit

Permalink
[7.x] make inserting timestamp with navigate methods optional with de…
Browse files Browse the repository at this point in the history
…fault true (#64655) (#64826)
  • Loading branch information
Lee Drengenberg authored Apr 30, 2020
1 parent 361e761 commit 7d313c3
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions test/functional/page_objects/common_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo
ensureCurrentUrl: boolean;
shouldLoginIfPrompted: boolean;
useActualUrl: boolean;
insertTimestamp: boolean;
}

class CommonPage {
Expand All @@ -65,7 +66,7 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo
* Logins to Kibana as default user and navigates to provided app
* @param appUrl Kibana URL
*/
private async loginIfPrompted(appUrl: string) {
private async loginIfPrompted(appUrl: string, insertTimestamp: boolean) {
let currentUrl = await browser.getCurrentUrl();
log.debug(`currentUrl = ${currentUrl}\n appUrl = ${appUrl}`);
await testSubjects.find('kibanaChrome', 6 * defaultFindTimeout); // 60 sec waiting
Expand All @@ -87,15 +88,21 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo
'[data-test-subj="kibanaChrome"] nav:not(.ng-hide)',
6 * defaultFindTimeout
);
await browser.get(appUrl);
await browser.get(appUrl, insertTimestamp);
currentUrl = await browser.getCurrentUrl();
log.debug(`Finished login process currentUrl = ${currentUrl}`);
}
return currentUrl;
}

private async navigate(navigateProps: NavigateProps) {
const { appConfig, ensureCurrentUrl, shouldLoginIfPrompted, useActualUrl } = navigateProps;
const {
appConfig,
ensureCurrentUrl,
shouldLoginIfPrompted,
useActualUrl,
insertTimestamp,
} = navigateProps;
const appUrl = getUrl.noAuth(config.get('servers.kibana'), appConfig);

await retry.try(async () => {
Expand All @@ -111,7 +118,7 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo
}

const currentUrl = shouldLoginIfPrompted
? await this.loginIfPrompted(appUrl)
? await this.loginIfPrompted(appUrl, insertTimestamp)
: await browser.getCurrentUrl();

if (ensureCurrentUrl && !currentUrl.includes(appUrl)) {
Expand All @@ -134,6 +141,7 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo
ensureCurrentUrl = true,
shouldLoginIfPrompted = true,
useActualUrl = false,
insertTimestamp = true,
} = {}
) {
const appConfig = {
Expand All @@ -146,6 +154,7 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo
ensureCurrentUrl,
shouldLoginIfPrompted,
useActualUrl,
insertTimestamp,
});
}

Expand All @@ -165,6 +174,7 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo
ensureCurrentUrl = true,
shouldLoginIfPrompted = true,
useActualUrl = true,
insertTimestamp = true,
} = {}
) {
const appConfig = {
Expand All @@ -178,6 +188,7 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo
ensureCurrentUrl,
shouldLoginIfPrompted,
useActualUrl,
insertTimestamp,
});
}

Expand Down Expand Up @@ -208,7 +219,7 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo

async navigateToApp(
appName: string,
{ basePath = '', shouldLoginIfPrompted = true, hash = '' } = {}
{ basePath = '', shouldLoginIfPrompted = true, hash = '', insertTimestamp = true } = {}
) {
let appUrl: string;
if (config.has(['apps', appName])) {
Expand Down Expand Up @@ -239,7 +250,7 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo
log.debug('returned from get, calling refresh');
await browser.refresh();
let currentUrl = shouldLoginIfPrompted
? await this.loginIfPrompted(appUrl)
? await this.loginIfPrompted(appUrl, insertTimestamp)
: await browser.getCurrentUrl();

if (currentUrl.includes('app/kibana')) {
Expand Down

0 comments on commit 7d313c3

Please sign in to comment.