+ var LOCATION = 'test';
+ var TEST_TIMEOUT = 10000;
+ var TEST_FILE_NAME_0 = 'index.html';
+ var TEST_FILE_NAME_1 = 'test.txt';
+ var app;
+
+ function waitForElement(elem) {
+ return browser.wait(until.elementLocated(elem), TEST_TIMEOUT).then(function () {
+ return browser.wait(until.elementIsVisible(browser.findElement(elem)), TEST_TIMEOUT);
+ });
+ }
+
+ // tests which are used more than once
+ function login(done) {
+ browser.manage().deleteAllCookies();
+ browser.get('https://' + app.fqdn + '/_admin');
+
+ waitForElement(by.id('loginUsernameInput')).then(function () {
+ browser.findElement(by.id('loginUsernameInput')).sendKeys(process.env.USERNAME);
+ browser.findElement(by.id('loginPasswordInput')).sendKeys(process.env.PASSWORD);
+ browser.findElement(by.id('loginSubmitButton')).click();
+
+ waitForElement(by.id('burgerMenuButton')).then(function () {
+ done();
+ });
+ });
+ }
+
+ function logout(done) {
+ browser.get('https://' + app.fqdn + '/_admin');
+
+ waitForElement(by.id('burgerMenuButton')).then(function () {
+ browser.findElement(by.id('burgerMenuButton')).click();
+
+ // wait for open animation
+ browser.sleep(5000);
+
+ waitForElement(by.id('logoutButton')).then(function () {
+ browser.findElement(by.id('logoutButton')).click();
+
+ waitForElement(by.id('loginUsernameInput')).then(function () {
+ done();
+ });
+ });
+ });
+ }
+
+ function checkFileIsListed(name, done) {
+ browser.get('https://' + app.fqdn + '/_admin');
+
+ waitForElement(by.xpath('//*[text()="' + name + '"]')).then(function () {
+ done();
+ });
+ }
+
+ function checkFileIsPresent(done) {
+ browser.get('https://' + app.fqdn + '/' + TEST_FILE_NAME_0);
+
+ waitForElement(by.xpath('//*[text()="test"]')).then(function () {
+ done();
+ });
+ }
+
+ function checkIndexFileIsServedUp(done) {
+ browser.get('https://' + app.fqdn);
+
+ waitForElement(by.xpath('//*[text()="test"]')).then(function () {
+ done();
+ });
+ }
+
+ function checkFileIsGone(name, done) {
+ superagent.get('https://' + app.fqdn + '/' + name).end(function (error, result) {
+ expect(error).to.be.an('object');
+ expect(error.response.status).to.equal(404);
+ expect(result).to.be.an('object');
+ done();
+ });
+ }
+
+ function cliLogin(done) {
+ execSync(util.format('%s login %s --username %s --password %s', path.join(__dirname, '/../cli/surfer.js'), app.fqdn, process.env.USERNAME, process.env.PASSWORD), { stdio: 'inherit' } );
+ done();
+ }
+
+ function uploadFile(name, done) {
+ // File upload can't be tested with selenium, since the file input is not visible and thus can't be interacted with :-(
+
+ execSync(path.join(__dirname, '/../cli/surfer.js') + ' put ' + path.join(__dirname, name) + '/', { stdio: 'inherit' } );
+ done();
+ }
+
+ xit('build app', function () {
+ execSync('cloudron build', EXEC_OPTIONS);