mirror of
https://github.com/mmumshad/ansible-playable.git
synced 2025-03-09 23:38:54 +00:00
Initial Commit
This commit is contained in:
commit
c92f737237
273 changed files with 16964 additions and 0 deletions
28
e2e/account/login/login.po.js
Normal file
28
e2e/account/login/login.po.js
Normal file
|
@ -0,0 +1,28 @@
|
|||
/**
|
||||
* This file uses the Page Object pattern to define the main page for tests
|
||||
* https://docs.google.com/presentation/d/1B6manhG0zEXkC-H-tPo2vwU06JhL8w9-XCF9oehXzAQ
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var LoginPage = function() {
|
||||
var form = this.form = element(by.css('.form'));
|
||||
form.email = form.element(by.model('vm.user.email'));
|
||||
form.password = form.element(by.model('vm.user.password'));
|
||||
form.submit = form.element(by.css('.btn-login'));
|
||||
form.oauthButtons = require('../../components/oauth-buttons/oauth-buttons.po').oauthButtons;
|
||||
|
||||
this.login = function(data) {
|
||||
for (var prop in data) {
|
||||
var formElem = form[prop];
|
||||
if (data.hasOwnProperty(prop) && formElem && typeof formElem.sendKeys === 'function') {
|
||||
formElem.sendKeys(data[prop]);
|
||||
}
|
||||
}
|
||||
|
||||
return form.submit.click();
|
||||
};
|
||||
};
|
||||
|
||||
module.exports = new LoginPage();
|
||||
|
87
e2e/account/login/login.spec.js
Normal file
87
e2e/account/login/login.spec.js
Normal file
|
@ -0,0 +1,87 @@
|
|||
'use strict';
|
||||
|
||||
var config = browser.params;
|
||||
var UserModel = require(config.serverConfig.root + '/server/api/user/user.model').default;
|
||||
|
||||
describe('Login View', function() {
|
||||
var page;
|
||||
|
||||
var loadPage = function() {
|
||||
let promise = browser.get(config.baseUrl + '/login');
|
||||
page = require('./login.po');
|
||||
return promise;
|
||||
};
|
||||
|
||||
var testUser = {
|
||||
name: 'Test User',
|
||||
email: 'test@example.com',
|
||||
password: 'test'
|
||||
};
|
||||
|
||||
before(function() {
|
||||
return UserModel
|
||||
.remove()
|
||||
.then(function() {
|
||||
return UserModel.create(testUser);
|
||||
})
|
||||
.then(loadPage);
|
||||
});
|
||||
|
||||
after(function() {
|
||||
return UserModel.remove();
|
||||
});
|
||||
|
||||
it('should include login form with correct inputs and submit button', function() {
|
||||
expect(page.form.email.getAttribute('type')).to.eventually.equal('email');
|
||||
expect(page.form.email.getAttribute('name')).to.eventually.equal('email');
|
||||
expect(page.form.password.getAttribute('type')).to.eventually.equal('password');
|
||||
expect(page.form.password.getAttribute('name')).to.eventually.equal('password');
|
||||
expect(page.form.submit.getAttribute('type')).to.eventually.equal('submit');
|
||||
expect(page.form.submit.getText()).to.eventually.equal('Login');
|
||||
});
|
||||
|
||||
it('should include oauth buttons with correct classes applied', function() {
|
||||
expect(page.form.oauthButtons.facebook.getText()).to.eventually.equal('Connect with Facebook');
|
||||
expect(page.form.oauthButtons.facebook.getAttribute('class')).to.eventually.contain('btn-block');
|
||||
expect(page.form.oauthButtons.google.getText()).to.eventually.equal('Connect with Google+');
|
||||
expect(page.form.oauthButtons.google.getAttribute('class')).to.eventually.contain('btn-block');
|
||||
});
|
||||
|
||||
describe('with local auth', function() {
|
||||
|
||||
it('should login a user and redirecting to "/"', function() {
|
||||
return page.login(testUser).then(() => {
|
||||
var navbar = require('../../components/navbar/navbar.po');
|
||||
|
||||
return browser.wait(
|
||||
() => element(by.css('.hero-unit')),
|
||||
5000,
|
||||
`Didn't find .hero-unit after 5s`
|
||||
).then(() => {
|
||||
expect(browser.getCurrentUrl()).to.eventually.equal(config.baseUrl + '/');
|
||||
expect(navbar.navbarAccountGreeting.getText()).to.eventually.equal('Hello ' + testUser.name);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('and invalid credentials', function() {
|
||||
before(function() {
|
||||
return loadPage();
|
||||
})
|
||||
|
||||
it('should indicate login failures', function() {
|
||||
page.login({
|
||||
email: testUser.email,
|
||||
password: 'badPassword'
|
||||
});
|
||||
|
||||
expect(browser.getCurrentUrl()).to.eventually.equal(config.baseUrl + '/login');
|
||||
|
||||
var helpBlock = page.form.element(by.css('.form-group.has-error .help-block.ng-binding'));
|
||||
expect(helpBlock.getText()).to.eventually.equal('This password is not correct.');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
});
|
51
e2e/account/logout/logout.spec.js
Normal file
51
e2e/account/logout/logout.spec.js
Normal file
|
@ -0,0 +1,51 @@
|
|||
'use strict';
|
||||
|
||||
var config = browser.params;
|
||||
var UserModel = require(config.serverConfig.root + '/server/api/user/user.model').default;
|
||||
|
||||
describe('Logout View', function() {
|
||||
var login = function(user) {
|
||||
let promise = browser.get(config.baseUrl + '/login');
|
||||
require('../login/login.po').login(user);
|
||||
return promise;
|
||||
};
|
||||
|
||||
var testUser = {
|
||||
name: 'Test User',
|
||||
email: 'test@example.com',
|
||||
password: 'test'
|
||||
};
|
||||
|
||||
beforeEach(function() {
|
||||
return UserModel
|
||||
.remove()
|
||||
.then(function() {
|
||||
return UserModel.create(testUser);
|
||||
})
|
||||
.then(function() {
|
||||
return login(testUser);
|
||||
});
|
||||
});
|
||||
|
||||
after(function() {
|
||||
return UserModel.remove();
|
||||
})
|
||||
|
||||
describe('with local auth', function() {
|
||||
|
||||
it('should logout a user and redirecting to "/"', function() {
|
||||
var navbar = require('../../components/navbar/navbar.po');
|
||||
|
||||
expect(browser.getCurrentUrl()).to.eventually.equal(config.baseUrl + '/');
|
||||
expect(navbar.navbarAccountGreeting.getText()).to.eventually.equal('Hello ' + testUser.name);
|
||||
|
||||
browser.get(config.baseUrl + '/logout');
|
||||
|
||||
navbar = require('../../components/navbar/navbar.po');
|
||||
|
||||
expect(browser.getCurrentUrl()).to.eventually.equal(config.baseUrl + '/');
|
||||
expect(navbar.navbarAccountGreeting.isDisplayed()).to.eventually.equal(false);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
30
e2e/account/signup/signup.po.js
Normal file
30
e2e/account/signup/signup.po.js
Normal file
|
@ -0,0 +1,30 @@
|
|||
/**
|
||||
* This file uses the Page Object pattern to define the main page for tests
|
||||
* https://docs.google.com/presentation/d/1B6manhG0zEXkC-H-tPo2vwU06JhL8w9-XCF9oehXzAQ
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var SignupPage = function() {
|
||||
var form = this.form = element(by.css('.form'));
|
||||
form.name = form.element(by.model('vm.user.name'));
|
||||
form.email = form.element(by.model('vm.user.email'));
|
||||
form.password = form.element(by.model('vm.user.password'));
|
||||
form.confirmPassword = form.element(by.model('vm.user.confirmPassword'));
|
||||
form.submit = form.element(by.css('.btn-register'));
|
||||
form.oauthButtons = require('../../components/oauth-buttons/oauth-buttons.po').oauthButtons;
|
||||
|
||||
this.signup = function(data) {
|
||||
for (var prop in data) {
|
||||
var formElem = form[prop];
|
||||
if (data.hasOwnProperty(prop) && formElem && typeof formElem.sendKeys === 'function') {
|
||||
formElem.sendKeys(data[prop]);
|
||||
}
|
||||
}
|
||||
|
||||
return form.submit.click();
|
||||
};
|
||||
};
|
||||
|
||||
module.exports = new SignupPage();
|
||||
|
84
e2e/account/signup/signup.spec.js
Normal file
84
e2e/account/signup/signup.spec.js
Normal file
|
@ -0,0 +1,84 @@
|
|||
'use strict';
|
||||
|
||||
var config = browser.params;
|
||||
var UserModel = require(config.serverConfig.root + '/server/api/user/user.model').default;
|
||||
|
||||
describe('Signup View', function() {
|
||||
var page;
|
||||
|
||||
var loadPage = function() {
|
||||
browser.manage().deleteAllCookies()
|
||||
let promise = browser.get(config.baseUrl + '/signup');
|
||||
page = require('./signup.po');
|
||||
return promise;
|
||||
};
|
||||
|
||||
var testUser = {
|
||||
name: 'Test',
|
||||
email: 'test@example.com',
|
||||
password: 'test',
|
||||
confirmPassword: 'test'
|
||||
};
|
||||
|
||||
before(function() {
|
||||
return loadPage();
|
||||
});
|
||||
|
||||
after(function() {
|
||||
return UserModel.remove();
|
||||
});
|
||||
|
||||
it('should include signup form with correct inputs and submit button', function() {
|
||||
expect(page.form.name.getAttribute('type')).to.eventually.equal('text');
|
||||
expect(page.form.name.getAttribute('name')).to.eventually.equal('name');
|
||||
expect(page.form.email.getAttribute('type')).to.eventually.equal('email');
|
||||
expect(page.form.email.getAttribute('name')).to.eventually.equal('email');
|
||||
expect(page.form.password.getAttribute('type')).to.eventually.equal('password');
|
||||
expect(page.form.password.getAttribute('name')).to.eventually.equal('password');
|
||||
expect(page.form.confirmPassword.getAttribute('type')).to.eventually.equal('password');
|
||||
expect(page.form.confirmPassword.getAttribute('name')).to.eventually.equal('confirmPassword');
|
||||
expect(page.form.submit.getAttribute('type')).to.eventually.equal('submit');
|
||||
expect(page.form.submit.getText()).to.eventually.equal('Sign up');
|
||||
});
|
||||
|
||||
it('should include oauth buttons with correct classes applied', function() {
|
||||
expect(page.form.oauthButtons.facebook.getText()).to.eventually.equal('Connect with Facebook');
|
||||
expect(page.form.oauthButtons.facebook.getAttribute('class')).to.eventually.contain('btn-block');
|
||||
expect(page.form.oauthButtons.google.getText()).to.eventually.equal('Connect with Google+');
|
||||
expect(page.form.oauthButtons.google.getAttribute('class')).to.eventually.contain('btn-block');
|
||||
});
|
||||
|
||||
describe('with local auth', function() {
|
||||
|
||||
before(function() {
|
||||
return UserModel.remove();
|
||||
})
|
||||
|
||||
it('should signup a new user, log them in, and redirecting to "/"', function() {
|
||||
page.signup(testUser);
|
||||
|
||||
var navbar = require('../../components/navbar/navbar.po');
|
||||
|
||||
expect(browser.getCurrentUrl()).to.eventually.equal(config.baseUrl + '/');
|
||||
expect(navbar.navbarAccountGreeting.getText()).to.eventually.equal('Hello ' + testUser.name);
|
||||
});
|
||||
|
||||
describe('and invalid credentials', function() {
|
||||
before(function() {
|
||||
return loadPage();
|
||||
});
|
||||
|
||||
it('should indicate signup failures', function() {
|
||||
page.signup(testUser);
|
||||
|
||||
expect(browser.getCurrentUrl()).to.eventually.equal(config.baseUrl + '/signup');
|
||||
expect(page.form.email.getAttribute('class')).to.eventually.contain('ng-invalid-mongoose');
|
||||
|
||||
var helpBlock = page.form.element(by.css('.form-group.has-error .help-block.ng-binding'));
|
||||
expect(helpBlock.getText()).to.eventually.equal('The specified email address is already in use.');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
});
|
16
e2e/components/navbar/navbar.po.js
Normal file
16
e2e/components/navbar/navbar.po.js
Normal file
|
@ -0,0 +1,16 @@
|
|||
/**
|
||||
* This file uses the Page Object pattern to define the main page for tests
|
||||
* https://docs.google.com/presentation/d/1B6manhG0zEXkC-H-tPo2vwU06JhL8w9-XCF9oehXzAQ
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var NavbarComponent = function() {
|
||||
this.navbar = element(by.css('.navbar'));
|
||||
this.navbarHeader = this.navbar.element(by.css('.navbar-header'));
|
||||
this.navbarNav = this.navbar.element(by.css('#navbar-main .nav.navbar-nav:not(.navbar-right)'));
|
||||
this.navbarAccount = this.navbar.element(by.css('#navbar-main .nav.navbar-nav.navbar-right'));
|
||||
this.navbarAccountGreeting = this.navbarAccount.element(by.binding('getCurrentUser().name'));
|
||||
};
|
||||
|
||||
module.exports = new NavbarComponent();
|
14
e2e/components/oauth-buttons/oauth-buttons.po.js
Normal file
14
e2e/components/oauth-buttons/oauth-buttons.po.js
Normal file
|
@ -0,0 +1,14 @@
|
|||
/**
|
||||
* This file uses the Page Object pattern to define the main page for tests
|
||||
* https://docs.google.com/presentation/d/1B6manhG0zEXkC-H-tPo2vwU06JhL8w9-XCF9oehXzAQ
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var OauthButtons = function() {
|
||||
var oauthButtons = this.oauthButtons = element(by.css('oauth-buttons'));
|
||||
oauthButtons.facebook = oauthButtons.element(by.css('.btn.btn-social.btn-facebook'));
|
||||
oauthButtons.google = oauthButtons.element(by.css('.btn.btn-social.btn-google'));
|
||||
};
|
||||
|
||||
module.exports = new OauthButtons();
|
15
e2e/main/main.po.js
Normal file
15
e2e/main/main.po.js
Normal file
|
@ -0,0 +1,15 @@
|
|||
/**
|
||||
* This file uses the Page Object pattern to define the main page for tests
|
||||
* https://docs.google.com/presentation/d/1B6manhG0zEXkC-H-tPo2vwU06JhL8w9-XCF9oehXzAQ
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var MainPage = function() {
|
||||
this.heroEl = element(by.css('.hero-unit'));
|
||||
this.h1El = this.heroEl.element(by.css('h1'));
|
||||
this.imgEl = this.heroEl.element(by.css('img'));
|
||||
};
|
||||
|
||||
module.exports = new MainPage();
|
||||
|
19
e2e/main/main.spec.js
Normal file
19
e2e/main/main.spec.js
Normal file
|
@ -0,0 +1,19 @@
|
|||
'use strict';
|
||||
|
||||
var config = browser.params;
|
||||
|
||||
describe('Main View', function() {
|
||||
var page;
|
||||
|
||||
beforeEach(function() {
|
||||
let promise = browser.get(config.baseUrl + '/');
|
||||
page = require('./main.po');
|
||||
return promise;
|
||||
});
|
||||
|
||||
it('should include jumbotron with correct data', function() {
|
||||
expect(page.h1El.getText()).to.eventually.equal('\'Allo, \'Allo!');
|
||||
expect(page.imgEl.getAttribute('src')).to.eventually.match(/yeoman(\.[a-zA-Z0-9]*)?\.png$/);
|
||||
expect(page.imgEl.getAttribute('alt')).to.eventually.equal('I\'m Yeoman');
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue