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

Convert tag cloud, vega and table tests to jest #57813

Closed
flash1293 opened this issue Feb 17, 2020 · 2 comments
Closed

Convert tag cloud, vega and table tests to jest #57813

flash1293 opened this issue Feb 17, 2020 · 2 comments
Assignees
Labels
Feature:NP Migration Feature:Visualizations Generic visualization features (in case no more specific feature label is available) Team:Visualizations Visualization editors, elastic-charts and infrastructure

Comments

@flash1293
Copy link
Contributor

flash1293 commented Feb 17, 2020

The tag cloud, vega and data table tests are currently using karma, angular mocking, visual diffs and require a real browser environment. To convert them to jest, multiple pieces have to be completed

Validate svg instead of rendered canvas

These tests have to be replaced by snapshot tests validating the svg tree instead of the rendered canvas. This has the additional benefit of being more stable than pixel comparisons (because of different fonts, ...)

For tag cloud, the following patching of jsdom apis tricks the rendering component into thinking there is enough space to layout the elements (the layouting itself happens within d3 and doesn't require a real dom):

      Object.defineProperties(window.HTMLElement.prototype, {
        offsetHeight: {
          get: function() { return 512; }
        },
        offsetWidth: {
          get: function() { return 512; }
        },
      });
      Object.defineProperties(window.SVGElement.prototype, {
        getBBox: {
          get: () => function () {
            return {
              x: 0,
              y: 0,
              width: 512,
              height: 512,
            }
          }
        }});

For vega specs, adding

      autosize: { type: 'none' }
      width: 512
      height: 512
      config: { kibana: { renderer: 'svg' }}

to the spec sets the size of the rendering area and makes sure an svg tree is created.

Get rid of ngMock and contracts of other plugins

  • ngMock is not required as angular isn't used within the visualizations
  • No real Vis object is needed to render successfully, the necessary parts can be simulated by an inline mock
  • The visualization does not have to be registered - all integrations createBaseVisualization of the visualizations plugin is setting up should be simulated by inline mocks if necessary

Get rid of hson files

Vega stores the test specs in hson files. In the new platform there is no raw loader - convert hson files to json, import json directly and pass it into the visualizations via JSON.stringify.

Add smoke test with FTR and percy

To test the wider integration, add a functional test runner test for tag cloud and vega doing a simple visual regression test via percy.

@flash1293 flash1293 added Feature:Visualizations Generic visualization features (in case no more specific feature label is available) Team:Visualizations Visualization editors, elastic-charts and infrastructure Feature:NP Migration labels Feb 17, 2020
@flash1293 flash1293 added this to To do in Kibana-app-np-migration via automation Feb 17, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app (Team:KibanaApp)

@flash1293 flash1293 moved this from To do to Cutover todos in Kibana-app-np-migration Mar 13, 2020
@kertal kertal closed this as completed Apr 29, 2020
Kibana-app-np-migration automation moved this from Cutover todos to Done Apr 29, 2020
@kertal kertal reopened this Apr 29, 2020
Kibana-app-np-migration automation moved this from Done to In progress Apr 29, 2020
@kertal kertal moved this from In progress to Cutover todos in Kibana-app-np-migration Apr 29, 2020
@flash1293 flash1293 changed the title Convert tag cloud and vega tests to jest Convert tag cloud, vega and table tests to jest May 29, 2020
DianaDerevyankina added a commit to DianaDerevyankina/kibana that referenced this issue Jul 8, 2020
DianaDerevyankina added a commit that referenced this issue Jul 14, 2020
* Convert vega tests to jest

Part of #57813

* Remove unused config

* Move assets to __test__ folder and remove unnecessary code

* clenup

* cleanup

* Revert default.spec.hjson file and mock default_spec

* Refactor some code

Co-authored-by: Alexey Antonov <alexwizp@gmail.com>
DianaDerevyankina added a commit to DianaDerevyankina/kibana that referenced this issue Jul 14, 2020
* Convert vega tests to jest

Part of elastic#57813

* Remove unused config

* Move assets to __test__ folder and remove unnecessary code

* clenup

* cleanup

* Revert default.spec.hjson file and mock default_spec

* Refactor some code

Co-authored-by: Alexey Antonov <alexwizp@gmail.com>
DianaDerevyankina added a commit that referenced this issue Jul 14, 2020
* Convert vega tests to jest

Part of #57813

* Remove unused config

* Move assets to __test__ folder and remove unnecessary code

* clenup

* cleanup

* Revert default.spec.hjson file and mock default_spec

* Refactor some code

Co-authored-by: Alexey Antonov <alexwizp@gmail.com>

Co-authored-by: Alexey Antonov <alexwizp@gmail.com>
@flash1293
Copy link
Contributor Author

Closed by linked PRs

Kibana-app-np-migration automation moved this from Cutover todos to Done Jul 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:NP Migration Feature:Visualizations Generic visualization features (in case no more specific feature label is available) Team:Visualizations Visualization editors, elastic-charts and infrastructure
Projects
Development

No branches or pull requests

4 participants