forked from cloudron-apps/gitea-app
Bring test deps up to date
This commit is contained in:
parent
5b625519c1
commit
b72d7ad682
3 changed files with 292 additions and 453 deletions
593
test/package-lock.json
generated
593
test/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -8,16 +8,12 @@
|
|||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"chromedriver": "^78.0.1",
|
||||
"dependencies": {
|
||||
"selenium-webdriver": "^3.6.0",
|
||||
"chromedriver": "^76.0.1",
|
||||
"expect.js": "^0.3.1",
|
||||
"mocha": "^6.2.2",
|
||||
"rimraf": "^3.0.0",
|
||||
"superagent": "^5.1.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"selenium-server-standalone-jar": "^3.141.59",
|
||||
"selenium-webdriver": "^3.6.0",
|
||||
"superagent": "^1.8.5"
|
||||
}
|
||||
}
|
||||
|
|
142
test/test.js
142
test/test.js
|
@ -9,49 +9,45 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
require('chromedriver');
|
||||
|
||||
var execSync = require('child_process').execSync,
|
||||
expect = require('expect.js'),
|
||||
fs = require('fs'),
|
||||
path = require('path'),
|
||||
rimraf = require('rimraf'),
|
||||
superagent = require('superagent');
|
||||
superagent = require('superagent'),
|
||||
{ Builder, By, until } = require('selenium-webdriver'),
|
||||
{ Options } = require('selenium-webdriver/chrome');
|
||||
|
||||
var by = require('selenium-webdriver').By,
|
||||
until = require('selenium-webdriver').until,
|
||||
Builder = require('selenium-webdriver').Builder;
|
||||
|
||||
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
|
||||
if (!process.env.USERNAME || !process.env.PASSWORD || !process.env.EMAIL) {
|
||||
console.log('USERNAME, PASSWORD and EMAIL env vars need to be set');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
describe('Application life cycle test', function () {
|
||||
this.timeout(0);
|
||||
var server, browser = new Builder().forBrowser('chrome').build();
|
||||
|
||||
var TIMEOUT = parseInt(process.env.TIMEOUT, 10) || 5000;
|
||||
var EXEC_ARGS = { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' };
|
||||
var LOCATION = 'test';
|
||||
var SSH_PORT = 29420;
|
||||
|
||||
var browser;
|
||||
var app;
|
||||
var token;
|
||||
|
||||
var repodir = '/tmp/testrepo';
|
||||
var app, reponame = 'testrepo';
|
||||
var reponame = 'testrepo';
|
||||
|
||||
var username = process.env.USERNAME;
|
||||
var password = process.env.PASSWORD;
|
||||
var TIMEOUT = parseInt(process.env.TIMEOUT, 10) || 5000;
|
||||
var email = process.env.EMAIL, token;
|
||||
var email = process.env.EMAIL;
|
||||
|
||||
before(function (done) {
|
||||
if (!process.env.USERNAME) return done(new Error('USERNAME env var not set'));
|
||||
if (!process.env.PASSWORD) return done(new Error('PASSWORD env var not set'));
|
||||
if (!process.env.EMAIL) return done(new Error('EMAIL env var not set'));
|
||||
|
||||
var seleniumJar= require('selenium-server-standalone-jar');
|
||||
var SeleniumServer = require('selenium-webdriver/remote').SeleniumServer;
|
||||
server = new SeleniumServer(seleniumJar.path, { port: 4444 });
|
||||
server.start();
|
||||
|
||||
done();
|
||||
before(function () {
|
||||
browser = new Builder().forBrowser('chrome').setChromeOptions(new Options().windowSize({ width: 1280, height: 1024 })).build();
|
||||
});
|
||||
|
||||
after(function (done) {
|
||||
browser.quit();
|
||||
server.stop();
|
||||
rimraf.sync(repodir);
|
||||
done();
|
||||
});
|
||||
|
@ -74,14 +70,14 @@ describe('Application life cycle test', function () {
|
|||
|
||||
function setAvatarOld(done) {
|
||||
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'));
|
||||
return browser.findElement(By.xpath('//input[@type="file" and @name="avatar"]')).sendKeys(path.resolve(__dirname, '../logo.png'));
|
||||
}).then(function () {
|
||||
return 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 () {
|
||||
if (app.manifest.version === '1.0.3') {
|
||||
return browser.wait(until.elementLocated(by.xpath('//p[contains(text(),"updated successfully")]')), TIMEOUT);
|
||||
return browser.wait(until.elementLocated(By.xpath('//p[contains(text(),"updated successfully")]')), TIMEOUT);
|
||||
} else {
|
||||
return browser.wait(until.elementLocated(by.xpath('//p[contains(text(),"Your avatar setting has been updated.")]')), TIMEOUT);
|
||||
return browser.wait(until.elementLocated(By.xpath('//p[contains(text(),"Your avatar setting has been updated.")]')), TIMEOUT);
|
||||
}
|
||||
}).then(function () {
|
||||
done();
|
||||
|
@ -92,16 +88,16 @@ describe('Application life cycle test', function () {
|
|||
if (app.manifest.version === '1.5.4') return setAvatarOld(done);
|
||||
|
||||
browser.get('https://' + app.fqdn + '/user/settings').then(function () {
|
||||
var button = browser.findElement(by.xpath('//label[contains(text(), "Use Custom Avatar")]'));
|
||||
var button = browser.findElement(By.xpath('//label[contains(text(), "Use Custom Avatar")]'));
|
||||
return browser.executeScript('arguments[0].scrollIntoView(false)', button);
|
||||
}).then(function () {
|
||||
return browser.findElement(by.xpath('//label[contains(text(), "Use Custom Avatar")]')).click();
|
||||
return browser.findElement(By.xpath('//label[contains(text(), "Use Custom Avatar")]')).click();
|
||||
}).then(function () {
|
||||
return browser.findElement(by.xpath('//input[@type="file" and @name="avatar"]')).sendKeys(path.resolve(__dirname, '../logo.png'));
|
||||
return browser.findElement(By.xpath('//input[@type="file" and @name="avatar"]')).sendKeys(path.resolve(__dirname, '../logo.png'));
|
||||
}).then(function () {
|
||||
return browser.findElement(by.xpath('//button[contains(text(), "Update Avatar")]')).click();
|
||||
return browser.findElement(By.xpath('//button[contains(text(), "Update Avatar")]')).click();
|
||||
}).then(function () {
|
||||
return browser.wait(until.elementLocated(by.xpath('//p[contains(text(),"Your avatar has been updated.")]')), TIMEOUT);
|
||||
return browser.wait(until.elementLocated(By.xpath('//p[contains(text(),"Your avatar has been updated.")]')), TIMEOUT);
|
||||
}).then(function () {
|
||||
done();
|
||||
});
|
||||
|
@ -118,13 +114,13 @@ return done();
|
|||
|
||||
function editFile(done) {
|
||||
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';
|
||||
return browser.executeScript('arguments[0].CodeMirror.setValue("' + text + '");', cm);
|
||||
}).then(function () {
|
||||
return browser.findElement(by.xpath('//input[@name="commit_summary"]')).sendKeys('Dummy edit');
|
||||
return browser.findElement(By.xpath('//input[@name="commit_summary"]')).sendKeys('Dummy edit');
|
||||
}).then(function () {
|
||||
return browser.findElement(by.xpath('//button[contains(text(), "Commit Changes")]')).click();
|
||||
return browser.findElement(By.xpath('//button[contains(text(), "Commit Changes")]')).click();
|
||||
}).then(function () {
|
||||
return waitForUrl('https://' + app.fqdn + '/' + username + '/' + reponame + '/src/branch/master/newfile');
|
||||
}).then(function () {
|
||||
|
@ -134,13 +130,13 @@ return done();
|
|||
|
||||
function login(username, password, done) {
|
||||
browser.get('https://' + app.fqdn + '/user/login').then(function () {
|
||||
return browser.findElement(by.id('user_name')).sendKeys(username);
|
||||
return browser.findElement(By.id('user_name')).sendKeys(username);
|
||||
}).then(function () {
|
||||
return browser.findElement(by.id('password')).sendKeys(password);
|
||||
return browser.findElement(By.id('password')).sendKeys(password);
|
||||
}).then(function () {
|
||||
return browser.findElement(by.tagName('form')).submit();
|
||||
return browser.findElement(By.tagName('form')).submit();
|
||||
}).then(function () {
|
||||
return browser.wait(until.elementLocated(by.linkText('Dashboard')), TIMEOUT);
|
||||
return browser.wait(until.elementLocated(By.linkText('Dashboard')), TIMEOUT);
|
||||
}).then(function () {
|
||||
done();
|
||||
});
|
||||
|
@ -164,21 +160,21 @@ return done();
|
|||
const sshPage = 'https://' + app.fqdn + '/user/settings/keys';
|
||||
|
||||
browser.get(sshPage).then(function () {
|
||||
return browser.findElement(by.xpath('//div[text()="Add Key"]')).click();
|
||||
return browser.findElement(By.xpath('//div[text()="Add Key"]')).click();
|
||||
}).then(function () {
|
||||
return browser.findElement(by.id('ssh-key-title')).sendKeys('testkey');
|
||||
return browser.findElement(By.id('ssh-key-title')).sendKeys('testkey');
|
||||
}).then(function () {
|
||||
return browser.findElement(by.id('ssh-key-content')).sendKeys(publicKey.trim()); // #3480
|
||||
return browser.findElement(By.id('ssh-key-content')).sendKeys(publicKey.trim()); // #3480
|
||||
}).then(function () {
|
||||
var button = browser.findElement(by.xpath('//button[contains(text(), "Add Key")]'));
|
||||
var button = browser.findElement(By.xpath('//button[contains(text(), "Add Key")]'));
|
||||
return browser.executeScript('arguments[0].scrollIntoView(false)', button);
|
||||
}).then(function () {
|
||||
return browser.findElement(by.xpath('//button[contains(text(), "Add Key")]')).click();
|
||||
return browser.findElement(By.xpath('//button[contains(text(), "Add Key")]')).click();
|
||||
}).then(function () {
|
||||
if (app.manifest.version === '1.0.3') {
|
||||
return browser.wait(until.elementLocated(by.xpath('//p[contains(text(), "added successfully!")]')), TIMEOUT);
|
||||
return browser.wait(until.elementLocated(By.xpath('//p[contains(text(), "added successfully!")]')), TIMEOUT);
|
||||
} else {
|
||||
return browser.wait(until.elementLocated(by.xpath('//p[contains(text(), "has been added.")]')), TIMEOUT);
|
||||
return browser.wait(until.elementLocated(By.xpath('//p[contains(text(), "has been added.")]')), TIMEOUT);
|
||||
}
|
||||
}).then(function () {
|
||||
done();
|
||||
|
@ -189,23 +185,23 @@ return done();
|
|||
var getRepoPage;
|
||||
if (app.manifest.version === '1.0.3') {
|
||||
getRepoPage = browser.get('https://' + app.fqdn).then(function () {
|
||||
return browser.findElement(by.linkText('New Repository')).click();
|
||||
return browser.findElement(By.linkText('New Repository')).click();
|
||||
}).then(function () {
|
||||
return browser.wait(until.elementLocated(by.xpath('//*[contains(text(), "New Repository")]')), TIMEOUT);
|
||||
return browser.wait(until.elementLocated(By.xpath('//*[contains(text(), "New Repository")]')), TIMEOUT);
|
||||
});
|
||||
} else {
|
||||
getRepoPage = browser.get('https://' + app.fqdn + '/repo/create');
|
||||
}
|
||||
|
||||
getRepoPage.then(function () {
|
||||
return browser.findElement(by.id('repo_name')).sendKeys(reponame);
|
||||
return browser.findElement(By.id('repo_name')).sendKeys(reponame);
|
||||
}).then(function () {
|
||||
var button = browser.findElement(by.xpath('//button[contains(text(), "Create Repository")]'));
|
||||
var button = browser.findElement(By.xpath('//button[contains(text(), "Create Repository")]'));
|
||||
return browser.executeScript('arguments[0].scrollIntoView(true)', button);
|
||||
}).then(function () {
|
||||
return browser.findElement(by.id('auto-init')).click();
|
||||
return browser.findElement(By.id('auto-init')).click();
|
||||
}).then(function () {
|
||||
return browser.findElement(by.xpath('//button[contains(text(), "Create Repository")]')).click();
|
||||
return browser.findElement(By.xpath('//button[contains(text(), "Create Repository")]')).click();
|
||||
}).then(function () {
|
||||
browser.wait(function () {
|
||||
return browser.getCurrentUrl().then(function (url) {
|
||||
|
@ -219,9 +215,9 @@ return done();
|
|||
|
||||
function checkCloneUrl(done) {
|
||||
browser.get('https://' + app.fqdn + '/' + username + '/' + reponame).then(function () {
|
||||
return browser.findElement(by.id('repo-clone-ssh')).click();
|
||||
return browser.findElement(By.id('repo-clone-ssh')).click();
|
||||
}).then(function () {
|
||||
return browser.findElement(by.id('repo-clone-url')).getAttribute('value');
|
||||
return browser.findElement(By.id('repo-clone-url')).getAttribute('value');
|
||||
}).then(function (cloneUrl) {
|
||||
expect(cloneUrl).to.be(`ssh://git@${app.fqdn}:${SSH_PORT}/${username}/${reponame}.git`);
|
||||
done();
|
||||
|
@ -268,21 +264,21 @@ return done();
|
|||
|
||||
function sendMail(done) {
|
||||
browser.get(`https://${app.fqdn}/admin/config`).then(function () {
|
||||
var button = browser.findElement(by.xpath('//button[@id="test-mail-btn"]'));
|
||||
var button = browser.findElement(By.xpath('//button[@id="test-mail-btn"]'));
|
||||
return browser.executeScript('arguments[0].scrollIntoView(true)', button);
|
||||
}).then(function () {
|
||||
return browser.findElement(by.xpath('//input[@name="email"]')).sendKeys('test@cloudron.io');
|
||||
return browser.findElement(By.xpath('//input[@name="email"]')).sendKeys('test@cloudron.io');
|
||||
}).then(function () {
|
||||
return browser.findElement(by.xpath('//button[@id="test-mail-btn"]')).click();
|
||||
return browser.findElement(By.xpath('//button[@id="test-mail-btn"]')).click();
|
||||
}).then(function () {
|
||||
return browser.wait(until.elementLocated(by.xpath('//p[contains(text(),"A testing email has been sent to \'test@cloudron.io\'")]')), TIMEOUT);
|
||||
return browser.wait(until.elementLocated(By.xpath('//p[contains(text(),"A testing email has been sent to \'test@cloudron.io\'")]')), TIMEOUT);
|
||||
}).then(function () {
|
||||
done();
|
||||
});
|
||||
}
|
||||
|
||||
xit('build app', function () {
|
||||
execSync('cloudron build', { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
||||
execSync('cloudron build', EXEC_ARGS);
|
||||
});
|
||||
|
||||
it('can login', function (done) {
|
||||
|
@ -308,8 +304,8 @@ return done();
|
|||
});
|
||||
});
|
||||
|
||||
it('install app', function () {
|
||||
execSync(`cloudron install --new --wait --location ${LOCATION} -p SSH_PORT=${SSH_PORT}`, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
||||
xit('install app', function () {
|
||||
execSync(`cloudron install --new --wait --location ${LOCATION} -p SSH_PORT=${SSH_PORT}`, EXEC_ARGS);
|
||||
});
|
||||
|
||||
it('can get app information', getAppInfo);
|
||||
|
@ -355,11 +351,11 @@ return done();
|
|||
it('file exists in repo', fileExists);
|
||||
|
||||
it('backup app', function () {
|
||||
execSync('cloudron backup create --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
||||
execSync('cloudron backup create --app ' + app.id, EXEC_ARGS);
|
||||
});
|
||||
|
||||
it('restore app', function () {
|
||||
execSync('cloudron restore --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
||||
execSync('cloudron restore --app ' + app.id, EXEC_ARGS);
|
||||
});
|
||||
|
||||
it('can login', login.bind(null, username, password));
|
||||
|
@ -371,7 +367,7 @@ return done();
|
|||
//browser.manage().deleteAllCookies(); // commented because of error "'Network.deleteCookie' wasn't found"
|
||||
// ensure we don't hit NXDOMAIN in the mean time
|
||||
browser.get('about:blank').then(function () {
|
||||
execSync('cloudron configure --wait --location ' + LOCATION + '2 --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
||||
execSync('cloudron configure --wait --location ' + LOCATION + '2 --app ' + app.id, EXEC_ARGS);
|
||||
var inspect = JSON.parse(execSync('cloudron inspect'));
|
||||
app = inspect.apps.filter(function (a) { return a.location === LOCATION + '2'; })[0];
|
||||
expect(app).to.be.an('object');
|
||||
|
@ -389,14 +385,14 @@ return done();
|
|||
it('uninstall app', function (done) {
|
||||
// ensure we don't hit NXDOMAIN in the mean time
|
||||
browser.get('about:blank').then(function () {
|
||||
execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
||||
execSync('cloudron uninstall --app ' + app.id, EXEC_ARGS);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
// check if the _first_ login via email succeeds
|
||||
it('can login via email', function (done) {
|
||||
execSync(`cloudron install --new --wait --location ${LOCATION} -p SSH_PORT=${SSH_PORT}`, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
||||
execSync(`cloudron install --new --wait --location ${LOCATION} -p SSH_PORT=${SSH_PORT}`, EXEC_ARGS);
|
||||
var inspect = JSON.parse(execSync('cloudron inspect'));
|
||||
|
||||
app = inspect.apps.filter(function (a) { return a.location === LOCATION; })[0];
|
||||
|
@ -407,7 +403,7 @@ return done();
|
|||
|
||||
// ensure we don't hit NXDOMAIN in the mean time
|
||||
browser.get('about:blank').then(function () {
|
||||
execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
||||
execSync('cloudron uninstall --app ' + app.id, EXEC_ARGS);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -415,7 +411,7 @@ return done();
|
|||
|
||||
// No SSO
|
||||
it('install app (no sso)', function () {
|
||||
execSync(`cloudron install --new --wait --no-sso --location ${LOCATION} -p SSH_PORT=${SSH_PORT}`, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
||||
execSync(`cloudron install --new --wait --no-sso --location ${LOCATION} -p SSH_PORT=${SSH_PORT}`, EXEC_ARGS);
|
||||
});
|
||||
|
||||
it('can get app information', function () {
|
||||
|
@ -430,12 +426,12 @@ return done();
|
|||
it('can logout', logout);
|
||||
|
||||
it('uninstall app (no sso)', function () {
|
||||
execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
||||
execSync('cloudron uninstall --app ' + app.id, EXEC_ARGS);
|
||||
});
|
||||
|
||||
// test update
|
||||
it('can install app', function () {
|
||||
execSync(`cloudron install --new --wait --appstore-id ${app.manifest.id} --location ${LOCATION} -p SSH_PORT=${SSH_PORT}`, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
||||
execSync(`cloudron install --new --wait --appstore-id ${app.manifest.id} --location ${LOCATION} -p SSH_PORT=${SSH_PORT}`, EXEC_ARGS);
|
||||
});
|
||||
|
||||
it('can get app information', getAppInfo);
|
||||
|
@ -448,7 +444,7 @@ return done();
|
|||
it('can add and push a file', pushFile);
|
||||
|
||||
it('can update', function () {
|
||||
execSync('cloudron install --wait --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
||||
execSync('cloudron install --wait --app ' + app.id, EXEC_ARGS);
|
||||
});
|
||||
|
||||
xit('can admin login', adminLogin);
|
||||
|
@ -463,7 +459,7 @@ return done();
|
|||
it('uninstall app', function (done) {
|
||||
// ensure we don't hit NXDOMAIN in the mean time
|
||||
browser.get('about:blank').then(function () {
|
||||
execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
||||
execSync('cloudron uninstall --app ' + app.id, EXEC_ARGS);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue