Skip to content
This repository has been archived by the owner on Dec 15, 2018. It is now read-only.

Commit

Permalink
Bug 1128979 - Improve usability of loop-client test server - allow te…
Browse files Browse the repository at this point in the history
…sts to be loaded when in the github context; also allow the full server url to be specified, not just the port. r=dmose NPOTB DONTBUILD
  • Loading branch information
Standard8 committed May 5, 2015
1 parent 237b0d0 commit 45e5cb1
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion browser/components/loop/standalone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"devDependencies": {
"eslint": "0.20.x",
"eslint-plugin-react": "2.2.x",
"express": "3.x"
"express": "4.x"
},
"scripts": {
"test": "make test",
Expand Down
15 changes: 12 additions & 3 deletions browser/components/loop/standalone/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,16 @@ var express = require('express');
var app = express();

var port = process.env.PORT || 3000;
var loopServerPort = process.env.LOOP_SERVER_PORT || 5000;
var feedbackApiUrl = process.env.LOOP_FEEDBACK_API_URL ||
"https://input.allizom.org/api/v1/feedback";
var feedbackProductName = process.env.LOOP_FEEDBACK_PRODUCT_NAME || "Loop";
var loopServerUrl = process.env.LOOP_SERVER_URL || "http://localhost:5000";

// Remove trailing slashes as double slashes in the url can confuse the server
// responses.
if (loopServerUrl[loopServerUrl.length - 1] === "/") {
loopServerUrl = loopServerUrl.slice(0, -1);
}

function getConfigFile(req, res) {
"use strict";
Expand All @@ -25,7 +31,7 @@ function getConfigFile(req, res) {
res.send([
"var loop = loop || {};",
"loop.config = loop.config || {};",
"loop.config.serverUrl = 'http://localhost:" + loopServerPort + "/v0';",
"loop.config.serverUrl = '" + loopServerUrl + "/v0';",
"loop.config.feedbackApiUrl = '" + feedbackApiUrl + "';",
"loop.config.feedbackProductName = '" + feedbackProductName + "';",
// XXX Update with the real marketplace url once the FxOS Loop app is
Expand Down Expand Up @@ -54,7 +60,6 @@ app.get('/content/c/config.js', getConfigFile);
// /ui - for the ui showcase
// /content - for the standalone files.

app.use('/test', express.static(__dirname + '/../test'));
app.use('/ui', express.static(__dirname + '/../ui'));

// This exists exclusively for the unit tests. They are served the
Expand All @@ -71,6 +76,10 @@ app.use('/content', express.static(__dirname + '/../content'));
app.use('/content/c', express.static(__dirname + '/content'));
app.use('/content/c', express.static(__dirname + '/../content'));

// Two lines for the same reason as /content above.
app.use('/test', express.static(__dirname + '/test'));
app.use('/test', express.static(__dirname + '/../test'));

// As we don't have hashes on the urls, the best way to serve the index files
// appears to be to be to closely filter the url and match appropriately.
function serveIndex(req, res) {
Expand Down
3 changes: 2 additions & 1 deletion browser/components/loop/test/functional/config.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Loop server configuration
CONTENT_SERVER_PORT = 3001
LOOP_SERVER_PORT = 5001
LOOP_SERVER_URL = "http://localhost:" + str(LOOP_SERVER_PORT)
FIREFOX_PREFERENCES = {
"loop.server": "http://localhost:" + str(LOOP_SERVER_PORT),
"loop.server": LOOP_SERVER_URL + "/v0",
"browser.dom.window.dump.enabled": True,
# Some more changes might be necesarry to have this working in offline mode
"media.peerconnection.default_iceservers": "[]",
Expand Down
4 changes: 2 additions & 2 deletions browser/components/loop/test/functional/serversetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# Set PORT so that it does not interfere with any other
# development server that might be running
CONTENT_SERVER_ENV.update({"PORT": str(CONTENT_SERVER_PORT),
"LOOP_SERVER_PORT": str(LOOP_SERVER_PORT)})
"LOOP_SERVER_URL": LOOP_SERVER_URL})

ROOMS_WEB_APP_URL = "http://localhost:" + str(CONTENT_SERVER_PORT) + \
"/content/{token}"
Expand All @@ -32,7 +32,7 @@
# development server that might be running
LOOP_SERVER_ENV.update({"NODE_ENV": "dev",
"PORT": str(LOOP_SERVER_PORT),
"SERVER_ADDRESS": "localhost:" + str(LOOP_SERVER_PORT),
"SERVER_ADDRESS": LOOP_SERVER_URL,
"ROOMS_WEB_APP_URL": ROOMS_WEB_APP_URL})


Expand Down

0 comments on commit 45e5cb1

Please sign in to comment.