From b4e3cc0e6cb26a2a7b743b00e1868b517145ea94 Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Mon, 15 May 2017 14:47:45 -0700 Subject: [PATCH] Load test page and run tests on start when NODE_ENV=test FREEBIE --- config/default.json | 1 + config/development.json | 1 - config/staging.json | 1 - config/test.json | 5 +++++ main.js | 35 +++++++++++++++++++++-------------- 5 files changed, 27 insertions(+), 16 deletions(-) create mode 100644 config/test.json diff --git a/config/default.json b/config/default.json index bc80b74af..244243b9c 100644 --- a/config/default.json +++ b/config/default.json @@ -1,4 +1,5 @@ { + "serverUrl": "https://textsecure-service-staging.whispersystems.org", "disableAutoUpdate": false, "openDevTools": false, "buildExpiration": 0 diff --git a/config/development.json b/config/development.json index 4024e4f0d..f0324abfe 100644 --- a/config/development.json +++ b/config/development.json @@ -1,5 +1,4 @@ { - "serverUrl": "https://textsecure-service-staging.whispersystems.org", "storageProfile": "development", "disableAutoUpdate": true, "openDevTools": true diff --git a/config/staging.json b/config/staging.json index a4f990b35..acc5ac72d 100644 --- a/config/staging.json +++ b/config/staging.json @@ -1,5 +1,4 @@ { - "serverUrl": "https://textsecure-service-staging.whispersystems.org", "storageProfile": "staging", "disableAutoUpdate": true, "openDevTools": true diff --git a/config/test.json b/config/test.json new file mode 100644 index 000000000..6d19ca42e --- /dev/null +++ b/config/test.json @@ -0,0 +1,5 @@ +{ + "storageProfile": "test", + "disableAutoUpdate": true, + "openDevTools": true +} diff --git a/main.js b/main.js index 55b64c304..748e4ac5b 100644 --- a/main.js +++ b/main.js @@ -96,20 +96,27 @@ function createWindow () { event.returnValue = localeData; }); - // and load the index.html of the app. - mainWindow.loadURL(url.format({ - pathname: path.join(__dirname, 'background.html'), - protocol: 'file:', - slashes: true, - query: { - locale: locale, - version: package_json.version, - buildExpiration: config.get('buildExpiration'), - serverUrl: config.get('serverUrl'), - environment: environment, - node_version: process.versions.node - } - })) + function prepareURL(pathSegments) { + return url.format({ + pathname: path.join.apply(null, pathSegments), + protocol: 'file:', + slashes: true, + query: { + locale: locale, + version: package_json.version, + buildExpiration: config.get('buildExpiration'), + serverUrl: config.get('serverUrl'), + environment: environment, + node_version: process.versions.node + } + }) + } + + if (process.env.NODE_ENV === 'test') { + mainWindow.loadURL(prepareURL([__dirname, 'test', 'index.html'])); + } else { + mainWindow.loadURL(prepareURL([__dirname, 'background.html'])); + } if (config.get('openDevTools')) { // Open the DevTools.