Skip to content

Functional testing with elastic-charts #70176

@timroes

Description

@timroes

We currently have a couple of functional tests that check on the chart rendered, by crapping it's SVG element, e.g. to get a list of all slices in a pie chart.

We're in the process of switching from our current Vislib implementation to the elastic-charts library for all classical visualizations in Kibana. The library does no longer use SVG, but the HTML canvas element for rendering. With that we can no longer dig deeper into DOM elements inside the chart to get data from it.

In a sync we discussed quickly what potential solutions for this are (and we're assuming that we're not wanting to get rid of any functional test that does that) and came up with the following idea:

elastic-charts should have a debug mode, that when enabled will attach "chart data" (or whatever other information we need) as a data-attribute to the DOM element, so we can retrieve it from there.

What are the benefits? This would still be better than using the inspector data table (as we do in some tests), since there are still quiet a lot of architectural layers between the inspector data panel and the data elastic-chart sees, why we think it's better testing on the data elastic-charts actually see. We can also keep all tests as they are, and just need to replace the page objects to parse the data from this attribute.

What are the drawbacks? Compared to the previous way of testing, we're testing slightly less the actual rendering of the chart. We're fine with that, since this should not be a concern of the functional tests in Kibana. Elastic-charts should be responsible for turning that data into a rendered chart, and thus the tests whether the data is turned into a correct chart should be within elastic-charts (and we have visual regression tests there - and in addition a couple of them in Kibana too).

Open questions

  • How will we enable the debug mode in elastic charts? We basically have two options: (a) make it an explicit property on the chart element. This has the advantage of being very explicit, but therefore require us to pass this somehow in all renderers from the test runner into the chart library. Or (b) elastic chart could look at some well known window property (like window.ELASTIC_CHARTS_DEBUG) and enable the mode if that's set to true and the test runner would just set this to true before starting tests. In case of (a) we also need to check how to get that information from the test runner into the chart renderers which would most likely work via a similar well-known window property. I currently have a slight tendency towards (b) but would like to gather your feedback on this.

cc @elastic/kibana-qa @markov00

Metadata

Metadata

Assignees

No one assigned

    Labels

    Feature:ElasticChartsIssues related to the elastic-charts libraryFeature:VislibVislib chart implementationTeam:VisualizationsTeam label for Lens, elastic-charts, Graph, legacy editors (TSVB, Visualize, Timelion) t//

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions