private-event-sourcing-examples-46 Write a single, simple protractor test:
- Sign Up (+cases) - Login (+cases) - Create Account (+cases) - [WIP] Create 3rd Party Account (+cases)
This commit is contained in:
@@ -1,3 +1,55 @@
|
||||
const salt = Math.random().toString().substr(2, 6);
|
||||
|
||||
const userData = (() => {
|
||||
|
||||
const [ fName, lName, email, pass, passConf, ssn ] = 'John|Doe|jd@em.com|12345|12345|12345'.split('|').map(k => `${k}_${salt}`);
|
||||
|
||||
return {
|
||||
fName, lName, email, pass, passConf, ssn
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
const otherUserData = (() => {
|
||||
|
||||
const [ fName, lName, email, pass, passConf, ssn ] = 'Jane|Dole|janed@ail.com|56789|56789|56789'.split('|').map(k => `${k}_${salt}`);
|
||||
|
||||
return {
|
||||
fName, lName, email, pass, passConf, ssn
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
const accountOne = (() => {
|
||||
|
||||
const [ title, amount, description ] = 'InitialAccount|100|One hundred'.split('|');
|
||||
|
||||
return {
|
||||
title,
|
||||
amount,
|
||||
description
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
const accountTwo = (() => {
|
||||
|
||||
const [ title, amount, description ] = 'SecondaryAccount|200|Two hundred'.split('|');
|
||||
|
||||
return {
|
||||
title,
|
||||
amount,
|
||||
description
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
|
||||
|
||||
export default {
|
||||
waitForConditionTimeout: 10000,
|
||||
userData,
|
||||
otherUserData,
|
||||
accountOne,
|
||||
accountTwo
|
||||
};
|
||||
@@ -1,9 +1,140 @@
|
||||
const mainCommands = {
|
||||
createAccount({ title, amount, description }, waitToHide) {
|
||||
this
|
||||
.waitForElementVisible('@modalCreateAccountHook')
|
||||
.click('@modalCreateAccountHook');
|
||||
|
||||
this.api.pause(500);
|
||||
this.waitForElementVisible('@modalCreateAccountModal')
|
||||
.waitForElementVisible('@modalCreateAccountForm')
|
||||
.setValue('@modalCreateAccountTitle', title)
|
||||
.setValue('@modalCreateAccountAmount', amount)
|
||||
.setValue('@modalCreateAccountDescription', description)
|
||||
.click('@modalCreateAccountSubmit');
|
||||
|
||||
if (waitToHide) {
|
||||
this.waitForElementNotPresent('@modalCreateAccountModal');
|
||||
this.api.pause(1500);
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
||||
createRef({ userQuery, accountQuery, title, description }, waitToHide) {
|
||||
this
|
||||
.waitForElementVisible('@modalCreateRefHook')
|
||||
.click('@modalCreateRefHook');
|
||||
|
||||
this.api.pause(500);
|
||||
this.waitForElementVisible('@modalCreateRefModal')
|
||||
.waitForElementVisible('@modalCreateRefForm')
|
||||
.waitForElementVisible('@modalCreateRefCustomerField')
|
||||
.click('@modalCreateRefCustomerField')
|
||||
.waitForElementVisible('@modealCreateRefCustomerOpen')
|
||||
.waitForElementVisible('@modalCreateRefCustomerInput')
|
||||
.setValue('@modalCreateRefCustomerInput', userQuery)
|
||||
.waitForElementVisible('@modealCreateRefDDOption')
|
||||
.click('@modealCreateRefDDOption')
|
||||
.setValue('@modalCreateRefAccount', accountQuery)
|
||||
.setValue('@modalCreateRefTitle', title)
|
||||
.setValue('@modalCreateRefDescription', description)
|
||||
.click('@modalCreateRefSubmit');
|
||||
|
||||
if (waitToHide) {
|
||||
this.waitForElementNotPresent('@modalCreateRefModal');
|
||||
this.api.pause(1500);
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
signOut() {
|
||||
this
|
||||
.waitForElementVisible('@signOutLink')
|
||||
.click('@signOutLink');
|
||||
return this.waitForElementNotPresent('@signOutLink');
|
||||
}
|
||||
};
|
||||
|
||||
export default {
|
||||
url: 'http://localhost:8080/#/',
|
||||
commands: [ mainCommands ],
|
||||
elements: {
|
||||
instancesListDescription: {
|
||||
selector: '//div[@class="description-field col-flex-1"]',
|
||||
signOutLink: {
|
||||
selector: '//li/a[text()=\'Sign Out\']',
|
||||
locateStrategy: 'xpath'
|
||||
}
|
||||
},
|
||||
modalCreateAccountHook: {
|
||||
selector: '//div/button[1][text()=\'Create Account\']',
|
||||
locateStrategy: 'xpath'
|
||||
},
|
||||
modalCreateAccountModal: {
|
||||
selector: '.modal-dialog'
|
||||
},
|
||||
modalCreateAccountForm: {
|
||||
selector: 'form.account-create-form'
|
||||
},
|
||||
modalCreateAccountTitle: {
|
||||
selector: 'form.account-create-form input[name=title]'
|
||||
},
|
||||
modalCreateAccountAmount: {
|
||||
selector: 'form.account-create-form input[name=balance]'
|
||||
},
|
||||
modalCreateAccountDescription: {
|
||||
selector: 'form.account-create-form textarea[name=description]'
|
||||
},
|
||||
modalCreateAccountSubmit: {
|
||||
selector: '.modal-dialog button[type=submit]'
|
||||
},
|
||||
modalCreateAccountErrors: {
|
||||
selector: 'form.account-create-form .inline-error-item'
|
||||
},
|
||||
modalCreateRefHook: {
|
||||
selector: '//div/button[2][text()=\'Add 3rd Party Recipients\']',
|
||||
locateStrategy: 'xpath'
|
||||
},
|
||||
modalCreateRefModal: {
|
||||
selector: '.modal-dialog'
|
||||
},
|
||||
modalCreateRefForm: {
|
||||
selector: 'form.account-create-ref'
|
||||
},
|
||||
modalCreateRefCustomerField: {
|
||||
selector: 'form.account-create-ref .Select.is-searchable div.Select-input'
|
||||
},
|
||||
modalCreateRefCustomerInput: {
|
||||
selector: 'form.account-create-ref .Select.is-searchable div.Select-input > input'
|
||||
},
|
||||
modealCreateRefCustomerOpen: {
|
||||
selector: 'form.account-create-ref .Select.is-searchable.is-open.is-focused div.Select-menu-outer > div.Select-menu' //has-value
|
||||
},
|
||||
modealCreateRefDDOption: {
|
||||
selector: 'form.account-create-ref .Select.is-searchable.is-open.is-focused div.Select-menu-outer > div.Select-menu > div.Select-option' //has-value
|
||||
},
|
||||
modalCreateRefAccount: {
|
||||
selector: 'form.account-create-ref .Select:not(.is-searchable) div.Select-input'
|
||||
},
|
||||
modalCreateRefTitle: {
|
||||
selector: 'form.account-create-ref input[name=title]'
|
||||
},
|
||||
modalCreateRefDescription: {
|
||||
selector: 'form.account-create-ref textarea[name=description]'
|
||||
},
|
||||
modalCreateRefSubmit: {
|
||||
selector: '.modal-dialog button[type=submit]'
|
||||
},
|
||||
modalCreateRefErrors: {
|
||||
selector: 'form.account-create-ref .inline-error-item'
|
||||
},
|
||||
accountLink: {
|
||||
selector: 'a[href^=\'#/account/\']'
|
||||
},
|
||||
firstAccountLink: {
|
||||
selector: '(//a[starts-with(@href, "#/account/")])[1]',
|
||||
locateStrategy: 'xpath'
|
||||
},
|
||||
secondAccountLink: {
|
||||
selector: '(//a[starts-with(@href, "#/account/")])[2]',
|
||||
locateStrategy: 'xpath'
|
||||
},
|
||||
}
|
||||
};
|
||||
@@ -1,12 +1,21 @@
|
||||
const loginCommands = {
|
||||
login({email, pass}) {
|
||||
login({ email, pass }) {
|
||||
|
||||
this
|
||||
.waitForElementVisible('@emailInput')
|
||||
.waitForElementVisible('@emailInput', 500);
|
||||
|
||||
this
|
||||
.clearValue('@emailInput')
|
||||
.setValue('@emailInput', email)
|
||||
.clearValue('@passInput')
|
||||
.setValue('@passInput', pass);
|
||||
|
||||
this.api.pause(500);
|
||||
this.getValue('@emailInput', (result) => {
|
||||
this.assert.equal(result.value, email);
|
||||
});
|
||||
|
||||
return this.waitForElementVisible('@loginButton')
|
||||
.click('@loginButton')
|
||||
.submitForm('@loginButton');
|
||||
|
||||
}
|
||||
@@ -27,6 +36,9 @@ export default {
|
||||
},
|
||||
loginButton: {
|
||||
selector: 'button[type=submit]'
|
||||
},
|
||||
formError: {
|
||||
selector: '.control-label.inline-error-item'
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1,5 +1,5 @@
|
||||
const signupCommands = {
|
||||
signup({fName, lName, email, pass, passConf, ssn}) {
|
||||
signup({fName, lName, email, pass, passConf, ssn}, waitForNext) {
|
||||
this
|
||||
.waitForElementVisible('@fNameInput')
|
||||
.setValue('@fNameInput', fName)
|
||||
@@ -9,12 +9,15 @@ const signupCommands = {
|
||||
.setValue('@passConfirmInput', passConf)
|
||||
.setValue('@ssnInput', ssn);
|
||||
|
||||
this.api.pause(500);
|
||||
this.waitForElementVisible('@signupButton')
|
||||
.submitForm('@signupButton');
|
||||
this.api.pause(500);
|
||||
|
||||
return this.waitForElementNotPresent('@fNameInput');
|
||||
if (waitForNext) {
|
||||
return this.waitForElementNotPresent('@signupButton');
|
||||
}
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
@@ -43,6 +46,9 @@ export default {
|
||||
signupButton: {
|
||||
// selector: 'button[type=submit]'
|
||||
selector: 'button[type=submit].email-sign-up-submit.btn.btn-default'
|
||||
},
|
||||
formError: {
|
||||
selector: '.control-label.inline-error-item'
|
||||
}
|
||||
}
|
||||
};
|
||||
27
js-frontend/tests/e2e-tests/test010_Signup.js
Normal file
27
js-frontend/tests/e2e-tests/test010_Signup.js
Normal file
@@ -0,0 +1,27 @@
|
||||
import globals from '../e2e-globals/globals';
|
||||
|
||||
export default {
|
||||
'@tags': ['register', 'sanity'],
|
||||
|
||||
'User signs up': (client) => {
|
||||
const signupPage = client.page.signupPage();
|
||||
const loginPage = client.page.loginPage();
|
||||
|
||||
const [ fName, lName, email, pass, passConf, ssn ] = '|||||'.split('|');
|
||||
signupPage
|
||||
.navigate()
|
||||
.signup({
|
||||
fName, lName, email, pass, passConf, ssn
|
||||
}, false);
|
||||
|
||||
signupPage.expect.element('@formError').to.be.visible;
|
||||
|
||||
signupPage
|
||||
.navigate()
|
||||
.signup(globals.userData, true);
|
||||
|
||||
loginPage.expect.element('@emailLoginPageInput').to.be.visible;
|
||||
|
||||
client.end();
|
||||
}
|
||||
};
|
||||
@@ -1,19 +0,0 @@
|
||||
export default {
|
||||
'@tags': ['register', 'sanity'],
|
||||
|
||||
'User signs up': (client) => {
|
||||
const page = client.page.signupPage();
|
||||
const loginPage = client.page.loginPage();
|
||||
|
||||
const [fName, lName, email, pass, passConf, ssn] = 'Andrew|Revinsky|ar@gm.com|12345|12345|12345'.split('|');
|
||||
page
|
||||
.navigate()
|
||||
.signup({
|
||||
fName, lName, email, pass, passConf, ssn
|
||||
});
|
||||
|
||||
loginPage.expect.element('@emailLoginPageInput').to.be.visible;
|
||||
|
||||
client.end();
|
||||
}
|
||||
};
|
||||
32
js-frontend/tests/e2e-tests/test020_Login.js
Normal file
32
js-frontend/tests/e2e-tests/test020_Login.js
Normal file
@@ -0,0 +1,32 @@
|
||||
import globals from '../e2e-globals/globals';
|
||||
|
||||
export default {
|
||||
'@tags': ['login', 'sanity'],
|
||||
|
||||
'User Logs in': (client) => {
|
||||
const loginPage = client.page.loginPage();
|
||||
const instancesPage = client.page.instancesPage();
|
||||
|
||||
const [email, pass] = '|'.split('|');
|
||||
|
||||
loginPage
|
||||
.navigate()
|
||||
.login({email, pass});
|
||||
|
||||
loginPage.expect.element('@formError').to.be.visible;
|
||||
|
||||
loginPage
|
||||
.navigate()
|
||||
.login(globals.userData);
|
||||
|
||||
instancesPage.expect.element('@signOutLink').to.be.visible;
|
||||
|
||||
instancesPage
|
||||
.navigate()
|
||||
.signOut();
|
||||
|
||||
client.assert.urlContains('/#/signin');
|
||||
|
||||
client.end();
|
||||
}
|
||||
};
|
||||
@@ -1,18 +0,0 @@
|
||||
export default {
|
||||
'@tags': ['login', 'sanity'],
|
||||
'User Logs in': (client) => {
|
||||
const loginPage = client.page.loginPage();
|
||||
const instancesPage = client.page.instancesPage();
|
||||
|
||||
const [email, pass] = 'ar@gm.com|12345'.split('|');
|
||||
|
||||
|
||||
loginPage
|
||||
.navigate()
|
||||
.login({email, pass});
|
||||
|
||||
instancesPage.expect.element('@instancesListDescription').to.be.visible;
|
||||
|
||||
client.end();
|
||||
}
|
||||
};
|
||||
49
js-frontend/tests/e2e-tests/test030_CreateAccount.js
Normal file
49
js-frontend/tests/e2e-tests/test030_CreateAccount.js
Normal file
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* Created by andrew on 9/28/16.
|
||||
*/
|
||||
import globals from '../e2e-globals/globals';
|
||||
|
||||
export default {
|
||||
'@tags': ['create accounts', 'sanity'],
|
||||
|
||||
'User Creates Accounts': (client) => {
|
||||
const loginPage = client.page.loginPage();
|
||||
const instancesPage = client.page.instancesPage();
|
||||
|
||||
const [ title, amount, description ] = '||'.split('|');
|
||||
|
||||
loginPage
|
||||
.navigate()
|
||||
.login(globals.userData);
|
||||
|
||||
instancesPage
|
||||
.navigate()
|
||||
.createAccount({ title, amount, description }, false);
|
||||
|
||||
instancesPage.expect.element('@modalCreateAccountErrors').to.be.visible;
|
||||
|
||||
instancesPage
|
||||
.createAccount(globals.accountOne, true);
|
||||
|
||||
instancesPage.expect.element('@modalCreateAccountErrors').to.not.be.present;
|
||||
instancesPage.expect.element('@modalCreateAccountForm').to.not.be.present;
|
||||
|
||||
instancesPage.expect.element('@accountLink').to.be.visible;
|
||||
|
||||
instancesPage.expect.element('@firstAccountLink').to.be.visible;
|
||||
instancesPage.expect.element('@secondAccountLink').to.not.be.present;
|
||||
|
||||
instancesPage.expect.element('@firstAccountLink').text.to.contain(globals.accountOne.title);
|
||||
|
||||
instancesPage
|
||||
.createAccount(globals.accountTwo, true);
|
||||
|
||||
instancesPage.expect.element('@firstAccountLink').to.be.visible;
|
||||
instancesPage.expect.element('@secondAccountLink').to.be.visible;
|
||||
|
||||
instancesPage.expect.element('@firstAccountLink').text.to.contain(globals.accountOne.title);
|
||||
instancesPage.expect.element('@secondAccountLink').text.to.contain(globals.accountTwo.title);
|
||||
|
||||
client.end();
|
||||
}
|
||||
};
|
||||
60
js-frontend/tests/e2e-tests/test040_Create3rdPartyAccs.js
Normal file
60
js-frontend/tests/e2e-tests/test040_Create3rdPartyAccs.js
Normal file
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
* Created by andrew on 9/28/16.
|
||||
*/
|
||||
import globals from '../e2e-globals/globals';
|
||||
|
||||
export default {
|
||||
'@tags': ['create 3rd party accounts', 'sanity'],
|
||||
|
||||
'User Creates 3rd Party Accounts': (client) => {
|
||||
const loginPage = client.page.loginPage();
|
||||
const signupPage = client.page.signupPage();
|
||||
const instancesPage = client.page.instancesPage();
|
||||
|
||||
// Step 1: Setup 3rd Party & Accounts
|
||||
|
||||
signupPage
|
||||
.navigate();
|
||||
|
||||
client.assert.urlContains('/#/register');
|
||||
|
||||
signupPage
|
||||
.signup(globals.otherUserData, true);
|
||||
|
||||
client.assert.urlContains('/#/signin');
|
||||
|
||||
loginPage
|
||||
.navigate()
|
||||
.login(globals.otherUserData);
|
||||
|
||||
const [ userQuery, accountQuery, title, description ] = '|||'.split('|');
|
||||
|
||||
instancesPage
|
||||
.navigate()
|
||||
.createRef({ userQuery, accountQuery, title, description }, false);
|
||||
|
||||
instancesPage.expect.element('@modalCreateRefErrors').to.be.visible;
|
||||
instancesPage.expect.element('@modalCreateRefForm').to.be.visible;
|
||||
|
||||
const [ refAccountTitle, refAccountDescription ] = 'Johns`s Initial Account|Johns`s Initial Account'.split('|');;
|
||||
instancesPage
|
||||
.createRef({
|
||||
userQuery: globals.userData.email,
|
||||
accountQuery: globals.accountOne.title,
|
||||
title: refAccountTitle,
|
||||
description: refAccountDescription
|
||||
}, true);
|
||||
|
||||
instancesPage.expect.element('@modalCreateRefErrors').to.not.be.present;
|
||||
instancesPage.expect.element('@modalCreateRefForm').to.not.be.present;
|
||||
|
||||
instancesPage.expect.element('@accountLink').to.be.visible;
|
||||
|
||||
instancesPage.expect.element('@firstAccountLink').to.be.visible;
|
||||
instancesPage.expect.element('@secondAccountLink').to.not.be.present;
|
||||
|
||||
instancesPage.expect.element('@firstAccountLink').text.to.contain(refAccountTitle);
|
||||
|
||||
client.end();
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user