superset icon indicating copy to clipboard operation
superset copied to clipboard

Add support for integration tests

Open michellethomas opened this issue 8 years ago • 4 comments

We want to add support for integration tests to improve the development process. I was planning on using Selenium, but I may need to also use another library that helps with performance (vcrpy is one option).

Some initial ideas for what to test:

  • Create integration tests for top chart types
    • Make sure returning charts have a slice container
    • Hover and find the tooltip (class-name: legend-color-guide), make sure it is correct
    • Create different types of filters, make sure those filters show up in the where clause
    • Create adhoc and saved metrics, check that the data returns (and that the metric shows up in the data)
    • Switch viz types and check functionality
  • Add tests for links on explore
    • Check query button, save chart (and check that the url is the same before / after), save as, download, json
  • Add tests for actions on dashboard
    • Add a chart to the dashboard
    • Change chart position on dashboard
  • Review popular dashboards to recreate functionality
  • Add tests for annotations
    • Create an annotation and check to make sure the line exists on the chart
  • Add tests for different roles / permissions groups
    • Looks like there's already an issue for this
  • Test remaining chart types and improve performance

@jeffreythewang mentioned that they also are working on testing for different database versions. They also have a script that runs a bunch of requests on different instances and compares the results.

Thoughts? Suggestions? @john-bodley @mistercrunch

michellethomas avatar Jul 16 '18 20:07 michellethomas

Just to note - our current testing setup is pretty naive and will not work for changes in query or response parameters. We primarily use it to run simple queries to sanity check our various databases, as we use internal SQLAlchemy dialects for some of them.

jeffreythewang avatar Jul 17 '18 22:07 jeffreythewang

After looking at a few options, we are currently exploring using Cypress. The main advantages of using cypress is that 1. it's promise based so we don't need to sleep to wait for responses, nice features around debugging, it's faster (doesn't need to spin up a browser for each test), and is less flaky.

Downsides: it runs tests inside the browser so it's harder to communicate with the db. Also currently there's no headless chrome, but it looks like they are working on it. It will currently run headless Electron. There's only support for Chrome and Electron, but this isn't a problem for us as we don't need to test on other platforms. List of trade offs here.

We are still exploring to make sure it will work for a variety of cases but anyone have any major concerns?

michellethomas avatar Aug 14 '18 00:08 michellethomas

Initial PR for Cypress tests: https://github.com/apache/incubator-superset/pull/5693

michellethomas avatar Sep 06 '18 22:09 michellethomas

Most of the initial test cases are now supported or will be supported once PRs get in soon. We will continue to work on improving the quality of the tests. For anyone fixing bugs, consider whether an integration test will help catch the case in the future. If anyone has questions about setting up cypress to create tests I included a section in contributing.

michellethomas avatar Oct 04 '18 00:10 michellethomas