Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
erp5 erp5
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Labels
    • Labels
  • Merge requests 143
    • Merge requests 143
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Environments
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Jobs
  • Commits
Collapse sidebar
  • nexedi
  • erp5erp5
  • Merge requests
  • !763

Merged
Created Oct 03, 2018 by Jérome Perrin@jeromeOwner

Tests for graphs on support request frontpage

  • Overview 22
  • Commits 11
  • Pipelines 2
  • Changes 26

Support request app has a nice feature (powered by the echarts gadget) that clicking on a series on the graph will filter the corresponding listbox to display all the supports requests from this series.

This was not covered by functional test and this is what this merge request is addressing.

Selenium comes with a clickAt ( locator,coordString ) API which is a "beautiful" way of simulating a click somewhere in the screen, so we could use this to simulate a click.

Problem is that we need to wait for chart to be displayed. The first step was just to wait for the canvas element to be in the DOM, this was enough for the bar chart, but not for the pie chart, because there is an animation and we need for the animation to stop, otherwise we might click before the series is completely and when we click, the animation is still running and we don't click on the series because it's still being animated:

clicking on chart while animation is still running

Good news is that echarts fires a finished event we can wait for, but for that we had to update echarts version to 4.1.0 . This was exposed on the chart gadget as a disabled attribute - the element initially has a disabled attribute and attribute is removed when ready to inspect in tests. I think this is the way we do in other gadgets.

After updating echarts, the way of simulating click by clickAt stopped working, this new version of echarts only understand clicks that comes after a mousedown event, so the test needs to mousedown and then click.

Where it gets really complicated, is the click must be given in pixel position on the chart canvas and the layout varies a bit depending on the size of the canvas, which itself depends on the browser window size. For this we calculate the click position based on a percentage of the canvas size (there are some ascii art explaining this in the test html). I was also considering to make the chart gadget listen to a custom test.clickSeries event with the same name and seriesName properties that are used in the chartItemClick method and have selenium dispatch such an event (in a assertEval or another selenium statement where we can write raw javascript). This test is still too fragile in my opinion - I'm still adjusting it for various screen sizes and I'm not sure it passes on testnodes. On the other hand, we could hardcode a firefox window size in our test suite.

Assignee
Assign to
Reviewer
Request review from
None
Milestone
None
Assign milestone
Time tracking
Source branch: feat/support-request-charts-test
GitLab Nexedi Edition | About GitLab | About Nexedi | 沪ICP备2021021310号-2 | 沪ICP备2021021310号-7