Fix for failed tests
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
"scripts": {
|
||||
"postinstall": "cd src && npm install",
|
||||
"start": "gulp build && electron src",
|
||||
"test": "mocha"
|
||||
"test": "gulp build && mocha"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-preset-react": "^6.3.13",
|
||||
|
@@ -166,13 +166,17 @@ var MattermostView = React.createClass({
|
||||
// 'disablewebsecurity' is necessary to display external images.
|
||||
// However, it allows also CSS/JavaScript.
|
||||
// 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 config = settings.readFileSync(configFile);
|
||||
config = settings.readFileSync(configFile);
|
||||
} catch (e) {
|
||||
window.location = 'settings.html';
|
||||
}
|
||||
|
||||
var contextMenu = require('./menus/context');
|
||||
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 fs = require('fs');
|
||||
|
||||
var settings = require('./common/settings');
|
||||
var appMenu = require('./menus/app');
|
||||
|
||||
var argv = require('yargs').argv;
|
||||
@@ -27,6 +28,18 @@ else {
|
||||
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
|
||||
// be closed automatically when the JavaScript object is garbage collected.
|
||||
var mainWindow = null;
|
||||
|
@@ -80,18 +80,30 @@ describe('electron-mattermost', function() {
|
||||
});
|
||||
|
||||
describe('index.html', function() {
|
||||
before(function() {
|
||||
fs.writeFileSync(config_file_path, JSON.stringify({
|
||||
const config = {
|
||||
version: 1,
|
||||
teams: [{
|
||||
name: 'example_1',
|
||||
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);
|
||||
client
|
||||
.init()
|
||||
.getAttribute('#mainWebview', 'src').then(function(attribute) {
|
||||
attribute.should.equal(mattermost_url);
|
||||
.getAttribute('.mattermostView', 'src').then(function(attribute) {
|
||||
console.log(attribute);
|
||||
attribute.forEach(function(attr, index) {
|
||||
attr.should.equal(config.teams[index].url);
|
||||
});
|
||||
})
|
||||
.end().then(function() {
|
||||
done();
|
||||
|
Reference in New Issue
Block a user