forked from mattermost/desktop
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
313 additions
and
240 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
'use strict'; | ||
|
||
const path = require('path'); | ||
const webdriverio = require('webdriverio'); | ||
|
||
const source_root_dir = path.join(__dirname, '../..'); | ||
const electron_binary_path = (function() { | ||
if (process.platform === 'darwin') { | ||
return path.join(source_root_dir, 'node_modules/electron-prebuilt/dist/Electron.app/Contents/MacOS/Electron'); | ||
} | ||
else { | ||
const exe_extension = (process.platform === 'win32') ? '.exe' : ''; | ||
return path.join(source_root_dir, 'node_modules/electron-prebuilt/dist/electron' + exe_extension); | ||
} | ||
})(); | ||
const config_file_path = path.join(source_root_dir, 'test_config.json'); | ||
const mattermost_url = 'http://example.com/team'; | ||
|
||
var options = { | ||
host: 'localhost', // Use localhost as chrome driver server | ||
port: 9515, // "9515" is the port opened by chrome driver. | ||
desiredCapabilities: { | ||
browserName: 'chrome', | ||
chromeOptions: { | ||
binary: electron_binary_path, // Path to your Electron binary. | ||
args: ['app=' + path.join(source_root_dir, 'dist'), '--config-file=' + config_file_path] // Optional, perhaps 'app=' + /path/to/your/app/ | ||
} | ||
} | ||
}; | ||
|
||
module.exports = { | ||
sourceRootDir: source_root_dir, | ||
configFilePath: config_file_path, | ||
mattermostURL: mattermost_url, | ||
spawnChromeDriver: function() { | ||
return require('child_process').spawn('node_modules/chromedriver/lib/chromedriver/chromedriver', ['--url-base=wd/hub', '--port=9515']); | ||
}, | ||
getWebDriverIoClient: function() { | ||
return webdriverio.remote(options); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
'use strict'; | ||
|
||
const should = require('should'); | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
|
||
const env = require('../modules/environment'); | ||
|
||
describe('application', function() { | ||
this.timeout(10000); | ||
|
||
var chromedriver; | ||
var client; | ||
before(function(done) { | ||
chromedriver = env.spawnChromeDriver(); | ||
client = env.getWebDriverIoClient(); | ||
|
||
fs.unlink(env.configFilePath, function(err) { | ||
// waiting for chromedriver | ||
setTimeout(done, 1000); | ||
}); | ||
}); | ||
|
||
afterEach(function() { | ||
return client.end(); | ||
}); | ||
|
||
after(function() { | ||
chromedriver.kill(); | ||
}); | ||
|
||
it('should show settings.html when there is no config file', function() { | ||
return client | ||
.init() | ||
.pause(1000) | ||
.getUrl().then(function(url) { | ||
var p = path.parse(url); | ||
p.base.should.equal('settings.html'); | ||
}) | ||
.end(); | ||
}); | ||
|
||
it('should show index.html when there is config file', function() { | ||
fs.writeFileSync(env.configFilePath, JSON.stringify({ | ||
url: env.mattermostURL | ||
})); | ||
return client | ||
.init() | ||
.pause(1000) | ||
.getUrl().then(function(url) { | ||
var p = path.parse(url); | ||
p.base.should.equal('index.html'); | ||
}) | ||
.end(); | ||
}); | ||
|
||
it('should upgrade v0 config file', function() { | ||
const settings = require('../../src/common/settings'); | ||
fs.writeFileSync(env.configFilePath, JSON.stringify({ | ||
url: env.mattermostURL | ||
})); | ||
return client | ||
.init() | ||
.pause(1000) | ||
.getUrl().then(function(url) { | ||
var p = path.parse(url); | ||
p.base.should.equal('index.html'); | ||
}) | ||
.end().then(function() { | ||
var str = fs.readFileSync(env.configFilePath, 'utf8'); | ||
var config = JSON.parse(str); | ||
config.version.should.equal(settings.version); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.