more test fixing

This commit is contained in:
Girish Ramakrishnan 2015-11-25 01:36:29 -08:00
parent 813bbcb003
commit cdeb4396d5

View file

@ -12,8 +12,6 @@ var execSync = require('child_process').execSync,
superagent = require('superagent'), superagent = require('superagent'),
webdriver = require('selenium-webdriver'); webdriver = require('selenium-webdriver');
var firefox = require('selenium-webdriver/firefox');
var server, browser = new firefox.Driver();
var by = require('selenium-webdriver').By, var by = require('selenium-webdriver').By,
until = require('selenium-webdriver').until; until = require('selenium-webdriver').until;
@ -21,7 +19,13 @@ process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
describe('Application life cycle test', function () { describe('Application life cycle test', function () {
this.timeout(0); this.timeout(0);
var server, browser = new require('selenium-webdriver/firefox').Driver(); var firefox = require('selenium-webdriver/firefox');
var server, browser = new firefox.Driver();
var LOCATION = 'gogstest';
var repodir = '/tmp/testrepo';
var app, reponame = 'testrepo';
var username = process.env.USERNAME;
var password = process.env.PASSWORD;
before(function (done) { before(function (done) {
if (!process.env.USERNAME) return done(new Error('USERNAME env var not set')); if (!process.env.USERNAME) return done(new Error('USERNAME env var not set'));
@ -38,15 +42,11 @@ describe('Application life cycle test', function () {
after(function (done) { after(function (done) {
browser.quit(); browser.quit();
server.stop(); server.stop();
rimraf.sync(repodir);
done(); done();
}); });
var LOCATION = 'test' + Date.now(); xit('build app', function () {
var app, reponame = 'testrepo';
var username = process.env.USERNAME;
var password = process.env.PASSWORD;
it('build app', function () {
execSync('cloudron build', { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }); execSync('cloudron build', { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
}); });
@ -76,7 +76,7 @@ describe('Application life cycle test', function () {
browser.findElement(by.id('user_name')).sendKeys(username); browser.findElement(by.id('user_name')).sendKeys(username);
browser.findElement(by.id('password')).sendKeys(password); browser.findElement(by.id('password')).sendKeys(password);
browser.findElement(by.tagName('form')).submit(); browser.findElement(by.tagName('form')).submit();
browser.wait(until.elementLocated(by.linkText('Dashboard')), 4000).then(done); browser.wait(until.elementLocated(by.linkText('Dashboard')), 4000).then(function () { done(); });
}); });
it('can add public key', function (done) { it('can add public key', function (done) {
@ -87,7 +87,7 @@ describe('Application life cycle test', function () {
browser.findElement(by.id('title')).sendKeys('testkey'); browser.findElement(by.id('title')).sendKeys('testkey');
browser.findElement(by.id('content')).sendKeys(publicKey); browser.findElement(by.id('content')).sendKeys(publicKey);
browser.findElement(by.xpath('//button[contains(text(), "Add Key")]')).click(); browser.findElement(by.xpath('//button[contains(text(), "Add Key")]')).click();
browser.wait(until.elementLocated(by.xpath('p[contains(text(), "added successfully!")]')), 4000).then(done); browser.wait(until.elementLocated(by.xpath('//p[contains(text(), "added successfully!")]')), 4000).then(function () { done(); });
}); });
it('can create repo', function (done) { it('can create repo', function (done) {
@ -101,7 +101,7 @@ describe('Application life cycle test', function () {
return browser.getCurrentUrl().then(function (url) { return browser.getCurrentUrl().then(function (url) {
return url === 'https://' + app.fqdn + '/' + username + '/' + reponame; return url === 'https://' + app.fqdn + '/' + username + '/' + reponame;
}); });
}, 4000).then(done); }, 4000).then(function () { done(); });
}); });
it('displays correct clone url', function (done) { it('displays correct clone url', function (done) {
@ -113,7 +113,17 @@ describe('Application life cycle test', function () {
}); });
it('can clone the url', function (done) { it('can clone the url', function (done) {
execSync('git clone ssh://cloudron@' + app.fqdn + ':29418/' + username + '/' + reponame + '.git /tmp/testrepo', { env: { GIT_SSH : __dirname + '/git_ssh_wrapper.sh' } }); var env = Object.create(process.env);
env.GIT_SSH = __dirname + '/git_ssh_wrapper.sh';
execSync('git clone ssh://cloudron@' + app.fqdn + ':29418/' + username + '/' + reponame + '.git ' + repodir, { env: env });
done();
});
it('can add and push a file', function (done) {
var env = Object.create(process.env);
env.GIT_SSH = __dirname + '/git_ssh_wrapper.sh';
execSync('touch newfile && git add newfile && git commit -a -mx && git push ssh://cloudron@' + app.fqdn + ':29418/' + username + '/' + reponame + ' master',
{ env: env, cwd: repodir });
rimraf.sync('/tmp/testrepo'); rimraf.sync('/tmp/testrepo');
done(); done();
}); });
@ -127,8 +137,11 @@ describe('Application life cycle test', function () {
}); });
it('can clone the url', function (done) { it('can clone the url', function (done) {
execSync('git clone ssh://cloudron@' + app.fqdn + ':29418/' + username + '/' + reponame + '.git /tmp/testrepo', { env: { GIT_SSH : __dirname + '/git_ssh_wrapper.sh' } }); var env = Object.create(process.env);
rimraf.sync('/tmp/testrepo'); env.GIT_SSH = __dirname + '/git_ssh_wrapper.sh';
execSync('git clone ssh://cloudron@' + app.fqdn + ':29418/' + username + '/' + reponame + '.git ' + repodir, { env: env });
expect(fs.existsSync(repodir + '/newfile')).to.be(true);
rimraf.sync(repodir);
done(); done();
}); });