Skip to content

Refactor the test cases to avoid hardcoded number #2535

Description

@FisherSkyi

What feature(s) would you like to see in RepoSense

Test cases use percentile instead of number of pixel to represent the point to click.

Is the feature request related to a problem?

Right now in frontend cypress tests, many test cases related to the chartView has hard-coded coordinates. As an example, in testcase subzoom panel range should work correctly when timeline is optimised in file chartView_optimiseTimeline.cy.js

cy.get('body').type(zoomKey, { release: false })
  .get('#summary-charts .summary-chart__ramp .ramp')
  .first()
  .click(110, 20) // <- 110
  .click(120, 20); // <- 120

However, browser window size and screen resolution may influence the actual coordinates and may fail these test cases. Since the test suite doesn't specify cy.viewpoint, it will default to an application viewport of 1000 × 660. The correctness depends on several hidden assumptions:

  • Cypress continues using the same viewport.
  • The ramp continues having approximately the same width.

If possible, describe the solution

Change to use the percentage, which is point's x coordinates divide by the whole length of the chart. The percentage would be better derived from commit timestamp and the displayed time period.

If applicable, describe alternatives you've considered

Additional context

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions