Fix for failed tests
This commit is contained in:
@@ -8,7 +8,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"postinstall": "cd src && npm install",
|
"postinstall": "cd src && npm install",
|
||||||
"start": "gulp build && electron src",
|
"start": "gulp build && electron src",
|
||||||
"test": "mocha"
|
"test": "gulp build && mocha"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"babel-preset-react": "^6.3.13",
|
"babel-preset-react": "^6.3.13",
|
||||||
|
@@ -166,13 +166,17 @@ var MattermostView = React.createClass({
|
|||||||
// 'disablewebsecurity' is necessary to display external images.
|
// 'disablewebsecurity' is necessary to display external images.
|
||||||
// However, it allows also CSS/JavaScript.
|
// However, it allows also CSS/JavaScript.
|
||||||
// So webview should use 'allowDisplayingInsecureContent' as same as BrowserWindow.
|
// So webview should use 'allowDisplayingInsecureContent' as same as BrowserWindow.
|
||||||
return (<webview style={ this.props.style } preload="webview/mattermost.js" src={ this.props.src } ref="webview"></webview>);
|
return (<webview className="mattermostView" style={ this.props.style } preload="webview/mattermost.js" src={ this.props.src } ref="webview"></webview>);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var config;
|
||||||
|
try {
|
||||||
var configFile = remote.getGlobal('config-file');
|
var configFile = remote.getGlobal('config-file');
|
||||||
var config = settings.readFileSync(configFile);
|
config = settings.readFileSync(configFile);
|
||||||
|
} catch (e) {
|
||||||
|
window.location = 'settings.html';
|
||||||
|
}
|
||||||
|
|
||||||
var contextMenu = require('./menus/context');
|
var contextMenu = require('./menus/context');
|
||||||
var menu = contextMenu.createDefault();
|
var menu = contextMenu.createDefault();
|
||||||
|
13
src/main.js
13
src/main.js
@@ -8,6 +8,7 @@ const Tray = electron.Tray;
|
|||||||
const ipc = electron.ipcMain;
|
const ipc = electron.ipcMain;
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
|
||||||
|
var settings = require('./common/settings');
|
||||||
var appMenu = require('./menus/app');
|
var appMenu = require('./menus/app');
|
||||||
|
|
||||||
var argv = require('yargs').argv;
|
var argv = require('yargs').argv;
|
||||||
@@ -27,6 +28,18 @@ else {
|
|||||||
global['config-file'] = app.getPath('userData') + '/config.json'
|
global['config-file'] = app.getPath('userData') + '/config.json'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
var configFile = global['config-file'];
|
||||||
|
var config = settings.readFileSync(configFile);
|
||||||
|
if (config.version != settings.version) {
|
||||||
|
config = settings.upgrade(config);
|
||||||
|
settings.writeFileSync(configFile, config);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
console.log('Failed to read or upgrade config.json');
|
||||||
|
}
|
||||||
|
|
||||||
// Keep a global reference of the window object, if you don't, the window will
|
// 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.
|
// be closed automatically when the JavaScript object is garbage collected.
|
||||||
var mainWindow = null;
|
var mainWindow = null;
|
||||||
|
@@ -80,18 +80,30 @@ describe('electron-mattermost', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('index.html', function() {
|
describe('index.html', function() {
|
||||||
before(function() {
|
const config = {
|
||||||
fs.writeFileSync(config_file_path, JSON.stringify({
|
version: 1,
|
||||||
|
teams: [{
|
||||||
|
name: 'example_1',
|
||||||
url: mattermost_url
|
url: mattermost_url
|
||||||
}));
|
}, {
|
||||||
|
name: 'example_2',
|
||||||
|
url: mattermost_url
|
||||||
|
}]
|
||||||
|
};
|
||||||
|
|
||||||
|
before(function() {
|
||||||
|
fs.writeFileSync(config_file_path, JSON.stringify(config));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set src of #mainWebview from config file', function(done) {
|
it('should set src of webview from config file', function(done) {
|
||||||
var client = webdriverio.remote(options);
|
var client = webdriverio.remote(options);
|
||||||
client
|
client
|
||||||
.init()
|
.init()
|
||||||
.getAttribute('#mainWebview', 'src').then(function(attribute) {
|
.getAttribute('.mattermostView', 'src').then(function(attribute) {
|
||||||
attribute.should.equal(mattermost_url);
|
console.log(attribute);
|
||||||
|
attribute.forEach(function(attr, index) {
|
||||||
|
attr.should.equal(config.teams[index].url);
|
||||||
|
});
|
||||||
})
|
})
|
||||||
.end().then(function() {
|
.end().then(function() {
|
||||||
done();
|
done();
|
||||||
|
Reference in New Issue
Block a user