Skip to content

Commit

Permalink
fix(test): update protractor test for angular 1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
kingcody committed Jul 23, 2015
1 parent f4aaae0 commit f5acad0
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 23 deletions.
6 changes: 3 additions & 3 deletions app/templates/e2e/account(auth)/login/login.spec(jasmine).js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe('Login View', function() {
var page;

var loadPage = function() {
browser.get('/login');
browser.get(config.baseUrl + '/login');
page = require('./login.po');
};

Expand Down Expand Up @@ -45,7 +45,7 @@ describe('Login View', function() {

var navbar = require('../../components/navbar/navbar.po');

expect(browser.getLocationAbsUrl()).toBe(config.baseUrl + '/');
expect(browser.getCurrentUrl()).toBe(config.baseUrl + '/');
expect(navbar.navbarAccountGreeting.getText()).toBe('Hello ' + testUser.name);
});

Expand All @@ -55,7 +55,7 @@ describe('Login View', function() {
password: 'badPassword'
});

expect(browser.getLocationAbsUrl()).toBe(config.baseUrl + '/login');
expect(browser.getCurrentUrl()).toBe(config.baseUrl + '/login');

var helpBlock = page.form.element(by.css('.form-group.has-error .help-block.ng-binding'));
expect(helpBlock.getText()).toBe('This password is not correct.');
Expand Down
6 changes: 3 additions & 3 deletions app/templates/e2e/account(auth)/login/login.spec(mocha).js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe('Login View', function() {
var page;

var loadPage = function() {
browser.get('/login');
browser.get(config.baseUrl + '/login');
page = require('./login.po');
};

Expand Down Expand Up @@ -50,7 +50,7 @@ describe('Login View', function() {

var navbar = require('../../components/navbar/navbar.po');

<%= does("browser.getLocationAbsUrl()") %>.eventually.equal(config.baseUrl + '/');
<%= does("browser.getCurrentUrl()") %>.eventually.equal(config.baseUrl + '/');
<%= does("navbar.navbarAccountGreeting.getText()") %>.eventually.equal('Hello ' + testUser.name);
});

Expand All @@ -65,7 +65,7 @@ describe('Login View', function() {
password: 'badPassword'
});

<%= does("browser.getLocationAbsUrl()") %>.eventually.equal(config.baseUrl + '/login');
<%= does("browser.getCurrentUrl()") %>.eventually.equal(config.baseUrl + '/login');

var helpBlock = page.form.element(by.css('.form-group.has-error .help-block.ng-binding'));
<%= does("helpBlock.getText()") %>.eventually.equal('This password is not correct.');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var UserModel = require(config.serverConfig.root + '/server/sqldb').User;<% } %>

describe('Logout View', function() {
var login = function(user) {
browser.get('/login');
browser.get(config.baseUrl + '/login');
require('../login/login.po').login(user);
};

Expand Down Expand Up @@ -34,14 +34,14 @@ describe('Logout View', function() {
it('should logout a user and redirecting to "/"', function() {
var navbar = require('../../components/navbar/navbar.po');

expect(browser.getLocationAbsUrl()).toBe(config.baseUrl + '/');
expect(browser.getCurrentUrl()).toBe(config.baseUrl + '/');
expect(navbar.navbarAccountGreeting.getText()).toBe('Hello ' + testUser.name);

browser.get('/logout');
browser.get(config.baseUrl + '/logout');

navbar = require('../../components/navbar/navbar.po');

expect(browser.getLocationAbsUrl()).toBe(config.baseUrl + '/');
expect(browser.getCurrentUrl()).toBe(config.baseUrl + '/');
expect(navbar.navbarAccountGreeting.isDisplayed()).toBe(false);
});

Expand Down
8 changes: 4 additions & 4 deletions app/templates/e2e/account(auth)/logout/logout.spec(mocha).js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var UserModel = require(config.serverConfig.root + '/server/sqldb').User;<% } %>

describe('Logout View', function() {
var login = function(user) {
browser.get('/login');
browser.get(config.baseUrl + '/login');
require('../login/login.po').login(user);
};

Expand Down Expand Up @@ -39,14 +39,14 @@ describe('Logout View', function() {
it('should logout a user and redirecting to "/"', function() {
var navbar = require('../../components/navbar/navbar.po');

<%= does("browser.getLocationAbsUrl()") %>.eventually.equal(config.baseUrl + '/');
<%= does("browser.getCurrentUrl()") %>.eventually.equal(config.baseUrl + '/');
<%= does("navbar.navbarAccountGreeting.getText()") %>.eventually.equal('Hello ' + testUser.name);

browser.get('/logout');
browser.get(config.baseUrl + '/logout');

navbar = require('../../components/navbar/navbar.po');

<%= does("browser.getLocationAbsUrl()") %>.eventually.equal(config.baseUrl + '/');
<%= does("browser.getCurrentUrl()") %>.eventually.equal(config.baseUrl + '/');
<%= does("navbar.navbarAccountGreeting.isDisplayed()") %>.eventually.equal(false);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ describe('Signup View', function() {
var page;

var loadPage = function() {
browser.get('/signup');
browser.manage().deleteAllCookies();
browser.get(config.baseUrl + '/signup');
page = require('./signup.po');
};

Expand Down Expand Up @@ -45,14 +46,14 @@ describe('Signup View', function() {

var navbar = require('../../components/navbar/navbar.po');

expect(browser.getLocationAbsUrl()).toBe(config.baseUrl + '/');
expect(browser.getCurrentUrl()).toBe(config.baseUrl + '/');
expect(navbar.navbarAccountGreeting.getText()).toBe('Hello ' + testUser.name);
});

it('should indicate signup failures', function() {
page.signup(testUser);

expect(browser.getLocationAbsUrl()).toBe(config.baseUrl + '/signup');
expect(browser.getCurrentUrl()).toBe(config.baseUrl + '/signup');
expect(page.form.email.getAttribute('class')).toContain('ng-invalid-mongoose');

var helpBlock = page.form.element(by.css('.form-group.has-error .help-block.ng-binding'));
Expand Down
7 changes: 4 additions & 3 deletions app/templates/e2e/account(auth)/signup/signup.spec(mocha).js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ describe('Signup View', function() {
var page;

var loadPage = function() {
browser.get('/signup');
browser.manage().deleteAllCookies()
browser.get(config.baseUrl + '/signup');
page = require('./signup.po');
};

Expand Down Expand Up @@ -50,7 +51,7 @@ describe('Signup View', function() {

var navbar = require('../../components/navbar/navbar.po');

<%= does("browser.getLocationAbsUrl()") %>.eventually.equal(config.baseUrl + '/');
<%= does("browser.getCurrentUrl()") %>.eventually.equal(config.baseUrl + '/');
<%= does("navbar.navbarAccountGreeting.getText()") %>.eventually.equal('Hello ' + testUser.name);
});

Expand All @@ -62,7 +63,7 @@ describe('Signup View', function() {
it('should indicate signup failures', function() {
page.signup(testUser);

<%= does("browser.getLocationAbsUrl()") %>.eventually.equal(config.baseUrl + '/signup');
<%= does("browser.getCurrentUrl()") %>.eventually.equal(config.baseUrl + '/signup');
<%= does("page.form.email.getAttribute('class')") %>.eventually.contain('ng-invalid-mongoose');

var helpBlock = page.form.element(by.css('.form-group.has-error .help-block.ng-binding'));
Expand Down
2 changes: 1 addition & 1 deletion app/templates/e2e/components/navbar/navbar.po.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var NavbarComponent = function() {
this.navbarHeader = this.navbar.element(by.css('.navbar-header'));
this.navbarNav = this.navbar.element(by.css('#navbar-main .nav.navbar-nav:not(.navbar-right)'));<% if (filters.auth) { %>
this.navbarAccount = this.navbar.element(by.css('#navbar-main .nav.navbar-nav.navbar-right'));
this.navbarAccountGreeting = this.navbarAccount.element(by.binding('Hello {{ getCurrentUser().name }}'));<% } %>
this.navbarAccountGreeting = this.navbarAccount.element(by.binding('getCurrentUser().name'));<% } %>
};

module.exports = new NavbarComponent();
4 changes: 3 additions & 1 deletion app/templates/e2e/main/main.spec(jasmine).js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
'use strict';

var config = browser.params;

describe('Main View', function() {
var page;

beforeEach(function() {
browser.get('/');
browser.get(config.baseUrl + '/');
page = require('./main.po');
});

Expand Down
4 changes: 3 additions & 1 deletion app/templates/e2e/main/main.spec(mocha).js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
'use strict';

var config = browser.params;

describe('Main View', function() {
var page;

beforeEach(function() {
browser.get('/');
browser.get(config.baseUrl + '/');
page = require('./main.po');
});

Expand Down

0 comments on commit f5acad0

Please sign in to comment.