## Summary
Refactoring general ui service to a kbn package.
Resolves an [Appex QA](https://github.com/elastic/appex-qa-team) issue.
---------
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
## Summary
Related to #162995
This PR unskip TSVB tests for Chrome browser since it is proved to be
stable
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/2836
100x passed
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/2835
100x passed
On Firefox the flakiness is related to Terms 2nd aggregation field
sometimes is not selected. I tested it manually in Firefox 116 and was
able to set fields, though I have a feeling that values are not always
selected on click in the drop-down. But I didn't see any errors in
console.
I also returned back retry for dropdown selection I removed in #161202
though flaky-test-runner proves there is no need. Let's have just to
keep logic as before my PR.
Related to #158972
I was able to reproduce the failure locally on the latest main with a
small code change:
b3d7b71076/test/functional/page_objects/visual_builder_page.ts (L867-L869)
```
| debg comboBox.isOptionSelected, value: machine.os.raw
│ info Taking screenshot "/Users/dmle/github/kibana/test/functional/screenshots/failure/visualize app visual builder Time Series basics Clicking on the chart should cre-a71516dab48cdb296c45e2b439ed3965cfd400204827bba7ce3cf4719afb093b.png"
│ info Current URL is: http://localhost:5620/app/visualize#/create?type=metrics&_g=(filters:!(),refreshInterval:(pause:!t,value:60000),time:(from:%272015-09-19T06:31:44.000Z%27,to:%272015-09-22T18:31:44.000Z%27))&_a=(filters:!(),linked:!f,query:(language:kuery,query:%27%27),uiState:(),vis:(aggs:!(),params:(axis_formatter:number,axis_position:left,axis_scale:normal,drop_last_bucket:1,id:b6ee5181-addb-436f-8190-4f2a178fee7b,index_pattern:(id:%27logstash-*%27),interval:%27%27,isModelInvalid:!f,max_lines_legend:1,series:!((axis_position:right,chart_type:line,color:%2368BC00,fill:0.5,formatter:default,id:%2724f639d7-d16e-44d1-ac0d-f2b590e94e8e%27,line_width:1,metrics:!((id:d4f68ace-b844-4e00-933f-8c3b49e19067,type:count)),override_index_pattern:0,palette:(name:default,type:palette),point_size:1,separate_axis:0,series_drop_last_bucket:0,split_mode:terms,stacked:none,terms_field:!(bytes,machine.os.raw),time_range_mode:entire_time_range)),show_grid:1,show_legend:1,time_field:%27%27,time_range_mode:entire_time_range,tooltip_mode:show_all,truncate_legend:1,type:timeseries,use_kibana_indexes:!t),title:%27%27,type:metrics))
│ info Saving page source to: /Users/dmle/github/kibana/test/functional/failure_debug/html/visualize app visual builder Time Series basics Clicking on the chart should cre-a71516dab48cdb296c45e2b439ed3965cfd400204827bba7ce3cf4719afb093b.html
└- ✖ fail: visualize app visual builder Time Series basics Clicking on the chart should create a filter for series with multiple split by terms fields one of which has formatting
│ StaleElementReferenceError: stale element reference: stale element not found
│ (Session info: chrome=114.0.5735.198)
│ at Object.throwDecodedError (node_modules/selenium-webdriver/lib/error.js:524:15)
│ at parseHttpResponse (node_modules/selenium-webdriver/lib/http.js:601:13)
│ at Executor.execute (node_modules/selenium-webdriver/lib/http.js:529:28)
│ at runMicrotasks (<anonymous>)
│ at processTicksAndRejections (node:internal/process/task_queues:96:5)
│ at Task.exec (prevent_parallel_calls.ts:28:20)
```
### Do we have any service to help with StaleElementReferenceError
handling in FTR?
We do. `WebElementWrapper` object have internal mechanism to handle it:
we wrap most of the actions (click, type, getAttribute, etc.) with
`retryCall` function, which execute command up to RETRY_MAX_ATTEMPTS
times (3 by default) and check for errors. So if we try to click element
that is no longer in the DOM, this mechanism will try to find the
element in the DOM again, assuming it is still there but referenceId was
changed due to page updates. And repeat the click.
https://github.com/elastic/kibana/blob/main/test/functional/services/lib/web_element_wrapper/web_element_wrapper.ts#L107-L140
You might notice a warning during timePicker dates selection
```
│ debg Find.findByCssSelector('[data-test-subj="superDatePickerAbsoluteTab"]') with timeout=10000
│ warn WebElementWrapper.click: StaleElementReferenceError: stale element reference: stale element not found
│ (Session info: chrome=114.0.5735.198)
│ debg Searching again for the element 'By(css selector, [data-test-subj="superDatePickerAbsoluteTab"])',
| 2 attempts left
```
It is helping a lot to minimize the flakiness.
### Why does FTR still fails with StaleElementReferenceError in
Visualize tests?
Because most methods use the same pattern for searching elements in the
DOM: get all elements and then pick one by index.
```
const byFields = await this.testSubjects.findAll('fieldSelectItem');
const selectedByField = byFields[byFields.length - 1];
await this.comboBox.setElement(selectedByField, field);
```
The problem is that WebElementWrapper retry mechanism relies on having
`locator` property defined and it is _only_ defined if you search for a
single element, e.g. `testSubjects.find` or `by.byCssSelector`. This
property is set to `null` for each `WebElementWrapper` object in array
you get from `await this.testSubjects.findAll('fieldSelectItem')`;
So when we pass this object in `this.comboBox.setElement` and go through
a list of actions, it will fail on the first StaleElementReferenceError
occurrence.
The devil is in the detail: usually searching for multiple elements and
doing actions on some of it is totally fine. But comboBox selection has
quite many actions with different child elements, that can be updated in
DOM and lead to the error. Wrapping things with classical `retry`
service only hides the issue, but does not actually solve it.
### Proposed solution
Afaik CSS locators does not support searching for elements and picking
up one by index (I looked at `:nth-child()
`, but it is not what we need).
But we can use xpath locators for this purpose.
```
const selectedByField = await this.find.byXPath(`(//*[@data-test-subj='fieldSelectItem'])[last()]`);
await this.comboBox.setElement(selectedByField, field);
```
This way `selectedByField` has locator property defined and internal
mechanism will be able to retry actions.
#### Why don't we store `locator` for multiple elements search.
We can, but it means every element in array has the same locator and
while retrying to find it WebDriver will return the first one in the DOM
ignoring the element index. Using xpath locator is basically the simpler
version of storing element index in WebElementWrapper object.
Flaky test runner: 50x for visualize/group1..5/config.ts
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/2554
100x for group5
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/2596#0189403c-ccd2-4186-a83e-af21fe88018c
100x flaky test runner
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/2794
## Summary
Fixes#143493
* Add the switch control in Layer Settings
* [x] Make sure it does not duplicate on Annotation Layer Settings
* [x] Data Layers
* [x] Reference line layers
* [x] Extended dataView picker to support multiple icons
* [x] Added unit tests
* [x] Functional tests
<img width="351" alt="Screenshot 2023-06-07 at 15 28 19"
src="00dc5523-0bec-4e9c-b1d0-4d36804b29f9">
<img width="340" alt="Screenshot 2023-06-07 at 15 31 31"
src="d36ca147-5d8c-4123-9be3-2932844cbd15">
<img width="331" alt="Screenshot 2023-06-07 at 15 28 25"
src="c7d4f166-b8ab-4439-a83c-debf82b913ad">
<img width="324" alt="Screenshot 2023-06-07 at 15 27 59"
src="3738a7e0-6e49-4e22-b857-965a953b4b84">
<img width="323" alt="Screenshot 2023-06-07 at 15 27 53"
src="5965bf1c-0e25-4c0e-b54f-fa315157fd44">
* Create `IgnoreGlobalFilter` shared component folder
* [x] Layer setting control component
* [x] Info badge component
* Extends `esaggs_fn` to support the flag
* [x] Avoid to pass the filter to the handler if set
* [x] Add unit tests
* Notification badges
* [x] Extends the badge component in Embeddable to support grouped
messages
* [x] Added unit tests
<img width="750" alt="Screenshot 2023-06-07 at 15 31 39"
src="01bf8203-9133-4429-9b79-17ec67613c7e">
<img width="828" alt="Screenshot 2023-06-07 at 15 30 57"
src="9acb78f2-d061-4225-a4af-b3a66e7454fc">
<img width="756" alt="Screenshot 2023-06-07 at 15 27 43"
src="b9f79aed-7c02-4060-9c0f-61f438dc031d">
* Add support for Open in Lens
* [x] Add unit tests for each converter
* [x] Functional tests
### Checklist
Delete any items that are not applicable to this PR.
- [x] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [x]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [x] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [x] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)
---------
Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
* Added convert to lens support for tsvb table
* Added unit tests
* Added functional tests
* Some refactoring of table metric option config
* Fixed imports
* Some small refactoring
* Fix flaky test
* Fixed test
* Some small fixes
* Fixed test
* Added tests for converting metric with params, unsupported metrics and not valid panels.
* Added tests for color ranges.
* Added tests for gauge.
* Fixed tests.
* Added test for metric with params.
* Added test for invalid model.
* Added test for unsupported aggregation.
* Added test for sibling pipeline agg.
* Added parent pipeline agg tests.
* Added functional tests for static value.
* Added tests for converting metric with params, unsupported metrics and not valid panels.
* Added tests for color ranges.
* Added timeseries test for reference line.
* Fixed tests for the prupose of running separatelly.
* Added test for metric with params.
* Added test for invalid model.
* Added test for unsupported aggregation.
* Added test for sibling pipeline agg.
* Added parent pipeline agg tests.
* Update x-pack/test/functional/apps/lens/group3/open_in_lens/tsvb/timeseries.ts
Co-authored-by: Uladzislau Lasitsa <vlad.lasitsa@gmail.com>
* Update x-pack/test/functional/apps/lens/group3/open_in_lens/tsvb/timeseries.ts
Co-authored-by: Uladzislau Lasitsa <vlad.lasitsa@gmail.com>
* Fixed code according to the suggestions.
Co-authored-by: Uladzislau Lasitsa <vlad.lasitsa@gmail.com>
* [WIP][TSVB] Apply filter event is not working for formatted fields
* Add termsSplitValue that might be as single string for terms as MultiFieldKey for multi terms, that allows to create filters for grouped by multi terms data
* Update tests and fix some nits
* Add couple of functional tests
* Remove flaky test
* Update test to fix flakiness
* Fix some nits
* Shorten a condition
* Fix import
* Wrap setting combo box values into retry.try to get rid of flakiness
* In functional test increase sleep a bit to make sure group by field has appeared
* Refactor some code
* Try again to update test coordinates
* Update test coordinates
* Fix condition for terms value
* Fix export of MultiFieldKey
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
* fieldSelect
* activate multifield support for table
* update table>pivot request_processor
* fix some tests
* apply some changes
* fix JEST
* push initial logic for series request_processor
* fix some broken cases for Table tab
* update convert_series_to_datatable / convert_series_to_vars
* add some logic
* fix table/terms
* do some logic
* fix some issues
* push some logic
* navigation to Lens
* fix CI
* add excludedFieldFormatsIds param into excludedFieldFormatsIds
* fix ci
* fix translations
* fix some comments
* fix series_agg label
* update labels in lens
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
* [TSVB] Add more functional tests for Timeseries Annotations
* Move common code to beforeEach block
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
* [TSVB] Fix the broken "aggregate function" in TSVB table
Closes: #91149
* [TSVB] Table series filter and aggregation function applied at the same time cause an error
# Conflicts:
# src/plugins/vis_types/timeseries/server/lib/vis_data/request_processors/table/split_by_everything.ts
# src/plugins/vis_types/timeseries/server/lib/vis_data/request_processors/table/split_by_terms.ts
* some work
* filter terms columns
* fix error message on no pivot_id
* fix CI
* enable aggregation function for entire timerange
* fix PR comments
* update check_aggs
* fix series aggs for table
* unify error messages
* fix pr comment: restrictions: UIRestrictions = DEFAULT_UI_RESTRICTION
* fix i18n translation error
* fixes translations
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
* [TSVB] Fix reappearing of hidden series on refresh and styles loading
* Add functional test
* Update condition and move loading component to another file
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
* [TSVB] Remove the input string mode
* Fix some tests
* Add some functional tests and fix failing CI
* Update telemetry mappings
* Rename useStringIndices to allowStringIndices, move it from TSVB to Data constants and refactor test
* Apply text suggestions from code review
Co-authored-by: Kaarina Tungseth <kaarina.tungseth@elastic.co>
* Apply formatting and remove unused translations
* Fix labels
* Remove unused import
* Move popover toggling to checkIndexPatternSelectionModeSwitchIsEnabled function to prevent flakiness
* Update some visual_builder_page functions
* Remove accidentally added newlines
* Move TSVB ui settings to constants, remove tooltip and update popover text
* Handle the case of editing advanced settings is restricted
* Add requiresPageReload to UI setting and condition for the case the setting is already enabled
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Kaarina Tungseth <kaarina.tungseth@elastic.co>
* Use date_histogram instead of auto_date_histogram in pipeline aggregations
* Fix ci
* Fix eslint
* start disable parent pipeline aggs and show error
* Fix CI
* Fix eslint
* Fix CI
* Add functional tests
* Some fixes
* Fix lint
* Use agg_utils
* Fix lint
* Fix text
* Fix lint
* Fix tests
* Fixed condition
* Fix math aggregation
* math should pass panel type as prop
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
* [TSVB] Support custom field format
Add format_label response processor for series vis data and bucket key formatting to process_bucket for table vis data
* Add ignore_field_formatting for series to support value formatting for all panel types except markdown
* Fix type issue for visData and rename getCustomFieldFormatter to createCustomFieldFormatter
* Update vis.test to cover custom field formats logic and add a migration script to set ignore_field_formatting to true for the series
* Move createCustomFieldFormatter to a separate file, make formatting respect only active metrics field name, refactor vis files and fix label formatting only for grouped by terms series
* Remove services, add getFieldFormatsService to use it in format_label and get_table_data, replace getCustomFieldFormatter with createCustomFieldFormatter
* Update plugin.ts
* Update start for plugin.ts
* Add formatting for annotations and markdown values
* Refactor some code
* Update some naming and conditions
* Fix formatting of data type labels
* In process_bucket fix case for no getFieldFormatByName
* Add field formatting functional tests for all panel types
* Update tests to make them run correctly for firefox
* Update _tsvb_markdown test setup
* Move series ignoreFieldFormatting check to a separate file, change convertSeriesToVars signature, update migration script and refactor a bit functional tests
* Fix type check for timeseries_visualization.tsx
* Update migrations.js test expected version to 7.15
* Fix tests in _tsvb_chart.ts
* Fix merge conflict remove process_bucket.js
* Update process_bucket.test.ts
* Fix markdown labels formatting
* Add ignore_field_formatting for annotations, enhanced migration script to set that flag to true, refactor data_format_picker
* Fix migration script and add disabling for ignore component when string index pattern is used
* Add supporting URL and color formatters in tsvb table
* Fix eslint
* Remove ignore formatting component, add field formatting option to TSVB data format picker and make it default, remove migration script, update tests and refactor some files
* Fix failing tests, refactor create_field_formatter and add test to it, update some other files
* Fix series formatting for top hit when it has not numeric result
* Handle no fieldFormatMap case for table/vis.js
* Remove "Default" option form DataFormatPicker when index pattern is string, fix markdown variables issue and refactor some code
* Chore(TSVB): Replace aggregations lookup with map
* Fix types, update test expected data and remove unused translations
* Fix i18 check and useEffect in agg.tsx
* Handle aggregations field formatting case
* Fix agg_utils, vis and check_if_numeric_metric tests
* Correct typo and refactor condition in std_metric
* Fix type check
* Get rid of IFieldType
* Add URL and color formatting for topN and metric tabs, fix setting initial custom formatter and switching formatter in agg.tsx
* Update tsvb.asciidoc
* Remove link icon from Date format field help text, update click logic for top N in case of custom field format and fix CI
* Remove unused import
* Revert top N bar extra logic for click
* Refactor some code in agg.tsx
* Add URL and color formatting to Gauge
* Fix bug with terms formatting, refactor some code, update create_field_formatter
* Add comments to _gauge.scss
* Remove unnecessary await
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Uladzislau Lasitsa <Uladzislau_Lasitsa@epam.com>
* [TSVB] Add more functional tests for Timeseries
* Fix failing test for timeseries
* Refactor visual_builder_page and _tsvb_time_series
* Add getChartItems to visual_builder_page
* Remove generic from getChartItems function
* [TSVB] Add more functional tests for Gauge and TopN
* Update visual_builder_page.ts
* Update functions related to gauge color and filter ratio numerator in visual_builder_page
* Update visual_builder_page and add some more test subjects
* Update _tsvb_chart.ts
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
* [TSVB] Add more functional tests for Table
* Update filter ratio setting numerator denominator function
* Refactor set filter ratio numerator and denominator functions in visual_builder_page.ts
* Update setFilterRatioOption function
* [TSVB] Refactor top-hit aggregation to work with fields instead of _source
* Allow select date strings for top_hit aggregation in table, metric, and markdown
* Fix agg_with handling for top_hit and add some tests
* Refactor get_agg_value and fix type check for _tsvb_chart
* Refactor top_hit.js
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
* Сhanged EuiCodeEditor to CodeEditor (monaco) at markdown_editor.js
* Added css lang support for monaco-editor.
* Added .d.ts for css lang import directly from monaco.
* Moved handlebars_url language to the code_editor.
Moved handlebars_url language registration to the code_editor.
Changed the way of registration of languages.
* Added merge for markdown_handlebars lang.
* Changed to simple markdown syntax.
Handlebars syntax breaks highlighting of special chars in markdown syntax.
* Removed useless mergeConfig function.
* Removed legacy import.
* Refactor export from monaco-editor.
* Fixed 'Could not find a declaration file for module'
* Fixed tests.
* Fixed typings errors.
* Added comment to typings.
* Fixed clearMarkdown for Monaco editor.
* Made changes based on suggestions.
* Fixed types errors.
* Fixed function tests types errors.
* Fixes, based on nits.
* Fixes based on nits.
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
* [TSVB] Show an indicator when using Last Value mode
* Extended some TSVB types, remove unused translations and do some refactoring
* Fix some functional tests and label displaying for Last value
* Fix some functional tests and label displaying for Last value
* Refactor data_time_range_mode_label and change some types
* fix CI
* Refactor timeseries_visualization seriesData
* Remove unused re export
* Replace "href" prop with "onClick" in EuiLink and refactor tooltip content
* Change link to text and add pointer style to it
* FIx import in kibana_framework_adapter
* Remove label for entire time range mode and add an icon for last value mode label
* Add action to show last value label for TSVB embeddables
* Fix TimeseriesVisParams import
* Revert "Add action to show last value label for TSVB embeddables"
This reverts commit 15f16d6f72.
* Put the "Last value" badge on the top of visualization and add an option to hide it
* Fix failing _tsvb_markdown test and refactor timeseries_visualization
* Move I18nProvider frim timeseries_visualization to timeseries_vis_renderer
* Add condition to hide gear button when entire time range mode is enabled, fix gauge scroll issue
* Change text in the popover, add condition to indicator if series data is empty, create migration script to hide last value label for previously created visualizations and a test for that
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Alexey Antonov <alexwizp@gmail.com>
* Make 'enter time range' value as default and add telemetry for 'last value' mode
* Fix telemetry schema
* Fix test
* Add possibility count timeseries created from dashboard
* Fix remark
* Fix remark
* Fix problem with time_range_mode
* Fix tests
* Fix tests
* Fix tests for markdown and table
* exclude TSVB which have type as timeseries
* Add description for field in schema in telemetry
* Fix telemetry schema
* Fix some remarks
* Added check for hits
* fix CI
* fix CI
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Alexey Antonov <alexwizp@gmail.com>
* [TSVB] Enable `dual mode`, support index patterns and strings
* modify UI
* add migration script
* refactoring
* fix CI
* prefill the index pattern name
* modify UI
* modify UI
* update UI
* fix functional test
* some work
* remove callouts
* fix rollup test
* update UI
* fix typo
* add some unit tests
* add functional test
* fix CI
* correct labels
* fix ci group 12
* cleanup interface
* fix CI
* cleanup API
* fix some of PR comments
* move index patterns into so references
* remove wrong logic
* fix JEST
* fix some ui issues
* update sample data
* indexPatternObject -> indexPatternValue
* fix comments
* I have a dashboard with two TSVB viz. One with the default (haven't applied it to the combobox) and one with the logs. The filter contains fields only from the logs index pattern
* When I am on the string mode and try to write my index, sometimes some of the chars are not added or they are deleted while typing, something with the denounce maybe?
* fix merge conflicts
* Does this PR also supports runtime fields? I created one from the editor and I see that I can select it
* fix UI issue
* If I create a viz with the string mode and a wildcard e.g. kibana_sample*, the index patterns are not communicated correctly to the dashboard.
* fix import/export refs for dashboard
* remove MigrationPopover
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>