Skip to content
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

Add sign-out e2e test code #54

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
67 changes: 67 additions & 0 deletions e2e-test/auth/signout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
var environment = require('../environment.js');
var traslate = require('../languages/index.js');

describe('Sign Out',() => {
const emailInput = element(by.css('[ng-model="signin.credentials.email"]'));
const passwdInput = element(by.css('[ng-model="signin.credentials.password"]'));
const signinButton = element(by.css('[ng-click="signin.submit()"]'));
const menuButton = element.all(by.css('[ng-click="$mdOpenMenu($event)"]'));
const signoutButton = element(by.css('[ng-click="nav.signOut($event)"]'));
const stayButton = element(by.css('[ng-click="dialog.abort()"]'));
const leaveButton = element(by.css('[ng-click="dialog.hide()"]'));

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 click [Sign Out] and double check selected [STAY] : ',() => {
beforeEach(() => {
emailInput.sendKeys(env.getCorrectEmail());
passwdInput.sendKeys(env.getCorrectPassword());
signinButton.click();
menuButton.then((btns) => {
btns[0].click();
});
signoutButton.click();
stayButton.click();
});
it('Should check this website will stay Bucket List page.',() => {
browser.getCurrentUrl().then((result) => {
expect(result).toBe(env.getWeb()+'/bucket');
});
});
});

describe('When user click [Sign Out] and double check selected [LEAVE] : ',() => {
beforeEach(() => {
menuButton.then((btns) => {
btns[0].click();
});
signoutButton.click();
leaveButton.click();
});
it('Should check this website will go to Sign In page.',() => {
expect(element(by.css('md-toast')).isDisplayed()).toBe(true);
browser.getCurrentUrl().then((result) => {
expect(result).toBe(env.getWeb()+'/auth/signin');
});
});
});

describe('When user logout and input URL to attempts to back Bucket list : ',() => {
beforeEach(() => {
browser.navigate().to(env.getWeb()+'/bucket');
});
it('Should check stay Sign in page.',() => {
browser.getCurrentUrl().then((result) => {
expect(result).toBe(env.getWeb()+'/auth/signin');
});
});
});
});
61 changes: 61 additions & 0 deletions e2e-test/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
exports.config = {
framework: 'jasmine2',
specs: [
'./auth/signup.js',
'./auth/signin.js',
'./auth/back.js',
'./auth/signout.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': '[email protected],chrome-ubuntu-14.04',
'firefox-ubuntu-14.04': '[email protected],firefox-ubuntu-14.04',
'chrome-win7': '[email protected],chrome-win7',
'firefox-win7': '[email protected],firefox-win7',
'internet explorer-win7': '[email protected],ie-win7',
'chrome-win8': '[email protected],chrome-win8',
'firefox-win8': '[email protected],firefox-win8',
'internet explorer-win8': '[email protected],ie-win8',
'chrome-win10': '[email protected],chrome-win10',
'firefox-win10': '[email protected],firefox-win10',
'internet explorer-win10': '[email protected],ie-win10',
'chrome-osx': '[email protected],chrome-osx',
'firefox-osx': '[email protected],firefox-osx',
'safari-osx': '[email protected],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;