Skip to content

Add tips for writing selection tests #2567

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

Merged

Conversation

GlennMatthys
Copy link
Contributor

Follow-up from the discussion in PR #2506, add documentation to help orient developers in the selection coordinate system.

CONTRIBUTING.md Outdated
@@ -177,6 +177,32 @@ which shows the baseline image, the generated image, the diff and the json mocks

To view the results of a run on CircleCI, download the `build/test_images/` and `build/test_images_diff/` artifacts into your local repo and then run `npm run start-image_viewer`.

### Writing selection tests
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this!

Your tips don't just apply to selection tests though. Hover and click tests also rely on these relative-top-left pixel coordinates. Maybe this section header could instead be Writing interaction tests?

CONTRIBUTING.md Outdated

```
Plotly.newPlot(gd,
[
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although not a linting mistake, we prefer formatting blocks like this one like this:

Plotly.newPlot(gd, [{
    // ...
}], {
    // ...
});

CONTRIBUTING.md Outdated

This will produce the following plot, and you want to simulate a selection path of (175, 175) to (225, 225):

<img src="https://user-images.githubusercontent.com/31989842/38889542-5303cf9c-427f-11e8-93a2-16ce2e29f521.png">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so nice 🥇

@GlennMatthys
Copy link
Contributor Author

Updated the diagram to make the point marked (0, 0) to be actually (0, 0) in the image, so that if you use a paint program to measure coordinates, it adds up:

plotly_test_select

(Plus a sneaky place to upload this)

CONTRIBUTING.md Outdated
margin: {l: 100, r: 100, t: 100, b: 100},
xaxis: {range: [0, 4]},
yaxis: {range: [0, 4]}
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. That's not quite right. Make sure there are 4 spaces before the keys and none before the }], { and ]); lines.

@etpinard
Copy link
Contributor

Beautifully done. Thank you very much!

@etpinard etpinard merged commit b548e6e into plotly:master Apr 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants