usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject [01/13] adding help framework adding google analytics framework bug fixes
Date Thu, 27 Mar 2014 19:20:49 GMT
Repository: incubator-usergrid
Updated Branches:
  refs/heads/master 8fc27ead1 -> 3090ddcdf
  refs/pull/83/head [created] 6d1e26b0f


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/097fd3bd/portal/tests/protractor/applications.spec.js
----------------------------------------------------------------------
diff --git a/portal/tests/protractor/applications.spec.js b/portal/tests/protractor/applications.spec.js
index ebff82e..b042d78 100644
--- a/portal/tests/protractor/applications.spec.js
+++ b/portal/tests/protractor/applications.spec.js
@@ -10,7 +10,7 @@ describe('Test Applications Dropdown', function () {
 
   describe('Test Application Switching',function(){
     it('should navigate to sandbox.',function(){
-      browser.driver.get(browser.baseUrl+'/#!/app-overview/summary');
+      browser.driver.get(browser.baseUrl+'#!/app-overview/summary');
       browser.wait(function(){
         return element(by.id('app-overview-title')).getText().then(function(text){
           return text===appName2.toUpperCase();

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/097fd3bd/portal/tests/protractor/coverage/coverage.spec.js
----------------------------------------------------------------------
diff --git a/portal/tests/protractor/coverage/coverage.spec.js b/portal/tests/protractor/coverage/coverage.spec.js
new file mode 100644
index 0000000..7677c2d
--- /dev/null
+++ b/portal/tests/protractor/coverage/coverage.spec.js
@@ -0,0 +1,7 @@
+'use strict';
+var util = require('../util');
+describe('Output the code coverage objects', function () {
+    it('should output the coverage object.',function(){
+      util.getCoverage();
+    });
+});

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/097fd3bd/portal/tests/protractor/data.spec.js
----------------------------------------------------------------------
diff --git a/portal/tests/protractor/data.spec.js b/portal/tests/protractor/data.spec.js
index d747b43..af6a0de 100644
--- a/portal/tests/protractor/data.spec.js
+++ b/portal/tests/protractor/data.spec.js
@@ -9,7 +9,7 @@ describe('Test Data', function () {
 
   describe('Add and delete', function () {
     it('should add and then delete', function () {
-      browser.driver.get(browser.baseUrl + '/#!/data');
+      browser.driver.get(browser.baseUrl + '#!/data');
 
       var entityName = 'test_e2e';
       var dateString = Date.now().toString();

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/097fd3bd/portal/tests/protractor/forgotPassword.spec.js
----------------------------------------------------------------------
diff --git a/portal/tests/protractor/forgotPassword.spec.js b/portal/tests/protractor/forgotPassword.spec.js
index eb57878..14f160d 100644
--- a/portal/tests/protractor/forgotPassword.spec.js
+++ b/portal/tests/protractor/forgotPassword.spec.js
@@ -2,7 +2,7 @@
 var util = require('./util');
 describe('Forgot Password', function () {
   beforeEach(function(){
-    browser.driver.get(browser.baseUrl + '/');
+    browser.driver.get(browser.baseUrl + '');
     browser.waitForAngular();
     util.logout();
   });
@@ -18,7 +18,7 @@ describe('Forgot Password', function () {
     });
     element(by.id('button-forgot-password')).isPresent().then(function () {
       element(by.id('button-forgot-password')).click();
-      browser.driver.get(browser.baseUrl+'/#!/forgot-password')
+      browser.driver.get(browser.baseUrl+'#!/forgot-password')
     });
     browser.wait(function () {
       return browser.driver.getCurrentUrl().then(function (url) {

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/097fd3bd/portal/tests/protractor/login.spec.js
----------------------------------------------------------------------
diff --git a/portal/tests/protractor/login.spec.js b/portal/tests/protractor/login.spec.js
new file mode 100644
index 0000000..c8b895f
--- /dev/null
+++ b/portal/tests/protractor/login.spec.js
@@ -0,0 +1,45 @@
+'use strict';
+var util = require('./util');
+describe('Login ', function () {
+
+  beforeEach(function () {
+    browser.driver.get(browser.baseUrl + '');
+  });
+
+  describe('should login', function () {
+    it('should fail to login', function () {
+
+      if (browser.params.useSso) {
+        return;
+      }
+      util.logout();
+
+      browser.wait(function () {
+        return element(by.model('login.username')).isPresent();
+      });
+
+      element(by.model('login.username')).isPresent().then(function () {
+        element(by.id('login-username')).sendKeys('baduser');
+        element(by.id('login-password')).sendKeys('badpassword');
+        element(by.id('button-login')).submit();
+      });
+
+      browser.wait(function(){
+        return  element(by.id('loginError')).isPresent();
+      })
+    });
+    it('should logout after login', function () {
+      util.login();
+      browser.wait(function(){
+        return browser.driver.getCurrentUrl().then(function (url) {
+          var test = /org-overview/.test(url) || url.indexOf('org-overview')>0;
+          test && util.logout();
+          return test;
+        });
+      })
+      browser.wait(function(){
+        return  element(by.id('login-username')).isPresent();
+      })
+    });
+  });
+});
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/097fd3bd/portal/tests/protractor/organization.spec.js
----------------------------------------------------------------------
diff --git a/portal/tests/protractor/organization.spec.js b/portal/tests/protractor/organization.spec.js
index 532358b..33d25a7 100644
--- a/portal/tests/protractor/organization.spec.js
+++ b/portal/tests/protractor/organization.spec.js
@@ -9,7 +9,7 @@ describe('Test Org Dropdown', function () {
   describe('Test Org Switching',function(){
     var appName = browser.params.orgName;
     it('should navigate to sandbox.',function(){
-      browser.driver.get(browser.baseUrl+'/#!/org-overview');
+      browser.driver.get(browser.baseUrl+'#!/org-overview');
       browser.wait(function () {
         return element.all(by.repeater("(k,v) in organizations")).count().then(function(count){
           var appCount =  count >0;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/097fd3bd/portal/tests/protractor/profile.spec.js
----------------------------------------------------------------------
diff --git a/portal/tests/protractor/profile.spec.js b/portal/tests/protractor/profile.spec.js
index f93073c..13e9bf0 100644
--- a/portal/tests/protractor/profile.spec.js
+++ b/portal/tests/protractor/profile.spec.js
@@ -12,7 +12,7 @@ describe('Test User Profile', function () {
       return;
     }
     it('should set email to some random value',function(){
-      browser.driver.get(browser.baseUrl+'/#!/profile');
+      browser.driver.get(browser.baseUrl+'#!/profile');
       element(by.id('account-link')).click();
       element(by.model('user.email')).isPresent().then(function() {
         element(by.id('account-link')).click();
@@ -66,8 +66,8 @@ describe('Test User Profile', function () {
         //this will not work with sso since its an enterprise config.
         return;
       }
-      browser.driver.get(browser.baseUrl+'/#!/org-overview');
-      browser.driver.get(browser.baseUrl+'/#!/profile');
+      browser.driver.get(browser.baseUrl+'#!/org-overview');
+      browser.driver.get(browser.baseUrl+'#!/profile');
       var email = element(by.model('user.email'));
       email.isPresent().then(function() {
         expect(email.getAttribute('value')).toEqual(browser.params.login.user);

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/097fd3bd/portal/tests/protractor/roles.spec.js
----------------------------------------------------------------------
diff --git a/portal/tests/protractor/roles.spec.js b/portal/tests/protractor/roles.spec.js
new file mode 100644
index 0000000..98956d0
--- /dev/null
+++ b/portal/tests/protractor/roles.spec.js
@@ -0,0 +1,40 @@
+'use strict';
+var util = require('./util');
+describe('Roles ', function () {
+
+  beforeEach(function () {
+    util.login();
+    util.navigate(browser.params.orgName,browser.params.appName1);
+    browser.driver.get(browser.baseUrl + '#!/roles');
+  });
+
+  describe('add and delete', function () {
+    it('should add and then delete', function () {
+      var dateString = Date.now().toString();
+      browser.wait(function(){
+        return element(by.id('add-role-btn')).isDisplayed();
+      });
+      element(by.id('add-role-btn')).isDisplayed().then(function(){
+        element(by.id('add-role-btn')).click();
+      });
+      element(by.id('new-role-roletitle')).isDisplayed().then(function(){
+        element(by.id('new-role-roletitle')).sendKeys('title'+dateString);
+        element(by.id('new-role-rolename')).sendKeys('name'+dateString);
+        element(by.id('dialogButton-roles')).submit();
+      });
+      element(by.id('role-title'+dateString+'-link')).isDisplayed().then(function(){
+        element(by.id('role-title'+dateString+'-link')).click();
+      });
+      element(by.id('role-title'+dateString+'-cb')).isDisplayed().then(function(){
+        element(by.id('role-title'+dateString+'-cb')).click();
+        element(by.id('delete-role-btn')).click();
+        element(by.id('dialogButton-deleteroles')).submit();
+      });
+      browser.wait(function(){
+        return element(by.id('role-title'+dateString+'-cb')).isPresent().then(function (present)
{
+          return !present;
+        });
+      });
+    });
+  });
+});
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/097fd3bd/portal/tests/protractor/shell.spec.js
----------------------------------------------------------------------
diff --git a/portal/tests/protractor/shell.spec.js b/portal/tests/protractor/shell.spec.js
new file mode 100644
index 0000000..f067596
--- /dev/null
+++ b/portal/tests/protractor/shell.spec.js
@@ -0,0 +1,121 @@
+'use strict';
+var util = require('./util');
+describe('Shell ', function () {
+
+  beforeEach(function () {
+    util.login();
+    util.navigate(browser.params.orgName,browser.params.appName1);
+    browser.driver.get(browser.baseUrl + '#!/shell');
+  });
+
+  describe('do a post and delete', function () {
+    it('should add and then delete', function () {
+      var dateString = Date.now().toString();
+      //browser.driver.get(browser.baseUrl + '#!/shell');
+
+      //Make sure shell window is displayed
+      browser.wait(function(){
+        return element(by.id("shell-input")).isDisplayed();
+      });
+      //POST:::do a post to add a "/tests" entity
+      element(by.id("shell-input")).isDisplayed().then(function(){
+        element(by.id('shell-input')).clear();
+        element(by.id('shell-input')).sendKeys('post /tests {"name":"' + dateString +'"}',
protractor.Key.RETURN);
+      });
+      //make sure call has returned before proceeding
+      browser.wait(function(){
+        return element(by.id('lastshelloutput')).getInnerHtml().then(function(text) {
+          return text.indexOf('{') === 0;
+        });
+      });
+      //verify that return values are as expected
+      element(by.id('lastshelloutput')).getInnerHtml().then(function(text){
+        var json = JSON.parse(text);
+        var entity = json.entities[0]["name"];
+        expect(entity).toEqual(dateString);
+      });
+
+      //PUT:::clear the input field and then update the entity with a PUT command
+      var newfield = "newfield";
+      element(by.id("shell-input")).isDisplayed().then(function(){
+        element(by.id('shell-input')).clear();
+        element(by.id('shell-input')).sendKeys('put /tests/' + dateString +' {"'+newfield+'":"'+newfield+'"}',
protractor.Key.RETURN);
+      });
+      //make sure call finished before proceeding
+      browser.wait(function(){
+        return element(by.id('lastshelloutput')).getInnerHtml().then(function(text) {
+          return text.indexOf('{') === 0;
+        });
+      });
+      //verify return values are good
+      element(by.id('lastshelloutput')).getInnerHtml().then(function(text){
+        var json = JSON.parse(text);
+        var entity = json.entities[0][newfield];
+        expect(entity).toEqual(newfield);
+      });
+
+      //GET:::clear input field, then do a GET to make sure entity is returned properly
+      element(by.id("shell-input")).isDisplayed().then(function(){
+        element(by.id('shell-input')).clear();
+        element(by.id('shell-input')).sendKeys('get /tests/' + dateString, protractor.Key.RETURN);
+      });
+      //make sure call has finished before proceeding
+      browser.wait(function(){
+        return element(by.id('lastshelloutput')).getInnerHtml().then(function(text) {
+          return text.indexOf('{') === 0;
+        });
+      });
+      //verify that the output is correct
+      element(by.id('lastshelloutput')).getInnerHtml().then(function(text){
+        var json = JSON.parse(text);
+        var field = json.entities[0]["name"];
+        expect(field).toEqual(dateString);
+        field = json.entities[0][newfield];
+        expect(field).toEqual(newfield);
+      });
+
+
+      //DELETE:::clear the input field and then delete the entity
+      element(by.id("shell-input")).isDisplayed().then(function(){
+        element(by.id('shell-input')).clear();
+        element(by.id('shell-input')).sendKeys('delete /tests/' + dateString, protractor.Key.RETURN);
+      });
+      //make sure the call finished before proceeding
+      browser.wait(function(){
+        return element(by.id('lastshelloutput')).getInnerHtml().then(function(text) {
+          return text.indexOf('{') === 0;
+        });
+      });
+      //make sure the output from the delete was good
+      element(by.id('lastshelloutput')).getInnerHtml().then(function(text){
+        var json = JSON.parse(text);
+        var action = json.action;
+        expect(action).toEqual('delete');
+        var entity = json.entities[0]["name"];
+        expect(entity).toEqual(dateString);
+      });
+
+
+      //GET:::clear input field, then do a GET to make sure entity has indeed been deleted
+      element(by.id("shell-input")).isDisplayed().then(function(){
+        element(by.id('shell-input')).clear();
+        element(by.id('shell-input')).sendKeys('get /tests/' + dateString, protractor.Key.RETURN);
+      });
+      //make sure call has finished before proceeding
+      browser.wait(function(){
+        return element(by.id('lastshelloutput')).getInnerHtml().then(function(text) {
+          return text.indexOf('{') === 0;
+        });
+      });
+      //verify that the output is correct
+      element(by.id('lastshelloutput')).getInnerHtml().then(function(text){
+        var json = JSON.parse(text);
+        var field = json.error;
+        expect(field).toEqual('service_resource_not_found');
+      });
+
+
+
+    });
+  });
+});
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/097fd3bd/portal/tests/protractor/users.spec.js
----------------------------------------------------------------------
diff --git a/portal/tests/protractor/users.spec.js b/portal/tests/protractor/users.spec.js
index f8a50ff..9392b6e 100644
--- a/portal/tests/protractor/users.spec.js
+++ b/portal/tests/protractor/users.spec.js
@@ -5,51 +5,14 @@ describe('Users ', function () {
   beforeEach(function () {
     util.login();
     util.navigate(browser.params.orgName,browser.params.appName1);
-    browser.driver.get(browser.baseUrl + '/#!/users');
+    browser.driver.get(browser.baseUrl + '#!/users');
   });
 
   describe('add and delete', function () {
     it('should add and then delete', function () {
-      var dateString = Date.now().toString();
-      browser.driver.get(browser.baseUrl + '/#!/users');
-
-      browser.wait(function(){
-        return element(by.id("new-user-button")).isDisplayed();
-      });
-      element(by.id("new-user-button")).isDisplayed().then(function(){
-        element(by.id("new-user-button")).click();
-      });
-      browser.wait(function(){
-        return element(by.id("new-user-username")).isDisplayed();
-      });
-      element(by.id('new-user-username')).isDisplayed().then(function () {
-        //fill in data
-        browser.sleep(500);
-        element(by.id('new-user-username')).clear();
-        element(by.id('new-user-username')).sendKeys('test' + dateString);
-        element(by.id('new-user-fullname')).sendKeys('Test ' + dateString);
-        element(by.id('new-user-email')).sendKeys('sfeldman+test' + dateString + '@apigee.com');
-        element(by.id('new-user-password')).sendKeys('P@ssw0rd1');
-        element(by.id('new-user-re-password')).sendKeys('P@ssw0rd1');
-        browser.sleep(1000);
-        element(by.id('dialogButton-users')).submit();
-      });
-
-      browser.wait(function () {
-        return element(by.id('user-' + 'test' + dateString + '-checkbox')).isPresent();
-      });
-      element(by.id('user-' + 'test' + dateString + '-checkbox')).isPresent().then(function
() {
-        element(by.id('user-' + 'test' + dateString + '-checkbox')).click();
-        browser.sleep(1000);
-        element(by.id('delete-user-button')).click();
-        element(by.id('dialogButton-deleteusers')).submit();
-      });
-      //need to wait for the element not to be there.
-      browser.wait(function(){
-        return element(by.id('user-' + 'test' + dateString + '-checkbox')).isPresent().then(function
(present) {
-          return !present;
-        });
-      });
+      var username = 'test' + Date.now().toString();
+      util.createUser(username);
+      util.deleteUser(username);
     });
   });
 });
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/097fd3bd/portal/tests/protractor/util.js
----------------------------------------------------------------------
diff --git a/portal/tests/protractor/util.js b/portal/tests/protractor/util.js
index 39bd7a0..9118bcb 100644
--- a/portal/tests/protractor/util.js
+++ b/portal/tests/protractor/util.js
@@ -1,5 +1,6 @@
 'use strict';
-
+var fs=require('fs');
+var path=require('path');
 module.exports = {
   loggedin:false,
   login: function(){
@@ -7,10 +8,10 @@ module.exports = {
       return;
     }
     var self = this;
-    browser.driver.get(browser.baseUrl + '/');
+    browser.driver.get(browser.baseUrl + '');
     browser.wait(function () {
       return browser.driver.getCurrentUrl().then(function (url) {
-        return/login/.test(url) || url.indexOf('accounts/sign_in')>0;
+        return /login/.test(url) || url.indexOf('accounts/sign_in')>0;
       });
     });
     if(browser.params.useSso){
@@ -57,7 +58,7 @@ module.exports = {
   logout:function(){
     if(this.loggedin){
       this.loggedin=false;
-      browser.driver.get(browser.baseUrl+'/#!/logout');
+      browser.driver.get(browser.baseUrl+'#!/logout');
       browser.wait(function () {
         return browser.driver.getCurrentUrl().then(function (url) {
           var test =  /login/.test(url) || url.indexOf('accounts/sign_in')>0;
@@ -68,7 +69,7 @@ module.exports = {
     }
   },
   navigate:function(orgName,appName){
-    browser.driver.get(browser.baseUrl+'/#!/org-overview');
+    browser.driver.get(browser.baseUrl+'#!/org-overview');
     browser.sleep(1000);
     browser.wait(function () {
       return element.all(by.repeater("(k,v) in organizations")).count().then(function(count){
@@ -100,11 +101,79 @@ module.exports = {
       element(by.id('app-'+appName+'-link-id')).click();
       browser.sleep(1000);
     });
-    browser.driver.get(browser.baseUrl+'/#!/app-overview/summary');
+    browser.driver.get(browser.baseUrl+'#!/app-overview/summary');
     browser.wait(function(){
       return element(by.id('app-overview-title')).getText().then(function(text){
         return text===appName.toUpperCase();
       })
     });
+  },
+  createUser:function(username){
+    this.login();
+    this.navigate(browser.params.orgName,browser.params.appName1);
+    browser.driver.get(browser.baseUrl + '#!/users');
+    browser.wait(function(){
+      return element(by.id("new-user-button")).isDisplayed();
+    });
+    element(by.id("new-user-button")).isDisplayed().then(function(){
+      element(by.id("new-user-button")).click();
+    });
+    browser.wait(function(){
+      return element(by.id("new-user-username")).isDisplayed();
+    });
+    element(by.id('new-user-username')).isDisplayed().then(function () {
+      //fill in data
+      browser.sleep(500);
+      element(by.id('new-user-username')).clear();
+      element(by.id('new-user-username')).sendKeys(username);
+      element(by.id('new-user-fullname')).sendKeys('Test ' + username);
+      element(by.id('new-user-email')).sendKeys('sfeldman+test' + username + '@apigee.com');
+      element(by.id('new-user-password')).sendKeys('P@ssw0rd1');
+      element(by.id('new-user-re-password')).sendKeys('P@ssw0rd1');
+      browser.sleep(1000);
+      element(by.id('dialogButton-users')).submit();
+    });
+
+    browser.wait(function () {
+      return element(by.id('user-' + username + '-checkbox')).isPresent();
+    });
+  },
+  deleteUser:function(username){
+    this.login();
+    this.navigate(browser.params.orgName,browser.params.appName1);
+    browser.driver.get(browser.baseUrl + '#!/users');
+
+    browser.wait(function () {
+      return element(by.id('user-' + username + '-checkbox')).isPresent();
+    });
+    
+    element(by.id('user-' + username + '-checkbox')).isPresent().then(function () {
+      element(by.id('user-' + username + '-checkbox')).click();
+      browser.sleep(1000);
+      element(by.id('delete-user-button')).click();
+      element(by.id('dialogButton-deleteusers')).submit();
+    });
+    //need to wait for the element not to be there.
+    browser.wait(function(){
+      return element(by.id('user-' + username + '-checkbox')).isPresent().then(function (present)
{
+        return !present;
+      });
+    });
+  },
+  getCoverage:function(){
+    var dname=path.normalize(__dirname+"/../../reports");
+    var fname=dname+'/coverage.json';
+    var browserCoverageObject="('__coverage__' in window)?__coverage__:null";
+    if(!fs.existsSync(dname)){
+      fs.mkdirSync(dname);
+    }
+    // console.log(__dirname, dname, fname);
+    browser.driver.executeScript("return "+browserCoverageObject+';').then(function(val){
+      if(val){
+        fs.writeFileSync(fname, JSON.stringify(val));
+      }else{
+        console.warn("No coverage object in the browser.")
+      }
+    });
   }
 };

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/097fd3bd/portal/tests/protractorConf.js
----------------------------------------------------------------------
diff --git a/portal/tests/protractorConf.js b/portal/tests/protractorConf.js
index 5aeb5d3..69292c9 100644
--- a/portal/tests/protractorConf.js
+++ b/portal/tests/protractorConf.js
@@ -51,6 +51,7 @@ exports.config = {
   // Spec patterns are relative to the location of this config.
   specs: [
     'protractor/*.spec.js',
+    'protractor/coverage/coverage.spec.js'
   ],
 
   // ----- Capabilities to be passed to the webdriver instance ----
@@ -79,7 +80,7 @@ exports.config = {
   //
   // A base URL for your application under test. Calls to protractor.get()
   // with relative paths will be prepended with this.
-  baseUrl: 'http://localhost:3000',
+  baseUrl: 'http://localhost:3000/',
 
 
   // Options to be passed to Jasmine-node.

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/097fd3bd/portal/tests/unit/sample.spec.js
----------------------------------------------------------------------
diff --git a/portal/tests/unit/sample.spec.js b/portal/tests/unit/sample.spec.js
index 1e2c540..e00b558 100644
--- a/portal/tests/unit/sample.spec.js
+++ b/portal/tests/unit/sample.spec.js
@@ -18,6 +18,7 @@ describe('PageCtrl', function(){
         'ug':{
           getAppSettings:function(){}
         },
+        'help':{},
         'utility':{},
         '$rootScope':$rootScope,
         '$location':{


Mime
View raw message