commit
47a9de45c9
214
test/test.js
214
test/test.js
|
@ -33,7 +33,7 @@ describe('Application life cycle test', function () {
|
||||||
var app, reponame = 'testrepo';
|
var app, reponame = 'testrepo';
|
||||||
var username = process.env.USERNAME;
|
var username = process.env.USERNAME;
|
||||||
var password = process.env.PASSWORD;
|
var password = process.env.PASSWORD;
|
||||||
var TIMEOUT = process.env.TIMEOUT || 5000;
|
var TIMEOUT = parseInt(process.env.TIMEOUT, 10) || 5000;
|
||||||
var email, token;
|
var email, token;
|
||||||
|
|
||||||
before(function (done) {
|
before(function (done) {
|
||||||
|
@ -64,11 +64,11 @@ describe('Application life cycle test', function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
function setAvatar(done) {
|
function setAvatar(done) {
|
||||||
browser.get('https://' + app.fqdn + '/user/settings/avatar');
|
browser.get('https://' + app.fqdn + '/user/settings/avatar').then(function () {
|
||||||
|
return browser.findElement(by.xpath('//input[@type="file" and @name="avatar"]')).sendKeys(path.resolve(__dirname, '../logo.png'));
|
||||||
browser.findElement(by.xpath('//input[@type="file" and @name="avatar"]')).sendKeys(path.resolve(__dirname, '../logo.png')).then(function () {
|
}).then(function () {
|
||||||
browser.findElement(by.xpath('//button[contains(text(), "Update Avatar Setting")]')).click();
|
return browser.findElement(by.xpath('//button[contains(text(), "Update Avatar Setting")]')).click();
|
||||||
|
}).then(function () {
|
||||||
browser.wait(until.elementLocated(by.xpath('//p[contains(text(),"updated successfully")]')), TIMEOUT).then(function () { done(); });
|
browser.wait(until.elementLocated(by.xpath('//p[contains(text(),"updated successfully")]')), TIMEOUT).then(function () { done(); });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -82,18 +82,92 @@ describe('Application life cycle test', function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
function editFile(done) {
|
function editFile(done) {
|
||||||
browser.get('https://' + app.fqdn + '/' + username + '/' + reponame + '/_edit/master/newfile');
|
browser.get('https://' + app.fqdn + '/' + username + '/' + reponame + '/_edit/master/newfile').then(function () {
|
||||||
|
var cm = browser.findElement(by.xpath('//div[contains(@class,"CodeMirror")]'));
|
||||||
var cm = browser.findElement(by.xpath('//div[contains(@class,"CodeMirror")]'));
|
var text = 'yo';
|
||||||
var text = 'yo';
|
return browser.executeScript('arguments[0].CodeMirror.setValue("' + text + '");', cm);
|
||||||
browser.executeScript('arguments[0].CodeMirror.setValue("' + text + '");', cm).then(function () {
|
}).then(function () {
|
||||||
browser.findElement(by.xpath('//input[@name="commit_summary"]')).sendKeys('Dummy edit');
|
return browser.findElement(by.xpath('//input[@name="commit_summary"]')).sendKeys('Dummy edit');
|
||||||
browser.findElement(by.xpath('//button[contains(text(), "Commit Changes")]')).click();
|
}).then(function () {
|
||||||
|
return browser.findElement(by.xpath('//button[contains(text(), "Commit Changes")]')).click();
|
||||||
|
}).then(function () {
|
||||||
waitForUrl('https://' + app.fqdn + '/' + username + '/' + reponame + '/src/master/newfile', done);
|
waitForUrl('https://' + app.fqdn + '/' + username + '/' + reponame + '/src/master/newfile', done);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function login(done) {
|
||||||
|
browser.get('https://' + app.fqdn + '/user/login').then(function () {
|
||||||
|
return browser.findElement(by.id('user_name')).sendKeys(username);
|
||||||
|
}).then(function () {
|
||||||
|
return browser.findElement(by.id('password')).sendKeys(password);
|
||||||
|
}).then(function () {
|
||||||
|
return browser.findElement(by.tagName('form')).submit();
|
||||||
|
}).then(function () {
|
||||||
|
return browser.wait(until.elementLocated(by.linkText('Dashboard')), TIMEOUT);
|
||||||
|
}).then(function () {
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function addPublicKey(done) {
|
||||||
|
var publicKey = fs.readFileSync(__dirname + '/id_rsa.pub', 'utf8');
|
||||||
|
|
||||||
|
browser.get('https://' + app.fqdn + '/user/settings/ssh').then(function () {
|
||||||
|
return browser.findElement(by.xpath('//div[text()="Add Key"]')).click();
|
||||||
|
}).then(function () {
|
||||||
|
return browser.findElement(by.id('ssh-key-title')).sendKeys('testkey');
|
||||||
|
}).then(function () {
|
||||||
|
return browser.findElement(by.id('ssh-key-content')).sendKeys(publicKey.trim()); // #3480
|
||||||
|
}).then(function () {
|
||||||
|
return browser.findElement(by.xpath('//button[contains(text(), "Add Key")]')).click();
|
||||||
|
}).then(function () {
|
||||||
|
return browser.wait(until.elementLocated(by.xpath('//p[contains(text(), "added successfully!")]')), TIMEOUT);
|
||||||
|
}).then(function () {
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function createRepo(done) {
|
||||||
|
browser.get('https://' + app.fqdn).then(function () {
|
||||||
|
return browser.findElement(by.linkText('New Repository')).click();
|
||||||
|
}).then(function () {
|
||||||
|
return browser.wait(until.elementLocated(by.xpath('//*[contains(text(), "New Repository")]')), TIMEOUT);
|
||||||
|
}).then(function () {
|
||||||
|
return browser.findElement(by.id('repo_name')).sendKeys(reponame);
|
||||||
|
}).then(function () {
|
||||||
|
return browser.findElement(by.id('auto-init')).click();
|
||||||
|
}).then(function () {
|
||||||
|
return browser.findElement(by.xpath('//button[contains(text(), "Create Repository")]')).click();
|
||||||
|
}).then(function () {
|
||||||
|
browser.wait(function () {
|
||||||
|
return browser.getCurrentUrl().then(function (url) {
|
||||||
|
return url === 'https://' + app.fqdn + '/' + username + '/' + reponame;
|
||||||
|
});
|
||||||
|
}, TIMEOUT);
|
||||||
|
}).then(function () {
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkCloneUrl(done) {
|
||||||
|
browser.get('https://' + app.fqdn + '/' + username + '/' + reponame).then(function () {
|
||||||
|
return browser.findElement(by.id('repo-clone-ssh')).click();
|
||||||
|
}).then(function () {
|
||||||
|
return browser.findElement(by.id('repo-clone-url')).getAttribute('value');
|
||||||
|
}).then(function (cloneUrl) {
|
||||||
|
expect(cloneUrl).to.be('ssh://git@' + app.fqdn + ':29418/' + username + '/' + reponame + '.git');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkGitClone(done) {
|
||||||
|
rimraf.sync(repodir);
|
||||||
|
var env = Object.create(process.env);
|
||||||
|
env.GIT_SSH = __dirname + '/git_ssh_wrapper.sh';
|
||||||
|
execSync('git clone ssh://git@' + app.fqdn + ':29418/' + username + '/' + reponame + '.git ' + repodir, { env: env });
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
|
||||||
xit('build app', function () {
|
xit('build app', function () {
|
||||||
execSync('cloudron build', { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
execSync('cloudron build', { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
||||||
});
|
});
|
||||||
|
@ -121,7 +195,6 @@ describe('Application life cycle test', function () {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('install app', function () {
|
it('install app', function () {
|
||||||
execSync('cloudron install --new --wait --location ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
execSync('cloudron install --new --wait --location ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
||||||
});
|
});
|
||||||
|
@ -143,57 +216,17 @@ describe('Application life cycle test', function () {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can login', function (done) {
|
it('can login', login);
|
||||||
browser.get('https://' + app.fqdn + '/user/login');
|
|
||||||
browser.findElement(by.id('user_name')).sendKeys(username);
|
|
||||||
browser.findElement(by.id('password')).sendKeys(password);
|
|
||||||
browser.findElement(by.tagName('form')).submit();
|
|
||||||
browser.wait(until.elementLocated(by.linkText('Dashboard')), TIMEOUT).then(function () { done(); });
|
|
||||||
});
|
|
||||||
|
|
||||||
it('can set avatar', setAvatar);
|
it('can set avatar', setAvatar);
|
||||||
it('can get avatar', checkAvatar);
|
it('can get avatar', checkAvatar);
|
||||||
|
|
||||||
it('can add public key', function (done) {
|
it('can add public key', addPublicKey);
|
||||||
browser.get('https://' + app.fqdn + '/user/settings/ssh');
|
|
||||||
var publicKey = fs.readFileSync(__dirname + '/id_rsa.pub', 'utf8');
|
|
||||||
|
|
||||||
browser.findElement(by.xpath('//div[text()="Add Key"]')).click();
|
it('can create repo', createRepo);
|
||||||
browser.findElement(by.id('ssh-key-title')).sendKeys('testkey');
|
|
||||||
browser.findElement(by.id('ssh-key-content')).sendKeys(publicKey.trim()); // #3480
|
|
||||||
browser.findElement(by.xpath('//button[contains(text(), "Add Key")]')).click();
|
|
||||||
browser.wait(until.elementLocated(by.xpath('//p[contains(text(), "added successfully!")]')), TIMEOUT).then(function () { done(); });
|
|
||||||
});
|
|
||||||
|
|
||||||
it('can create repo', function (done) {
|
it('displays correct clone url', checkCloneUrl);
|
||||||
browser.get('https://' + app.fqdn);
|
|
||||||
browser.findElement(by.linkText('New Repository')).click();
|
|
||||||
browser.wait(until.elementLocated(by.xpath('//*[contains(text(), "New Repository")]')), TIMEOUT);
|
|
||||||
browser.findElement(by.id('repo_name')).sendKeys(reponame);
|
|
||||||
browser.findElement(by.id('auto-init')).click();
|
|
||||||
browser.findElement(by.xpath('//button[contains(text(), "Create Repository")]')).click();
|
|
||||||
browser.wait(function () {
|
|
||||||
return browser.getCurrentUrl().then(function (url) {
|
|
||||||
return url === 'https://' + app.fqdn + '/' + username + '/' + reponame;
|
|
||||||
});
|
|
||||||
}, TIMEOUT).then(function () { done(); });
|
|
||||||
});
|
|
||||||
|
|
||||||
it('displays correct clone url', function (done) {
|
it('can clone the url', checkGitClone);
|
||||||
browser.get('https://' + app.fqdn + '/' + username + '/' + reponame);
|
|
||||||
browser.findElement(by.id('repo-clone-ssh')).click();
|
|
||||||
browser.findElement(by.id('repo-clone-url')).getAttribute('value').then(function (cloneUrl) {
|
|
||||||
expect(cloneUrl).to.be('ssh://git@' + app.fqdn + ':29418/' + username + '/' + reponame + '.git');
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('can clone the url', function (done) {
|
|
||||||
var env = Object.create(process.env);
|
|
||||||
env.GIT_SSH = __dirname + '/git_ssh_wrapper.sh';
|
|
||||||
execSync('git clone ssh://git@' + app.fqdn + ':29418/' + username + '/' + reponame + '.git ' + repodir, { env: env });
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('can add and push a file', function (done) {
|
it('can add and push a file', function (done) {
|
||||||
var env = Object.create(process.env);
|
var env = Object.create(process.env);
|
||||||
|
@ -207,18 +240,13 @@ describe('Application life cycle test', function () {
|
||||||
it('can edit file', editFile);
|
it('can edit file', editFile);
|
||||||
|
|
||||||
it('can restart app', function (done) {
|
it('can restart app', function (done) {
|
||||||
execSync('cloudron restart');
|
execSync('cloudron restart --wait');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can clone the url', function (done) {
|
it('can clone the url', checkCloneUrl);
|
||||||
var env = Object.create(process.env);
|
it('can clone the url', checkGitClone);
|
||||||
env.GIT_SSH = __dirname + '/git_ssh_wrapper.sh';
|
it('file exists in repo', function () { expect(fs.existsSync(repodir + '/newfile')).to.be(true); });
|
||||||
execSync('git clone ssh://git@' + app.fqdn + ':29418/' + username + '/' + reponame + '.git ' + repodir, { env: env });
|
|
||||||
expect(fs.existsSync(repodir + '/newfile')).to.be(true);
|
|
||||||
rimraf.sync(repodir);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('backup app', function () {
|
it('backup app', function () {
|
||||||
execSync('cloudron backup create --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
execSync('cloudron backup create --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
||||||
|
@ -229,15 +257,8 @@ describe('Application life cycle test', function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can get avatar', checkAvatar);
|
it('can get avatar', checkAvatar);
|
||||||
|
it('can clone the url', checkGitClone);
|
||||||
it('can clone the url', function (done) {
|
it('file exists in repo', function () { expect(fs.existsSync(repodir + '/newfile')).to.be(true); });
|
||||||
var env = Object.create(process.env);
|
|
||||||
env.GIT_SSH = __dirname + '/git_ssh_wrapper.sh';
|
|
||||||
execSync('git clone ssh://git@' + app.fqdn + ':29418/' + username + '/' + reponame + '.git ' + repodir, { env: env });
|
|
||||||
expect(fs.existsSync(repodir + '/newfile')).to.be(true);
|
|
||||||
rimraf.sync(repodir);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('move to different location', function () {
|
it('move to different location', function () {
|
||||||
browser.manage().deleteAllCookies();
|
browser.manage().deleteAllCookies();
|
||||||
|
@ -247,33 +268,11 @@ describe('Application life cycle test', function () {
|
||||||
expect(app).to.be.an('object');
|
expect(app).to.be.an('object');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can login', function (done) {
|
it('can login', login);
|
||||||
browser.get('https://' + app.fqdn + '/user/login');
|
|
||||||
browser.findElement(by.id('user_name')).sendKeys(username);
|
|
||||||
browser.findElement(by.id('password')).sendKeys(password);
|
|
||||||
browser.findElement(by.tagName('form')).submit();
|
|
||||||
browser.wait(until.elementLocated(by.linkText('Dashboard')), TIMEOUT).then(function () { done(); });
|
|
||||||
});
|
|
||||||
|
|
||||||
it('can get avatar', checkAvatar);
|
it('can get avatar', checkAvatar);
|
||||||
|
it('displays correct clone url', checkCloneUrl);
|
||||||
it('displays correct clone url', function (done) {
|
it('can clone the url', checkGitClone);
|
||||||
browser.get('https://' + app.fqdn + '/' + username + '/' + reponame);
|
it('file exists in repo', function () { expect(fs.existsSync(repodir + '/newfile')).to.be(true); });
|
||||||
browser.findElement(by.id('repo-clone-ssh')).click();
|
|
||||||
browser.findElement(by.id('repo-clone-url')).getAttribute('value').then(function (cloneUrl) {
|
|
||||||
expect(cloneUrl).to.be('ssh://git@' + app.fqdn + ':29418/' + username + '/' + reponame + '.git');
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('can clone the url', function (done) {
|
|
||||||
var env = Object.create(process.env);
|
|
||||||
env.GIT_SSH = __dirname + '/git_ssh_wrapper.sh';
|
|
||||||
execSync('git clone ssh://git@' + app.fqdn + ':29418/' + username + '/' + reponame + '.git ' + repodir, { env: env });
|
|
||||||
expect(fs.existsSync(repodir + '/newfile')).to.be(true);
|
|
||||||
rimraf.sync(repodir);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('uninstall app', function () {
|
it('uninstall app', function () {
|
||||||
execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
||||||
|
@ -287,11 +286,8 @@ describe('Application life cycle test', function () {
|
||||||
app = inspect.apps.filter(function (a) { return a.location === LOCATION; })[0];
|
app = inspect.apps.filter(function (a) { return a.location === LOCATION; })[0];
|
||||||
expect(app).to.be.an('object');
|
expect(app).to.be.an('object');
|
||||||
|
|
||||||
browser.get('https://' + app.fqdn + '/user/login');
|
login(function (error) {
|
||||||
browser.findElement(by.id('user_name')).sendKeys(email);
|
if (error) return done(error);
|
||||||
browser.findElement(by.id('password')).sendKeys(password);
|
|
||||||
browser.findElement(by.tagName('form')).submit();
|
|
||||||
browser.wait(until.elementLocated(by.linkText('Dashboard')), TIMEOUT).then(function () {
|
|
||||||
execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue