Girish Ramakrishnan 8 жил өмнө
parent
commit
51b4b32d04
1 өөрчлөгдсөн 37 нэмэгдсэн , 5 устгасан
  1. 37 5
      test/test.js

+ 37 - 5
test/test.js

@@ -75,9 +75,10 @@ describe('Application life cycle test', function () {
         }).then(function () {
             return browser.findElement(by.xpath('//button[text()="OK"]')).click();
         }).then(function () {
-            return browser.sleep(10000); // wait 10secs for reload
+            return browser.sleep(20000); // wait 20secs for reload
+        }).then(function () {
+            return browser.get('https://' + app.fqdn + '/admin');
         }).then(function () {
-            browser.get('https://' + app.fqdn + '/admin');
             return browser.findElement(by.xpath('//h1[text()="Dashboard"]'))
         }).then(function () { done(); });
     }
@@ -105,13 +106,39 @@ describe('Application life cycle test', function () {
         });
     }
 
-    // function uploadImage()
+    function uploadImage(done) {
+        browser.get('https://' + app.fqdn + '/user/admin/edit');
+        browser.findElement(by.xpath('//a[text()="Change Picture"]')).click().then(function () {
+            return browser.sleep(4000);
+        }).then(function () {
+            return browser.findElement(by.xpath('//span[contains(text(), "Upload New Picture")]')).click();
+        }).then(function () {
+            return browser.sleep(4000);
+        }).then(function () {
+            return browser.findElement(by.xpath('//input[@type="file"]')).sendKeys(path.resolve(__dirname, '../logo.png'));
+        }).then(function () {
+            browser.sleep(3000);
+        }).then(function () {
+            return browser.findElement(by.id('fileUploadSubmitBtn')).click();
+        }).then(function () {
+            browser.sleep(3000).then(function () { done(); });
+        });
+    }
+
+    function checkImage(done) {
+        browser.get('https://' + app.fqdn + '/user/admin');
+        browser.wait(until.elementLocated(by.xpath('//img[@src="/uploads/profile/1-profileimg.png"]')), TEST_TIMEOUT);
+        var img = browser.findElement(by.xpath('//img[@src="/uploads/profile/1-profileimg.png"]'));
+        browser.executeScript('return arguments[0].complete && arguments[0].naturalWidth', img).then(function (imageWidth) {
+            done(imageWidth === 250 ? null : new Error('failed to load image'));
+        });
+    }
 
     xit('build app', function () {
         execSync('cloudron build', { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
     });
 
-    xit('install app', function () {
+    it('install app', function () {
         execSync('cloudron install --new --wait --location ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
     });
 
@@ -125,10 +152,12 @@ describe('Application life cycle test', function () {
 
     it('can login', login);
     it('check mail plugin', checkMailPlugin);
-    xit('can install custom plugin', installCustomPlugin);
+    it('can install custom plugin', installCustomPlugin);
     it('can restart forum', restartForum); // required before activate!
     it('can activate custom plugin', activateCustomPlugin);
     it('can list custom plugin', listCustomPlugin);
+    it('can upload image', uploadImage);
+    it('can check image', checkImage);
 
     it('backup app', function () {
         execSync('cloudron backup --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
@@ -140,6 +169,7 @@ describe('Application life cycle test', function () {
 
     it('can login', login);
     it('can list custom plugin', listCustomPlugin);
+    it('can check image', checkImage);
 
     it('can restart app', function (done) {
         execSync('cloudron restart');
@@ -148,6 +178,7 @@ describe('Application life cycle test', function () {
 
     it('can login', login);
     it('can list custom plugin', listCustomPlugin);
+    it('can check image', checkImage);
 
     it('move to different location', function () {
         execSync('cloudron install --wait --location ' + LOCATION + '2', { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
@@ -158,6 +189,7 @@ describe('Application life cycle test', function () {
 
     it('can login', login);
     it('can list custom plugin', listCustomPlugin);
+    it('can check image', checkImage);
 
     it('uninstall app', function () {
         execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });