-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added `--graph-only` option for the `orca serve` entry point When this option is present, only the plotly-graph component is run (not thumbnail, dash, etc.). When graph conversion is the only service needed, this option reduces the number of electron processes, the memory usage, and startup time.
- Loading branch information
Showing
2 changed files
with
103 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
const tap = require('tap') | ||
const Application = require('spectron').Application | ||
const request = require('request') | ||
|
||
const { paths } = require('../common') | ||
const PORT = 9109 | ||
const SERVER_URL = `http://localhost:${PORT}` | ||
|
||
const app = new Application({ | ||
path: paths.bin, | ||
args: ['serve', '--port', PORT, '--graph-only'] | ||
}) | ||
|
||
tap.tearDown(() => { | ||
if (app && app.isRunning()) { | ||
app.stop() | ||
} | ||
}) | ||
|
||
tap.test('should launch', t => { | ||
app.start().then(() => { | ||
app.client.getWindowCount().then(cnt => { | ||
// Only one window since only graph component should be running | ||
t.equal(cnt, 1) | ||
t.end() | ||
}) | ||
}) | ||
}) | ||
|
||
tap.test('should reply pong to ping POST', t => { | ||
request.post(SERVER_URL + '/ping', (err, res, body) => { | ||
if (err) t.fail(err) | ||
|
||
t.equal(res.statusCode, 200, 'code') | ||
t.equal(body, 'pong', 'body') | ||
t.end() | ||
}) | ||
}) | ||
|
||
tap.test('should work for *plotly-graph* component', t => { | ||
request({ | ||
method: 'POST', | ||
url: SERVER_URL + '/', | ||
body: JSON.stringify({ | ||
figure: { | ||
layout: { | ||
data: [{y: [1, 2, 1]}] | ||
} | ||
} | ||
}) | ||
}, (err, res, body) => { | ||
if (err) t.fail(err) | ||
|
||
t.equal(res.statusCode, 200, 'code') | ||
t.type(body, 'string') | ||
t.end() | ||
}) | ||
}) | ||
|
||
tap.test('should teardown', t => { | ||
app.stop() | ||
.catch(t.fail) | ||
.then(t.end) | ||
}) | ||
|
||
tap.test('should not work for *plotly-thumbnail* component', t => { | ||
request({ | ||
method: 'POST', | ||
url: SERVER_URL + '/thumbnail', | ||
body: JSON.stringify({ | ||
figure: { | ||
layout: { | ||
data: [{y: [1, 2, 1]}] | ||
} | ||
} | ||
}) | ||
}, (err, res) => { | ||
t.equal(err.code, 'ECONNREFUSED') | ||
t.equal(res, undefined, 'should be undefined') | ||
t.end() | ||
}) | ||
}) |