diff --git a/e2e-test/auth/signout.js b/e2e-test/auth/signout.js new file mode 100644 index 0000000..e3d93ec --- /dev/null +++ b/e2e-test/auth/signout.js @@ -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'); + }); + }); + }); +}); \ No newline at end of file diff --git a/e2e-test/config.js b/e2e-test/config.js new file mode 100755 index 0000000..888317d --- /dev/null +++ b/e2e-test/config.js @@ -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'})); + } +} \ No newline at end of file diff --git a/e2e-test/environment.js b/e2e-test/environment.js new file mode 100755 index 0000000..1c5da42 --- /dev/null +++ b/e2e-test/environment.js @@ -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; diff --git a/e2e-test/languages/cn.js b/e2e-test/languages/cn.js new file mode 100644 index 0000000..b9dfa17 --- /dev/null +++ b/e2e-test/languages/cn.js @@ -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; \ No newline at end of file diff --git a/e2e-test/languages/en.js b/e2e-test/languages/en.js new file mode 100644 index 0000000..b9dfa17 --- /dev/null +++ b/e2e-test/languages/en.js @@ -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; \ No newline at end of file diff --git a/e2e-test/languages/index.js b/e2e-test/languages/index.js new file mode 100644 index 0000000..3e75a4a --- /dev/null +++ b/e2e-test/languages/index.js @@ -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; \ No newline at end of file diff --git a/e2e-test/languages/tw.js b/e2e-test/languages/tw.js new file mode 100644 index 0000000..b9dfa17 --- /dev/null +++ b/e2e-test/languages/tw.js @@ -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; \ No newline at end of file