Use primitive and promise-style test cases
On OS X, tests for multiple elements often failed (#5). So I replaced them with primitive way.
This commit is contained in:
parent
0b2ad75712
commit
e53a43d17a
|
@ -75,7 +75,8 @@ var MainPage = React.createClass({
|
||||||
var handleNotificationClick = function() {
|
var handleNotificationClick = function() {
|
||||||
thisObj.handleSelect(index);
|
thisObj.handleSelect(index);
|
||||||
}
|
}
|
||||||
return (<MattermostView style={ thisObj.visibleStyle(thisObj.state.key === index) } src={ team.url } onUnreadCountChange={ handleUnreadCountChange } onNotificationClick={ handleNotificationClick } />)
|
return (<MattermostView id={ 'mattermostView' + index } style={ thisObj.visibleStyle(thisObj.state.key === index) } src={ team.url } onUnreadCountChange={ handleUnreadCountChange } onNotificationClick={ handleNotificationClick }
|
||||||
|
/>)
|
||||||
});
|
});
|
||||||
return (
|
return (
|
||||||
<Grid fluid>
|
<Grid fluid>
|
||||||
|
@ -166,7 +167,7 @@ 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 className="mattermostView" style={ this.props.style } preload="webview/mattermost.js" src={ this.props.src } ref="webview"></webview>);
|
return (<webview id={ this.props.id } className="mattermostView" style={ this.props.style } preload="webview/mattermost.js" src={ this.props.src } ref="webview"></webview>);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -45,49 +45,43 @@ describe('electron-mattermost', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function(done) {
|
afterEach(function() {
|
||||||
client.end().then(function() {
|
return client.end();
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
after(function() {
|
after(function() {
|
||||||
chromedriver.kill();
|
chromedriver.kill();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should show settings.html when there is no config file', function(done) {
|
it('should show settings.html when there is no config file', function() {
|
||||||
client
|
return client
|
||||||
.init()
|
.init()
|
||||||
.getUrl().then(function(url) {
|
.getUrl().then(function(url) {
|
||||||
var p = path.parse(url);
|
var p = path.parse(url);
|
||||||
p.base.should.equal('settings.html');
|
p.base.should.equal('settings.html');
|
||||||
})
|
})
|
||||||
.end().then(function() {
|
.end();
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should show index.html when there is config file', function(done) {
|
it('should show index.html when there is config file', function() {
|
||||||
fs.writeFileSync(config_file_path, JSON.stringify({
|
fs.writeFileSync(config_file_path, JSON.stringify({
|
||||||
url: mattermost_url
|
url: mattermost_url
|
||||||
}));
|
}));
|
||||||
client
|
return client
|
||||||
.init()
|
.init()
|
||||||
.getUrl().then(function(url) {
|
.getUrl().then(function(url) {
|
||||||
var p = path.parse(url);
|
var p = path.parse(url);
|
||||||
p.base.should.equal('index.html');
|
p.base.should.equal('index.html');
|
||||||
})
|
})
|
||||||
.end().then(function() {
|
.end();
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should upgrade v0 config file', function(done) {
|
it('should upgrade v0 config file', function() {
|
||||||
const settings = require('../src/common/settings');
|
const settings = require('../src/common/settings');
|
||||||
fs.writeFileSync(config_file_path, JSON.stringify({
|
fs.writeFileSync(config_file_path, JSON.stringify({
|
||||||
url: mattermost_url
|
url: mattermost_url
|
||||||
}));
|
}));
|
||||||
client
|
return client
|
||||||
.init()
|
.init()
|
||||||
.getUrl().then(function(url) {
|
.getUrl().then(function(url) {
|
||||||
var p = path.parse(url);
|
var p = path.parse(url);
|
||||||
|
@ -97,7 +91,6 @@ describe('electron-mattermost', function() {
|
||||||
var str = fs.readFileSync(config_file_path, 'utf8');
|
var str = fs.readFileSync(config_file_path, 'utf8');
|
||||||
var config = JSON.parse(str);
|
var config = JSON.parse(str);
|
||||||
config.version.should.equal(settings.version);
|
config.version.should.equal(settings.version);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -106,10 +99,10 @@ describe('electron-mattermost', function() {
|
||||||
version: 1,
|
version: 1,
|
||||||
teams: [{
|
teams: [{
|
||||||
name: 'example_1',
|
name: 'example_1',
|
||||||
url: mattermost_url
|
url: mattermost_url + '1'
|
||||||
}, {
|
}, {
|
||||||
name: 'example_2',
|
name: 'example_2',
|
||||||
url: mattermost_url
|
url: mattermost_url + '2'
|
||||||
}]
|
}]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -117,55 +110,49 @@ describe('electron-mattermost', function() {
|
||||||
fs.writeFileSync(config_file_path, JSON.stringify(config));
|
fs.writeFileSync(config_file_path, JSON.stringify(config));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set src of webview from config file', function(done) {
|
it('should set src of webview from config file', function() {
|
||||||
client
|
return client
|
||||||
.init()
|
.init()
|
||||||
.getAttribute('.mattermostView', 'src').then(function(attribute) {
|
.getAttribute('#mattermostView0', 'src').then(function(attribute) {
|
||||||
attribute.forEach(function(attr, index) {
|
attribute.should.equal(config.teams[0].url);
|
||||||
attr.should.equal(config.teams[index].url);
|
|
||||||
});
|
|
||||||
})
|
})
|
||||||
.end().then(function() {
|
.getAttribute('#mattermostView1', 'src').then(function(attribute) {
|
||||||
done();
|
attribute.should.equal(config.teams[1].url);
|
||||||
});
|
})
|
||||||
|
.isExisting('#mattermostView2').then(function(isExisting) {
|
||||||
|
isExisting.should.be.false();
|
||||||
|
})
|
||||||
|
.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set name of tab from config file', function(done) {
|
it('should set name of tab from config file', function() {
|
||||||
client
|
return client
|
||||||
.init()
|
.init()
|
||||||
.getText('.teamTabItem').then(function(text) {
|
.getText('#teamTabItem0').then(function(text) {
|
||||||
text.forEach(function(t, index) {
|
text.should.equal(config.teams[0].name);
|
||||||
t.should.equal(config.teams[index].name);
|
|
||||||
});
|
|
||||||
})
|
})
|
||||||
.end().then(function() {
|
.getText('#teamTabItem1').then(function(text) {
|
||||||
done();
|
text.should.equal(config.teams[1].name);
|
||||||
});
|
})
|
||||||
|
.isExisting('#teamTabItem2').then(function(isExisting) {
|
||||||
|
isExisting.should.be.false();
|
||||||
|
})
|
||||||
|
.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should show only the selected team', function(done) {
|
it('should show only the selected team', function() {
|
||||||
var checkVisility = function(visibleIndex) {
|
return client
|
||||||
return function(isVisible) {
|
|
||||||
isVisible.forEach(function(v, index) {
|
|
||||||
if (index === visibleIndex) {
|
|
||||||
v.should.equal(true);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
v.should.equal(false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
};
|
|
||||||
client
|
|
||||||
.init()
|
.init()
|
||||||
.isVisible('.mattermostView').then(checkVisility(0))
|
.waitForVisible('#mattermostView0')
|
||||||
|
.isVisible('#mattermostView1').then(function(visility) {
|
||||||
|
visility.should.be.false();
|
||||||
|
})
|
||||||
.click('#teamTabItem1')
|
.click('#teamTabItem1')
|
||||||
.isVisible('.mattermostView').then(checkVisility(1))
|
.waitForVisible('#mattermostView1')
|
||||||
.click('#teamTabItem0')
|
.isVisible('#mattermostView0').then(function(visility) {
|
||||||
.isVisible('.mattermostView').then(checkVisility(0))
|
visility.should.be.false();
|
||||||
.end().then(function() {
|
})
|
||||||
done();
|
.end();
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -185,8 +172,8 @@ describe('electron-mattermost', function() {
|
||||||
fs.writeFileSync(config_file_path, JSON.stringify(config));
|
fs.writeFileSync(config_file_path, JSON.stringify(config));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should show index.thml when Cancel button is clicked', function(done) {
|
it('should show index.thml when Cancel button is clicked', function() {
|
||||||
client
|
return client
|
||||||
.init()
|
.init()
|
||||||
.url('file://' + path.join(source_root_dir, 'src/browser/settings.html'))
|
.url('file://' + path.join(source_root_dir, 'src/browser/settings.html'))
|
||||||
.waitForExist('#btnCancel')
|
.waitForExist('#btnCancel')
|
||||||
|
@ -196,13 +183,11 @@ describe('electron-mattermost', function() {
|
||||||
var url_split = url.split('/');
|
var url_split = url.split('/');
|
||||||
url_split[url_split.length - 1].should.equal('index.html');
|
url_split[url_split.length - 1].should.equal('index.html');
|
||||||
})
|
})
|
||||||
.end().then(function() {
|
.end();
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should show index.thml when Save button is clicked', function(done) {
|
it('should show index.thml when Save button is clicked', function() {
|
||||||
client
|
return client
|
||||||
.init()
|
.init()
|
||||||
.url('file://' + path.join(source_root_dir, 'src/browser/settings.html'))
|
.url('file://' + path.join(source_root_dir, 'src/browser/settings.html'))
|
||||||
.waitForExist('#btnSave')
|
.waitForExist('#btnSave')
|
||||||
|
@ -212,9 +197,7 @@ describe('electron-mattermost', function() {
|
||||||
var url_split = url.split('/');
|
var url_split = url.split('/');
|
||||||
url_split[url_split.length - 1].should.equal('index.html');
|
url_split[url_split.length - 1].should.equal('index.html');
|
||||||
})
|
})
|
||||||
.end().then(function() {
|
.end();
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue