lint(tests): Add e2e tests to linter

This commit is contained in:
Blade Barringer
2016-01-06 20:52:24 -06:00
parent a92646b4e9
commit 8a19a84f3f
3 changed files with 27 additions and 14 deletions

View File

@@ -21,7 +21,6 @@ const TEST_FILES = [
'!./test/api-legacy/**/*',
'!./test/common/simulations/**/*',
'!./test/content/**/*',
'!./test/e2e/**/*',
'!./test/server_side/**/*',
'!./test/spec/**/*',
];

13
test/e2e/.eslintrc Normal file
View File

@@ -0,0 +1,13 @@
{
"rules": {
"func-names": 0,
"no-var": 0,
"prefer-template": 0
},
"globals": {
"browser": true,
"by": true,
"element": true,
"jasmine": true
}
}

View File

@@ -1,20 +1,21 @@
'use strict';
describe('front page', function() {
beforeEach(function(){
var fs = require('fs');
describe('front page', function () {
beforeEach(function () {
browser.ignoreSynchronization = true;
browser.get('/');
browser.sleep(1000);
});
// based on https://github.com/angular/protractor/issues/114#issuecomment-29046939
afterEach(function(){
afterEach(function () {
var currentSpec = jasmine.getEnv().currentSpec;
var passed = currentSpec.results().passed();
if(!passed){
if (!passed) {
var filename = 'exception_' + currentSpec.description + '.png';
browser.takeScreenshot().then(function(png){
var fs = require('fs');
browser.takeScreenshot().then(function (png) {
var buffer = new Buffer(png, 'base64');
var stream = fs.createWriteStream(filename);
stream.write(buffer);
@@ -23,25 +24,25 @@ describe('front page', function() {
}
});
it('shows the front page', function(){
it('shows the front page', function () {
var button = element(by.id('play-btn'));
expect(button.getText()).toEqual('Join for free');
});
it("doesn't login when using wrong credentials", function(){
it('does not login when using wrong credentials', function () {
var button = element(by.id('play-btn'));
button.click();
browser.sleep(1000);
element(by.model('loginUsername')).sendKeys('username');
element(by.model('loginPassword')).sendKeys('pass');
var login = element(by.css("#loginForm input[value='Login']"));
var login = element(by.css('#loginForm input[value="Login"]'));
login.click();
var alertDialog = browser.switchTo().alert();
expect(alertDialog.getText()).toMatch("Uh-oh - your username or password is incorrect.\n- Make sure your username or email is typed correctly.\n- You may have signed up with Facebook, not email. Double-check by trying Facebook login.\n- If you forgot your password, click \"Forgot Password\" on the habitica.com website's login form.");
expect(alertDialog.getText()).toMatch('Uh-oh - your username or password is incorrect.\n- Make sure your username or email is typed correctly.\n- You may have signed up with Facebook, not email. Double-check by trying Facebook login.\n- If you forgot your password, click "Forgot Password" on the habitica.com website\'s login form.');
alertDialog.accept();
});
xit('registers a new user', function(){
xit('registers a new user', function () {
var button = element(by.id('play-btn'));
button.click();
browser.sleep(1000);
@@ -51,10 +52,10 @@ describe('front page', function() {
element(by.model('registerVals.email')).sendKeys('user@example.com');
element(by.model('registerVals.password')).sendKeys('pass');
element(by.model('registerVals.confirmPassword')).sendKeys('pass');
var register = element(by.css("#registrationForm input[value='Register']"));
var register = element(by.css('#registrationForm input[value="Register"]'));
register.click();
browser.sleep(1000);
browser.getCurrentUrl().then(function(url){
browser.getCurrentUrl().then(function (url) {
expect(url).not.toMatch(/static\/front/);
});
});