Combine save/load tests

This commit is contained in:
Yuya Ochiai
2016-06-23 21:02:08 +09:00
parent 4fca00ec9d
commit 580bebdc66

View File

@@ -68,85 +68,73 @@ describe('browser/settings.html', function() {
}); });
[true, false].forEach(function(v) { [true, false].forEach(function(v) {
it(`should be loaded from config: ${v}`, function() { it(`should be saved and loaded: ${v}`, function() {
env.shouldTestForPlatforms(this, ['win32', 'linux']); env.shouldTestForPlatforms(this, ['win32', 'linux']);
var new_config = {}; addClientCommands(this.app.client);
Object.assign(new_config, config); return this.app.client
new_config.hideMenuBar = v; .loadSettingsPage()
fs.writeFileSync(env.configFilePath, JSON.stringify(new_config)); .isSelected('#inputHideMenuBar input').then((isSelected) => {
return this.app.restart().then(() => { if (isSelected !== v) {
addClientCommands(this.app.client); return this.app.client.click('#inputHideMenuBar input')
return this.app.client }
.loadSettingsPage() })
.isSelected('#inputHideMenuBar input').should.eventually.equal(v) .click('#btnSave')
.browserWindow.isMenuBarAutoHide().should.eventually.equal(v); .pause(1000).then(() => {
}); const saved_config = JSON.parse(fs.readFileSync(env.configFilePath, 'utf8'));
}); saved_config.hideMenuBar.should.equal(v);
}); })
// confirm actual behavior
[true, false].forEach(function(v) { .browserWindow.isMenuBarAutoHide().should.eventually.equal(v).then(() => {
it(`should be saved as config.json: ${v}`, function() { return this.app.restart();
env.shouldTestForPlatforms(this, ['win32', 'linux']); }).then(() => {
return this.app.restart().then(() => { addClientCommands(this.app.client);
addClientCommands(this.app.client); return this.app.client
return this.app.client // confirm actual behavior
.loadSettingsPage() .browserWindow.isMenuBarAutoHide().should.eventually.equal(v)
.isSelected('#inputHideMenuBar input').then((isSelected) => { .loadSettingsPage()
if (isSelected !== v) { .isSelected('#inputHideMenuBar input').should.eventually.equal(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);
});
});
}); });
}); });
}); });
describe('Allow mixed content', function() { describe('Allow mixed content', function() {
[true, false].forEach(function(v) { [true, false].forEach(function(v) {
it(`should be loaded from config: ${v}`, function() { it(`should be saved and loaded: ${v}`, function() {
var new_config = {}; addClientCommands(this.app.client);
Object.assign(new_config, config); return this.app.client
new_config.disablewebsecurity = v; .loadSettingsPage()
fs.writeFileSync(env.configFilePath, JSON.stringify(new_config)); .isSelected('#inputDisableWebSecurity input').then((isSelected) => {
return this.app.restart().then(() => { if (isSelected !== v) {
addClientCommands(this.app.client); return this.app.client.click('#inputDisableWebSecurity input')
return this.app.client }
.getAttribute('.mattermostView', 'disablewebsecurity').then((disablewebsecurity) => { })
// disablewebsecurity is an array of String .click('#btnSave')
disablewebsecurity.forEach((d) => { .pause(1000).then(() => {
v.toString().should.equal(d) 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);
})
}).then(() => {
return this.app.restart();
}).then(() => {
addClientCommands(this.app.client);
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()
.loadSettingsPage() .isSelected('#inputDisableWebSecurity input').should.eventually.equal(v);
.isSelected('#inputDisableWebSecurity input').should.eventually.equal(v); });
});
});
});
[true, false].forEach(function(v) {
it(`should be saved as config.json: ${v}`, function() {
return this.app.restart().then(() => {
addClientCommands(this.app.client);
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);
});
});
}); });
}); });
}); });