Fix tests
This commit is contained in:
parent
319d23ead8
commit
1901d8450d
2
start.sh
2
start.sh
|
@ -10,10 +10,12 @@ if [ ! -f /app/data/config/config.xml ]; then
|
||||||
STNODEFAULTFOLDER=1 /app/code/syncthing --generate="/app/data/config"
|
STNODEFAULTFOLDER=1 /app/code/syncthing --generate="/app/data/config"
|
||||||
|
|
||||||
# The password value was determined by reading config.xml and setting value in the GUI
|
# 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 \
|
xmlstarlet ed --inplace \
|
||||||
--subnode "//configuration/gui" -t elem -n user -v "admin" \
|
--subnode "//configuration/gui" -t elem -n user -v "admin" \
|
||||||
--subnode "//configuration/gui" -t elem -n password -v '$2a$10$93OsgwAMD4NcPFTpGDnuTORMMbj5dc1ZlYUPrQCcy1N/Bsy9scUvK' \
|
--subnode "//configuration/gui" -t elem -n password -v '$2a$10$93OsgwAMD4NcPFTpGDnuTORMMbj5dc1ZlYUPrQCcy1N/Bsy9scUvK' \
|
||||||
--update "//configuration/options/defaultFolderPath" -v '/app/data/folders' \
|
--update "//configuration/options/defaultFolderPath" -v '/app/data/folders' \
|
||||||
|
--update "//configuration/options/urAccepted" -v '-1' \
|
||||||
/app/data/config/config.xml
|
/app/data/config/config.xml
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
65
test/test.js
65
test/test.js
|
@ -43,9 +43,14 @@ describe('Application life cycle test', function () {
|
||||||
|
|
||||||
var LOCATION = 'test';
|
var LOCATION = 'test';
|
||||||
var TEST_TIMEOUT = 30000;
|
var TEST_TIMEOUT = 30000;
|
||||||
|
var FOLDER = 'outerspace';
|
||||||
var SYNC_PORT = 22001;
|
var SYNC_PORT = 22001;
|
||||||
var app;
|
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() {
|
function pageLoaded() {
|
||||||
return browser.wait(until.titleMatches(/[0-9a-f]{12} \| Syncthing/), TEST_TIMEOUT);
|
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) {
|
function addFolder(callback) {
|
||||||
pageLoaded().then(function() {
|
browser.get('https://' + app.fqdn).then(function () {
|
||||||
return browser.findElement(by.css('[ng-click*=addFolder]')).click();
|
return browser.findElement(by.css('[ng-click*=addFolder]')).click();
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
return visible(by.id('folderPath'));
|
return visible(by.id('folderPath'));
|
||||||
}).then(function() {
|
}).then(function() {
|
||||||
return browser.findElement(by.id('folderLabel')).sendKeys('test');
|
return browser.findElement(by.id('folderLabel')).sendKeys(FOLDER);
|
||||||
}).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');
|
|
||||||
}).then(function() {
|
}).then(function() {
|
||||||
return browser.findElement(by.css('[ng-click*=saveFolder]')).click();
|
return browser.findElement(by.css('[ng-click*=saveFolder]')).click();
|
||||||
}).then(function() {
|
}).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) {
|
function removeFolder(callback) {
|
||||||
browser.get('https://' + username + ':' + encodeURIComponent(password) + '@' + app.fqdn).then(function () {
|
browser.get('https://' + app.fqdn).then(function () {
|
||||||
return browser.get('https://' + app.fqdn);
|
|
||||||
}).then(function () {
|
|
||||||
return pageLoaded();
|
return pageLoaded();
|
||||||
}).then(function() {
|
}).then(function() {
|
||||||
return browser.findElement(by.css('#folders button')).click();
|
return browser.findElement(by.css('#folders button')).click();
|
||||||
}).then(function () {
|
}).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 () {
|
}).then(function () {
|
||||||
return browser.findElement(by.css('#folder-0 button[ng-click*=editFolder]')).click();
|
return browser.findElement(by.css('#folder-0 button[ng-click*=editFolder]')).click();
|
||||||
}).then(function () {
|
}).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 () {
|
}).then(function () {
|
||||||
return browser.findElement(by.css('[ng-click*=deleteFolder]')).click();
|
return browser.findElement(by.css('[ng-click*=deleteFolder]')).click();
|
||||||
}).then(function () {
|
}).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 () {
|
}).then(function () {
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
|
@ -117,9 +125,7 @@ describe('Application life cycle test', function () {
|
||||||
execSync('cloudron build', { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
execSync('cloudron build', { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
||||||
});
|
});
|
||||||
|
|
||||||
it('install app', function () {
|
it('install app', installApp);
|
||||||
execSync('cloudron install --new --wait --port-bindings SYNC_PORT=' + SYNC_PORT + ' --location ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
|
||||||
});
|
|
||||||
|
|
||||||
it('can get app information', function () {
|
it('can get app information', function () {
|
||||||
var inspect = JSON.parse(execSync('cloudron inspect'));
|
var inspect = JSON.parse(execSync('cloudron inspect'));
|
||||||
|
@ -131,7 +137,6 @@ describe('Application life cycle test', function () {
|
||||||
|
|
||||||
it('can load page', loadPage);
|
it('can load page', loadPage);
|
||||||
it('can add folder', addFolder);
|
it('can add folder', addFolder);
|
||||||
it('can remove folder', removeFolder);
|
|
||||||
|
|
||||||
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' });
|
||||||
|
@ -142,8 +147,7 @@ describe('Application life cycle test', function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can load page', loadPage);
|
it('can load page', loadPage);
|
||||||
it('can add folder', addFolder);
|
it('can check folder', checkFolder);
|
||||||
it('can remove folder', removeFolder);
|
|
||||||
|
|
||||||
it('move to different location', function () {
|
it('move to different location', function () {
|
||||||
browser.manage().deleteAllCookies();
|
browser.manage().deleteAllCookies();
|
||||||
|
@ -154,11 +158,26 @@ describe('Application life cycle test', function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can load page', loadPage);
|
it('can load page', loadPage);
|
||||||
it('can add folder', addFolder);
|
it('can check folder', checkFolder);
|
||||||
it('can remove folder', removeFolder);
|
|
||||||
|
|
||||||
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' });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 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' });
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue