Skip to content

Add sign-up e2e test code #51

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
182 changes: 182 additions & 0 deletions e2e-test/auth/signup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
var environment = require('../environment.js');
var traslate = require('../languages/index.js');

describe('Sign up : ',() => {
const emailInput = element(by.css('[ng-model="signup.credentials.email"]'));
const passwdInput = element(by.css('[ng-model="signup.credentials.password"]'));
const passwdConfInput = element(by.css('[ng-model="signup.credentials.password_confirmation"]'));
const loginPageButton = element(by.css('[href="/auth/signup"]'));
const signupButton = element(by.css('[ng-click="signup.submit()"]'));
const emailMessage = element(by.css('[ng-messages="signup.form.email.$error"]'));
const passwordMessage = element(by.css('[ng-messages="signup.form.password.$error"]'));
const passwordConfMessage = element(by.css('[ng-messages="signup.form.password_confirmation.$error"]'));
const emailExsitMessage = element(by.css('[ng-show="signup.emailIsInvalid && signup.showEmailCheckedMessage"]'));
const successMessage = element(by.css('md-toast span[class="ng-binding flex"]'));

const env = new environment();

browser.getProcessedConfig().then((config) => {
env.setUser(config.capabilities.browserName+"-"+config.capabilities.os);
});

beforeEach(() => {
browser.get(env.getWeb()+'/auth/signin');
});

describe('When user enter this website and click [Create an account] : ',() => {
beforeEach(() => {
loginPageButton.click();
});
it('Should check the website will go to Sign-In page".',() => {
browser.getCurrentUrl().then((result) => {
expect(result).toBe(env.getWeb()+'/auth/signup');
});
});
});

describe('When user not input email 、 password and retype password : ',() => {
beforeEach(() => {
loginPageButton.click();
});
it('Should check [SIGN UP] button will disabled.',() => {
expect(signupButton.isEnabled()).not.toBe(true);
});
});

describe('When user input null in email 、 password and retype password : ',() => {
beforeEach(() => {
loginPageButton.click();
emailInput.sendKeys();
passwdInput.sendKeys();
passwdConfInput.sendKeys();
emailInput.sendKeys();
});
it('Should check [SIGN UP] button will disabled.',() => {
expect(signupButton.isEnabled()).not.toBe(true);
});
it('Should check messages will displayed.',() => {
expect(emailMessage.isDisplayed()).toBe(true);
expect(passwordMessage.isDisplayed()).toBe(true);
expect(passwdConfInput.isDisplayed()).toBe(true);
});
});

describe('When user input correct format email : ',() => {
beforeEach(() => {
loginPageButton.click();
emailInput.sendKeys(env.getCorrectEmail());
passwdInput.sendKeys();
});
it('Should check [SIGN UP] button will disabled.',() => {
expect(signupButton.isEnabled()).not.toBe(true);
});
it('Should check message will not displayed.',() => {
expect(emailMessage.isDisplayed()).toBe(false);
});
});

describe('When user input incorrect email',() => {
beforeEach(() => {
loginPageButton.click();
emailInput.sendKeys(env.getIncorrectEmail());
passwdInput.sendKeys();
});
it('Should check [SIGN UP] button will disabled.',() => {
expect(signupButton.isEnabled()).not.toBe(true);
});
it('Should check message will Displayed.',() => {
expect(emailMessage.isDisplayed()).toBe(true);
});
});

describe('When user input correct format password : ',() => {
beforeEach(() => {
loginPageButton.click();
passwdInput.sendKeys(env.getCorrectPassword());
passwdConfInput.sendKeys();
});
it('Should check [SIGN UP] button will disabled.',() => {
expect(signupButton.isEnabled()).not.toBe(true);
});
it('Should check message will not displayed.',() => {
expect(passwordMessage.isDisplayed()).toBe(false);
});
});

describe('When user input incorrect password : ',() => {
beforeEach(() => {
loginPageButton.click();
passwdInput.sendKeys(env.getIncorrectPassword());
passwdConfInput.sendKeys();
});
it('Should check [SIGN UP] button will disabled.',() => {
expect(signupButton.isEnabled()).not.toBe(true);
});
it('Should check message will Displayed.',() => {
expect(passwordMessage.isDisplayed()).toBe(true);
});
});

describe('When user input password and retype password, but they don\'t match :',() => {
beforeEach(() => {
loginPageButton.click();
passwdInput.sendKeys(env.getCorrectPassword());
passwdConfInput.sendKeys(env.getIncorrectPassword());
emailInput.sendKeys();
});
it('Should check [SIGN UP] button will disabled.',() => {
expect(signupButton.isEnabled()).not.toBe(true);
});
it('Should check message will Displayed.',() => {
expect(passwordConfMessage.isDisplayed()).toBe(true);
});
});

describe('When user input correct email 、 password and retype password : ',() => {
beforeEach(() => {
loginPageButton.click();
emailInput.sendKeys(env.getCorrectEmail());
passwdInput.sendKeys(env.getCorrectPassword());
passwdConfInput.sendKeys(env.getCorrectPassword());
emailInput.sendKeys();
});
it('Should check [SIGN UP] button will enabled.',() => {
expect(signupButton.isEnabled()).toBe(true);
});
it('Should check message will not displayed.',() => {
expect(emailMessage.isDisplayed()).not.toBe(true);
expect(passwordMessage.isDisplayed()).not.toBe(true);
expect(passwordConfMessage.isDisplayed()).not.toBe(true);
});
});

describe('When user input all and click [SIGN UP] : ',() => {
beforeEach(() => {
loginPageButton.click();
emailInput.sendKeys(env.getCorrectEmail());
passwdInput.sendKeys(env.getCorrectPassword());
passwdConfInput.sendKeys(env.getCorrectPassword());
signupButton.click();
});
it('Should check message will show message and the website will go to Sign-In page.',() => {
expect(successMessage.isDisplayed()).toBe(true);
browser.getCurrentUrl().then((result) => {
expect(result).toBe(env.getWeb()+'/auth/signin');
});
});
});

describe('When user input exist email :',() => {
beforeEach(() => {
loginPageButton.click();
emailInput.sendKeys(env.getCorrectEmail());
passwdInput.sendKeys();
});
it('Should check [SIGN UP] button will disabled.',() => {
expect(signupButton.isEnabled()).not.toBe(true);
});
it('Should check message will displayed.',() => {
expect(emailExsitMessage.isDisplayed()).toBe(true);
});
});
});
57 changes: 57 additions & 0 deletions e2e-test/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
exports.config = {
framework: 'jasmine2',
specs: [
'./auth/signup.js'
],
multiCapabilities: [{
browserName: 'chrome',
seleniumAddress: 'http://10.26.1.27:4444/wd/hub',
os: 'ubuntu-14.04'
},{
browserName: 'firefox',
seleniumAddress: 'http://10.26.1.27:4444/wd/hub',
os: 'ubuntu-14.04'
}
,{
browserName: 'chrome',
seleniumAddress: 'http://10.26.1.34:4444/wd/hub',
os: 'win7'
},{
browserName: 'firefox',
seleniumAddress: 'http://10.26.1.34:4444/wd/hub',
os: 'win7'
},{
browserName: 'chrome',
seleniumAddress: 'http://10.26.1.55:4444/wd/hub',
os: 'win8'
},{
browserName: 'firefox',
seleniumAddress: 'http://10.26.1.55:4444/wd/hub',
os: 'win8'
},{
browserName: 'chrome',
seleniumAddress: 'http://10.26.1.56:4444/wd/hub',
os: 'win10'
},{
browserName: 'firefox',
seleniumAddress: 'http://10.26.1.56:4444/wd/hub',
os: 'win10'
},{
browserName: 'chrome',
seleniumAddress: 'http://127.0.0.1:4444/wd/hub',
os: 'osx'
},{
browserName: 'firefox',
seleniumAddress: 'http://127.0.0.1:4444/wd/hub',
os: 'osx'
},{
browserName: 'safari',
seleniumAddress: 'http://127.0.0.1:4444/wd/hub',
os: 'osx'
}
],
onPrepare: function() {
const SpecReporter = require('jasmine-spec-reporter');
jasmine.getEnv().addReporter(new SpecReporter({displayStacktrace: 'all'}));
}
}
51 changes: 51 additions & 0 deletions e2e-test/environment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
function User() {
this.correctEmail = 'no';
this.incorrectEmail = 'no';
this.correctpassword = 'password';
this.incorrectPassword = 'pass';
this.web = 'http://10.26.1.124:3000';
};

var array = {
'chrome-ubuntu-14.04': 'chrome-ubuntu-14.04@inwinstack.com,chrome-ubuntu-14.04',
'firefox-ubuntu-14.04': 'firefox-ubuntu-14.04@inwinstack.com,firefox-ubuntu-14.04',
'chrome-win7': 'chrome-win7@inwinstack.com,chrome-win7',
'firefox-win7': 'firefox-win7@inwinstack.com,firefox-win7',
'internet explorer-win7': 'ie-win7@inwinstack.com,ie-win7',
'chrome-win8': 'chrome-win8@inwinstack.com,chrome-win8',
'firefox-win8': 'firefox-win8@inwinstack.com,firefox-win8',
'internet explorer-win8': 'ie-win8@inwinstack.com,ie-win8',
'chrome-win10': 'chrome-win10@inwinstack.com,chrome-win10',
'firefox-win10': 'firefox-win10@inwinstack.com,firefox-win10',
'internet explorer-win10': 'ie-win10@inwinstack.com,ie-win10',
'chrome-osx': 'chrome-osx@inwinstack.com,chrome-osx',
'firefox-osx': 'firefox-osx@inwinstack.com,firefox-osx',
'safari-osx': 'safari-osx@inwinstack.com,safari-osx'
};

User.prototype.getWeb = function(){
return this.web;
};

User.prototype.setUser = function(user){
this.correctEmail = array[user].split(',')[0];
this.incorrectEmail = array[user].split(',')[1];
};

User.prototype.getCorrectEmail = function(){
return this.correctEmail;
};

User.prototype.getIncorrectEmail = function(){
return this.incorrectEmail;
};

User.prototype.getCorrectPassword = function(){
return this.correctpassword;
};

User.prototype.getIncorrectPassword = function(){
return this.incorrectPassword;
};

module.exports = User;
12 changes: 12 additions & 0 deletions e2e-test/languages/cn.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
function Translate(){
this.languages = null;
}

Translate.prototype.get = function(term){
this.languages = languages[term];
return this.languages
}

const languages = {}

module.exports = Translate;
12 changes: 12 additions & 0 deletions e2e-test/languages/en.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
function Translate(){
this.languages = null;
}

Translate.prototype.get = function(term){
this.languages = languages[term];
return this.languages
}

const languages = {}

module.exports = Translate;
23 changes: 23 additions & 0 deletions e2e-test/languages/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const tw = require('./tw.js');
const cn = require('./cn.js');
const en = require('./en.js');

const twTranslate = new tw();
const cnTranslate = new cn();
const enTranslate = new en();

function Translate(language, term){
switch(language){
case 'tw':
return twTranslate.get(term);
break;
case 'cn':
return cnTranslate.get(term);
break;
case 'en':
return enTranslate.get(term);
break;
}
}

module.exports = Translate;
12 changes: 12 additions & 0 deletions e2e-test/languages/tw.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
function Translate(){
this.languages = null;
}

Translate.prototype.get = function(term){
this.languages = languages[term];
return this.languages
}

const languages = {}

module.exports = Translate;