Browse Source

test if a custom plugin can be installed and is restored

Girish Ramakrishnan 8 years ago
parent
commit
f3b2b9cf00
1 changed files with 27 additions and 3 deletions
  1. 27 3
      test/test.js

+ 27 - 3
test/test.js

@@ -37,7 +37,7 @@ describe('Application life cycle test', function () {
     });
 
     var LOCATION = 'nodebbtest';
-    var TEST_TIMEOUT = parseInt(process.env.TEST_TIMEOUT, 10) || 5000;
+    var TEST_TIMEOUT = parseInt(process.env.TEST_TIMEOUT, 10) || 10000;
     var app;
     var email, token;
 
@@ -47,6 +47,7 @@ describe('Application life cycle test', function () {
         browser.executeScript('localStorage.clear();')
 
         browser.get('https://' + app.fqdn + '/login');
+        browser.sleep(5000); // takes some time for username to be visible
         browser.wait(until.elementLocated(by.id('username')), TEST_TIMEOUT).then(function () {
             browser.findElement(by.id('username')).sendKeys(username);
             browser.findElement(by.id('password')).sendKeys(password);
@@ -57,6 +58,7 @@ describe('Application life cycle test', function () {
 
     function checkMailPlugin(done) {
         browser.get('https://' + app.fqdn + '/admin/emailers/local');
+        browser.sleep(4000);
         browser.wait(until.elementLocated(by.id('emailer:local:host')), TEST_TIMEOUT).then(function () {
             browser.findElement(by.id('emailer:local:host')).getAttribute('value').then(function (val) {
                 if (val !== 'mail') return done(new Error('Incorrect mail server value: ' + val));
@@ -66,7 +68,25 @@ describe('Application life cycle test', function () {
     }
 
     // function restartForum()
-    // function installPlugin()
+    function installCustomPlugin(done) {
+        execSync('cloudron exec -- /usr/local/bin/gosu cloudron:cloudron npm install nodebb-plugin-beep', { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
+
+        browser.get('https://' + app.fqdn + '/admin/extend/plugins#installed');
+        browser.wait(until.elementLocated(by.xpath('//ul[contains(@class, "installed")]//strong[text()="nodebb-plugin-beep"]')), TEST_TIMEOUT).then(function () {
+            browser.sleep(10000).then(function () {
+                browser.findElement(by.xpath('//li[@id="nodebb-plugin-beep"]//button[@data-action="toggleActive"]')).click(); // activate the plugin
+                browser.sleep(3000).then(function() { done(); }); // wait for the action to succeed
+            });
+        });
+    }
+
+    function listCustomPlugin(done) {
+        browser.get('https://' + app.fqdn + '/admin/extend/plugins#installed');
+        browser.wait(until.elementLocated(by.xpath('//ul[contains(@class, "installed")]//strong[text()="nodebb-plugin-beep"]')), TEST_TIMEOUT).then(function () {
+            done();
+        });
+    }
+
     // function uploadImage()
 
     xit('build app', function () {
@@ -86,8 +106,9 @@ describe('Application life cycle test', function () {
     });
 
     it('can login', login);
-
     it('check mail plugin', checkMailPlugin);
+    it('can install custom plugin', installCustomPlugin);
+    it('can list custom plugin', listCustomPlugin);
 
     it('backup app', function () {
         execSync('cloudron backup --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
@@ -98,6 +119,7 @@ describe('Application life cycle test', function () {
     });
 
     it('can login', login);
+    it('can list custom plugin', listCustomPlugin);
 
     it('can restart app', function (done) {
         execSync('cloudron restart');
@@ -105,6 +127,7 @@ describe('Application life cycle test', function () {
     });
 
     it('can login', login);
+    it('can list custom plugin', listCustomPlugin);
 
     it('move to different location', function () {
         execSync('cloudron install --wait --location ' + LOCATION + '2', { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
@@ -114,6 +137,7 @@ describe('Application life cycle test', function () {
     });
 
     it('can login', login);
+    it('can list custom plugin', listCustomPlugin);
 
     it('uninstall app', function () {
         execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });