Fix tests

This commit is contained in:
Girish Ramakrishnan 2018-02-26 16:56:42 -08:00
parent 319d23ead8
commit 1901d8450d
2 changed files with 44 additions and 23 deletions

View File

@ -10,10 +10,12 @@ if [ ! -f /app/data/config/config.xml ]; then
STNODEFAULTFOLDER=1 /app/code/syncthing --generate="/app/data/config"
# The password value was determined by reading config.xml and setting value in the GUI
# urAccepted is 0 for not decided, -1 for no reporting
xmlstarlet ed --inplace \
--subnode "//configuration/gui" -t elem -n user -v "admin" \
--subnode "//configuration/gui" -t elem -n password -v '$2a$10$93OsgwAMD4NcPFTpGDnuTORMMbj5dc1ZlYUPrQCcy1N/Bsy9scUvK' \
--update "//configuration/options/defaultFolderPath" -v '/app/data/folders' \
--update "//configuration/options/urAccepted" -v '-1' \
/app/data/config/config.xml
fi

View File

@ -43,9 +43,14 @@ describe('Application life cycle test', function () {
var LOCATION = 'test';
var TEST_TIMEOUT = 30000;
var FOLDER = 'outerspace';
var SYNC_PORT = 22001;
var app;
function installApp() {
execSync('cloudron install --new --wait --port-bindings SYNC_PORT=' + SYNC_PORT + ' --location ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
}
function pageLoaded() {
return browser.wait(until.titleMatches(/[0-9a-f]{12} \| Syncthing/), TEST_TIMEOUT);
}
@ -69,19 +74,12 @@ describe('Application life cycle test', function () {
}
function addFolder(callback) {
pageLoaded().then(function() {
browser.get('https://' + app.fqdn).then(function () {
return browser.findElement(by.css('[ng-click*=addFolder]')).click();
}).then(function () {
return visible(by.id('folderPath'));
}).then(function() {
return browser.findElement(by.id('folderLabel')).sendKeys('test');
}).then(function () {
return browser.findElement(by.id('folderPath')).sendKeys('/app/data/test');
}).then(function() {
//Clear and re-enter the folder to avoid race with auto-completion
return browser.findElement(by.id('folderPath')).clear();
}).then(function() {
return browser.findElement(by.id('folderPath')).sendKeys('/app/data/test');
return browser.findElement(by.id('folderLabel')).sendKeys(FOLDER);
}).then(function() {
return browser.findElement(by.css('[ng-click*=saveFolder]')).click();
}).then(function() {
@ -91,23 +89,33 @@ describe('Application life cycle test', function () {
});
}
function checkFolder(callback) {
browser.get('https://' + app.fqdn).then(function () {
return browser.wait(until.elementLocated(by.xpath(`//span[text()="${FOLDER}"]`), TEST_TIMEOUT));
}).then(function () {
callback();
});
}
function removeFolder(callback) {
browser.get('https://' + username + ':' + encodeURIComponent(password) + '@' + app.fqdn).then(function () {
return browser.get('https://' + app.fqdn);
}).then(function () {
browser.get('https://' + app.fqdn).then(function () {
return pageLoaded();
}).then(function() {
return browser.findElement(by.css('#folders button')).click();
}).then(function () {
return browser.sleep(1000); //No way to check for visibility of angular-js components
return browser.sleep(3000); //No way to check for visibility of angular-js components
}).then(function () {
return browser.findElement(by.css('#folder-0 button[ng-click*=editFolder]')).click();
}).then(function () {
return browser.sleep(1000); //No way to check for visibility of angular-js components
return browser.sleep(3000); //No way to check for visibility of angular-js components
}).then(function () {
return browser.findElement(by.xpath('//button[@data-target="#remove-folder-confirmation"]')).click();
}).then(function () {
return browser.sleep(3000); //No way to check for visibility of angular-js components
}).then(function () {
return browser.findElement(by.css('[ng-click*=deleteFolder]')).click();
}).then(function () {
return browser.sleep(1000); //This needs to run for some time
return browser.sleep(3000); //This needs to run for some time
}).then(function () {
callback();
});
@ -117,9 +125,7 @@ describe('Application life cycle test', function () {
execSync('cloudron build', { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
});
it('install app', function () {
execSync('cloudron install --new --wait --port-bindings SYNC_PORT=' + SYNC_PORT + ' --location ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
});
it('install app', installApp);
it('can get app information', function () {
var inspect = JSON.parse(execSync('cloudron inspect'));
@ -131,7 +137,6 @@ describe('Application life cycle test', function () {
it('can load page', loadPage);
it('can add folder', addFolder);
it('can remove folder', removeFolder);
it('backup app', function () {
execSync('cloudron backup create --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
@ -142,8 +147,7 @@ describe('Application life cycle test', function () {
});
it('can load page', loadPage);
it('can add folder', addFolder);
it('can remove folder', removeFolder);
it('can check folder', checkFolder);
it('move to different location', function () {
browser.manage().deleteAllCookies();
@ -154,11 +158,26 @@ describe('Application life cycle test', function () {
});
it('can load page', loadPage);
it('can add folder', addFolder);
it('can remove folder', removeFolder);
it('can check folder', checkFolder);
it('uninstall app', function () {
execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
});
// test update
it('can install app', function () {
installApp();
var inspect = JSON.parse(execSync('cloudron inspect'));
app = inspect.apps.filter(function (a) { return a.location === LOCATION; })[0];
expect(app).to.be.an('object');
});
it('can load page', loadPage);
it('can add folder', addFolder);
it('can update', function () {
execSync('cloudron install --wait --app ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
});
it('can check folder', checkFolder);
it('uninstall app', function () {
execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
});
});