2016-05-02 06:34:00 -07:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const path = require('path');
|
|
|
|
const fs = require('fs');
|
|
|
|
|
|
|
|
const env = require('../../modules/environment');
|
|
|
|
|
|
|
|
describe('browser/settings.html', function() {
|
|
|
|
this.timeout(10000);
|
|
|
|
|
|
|
|
const config = {
|
|
|
|
version: 1,
|
|
|
|
teams: [{
|
|
|
|
name: 'example_1',
|
|
|
|
url: env.mattermostURL
|
|
|
|
}, {
|
|
|
|
name: 'example_2',
|
|
|
|
url: env.mattermostURL
|
|
|
|
}]
|
|
|
|
};
|
|
|
|
|
|
|
|
beforeEach(function() {
|
|
|
|
fs.writeFileSync(env.configFilePath, JSON.stringify(config));
|
2016-06-05 08:41:35 -07:00
|
|
|
this.app = env.getSpectronApp();
|
|
|
|
return this.app.start();
|
2016-05-02 06:34:00 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function() {
|
2016-05-21 01:23:23 -07:00
|
|
|
if (this.app && this.app.isRunning()) {
|
|
|
|
return this.app.stop()
|
|
|
|
}
|
2016-05-02 06:34:00 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should show index.thml when Cancel button is clicked', function() {
|
2016-06-25 05:21:10 -07:00
|
|
|
env.addClientCommands(this.app.client);
|
2016-06-21 08:35:04 -07:00
|
|
|
return this.app.client
|
|
|
|
.loadSettingsPage()
|
2016-06-05 08:41:35 -07:00
|
|
|
.click('#btnCancel')
|
|
|
|
.pause(1000)
|
|
|
|
.getUrl().should.eventually.match(/\/index.html$/)
|
2016-05-02 06:34:00 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should show index.thml when Save button is clicked', function() {
|
2016-06-25 05:21:10 -07:00
|
|
|
env.addClientCommands(this.app.client);
|
2016-06-21 08:35:04 -07:00
|
|
|
return this.app.client
|
|
|
|
.loadSettingsPage()
|
2016-06-05 08:41:35 -07:00
|
|
|
.click('#btnSave')
|
|
|
|
.pause(1000)
|
|
|
|
.getUrl().should.eventually.match(/\/index.html$/)
|
2016-05-02 06:34:00 -07:00
|
|
|
});
|
2016-05-02 08:42:13 -07:00
|
|
|
|
|
|
|
describe('Options', function() {
|
|
|
|
describe('Hide Menu Bar', function() {
|
|
|
|
it('should appear on win32 or linux', function() {
|
2016-06-05 08:41:35 -07:00
|
|
|
const expected = (process.platform === 'win32' || process.platform === 'linux');
|
2016-06-25 05:21:10 -07:00
|
|
|
env.addClientCommands(this.app.client);
|
2016-06-21 08:35:04 -07:00
|
|
|
return this.app.client
|
|
|
|
.loadSettingsPage()
|
2016-06-05 08:41:35 -07:00
|
|
|
.isExisting('#inputHideMenuBar').should.eventually.equal(expected)
|
2016-05-02 08:42:13 -07:00
|
|
|
});
|
|
|
|
|
2016-05-21 04:57:59 -07:00
|
|
|
[true, false].forEach(function(v) {
|
2016-06-25 01:05:51 -07:00
|
|
|
env.shouldTest(it, env.isOneOf(['win32', 'linux']))
|
|
|
|
(`should be saved and loaded: ${v}`, function() {
|
2016-06-25 05:21:10 -07:00
|
|
|
env.addClientCommands(this.app.client);
|
2016-06-25 01:05:51 -07:00
|
|
|
return this.app.client
|
|
|
|
.loadSettingsPage()
|
|
|
|
.isSelected('#inputHideMenuBar input').then((isSelected) => {
|
|
|
|
if (isSelected !== v) {
|
|
|
|
return this.app.client.click('#inputHideMenuBar input')
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.click('#btnSave')
|
|
|
|
.pause(1000).then(() => {
|
|
|
|
const saved_config = JSON.parse(fs.readFileSync(env.configFilePath, 'utf8'));
|
|
|
|
saved_config.hideMenuBar.should.equal(v);
|
|
|
|
})
|
|
|
|
// confirm actual behavior
|
|
|
|
.browserWindow.isMenuBarAutoHide().should.eventually.equal(v).then(() => {
|
|
|
|
return this.app.restart();
|
|
|
|
}).then(() => {
|
2016-06-25 05:21:10 -07:00
|
|
|
env.addClientCommands(this.app.client);
|
2016-06-25 01:05:51 -07:00
|
|
|
return this.app.client
|
|
|
|
// confirm actual behavior
|
|
|
|
.browserWindow.isMenuBarAutoHide().should.eventually.equal(v)
|
|
|
|
.loadSettingsPage()
|
|
|
|
.isSelected('#inputHideMenuBar input').should.eventually.equal(v);
|
|
|
|
});
|
|
|
|
});
|
2016-05-21 04:57:59 -07:00
|
|
|
});
|
2016-05-02 08:42:13 -07:00
|
|
|
});
|
2016-06-21 08:33:14 -07:00
|
|
|
|
|
|
|
describe('Allow mixed content', function() {
|
|
|
|
[true, false].forEach(function(v) {
|
2016-06-23 05:02:08 -07:00
|
|
|
it(`should be saved and loaded: ${v}`, function() {
|
2016-06-25 05:21:10 -07:00
|
|
|
env.addClientCommands(this.app.client);
|
2016-06-23 05:02:08 -07:00
|
|
|
return this.app.client
|
|
|
|
.loadSettingsPage()
|
|
|
|
.isSelected('#inputDisableWebSecurity input').then((isSelected) => {
|
|
|
|
if (isSelected !== v) {
|
|
|
|
return this.app.client.click('#inputDisableWebSecurity input')
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.click('#btnSave')
|
|
|
|
.pause(1000).then(() => {
|
|
|
|
const saved_config = JSON.parse(fs.readFileSync(env.configFilePath, 'utf8'));
|
|
|
|
saved_config.disablewebsecurity.should.equal(v);
|
|
|
|
})
|
|
|
|
// confirm actual behavior
|
|
|
|
.getAttribute('.mattermostView', 'disablewebsecurity').then((disablewebsecurity) => {
|
|
|
|
// disablewebsecurity is an array of String
|
|
|
|
disablewebsecurity.forEach((d) => {
|
|
|
|
v.toString().should.equal(d);
|
2016-06-21 08:33:14 -07:00
|
|
|
})
|
2016-06-23 05:02:08 -07:00
|
|
|
}).then(() => {
|
|
|
|
return this.app.restart();
|
|
|
|
}).then(() => {
|
2016-06-25 05:21:10 -07:00
|
|
|
env.addClientCommands(this.app.client);
|
2016-06-23 05:02:08 -07:00
|
|
|
return this.app.client
|
|
|
|
// confirm actual behavior
|
|
|
|
.getAttribute('.mattermostView', 'disablewebsecurity').then((disablewebsecurity) => {
|
|
|
|
// disablewebsecurity is an array of String
|
|
|
|
disablewebsecurity.forEach((d) => {
|
|
|
|
v.toString().should.equal(d);
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.loadSettingsPage()
|
|
|
|
.isSelected('#inputDisableWebSecurity input').should.eventually.equal(v);
|
|
|
|
});
|
2016-06-21 08:33:14 -07:00
|
|
|
});
|
|
|
|
});
|
2016-06-22 08:03:04 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
describe('Start app on login', function() {
|
|
|
|
it('should appear on win32 or linux', function() {
|
|
|
|
const expected = (process.platform === 'win32' || process.platform === 'linux');
|
2016-06-25 05:21:10 -07:00
|
|
|
env.addClientCommands(this.app.client);
|
2016-06-22 08:03:04 -07:00
|
|
|
return this.app.client
|
|
|
|
.loadSettingsPage()
|
|
|
|
.isExisting('#inputAutoStart').should.eventually.equal(expected)
|
|
|
|
});
|
|
|
|
});
|
2016-06-21 08:33:14 -07:00
|
|
|
|
2016-06-22 08:03:04 -07:00
|
|
|
describe('Show tray icon', function() {
|
|
|
|
it('should appear on darwin or linux', function() {
|
|
|
|
const expected = (process.platform === 'darwin' || process.platform === 'linux');
|
2016-06-25 05:21:10 -07:00
|
|
|
env.addClientCommands(this.app.client);
|
2016-06-22 08:03:04 -07:00
|
|
|
return this.app.client
|
|
|
|
.loadSettingsPage()
|
|
|
|
.isExisting('#inputShowTrayIcon').should.eventually.equal(expected)
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2016-07-03 07:12:04 -07:00
|
|
|
describe('Minimize to tray', function() {
|
2016-07-05 07:49:10 -07:00
|
|
|
it('should appear on darwin or linux', function() {
|
|
|
|
const expected = (process.platform === 'darwin' || process.platform === 'linux');
|
2016-07-03 07:12:04 -07:00
|
|
|
env.addClientCommands(this.app.client);
|
|
|
|
return this.app.client
|
|
|
|
.loadSettingsPage()
|
|
|
|
.isExisting('#inputMinimizeToTray').should.eventually.equal(expected)
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2016-06-28 06:09:05 -07:00
|
|
|
describe('Toggle window visibility when clicking on the tray icon', function() {
|
2016-06-30 13:17:31 -07:00
|
|
|
it('should appear on win32', function() {
|
2016-06-28 06:09:05 -07:00
|
|
|
const expected = (process.platform === 'win32');
|
|
|
|
env.addClientCommands(this.app.client);
|
|
|
|
return this.app.client
|
|
|
|
.loadSettingsPage()
|
|
|
|
.isExisting('#inputToggleWindowOnTrayIconClick').should.eventually.equal(expected)
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2016-09-12 08:53:45 -07:00
|
|
|
describe('Flash taskbar icon on new messages', function() {
|
2016-07-12 13:14:32 -07:00
|
|
|
it('should appear on win32 and linux', function() {
|
|
|
|
const expected = (process.platform === 'win32' || process.platform === 'linux');
|
2016-06-25 05:21:10 -07:00
|
|
|
env.addClientCommands(this.app.client);
|
2016-06-22 08:03:04 -07:00
|
|
|
return this.app.client
|
|
|
|
.loadSettingsPage()
|
2016-09-12 08:53:45 -07:00
|
|
|
.isExisting('#inputflashWindow').should.eventually.equal(expected)
|
2016-06-22 08:03:04 -07:00
|
|
|
});
|
2016-06-21 08:33:14 -07:00
|
|
|
});
|
2016-07-15 04:04:14 -07:00
|
|
|
|
|
|
|
describe('Show red icon for unread', function() {
|
|
|
|
it('should appear on darwin or win32', function() {
|
|
|
|
const expected = (process.platform === 'darwin' || process.platform === 'win32');
|
|
|
|
env.addClientCommands(this.app.client);
|
|
|
|
return this.app.client
|
|
|
|
.loadSettingsPage()
|
|
|
|
.isExisting('#inputShowUnreadBadge').should.eventually.equal(expected)
|
|
|
|
});
|
|
|
|
});
|
2016-05-02 08:42:13 -07:00
|
|
|
});
|
2016-09-12 08:53:45 -07:00
|
|
|
});
|