From 203f35d6880d04cc5d61e7ed73a0764da5046d83 Mon Sep 17 00:00:00 2001 From: Glenn Matthys Date: Tue, 17 Apr 2018 20:44:33 +0200 Subject: [PATCH 1/4] Add tips for writing selection tests --- CONTRIBUTING.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 22248ce4809..90468bcf3fb 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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 +Keep in mind that the selection coordinates are relative to the top-left corner of the plot, including the margins. To produce a reliable selection test, +it may be necessary to to fix the width, height, margins, X axis range and Y axis range of the plot. For example: + +``` +Plotly.newPlot(gd, + [ + { + x: [1, 1, 1, 2, 2, 2, 3, 3, 3], + y: [1, 2, 3, 1, 2, 3, 1, 2, 3], + mode: 'markers' + } + ], + { + width: 400, height: 400, + margin: {l: 100, r: 100, t: 100, b: 100}, + xaxis: {range: [0, 4]}, + yaxis: {range: [0, 4]} + } +) +``` + +This will produce the following plot, and you want to simulate a selection path of (175, 175) to (225, 225): + + + ## Repo organization From 7e3ac005aa613970fdca6d3765e800c5ae83aa97 Mon Sep 17 00:00:00 2001 From: Glenn Matthys Date: Tue, 17 Apr 2018 21:00:57 +0200 Subject: [PATCH 2/4] Improve code formatting, update diagram, generalize terminology to "interaction tests" --- CONTRIBUTING.md | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 90468bcf3fb..4c04280c3de 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -177,31 +177,26 @@ 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 -Keep in mind that the selection coordinates are relative to the top-left corner of the plot, including the margins. To produce a reliable selection test, +### Writing interaction tests +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, it may be necessary to to fix the width, height, margins, X axis range and Y axis range of the plot. For example: ``` -Plotly.newPlot(gd, - [ - { +Plotly.newPlot(gd, [{ x: [1, 1, 1, 2, 2, 2, 3, 3, 3], y: [1, 2, 3, 1, 2, 3, 1, 2, 3], mode: 'markers' - } - ], - { - width: 400, height: 400, - margin: {l: 100, r: 100, t: 100, b: 100}, - xaxis: {range: [0, 4]}, - yaxis: {range: [0, 4]} - } -) + }], { + width: 400, height: 400, + margin: {l: 100, r: 100, t: 100, b: 100}, + xaxis: {range: [0, 4]}, + yaxis: {range: [0, 4]} + }); ``` -This will produce the following plot, and you want to simulate a selection path of (175, 175) to (225, 225): +This will produce the following plot, and say you want to simulate a selection path of (175, 175) to (225, 225): - + ## Repo organization From 6cc20d8574212e3a32cde5a07d93bb30fba9c243 Mon Sep 17 00:00:00 2001 From: Glenn Matthys Date: Tue, 17 Apr 2018 21:07:16 +0200 Subject: [PATCH 3/4] Remove excessive spacing in code sample --- CONTRIBUTING.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4c04280c3de..e7308fe301d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -183,15 +183,15 @@ it may be necessary to to fix the width, height, margins, X axis range and Y axi ``` Plotly.newPlot(gd, [{ - x: [1, 1, 1, 2, 2, 2, 3, 3, 3], - y: [1, 2, 3, 1, 2, 3, 1, 2, 3], - mode: 'markers' - }], { - width: 400, height: 400, - margin: {l: 100, r: 100, t: 100, b: 100}, - xaxis: {range: [0, 4]}, - yaxis: {range: [0, 4]} - }); + x: [1, 1, 1, 2, 2, 2, 3, 3, 3], + y: [1, 2, 3, 1, 2, 3, 1, 2, 3], + mode: 'markers' +}], { + width: 400, height: 400, + margin: {l: 100, r: 100, t: 100, b: 100}, + xaxis: {range: [0, 4]}, + yaxis: {range: [0, 4]} +}); ``` This will produce the following plot, and say you want to simulate a selection path of (175, 175) to (225, 225): From 24bef4373b737871fdab489ac0f8242c0cd0f416 Mon Sep 17 00:00:00 2001 From: Glenn Matthys Date: Tue, 17 Apr 2018 21:09:16 +0200 Subject: [PATCH 4/4] Typo fix --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e7308fe301d..4c637c3924e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -179,7 +179,7 @@ To view the results of a run on CircleCI, download the `build/test_images/` and ### Writing interaction tests 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, -it may be necessary to to fix the width, height, margins, X axis range and Y axis range of the plot. For example: +it may be necessary to fix the width, height, margins, X axis range and Y axis range of the plot. For example: ``` Plotly.newPlot(gd, [{