瀏覽代碼

add phpmyadmin tests

part of #5
Girish Ramakrishnan 8 年之前
父節點
當前提交
ced4278d85
共有 2 個文件被更改,包括 19 次插入7 次删除
  1. 3 0
      test/package.json
  2. 16 7
      test/test.js

+ 3 - 0
test/package.json

@@ -17,5 +17,8 @@
     "selenium-server-standalone-jar": "^2.53.0",
     "selenium-webdriver": "^2.53.3",
     "superagent": "^1.4.0"
+  },
+  "dependencies": {
+    "superagent": "^1.8.5"
   }
 }

+ 16 - 7
test/test.js

@@ -5,6 +5,7 @@
 var execSync = require('child_process').execSync,
     expect = require('expect.js'),
     path = require('path'),
+    superagent = require('superagent'),
     util = require('util'),
     webdriver = require('selenium-webdriver');
 
@@ -68,15 +69,23 @@ describe('Application life cycle test', function () {
     }
 
     function checkPhpMyAdmin(callback) {
-        browser.get('https://' + app.fqdn + '/phpmyadmin');
+        superagent.get('https://' + app.fqdn + '/phpmyadmin').end(function (error, result) {
+            if (error && !error.response) return callback(error); // network error
 
-        browser.wait(by.xpath('//h2[text()="General settings"]'), TEST_TIMEOUT)
-            .catch(function () {
-            // let's assume we could not login
+            if (result.statusCode !== 401) return callback('Expecting 401 error');
 
-            browser.get('https://' + process.env.USERNAME + ':' + process.env.PASSWORD + '@' + app.fqdn + '/phpmyadmin');
+            superagent.get('https://' + app.fqdn + '/phpmyadmin')
+                .auth(process.env.USERNAME, process.env.PASSWORD)
+                .end(function (error, result) {
+                if (error) return callback(error);
 
-            waitForElement(by.xpath('//h2[text()="General settings"]'), callback);
+                if (result.text.indexOf('.cloudron.info / mysql | phpMyAdmin') === -1) { // in the title
+                    console.log(result.text);
+                    return callback(new Error('could not detect phpmyadmin'));
+                }
+
+                callback();
+            });
         });
     }
 
@@ -103,7 +112,6 @@ describe('Application life cycle test', function () {
         execSync(util.format('lftp sftp://%s:%s@%s:%s  -e "set sftp:auto-confirm yes; cd public/; put test.php; bye"', process.env.USERNAME, process.env.PASSWORD, app.fqdn, app.portBindings.SFTP_PORT));
     });
     it('can get uploaded file', uploadedFileExists);
-
     it('can access phpmyadmin', checkPhpMyAdmin);
 
     it('backup app', function () {
@@ -125,6 +133,7 @@ describe('Application life cycle test', function () {
     });
 
     it('can get uploaded file', uploadedFileExists);
+    it('can access phpmyadmin', checkPhpMyAdmin);
 
     it('uninstall app', function () {
         execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });