updated zombie_auth
authorTravis Webb <me@traviswebb.com>
Tue, 17 Jun 2014 08:09:22 +0000 (04:09 -0400)
committerTravis Webb <me@traviswebb.com>
Tue, 17 Jun 2014 08:09:22 +0000 (04:09 -0400)
test/lib/login.js
test/lib/zombie_auth.js

index 9140ecd..f1748f2 100755 (executable)
@@ -9,14 +9,16 @@
   var zombieAuth = require('../lib/zombie_auth'),
     prepDatabase = require('../lib/prep_database');
 
-  before(function (done) {
-    this.timeout(10 * 120 * 1000);
+  describe('xTuple Login', function () {
+    this.timeout(60 * 1000);
 
-    zombieAuth.loadApp({
-      refreshLogin: true,
-      callback: function () {
-        prepDatabase.prepDatabase(done);
-      }
+    it('should login', function (done) {
+      zombieAuth.loadApp(done);
     });
+
+    it('should prepare database', function (done) {
+      prepDatabase.prepDatabase(done);
+    });
+
   });
 }());
index 78acb8e..9906d90 100644 (file)
@@ -15,11 +15,10 @@ XZ = {}; // xTuple Zombie. Used to help zombie within the context of these tests
 global.URL = require('url');
 
 var assert = require('assert'),
-  zombie = require('zombie'),
+  Browser = require('zombie'),
   _ = require('underscore');
 
 (function () {
-  "use strict";
 
   var secondsToWait = 40;
 
@@ -110,31 +109,46 @@ var assert = require('assert'),
       }
     };
 
-    zombie.visit(host, {runScripts: false, debug: verboseMode}, function (e, browser) {
-      if (e) {
-        console.log("Zombie visit error: ", e);
-      }
-      //
-      // This is the login screen
-      //
-      browser
-        .fill('id', username)
-        .fill('password', password)
-        .select('database', database)
-        .pressButton('submit', function () {
+    var browser = new Browser({
+      runScripts: false,
+      site: host,
+      maxWait: 30 * 1000
+    });
+
+    browser
+      .visit(host)
+      .then(function (e) {
+        if (e) {
+          console.log("Zombie visit error: ", e);
+        }
+        //
+        // This is the login screen
+        //
+        browser.fill('id', 'admin');
+        browser.fill('password', 'VXalkO2g');
+        browser.select('database', 'xtuple_demo');
+      })
+      .then(function () {
+        browser.runScripts = true;
+        return browser.pressButton('Sign In');
+      })
+      .then(function () {
 
           //
           // Plan to give up after a set time
           //
+          /*
           var timeout = setTimeout(function () {
               console.log("App did not fully load");
               process.exit(1);
             }, secondsToWait * 1000);
+            */
 
           //
           // Check frequently to see if the app is loaded, and move forward when it is
           //
           var interval = setInterval(function () {
+            //console.dir(browser.windows);
             if (browser.window.XT && browser.window.XT.app && browser.window.XT.app.state === 6) {
 
               // add the global objects to our global namespace
@@ -164,13 +178,11 @@ var assert = require('assert'),
               // clear out both is interval and the I'm-giving-up timeout
               // we really want neither to be run again.
               clearInterval(interval);
-              clearTimeout(timeout);
 
               // give control back to whoever called us
               callback();
             }
           }, 500); // 100 = check to see if the app is loaded every 0.1 seconds
         });
-    });
   };
 }());