Merge branch 'e2e-test'
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,2 +1,5 @@
|
||||
node_modules/
|
||||
release/
|
||||
npm-debug.log
|
||||
|
||||
test_config.json
|
||||
|
@@ -1,3 +1,7 @@
|
||||
machine:
|
||||
node:
|
||||
version: 4.2.2
|
||||
|
||||
dependencies:
|
||||
post:
|
||||
- sudo service docker start
|
||||
@@ -12,10 +16,6 @@ dependencies:
|
||||
- tar zcvf $CIRCLE_ARTIFACTS/electron-mattermost-linux-ia32.tar.gz -C release electron-mattermost-linux-ia32
|
||||
- tar zcvf $CIRCLE_ARTIFACTS/electron-mattermost-linux-x64.tar.gz -C release electron-mattermost-linux-x64
|
||||
|
||||
test:
|
||||
override:
|
||||
- exit 0
|
||||
|
||||
deployment:
|
||||
release:
|
||||
tag: /v[0-9]+(\.[0-9]+)*/
|
||||
|
@@ -1,7 +1,7 @@
|
||||
FROM suchja/wine:latest
|
||||
MAINTAINER Yuya Ochiai <yuya0321@gmail.com>
|
||||
|
||||
ENV NODE_VERSION=v4.2.3
|
||||
ENV NODE_VERSION=v4.2.2
|
||||
ENV PATH=$HOME/.nodebrew/current/bin:$PATH
|
||||
|
||||
USER root
|
||||
|
@@ -7,13 +7,18 @@
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"postinstall": "cd src && npm install",
|
||||
"start": "electron src"
|
||||
"start": "electron src",
|
||||
"test": "mocha"
|
||||
},
|
||||
"devDependencies": {
|
||||
"chromedriver": "^2.20.0",
|
||||
"electron-connect": "^0.3.3",
|
||||
"electron-packager": "^5.1.0",
|
||||
"electron-prebuilt": "^0.35.1",
|
||||
"gulp": "^3.9.0",
|
||||
"gulp-jsbeautifier": "^1.0.1"
|
||||
"gulp-jsbeautifier": "^1.0.1",
|
||||
"mocha": "^2.3.4",
|
||||
"should": "^8.0.1",
|
||||
"webdriverio": "^3.3.0"
|
||||
}
|
||||
}
|
||||
|
@@ -12,8 +12,9 @@ var contextMenu = require('./menus/context');
|
||||
var webView = document.getElementById('mainWebview');
|
||||
|
||||
try {
|
||||
var configFile = electron.remote.app.getPath('userData') + '/config.json';
|
||||
var config = require(configFile);
|
||||
var configFile = remote.getGlobal('config-file');
|
||||
var str = fs.readFileSync(configFile);
|
||||
var config = JSON.parse(str);
|
||||
if (config.url) {
|
||||
webView.setAttribute('src', config.url);
|
||||
}
|
||||
|
11
src/main.js
11
src/main.js
@@ -10,14 +10,23 @@ const fs = require('fs');
|
||||
|
||||
var appMenu = require('./menus/app');
|
||||
|
||||
var argv = require('yargs').argv;
|
||||
|
||||
var client = null;
|
||||
if (process.argv.indexOf('--livereload') > 0) {
|
||||
if (argv.livereload) {
|
||||
client = require('electron-connect').client.create();
|
||||
client.on('stop', function() {
|
||||
app.quit();
|
||||
});
|
||||
}
|
||||
|
||||
if (argv['config-file']) {
|
||||
global['config-file'] = argv['config-file'];
|
||||
}
|
||||
else {
|
||||
global['config-file'] = app.getPath('userData') + '/config.json'
|
||||
}
|
||||
|
||||
// Keep a global reference of the window object, if you don't, the window will
|
||||
// be closed automatically when the JavaScript object is garbage collected.
|
||||
var mainWindow = null;
|
||||
|
@@ -9,6 +9,7 @@
|
||||
"electron-connect": "^0.3.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"os-locale": "^1.4.0"
|
||||
"os-locale": "^1.4.0",
|
||||
"yargs": "^3.31.0"
|
||||
}
|
||||
}
|
||||
|
@@ -19,7 +19,7 @@
|
||||
var fs = require('fs');
|
||||
|
||||
var saveSettings = function() {
|
||||
var configFile = remote.app.getPath('userData') + '/config.json';
|
||||
var configFile = remote.getGlobal('config-file');
|
||||
var urlInput = document.getElementById('url');
|
||||
var config = {
|
||||
url: urlInput.value
|
||||
|
81
test/test.js
Normal file
81
test/test.js
Normal file
@@ -0,0 +1,81 @@
|
||||
const webdriverio = require('webdriverio');
|
||||
const should = require('should');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
const exe_extension = (process.platform === 'win32') ? ".exe" : "";
|
||||
const source_root_dir = path.join(__dirname, '..');
|
||||
const electron_binary_path = path.join(source_root_dir, 'node_modules/electron-prebuilt/dist/electron' + exe_extension);
|
||||
const config_file_path = path.join(source_root_dir, 'test_config.json');
|
||||
const mattermost_url = 'http://example.com/team';
|
||||
|
||||
var chromedriver = require('child_process').spawn('node_modules/chromedriver/lib/chromedriver/chromedriver', ['--url-base=wd/hub', '--port=9515']);
|
||||
|
||||
var options = {
|
||||
host: "localhost", // Use localhost as chrome driver server
|
||||
port: 9515, // "9515" is the port opened by chrome driver.
|
||||
desiredCapabilities: {
|
||||
browserName: 'chrome',
|
||||
chromeOptions: {
|
||||
binary: electron_binary_path, // Path to your Electron binary.
|
||||
args: ['app=' + path.join(source_root_dir, 'src'), '--config-file=' + config_file_path] // Optional, perhaps 'app=' + /path/to/your/app/
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
describe('electron-mattermost', function() {
|
||||
before(function(done) {
|
||||
fs.unlink(config_file_path, function(err) {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should show settings.html when there is no config file', function(done) {
|
||||
var client = webdriverio.remote(options);
|
||||
client
|
||||
.init()
|
||||
.getUrl().then(function(url) {
|
||||
var p = path.parse(url);
|
||||
p.base.should.equal('settings.html');
|
||||
})
|
||||
.end().then(function() {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should show index.html when there is config file', function(done) {
|
||||
fs.writeFileSync(config_file_path, JSON.stringify({
|
||||
url: mattermost_url
|
||||
}));
|
||||
var client = webdriverio.remote(options);
|
||||
client
|
||||
.init()
|
||||
.getUrl().then(function(url) {
|
||||
var p = path.parse(url);
|
||||
p.base.should.equal('index.html');
|
||||
})
|
||||
.end().then(function() {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
describe('index.html', function() {
|
||||
before(function() {
|
||||
fs.writeFileSync(config_file_path, JSON.stringify({
|
||||
url: mattermost_url
|
||||
}));
|
||||
});
|
||||
|
||||
it('should set src of #mainWebview from config file', function(done) {
|
||||
var client = webdriverio.remote(options);
|
||||
client
|
||||
.init()
|
||||
.getAttribute('#mainWebview', 'src').then(function(attribute) {
|
||||
attribute.should.equal(mattermost_url);
|
||||
})
|
||||
.end().then(function() {
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user