Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make inserting timestamp with navigate methods optional with default true #64655

Merged
merged 1 commit into from
Apr 29, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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