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

[page_objects/common_page] convert to ts #50771

Merged
merged 5 commits into from
Nov 18, 2019

Conversation

dmlemeshko
Copy link
Member

Summary

Covert common_page.js to ts and simplify the logic

Checklist

Use strikethroughs to remove checklist items you don't feel are applicable to this PR.

For maintainers

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@dmlemeshko dmlemeshko marked this pull request as ready for review November 15, 2019 19:26
@dmlemeshko dmlemeshko requested a review from a team as a code owner November 15, 2019 19:26
private async loginIfPrompted(appUrl: string) {
let currentUrl = await browser.getCurrentUrl();
log.debug(`currentUrl = ${currentUrl}\n appUrl = ${appUrl}`);
await find.byCssSelector('[data-test-subj="kibanaChrome"]', 6 * defaultFindTimeout); // 60 sec waiting
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decreased timeout from 4 min to 1 min because it makes sense to fail and retry from scratch with url navigation rather than wait so long for the page to be loaded

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious, why private?

Copy link
Member Author

@dmlemeshko dmlemeshko Nov 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it is used only in the same class as a helper function. For the tests we expose navigation functions, e.g. navigateToApp and use { shouldLoginIfPrompted: boolean } to manage login. I'm open to change it, but not sure we want it to be used directly

});
}

log.debug('navigating to ' + appName + ' url: ' + appUrl);

function navigateTo(url) {
return retry.try(function () {
await retry.tryForTime(defaultTryTimeout * 2, async () => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decreased retry timeout from 6 min to 4 min since it should be fairly enough time for navigation + login, in case of failure we should get a screenshot with stack trace instead of mocha timeout

// since we're using hash URLs, always reload first to force re-render
return kibanaServer.uiSettings.getDefaultIndex()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed this line since we didn't use the return result. Not sure what was the purpose?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was code here at one time that checked if the default index was set when we tried to navigate to Discover, Visualize, Dashboard (but not Management). If you didn't have it set, it would set it to logstash-* and log a warning message. Maybe we fixed any tests which weren't setting the default index, in which case that code isn't needed any more.


if (!navSuccessful) {
const msg =
'App failed to load: ' +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it required to break this up into so many lines :-(

image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A template literal would make this much more readable.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, I will fix it :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in a362ca3

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@dmlemeshko
Copy link
Member Author

retest

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@dmlemeshko
Copy link
Member Author

retest

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@dmlemeshko
Copy link
Member Author

@elasticmachine merge upstream

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Member

@mistic mistic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes LGTM in the perspective of the operations team code owners files

// Browsers don't show the ':port' if it's 80 or 443 so we have to
// remove that part so we can get a match in the tests.
const navSuccessful = new RegExp(
appUrl.replace(':80/', '/').replace(':443/', '/') +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be shorter (just less code to read)

Suggested change
appUrl.replace(':80/', '/').replace(':443/', '/') +
appUrl.replace(/:80\/|:443\//, '/') +

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dmlemeshko If you have to re-push, maybe this suggestion is useful.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool @wayneseymour, I didn't notice it. I will push next time :)

Copy link
Contributor

@LeeDr LeeDr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dmlemeshko dmlemeshko merged commit 6bc43bb into elastic:master Nov 18, 2019
dmlemeshko added a commit to dmlemeshko/kibana that referenced this pull request Nov 18, 2019
* [page_objects/common_page] convert to ts

* fix lint errors

* descrease navigation timeouts

* use template literal for log messages
dmlemeshko added a commit to dmlemeshko/kibana that referenced this pull request Nov 18, 2019
* [page_objects/common_page] convert to ts

* fix lint errors

* descrease navigation timeouts

* use template literal for log messages
jloleysens added a commit to jloleysens/kibana that referenced this pull request Nov 18, 2019
…-fallback

* 'master' of github.com:elastic/kibana: (116 commits)
  [Maps] move apply global filter settting from layer to source (elastic#50523)
  [SIEM] Fix: Empty `Source` / `Destination` shown when only ports are populated (elastic#50843)
  [Maps] Delay vector tile layer syncing until spritesheet is loaded (elastic#48955)
  [Maps] prevent users from overflowing URL when filtering by shape (elastic#50747)
  [DOCS] Mark Beats central management as discontinued (elastic#49423)
  [page_objects/common_page] convert to ts (elastic#50771)
  [NP Kibana Migrations ] kibana plugin home (elastic#50444)
  [DOCS] Shareables naming convention (elastic#50497)
  [ML] DF Analytics - auto-populate model_memory_limit (elastic#50714)
  Increase alerting test stability and reduce flakiness (elastic#50246)
  [ML] Remaning new_job_new folder (elastic#50917)
  [Telemetry] Show opt-in changes for OSS users (elastic#50831)
  [ML] Fix lat_long anomalies table links menu and value formatting (elastic#50916)
  [Dev] Fix serialising a really big string (elastic#50915)
  Better explanation about the Prettier recommendation (extension vs. NPM module) (elastic#50629)
  [Monitoring] Use a basic monitoring user for tests (elastic#47865)
  [Monitoring] Gracefully handle issue with filebeat indices (elastic#48929)
  [Monitoring] Improve permissions required around setup mode (elastic#50421)
  Additional validation for elasticsearch username (elastic#48247)
  Revert changes to use_kibana_ui_setting (elastic#50877)
  ...

# Conflicts:
#	src/legacy/core_plugins/console/server/request.test.ts
dmlemeshko added a commit that referenced this pull request Nov 18, 2019
* [page_objects/common_page] convert to ts

* fix lint errors

* descrease navigation timeouts

* use template literal for log messages
dmlemeshko added a commit that referenced this pull request Nov 18, 2019
* [page_objects/common_page] convert to ts

* fix lint errors

* descrease navigation timeouts

* use template literal for log messages
@dmlemeshko dmlemeshko deleted the ftr/ts-common_page branch March 24, 2020 07:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants