[8.6] quick check of current URL to skip timepicker (#146462) (#146954)

# Backport

This will backport the following commits from `main` to `8.6`:
- [quick check of current URL to skip timepicker
(#146462)](https://github.com/elastic/kibana/pull/146462)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Lee
Drengenberg","email":"lee.drengenberg@elastic.co"},"sourceCommit":{"committedDate":"2022-12-04T20:50:50Z","message":"quick
check of current URL to skip timepicker (#146462)\n\n##
Summary\r\n\r\nWe have some tests which set the default time but then
also call\r\nsetAbsoluteTime in every test. This PR adds code in
setAbsoluteTime to\r\nquickly check if the desired start and end (from
and to) times are\r\nalready set, and if so, just return. The end result
should be less time\r\nspent on functional tests. It could also reduce
occasional flakiness\r\nsetting the time.\r\n\r\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\r\nCo-authored-by:
Dzmitry Lemechko
<dzmitry.lemechko@elastic.co>","sha":"1734b0e5db897453bcd532f2896234aa15db8139","branchLabelMapping":{"^v8.7.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:QA","test_ui_functional","test_xpack_functional","release_note:skip","backport:prev-minor","v8.7.0"],"number":146462,"url":"https://github.com/elastic/kibana/pull/146462","mergeCommit":{"message":"quick
check of current URL to skip timepicker (#146462)\n\n##
Summary\r\n\r\nWe have some tests which set the default time but then
also call\r\nsetAbsoluteTime in every test. This PR adds code in
setAbsoluteTime to\r\nquickly check if the desired start and end (from
and to) times are\r\nalready set, and if so, just return. The end result
should be less time\r\nspent on functional tests. It could also reduce
occasional flakiness\r\nsetting the time.\r\n\r\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\r\nCo-authored-by:
Dzmitry Lemechko
<dzmitry.lemechko@elastic.co>","sha":"1734b0e5db897453bcd532f2896234aa15db8139"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.7.0","labelRegex":"^v8.7.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/146462","number":146462,"mergeCommit":{"message":"quick
check of current URL to skip timepicker (#146462)\n\n##
Summary\r\n\r\nWe have some tests which set the default time but then
also call\r\nsetAbsoluteTime in every test. This PR adds code in
setAbsoluteTime to\r\nquickly check if the desired start and end (from
and to) times are\r\nalready set, and if so, just return. The end result
should be less time\r\nspent on functional tests. It could also reduce
occasional flakiness\r\nsetting the time.\r\n\r\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\r\nCo-authored-by:
Dzmitry Lemechko
<dzmitry.lemechko@elastic.co>","sha":"1734b0e5db897453bcd532f2896234aa15db8139"}}]}]
BACKPORT-->

Co-authored-by: Lee Drengenberg <lee.drengenberg@elastic.co>
This commit is contained in:
Kibana Machine 2022-12-04 16:43:36 -05:00 committed by GitHub
parent f380be5287
commit ff7d73d304
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -123,8 +123,21 @@ export class TimePickerPageObject extends FtrService {
/**
* @param {String} fromTime MMM D, YYYY @ HH:mm:ss.SSS
* @param {String} toTime MMM D, YYYY @ HH:mm:ss.SSS
* @param {Boolean} force time picker force update, default is false
*/
public async setAbsoluteRange(fromTime: string, toTime: string) {
public async setAbsoluteRange(fromTime: string, toTime: string, force = false) {
if (!force) {
const currentUrl = decodeURI(await this.browser.getCurrentUrl());
const DEFAULT_DATE_FORMAT = 'MMM D, YYYY @ HH:mm:ss.SSS';
const startMoment = moment.utc(fromTime, DEFAULT_DATE_FORMAT).toISOString();
const endMoment = moment.utc(toTime, DEFAULT_DATE_FORMAT).toISOString();
if (currentUrl.includes(`time:(from:'${startMoment}',to:'${endMoment}'`)) {
this.log.debug(
`We already have the desired start (${fromTime}) and end (${toTime}) in the URL, returning from setAbsoluteRange`
);
return;
}
}
this.log.debug(`Setting absolute range to ${fromTime} to ${toTime}`);
await this.showStartEndTimes();
let panel!: WebElementWrapper;