Skip to content

Commit 4e3f59f

Browse files
committed
fix(e2e): fix some async quirks
1 parent 536e9a1 commit 4e3f59f

File tree

2 files changed

+24
-12
lines changed

2 files changed

+24
-12
lines changed

templates/app/e2e/account(auth)/login/login.spec(jasmine).js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,18 @@ describe('Login View', function() {
5656
describe('with local auth', function() {
5757

5858
it('should login a user and redirecting to "/"', function() {
59-
page.login(testUser);
60-
61-
var navbar = require('../../components/navbar/navbar.po');
62-
63-
expect(browser.getCurrentUrl()).toBe(config.baseUrl + '/');
64-
expect(navbar.navbarAccountGreeting.getText()).toBe('Hello ' + testUser.name);
59+
return page.login(testUser).then(() => {
60+
var navbar = require('../../components/navbar/navbar.po');
61+
62+
return browser.wait(
63+
() => element(by.css('.hero-unit')),
64+
5000,
65+
`Didn't find .hero-unit after 5s`
66+
).then(() => {
67+
expect(browser.getCurrentUrl()).toBe(config.baseUrl + '/');
68+
expect(navbar.navbarAccountGreeting.getText()).toBe('Hello ' + testUser.name);
69+
});
70+
});
6571
});
6672

6773
it('should indicate login failures', function() {

templates/app/e2e/account(auth)/login/login.spec(mocha).js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,18 @@ describe('Login View', function() {
5656
describe('with local auth', function() {
5757

5858
it('should login a user and redirecting to "/"', function() {
59-
page.login(testUser);
60-
61-
var navbar = require('../../components/navbar/navbar.po');
62-
63-
<%= expect() %>browser.getCurrentUrl()<%= to() %>.eventually.equal(config.baseUrl + '/');
64-
<%= expect() %>navbar.navbarAccountGreeting.getText()<%= to() %>.eventually.equal('Hello ' + testUser.name);
59+
return page.login(testUser).then(() => {
60+
var navbar = require('../../components/navbar/navbar.po');
61+
62+
return browser.wait(
63+
() => element(by.css('.hero-unit')),
64+
5000,
65+
`Didn't find .hero-unit after 5s`
66+
).then(() => {
67+
<%= expect() %>browser.getCurrentUrl()<%= to() %>.eventually.equal(config.baseUrl + '/');
68+
<%= expect() %>navbar.navbarAccountGreeting.getText()<%= to() %>.eventually.equal('Hello ' + testUser.name);
69+
});
70+
});
6571
});
6672

6773
describe('and invalid credentials', function() {

0 commit comments

Comments
 (0)