Bug 1128979 - Improve usability of loop-client test server - allow tests 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

This commit is contained in:
Mark Banner 2015-05-05 09:03:43 +01:00
Родитель 237b0d0d47
Коммит 45e5cb1b04
4 изменённых файлов: 17 добавлений и 7 удалений

Просмотреть файл

@ -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",

Просмотреть файл

@ -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";
@ -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
@ -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
@ -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) {

Просмотреть файл

@ -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": "[]",

Просмотреть файл

@ -21,7 +21,7 @@ CONTENT_SERVER_ENV = os.environ.copy()
# 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}"
@ -32,7 +32,7 @@ LOOP_SERVER_ENV = os.environ.copy()
# 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})