Bläddra i källkod

add basic update tests

Johannes Zellner 8 år sedan
förälder
incheckning
6aac3c9784
1 ändrade filer med 43 tillägg och 19 borttagningar
  1. 43 19
      test/test.js

+ 43 - 19
test/test.js

@@ -56,6 +56,10 @@ describe('Application life cycle test SSO', function () {
 
     function login(callback) {
         browser.manage().deleteAllCookies();
+        browser.get('https://' + app.fqdn);
+        browser.executeScript('localStorage.clear();');
+        browser.executeScript('sessionStorage.clear();');
+
         browser.get('https://' + app.fqdn + '/login?next=%252Fprofile');
 
         waitForElement(by.name('username'), function () {
@@ -73,25 +77,13 @@ describe('Application life cycle test SSO', function () {
         waitForElement(by.xpath('//span[text()="' + USER_STORY_SUBJECT + '"]'), callback);
     }
 
-    xit('build app', function () {
-        execSync('cloudron build', { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
-    });
-
-    it('install app', function () {
-        execSync('cloudron install --new --wait --location ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
-    });
-
-    it('can get app information', function () {
+    function getAppInfo() {
         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 login', login);
+    }
 
-    it('can dismiss tutorial', function (done) {
+    function dismissTutorial(done) {
         browser.get('https://' + app.fqdn);
 
         waitForElement(by.className('introjs-skipbutton'), function () {
@@ -100,9 +92,9 @@ describe('Application life cycle test SSO', function () {
             // give some time to ack
             setTimeout(done, 5000);
         });
-    });
+    }
 
-    it('can create project', function (done) {
+    function createProject(done) {
         browser.get('https://' + app.fqdn + '/project/new/scrum');
 
         waitForElement(by.name('project-name'), function () {
@@ -115,9 +107,9 @@ describe('Application life cycle test SSO', function () {
 
             browser.wait(until.elementLocated(by.xpath('//span[text()[contains(., "' + PROJECT_NAME + '")]]')), TEST_TIMEOUT).then(function () { done(); });
         });
-    });
+    }
 
-    it('can create user story', function (done) {
+    function createUserStory(done) {
         browser.get('https://' + app.fqdn + '/project/' + process.env.USERNAME + '-' + PROJECT_NAME + '/backlog');
 
         waitForElement(by.xpath('//a[@tg-check-permission="add_us"]'), function () {
@@ -132,8 +124,21 @@ describe('Application life cycle test SSO', function () {
                 waitForElement(by.xpath('//span[text()[contains(., "' + USER_STORY_SUBJECT + '")]]'), done);
             });
         });
+    }
+
+    xit('build app', function () {
+        execSync('cloudron build', { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
+    });
+
+    it('install app', function () {
+        execSync('cloudron install --new --wait --location ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
     });
 
+    it('can get app information', getAppInfo);
+    it('can login', login);
+    it('can dismiss tutorial', dismissTutorial);
+    it('can create project', createProject);
+    it('can create user story', createUserStory);
     it('user story exists', userStoryExists);
 
     it('backup app', function () {
@@ -176,4 +181,23 @@ describe('Application life cycle test SSO', function () {
     it('uninstall app', function () {
         execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
     });
+
+    // test update
+    it('can install app', function () {
+        execSync('cloudron install --new --wait --appstore-id ' + app.manifest.id + ' --location ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
+    });
+
+    it('can get app information', getAppInfo);
+    it('can login', login);
+    it('can dismiss tutorial', dismissTutorial);
+    it('can create project', createProject);
+    it('can create user story', createUserStory);
+    it('user story exists', userStoryExists);
+    it('can update', function () {
+        execSync('cloudron install --wait --app ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
+    });
+    it('user story exists', userStoryExists);
+    it('uninstall app', function () {
+        execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
+    });
 });