Skip to content

Commit b548e6e

Browse files
authored
Merge pull request #2567 from ECraneWorldwide/writing-select-tests-documentation
Add tips for writing selection tests
2 parents 63db2a1 + 24bef43 commit b548e6e

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Diff for: CONTRIBUTING.md

+21
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,27 @@ which shows the baseline image, the generated image, the diff and the json mocks
177177

178178
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`.
179179

180+
### Writing interaction tests
181+
Keep in mind that the interaction coordinates are relative to the top-left corner of the plot, including the margins. To produce a reliable interaction test,
182+
it may be necessary to fix the width, height, margins, X axis range and Y axis range of the plot. For example:
183+
184+
```
185+
Plotly.newPlot(gd, [{
186+
x: [1, 1, 1, 2, 2, 2, 3, 3, 3],
187+
y: [1, 2, 3, 1, 2, 3, 1, 2, 3],
188+
mode: 'markers'
189+
}], {
190+
width: 400, height: 400,
191+
margin: {l: 100, r: 100, t: 100, b: 100},
192+
xaxis: {range: [0, 4]},
193+
yaxis: {range: [0, 4]}
194+
});
195+
```
196+
197+
This will produce the following plot, and say you want to simulate a selection path of (175, 175) to (225, 225):
198+
199+
<img src="https://user-images.githubusercontent.com/31989842/38890553-0bc6190c-4282-11e8-8efc-077bf05ca565.png">
200+
180201

181202
## Repo organization
182203

0 commit comments

Comments
 (0)