Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 15616b0

Browse files
committed
add pretest task:
- puts environment varialbe MAPBOX_ACCESS_TOKEN into test ready json file and Plotly.setPlotConfig wrapper.
1 parent 2f858aa commit 15616b0

File tree

5 files changed

+61
-6
lines changed

5 files changed

+61
-6
lines changed

CONTRIBUTING.md

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ Implementation questions should be asked on
1414
community.plot.ly (tagged [`plotly-js`](http://community.plot.ly/c/plotly-js)) or on Stack Overflow (tagged
1515
[`plotly`](https://stackoverflow.com/questions/tagged/plotly)).
1616

17-
Comments on GitHub issues or pull requests should add content to the discussions.
18-
Approbation comments such as *+1* or *I would like this feature to be implemented as well*
19-
will be deleted by the maintainers. Please use
20-
[GitHub reactions](https://github.com/blog/2119-add-reactions-to-pull-requests-issues-and-comments)
17+
Comments on GitHub issues or pull requests should add content to the discussions.
18+
Approbation comments such as *+1* or *I would like this feature to be implemented as well*
19+
will be deleted by the maintainers. Please use
20+
[GitHub reactions](https://github.com/blog/2119-add-reactions-to-pull-requests-issues-and-comments)
2121
instead.
2222

2323
## Making pull requests
@@ -28,11 +28,11 @@ pull request is deemed satisfactory, the developer will be asked to make a pull
2828
request to the main plotly.js repo and may be asked to squash some commits
2929
before doing so.
3030

31-
Developers should `git rebase` their local branch off the latest `master` before
31+
Developers should `git rebase` their local branch off the latest `master` before
3232
opening a pull request.
3333

3434
Note that it is forbidden to force push (i.e. `git push -f`) to remote branches
35-
associated with opened pull requests. Force pushes make it hard for maintainers
35+
associated with opened pull requests. Force pushes make it hard for maintainers
3636
to keep track of updates. Therefore, if required, please
3737
`git merge master` into your PR branch instead of `git rebase master`.
3838

@@ -157,6 +157,18 @@ which shows the baseline image, the generated image, the diff and the json mocks
157157

158158
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`.
159159

160+
### Note on testing our `mapbox-gl` integration
161+
162+
Creating `mapbox-gl` graphs requires an
163+
[`accessToken`](https://www.mapbox.com/help/define-access-token/). To make sure
164+
that mapbox image and jasmine tests run properly, locate your Mapbox access
165+
token and run:
166+
167+
168+
```bash
169+
export MAPBOX_ACCESS_TOKEN="<your access token>" && npm run pretest
170+
```
171+
160172

161173
## Repo organization
162174

circle.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ dependencies:
1515
- docker pull plotly/testbed:latest
1616
post:
1717
- npm run cibuild
18+
- npm run pretest
1819
- docker run -d --name mytestbed -v $PWD:/var/www/streambed/image_server/plotly.js -p 9010:9010 plotly/testbed:latest
1920
- sudo lxc-attach -n "$(docker inspect --format '{{.Id}}' mytestbed)" -- bash -c "cp -f /var/www/streambed/image_server/plotly.js/test/image/index.html /var/www/streambed/image_server/server_app/index.html"
2021
- wget --server-response --spider --tries=8 --retry-connrefused http://localhost:9010/ping

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"watch": "node tasks/watch_plotly.js",
3030
"lint": "eslint . || true",
3131
"lint-fix": "eslint . --fix",
32+
"pretest": "node tasks/pretest.js",
3233
"test-jasmine": "karma start test/jasmine/karma.conf.js",
3334
"citest-jasmine": "karma start test/jasmine/karma.ciconf.js",
3435
"test-image": "./tasks/test_image.sh",

tasks/pretest.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
var fs = require('fs');
2+
var constants = require('./util/constants');
3+
var mapboxAccessToken = process.env.MAPBOX_ACCESS_TOKEN;
4+
5+
6+
if(!mapboxAccessToken) {
7+
throw new Error([
8+
'MAPBOX_ACCESS_TOKEN not found!!!',
9+
'Please export your mapbox access token into and try again.'
10+
].join('\n'));
11+
}
12+
13+
// Create a credentials json file,
14+
// to be required in jasmine test suites and test dashboard
15+
var credentials = JSON.stringify({
16+
MAPBOX_ACCESS_TOKEN: process.env.MAPBOX_ACCESS_TOKEN
17+
}, null, 2);
18+
19+
fs.writeFile(constants.pathToCredentials, credentials, function(err) {
20+
if(err) throw err;
21+
});
22+
23+
// Create a 'set plot config' file,
24+
// to be included in the image test index
25+
var setPlotConfig = [
26+
'\'use strict\';',
27+
'',
28+
'/* global Plotly:false */',
29+
'',
30+
'Plotly.setPlotConfig({',
31+
' mapboxAccessToken: \'' + process.env.MAPBOX_ACCESS_TOKEN + '\'',
32+
'});',
33+
''
34+
].join('\n');
35+
36+
fs.writeFile(constants.pathToSetPlotConfig, setPlotConfig, function(err) {
37+
if(err) throw err;
38+
});

tasks/util/constants.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ module.exports = {
5151
pathToJasmineTests: path.join(pathToRoot, 'test/jasmine/tests'),
5252
pathToJasmineBundleTests: path.join(pathToRoot, 'test/jasmine/bundle_tests'),
5353

54+
pathToCredentials: path.join(pathToBuild, 'credentials.json'),
55+
pathToSetPlotConfig: path.join(pathToBuild, 'set_plot_config.js'),
56+
5457
uglifyOptions: {
5558
fromString: true,
5659
mangle: true,

0 commit comments

Comments
 (0)