Advertisement
Guest User

user

a guest
Nov 17th, 2016
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.48 KB | None | 0 0
  1. manage_users.spec
  2.  
  3. 'use strict';
  4.  
  5. const pageObject = require('./../../services').container.PageObject;
  6. const signInPage = pageObject.getSignInPage();
  7. const dashboardPage = pageObject.getDashboardPage();
  8. const profilePage = pageObject.getProfilePage();
  9. const addProfilePage = pageObject.getAddProfilePage();
  10. const addSkuPage = pageObject.getAddSkuPage();
  11. const editTicketPage = pageObject.getEditTicketPage();
  12. const addCompanyPage = pageObject.getAddCompanyPage();
  13. const addContactsPage = pageObject.getAddContactPage();
  14. const jobCodePage = pageObject.getJobCodePage();
  15. const signInData = require('./../../data/sign_in');
  16. const dashboardData = require('./../../data/dashboard');
  17. const profileData = require('./../../data/profile');
  18. const commonHelper = require('./../../services/helpers/common.helper');
  19.  
  20. describe('Manage users', () => {
  21.  
  22. var username = signInData.testAccount.username;
  23. var password = signInData.testAccount.password;
  24. var dashboardTitle = dashboardData.title;
  25.  
  26. var firstName = profileData.profile.firstName;
  27. var lastName = profileData.profile.lastName;
  28. var title = profileData.profile.title;
  29. var email = profileData.profile.email;
  30. var phoneNumber = profileData.profile.phoneNumber;
  31. var usernameManager = profileData.profile.username;
  32. var passwordManager = profileData.profile.password;
  33.  
  34. var editFirstName = profileData.editProfile.firstName;
  35. var editLastName = profileData.editProfile.lastName;
  36. var editTitle = profileData.editProfile.title;
  37. var editEmail = profileData.editProfile.email;
  38. var editPhoneNumber = profileData.editProfile.phoneNumber;
  39. var editUsername = profileData.editProfile.username;
  40.  
  41. beforeAll(() => {
  42. browser.ignoreSynchronization = false;
  43. browser.driver.manage().window().setSize(1440, 900);
  44. });
  45.  
  46. afterAll(() => {
  47. commonHelper.clearAllData();
  48. });
  49. describe('checking add user', () => {
  50.  
  51. var time = commonHelper.uniqueValue();
  52.  
  53. beforeAll(() => {
  54. browser.get(signInData.link);
  55. });
  56.  
  57. afterAll(() => {
  58. commonHelper.clearAllData();
  59. });
  60.  
  61. it('should open login page', () => {
  62. expect(signInPage.btnLogin.isDisplayed()).toBe(true);
  63. });
  64.  
  65. it('should redirect on dashboard page after login', () => {
  66. signInPage.login(username, password);
  67. commonHelper.waitUntilElementPresent(dashboardPage.menu);
  68.  
  69. expect(dashboardPage.pageTitle()).toEqual(dashboardTitle);
  70. });
  71.  
  72. it('should click on manage users', () => {
  73. dashboardPage.clickUser();
  74.  
  75. commonHelper.waitUntilElementVisible(dashboardPage.btnManageUsers);
  76. dashboardPage.clickManageUsers();
  77.  
  78. expect(dashboardPage.pageTitle()).toEqual('Users');
  79. });
  80.  
  81. it('should click on add user', () => {
  82. profilePage.clickAddUser();
  83.  
  84. commonHelper.waitUntilElementVisible(addProfilePage.txtFirstName);
  85. });
  86.  
  87. it('should add user', () => {
  88. addProfilePage.fillFirstName(firstName + time);
  89. addProfilePage.fillLastName(lastName + time);
  90. addProfilePage.fillTitle(title + time);
  91. addProfilePage.fillEmail(time + email);
  92. addProfilePage.fillPhoneNumber(phoneNumber);
  93. addProfilePage.fillUsername(usernameManager + time);
  94. addProfilePage.fillPassword(passwordManager);
  95. addProfilePage.fillPasswordConfirm(passwordManager);
  96. });
  97.  
  98. it('should save user',() => {
  99. addCompanyPage.clickSave();
  100.  
  101. expect(dashboardPage.pageTitle()).toEqual('Users');
  102. });
  103.  
  104. it('should logout', () => {
  105. dashboardPage.clickUser();
  106. dashboardPage.clickLogout();
  107.  
  108. commonHelper.waitUntilElementVisible(signInPage.btnLogin);
  109. });
  110.  
  111. it('should login as new user', () => {
  112. signInPage.login(usernameManager + time, passwordManager);
  113. commonHelper.waitUntilElementPresent(dashboardPage.menu);
  114.  
  115. expect(dashboardPage.pageTitle()).toEqual(dashboardData.title);
  116. });
  117.  
  118. it('should logout', () => {
  119. dashboardPage.clickUser();
  120. dashboardPage.clickLogout();
  121.  
  122. commonHelper.waitUntilElementVisible(signInPage.btnLogin);
  123. });
  124.  
  125. it('should redirect on dashboard page after login', () => {
  126. signInPage.login(username, password);
  127. commonHelper.waitUntilElementPresent(dashboardPage.menu);
  128.  
  129. expect(dashboardPage.pageTitle()).toEqual(dashboardData.title);
  130. });
  131.  
  132. it('should click on manage users', () => {
  133. dashboardPage.clickUser();
  134.  
  135. commonHelper.waitUntilElementVisible(dashboardPage.btnManageUsers);
  136. dashboardPage.clickManageUsers();
  137.  
  138. expect(dashboardPage.pageTitle()).toEqual('Users');
  139. });
  140.  
  141. it('should click edit user', () => {
  142. addContactsPage.fillSearchContacts(time);
  143. jobCodePage.clickDetails();
  144.  
  145. commonHelper.waitUntilElementVisible(addProfilePage.txtFirstName);
  146. });
  147.  
  148. it('should edit user', () => {
  149. addProfilePage.fillFirstName(editFirstName + time);
  150. addProfilePage.fillLastName(editLastName + time);
  151. addProfilePage.fillTitle(editTitle + time);
  152. addProfilePage.fillEmail(time + editEmail);
  153. addProfilePage.fillPhoneNumber(editPhoneNumber);
  154. addProfilePage.fillUsername(editUsername + time);
  155. addProfilePage.fillPassword(password);
  156. addProfilePage.fillPasswordConfirm(password);
  157. });
  158.  
  159. it('should save edited user',() => {
  160. addCompanyPage.clickSave();
  161.  
  162. expect(dashboardPage.pageTitle()).toEqual('Users');
  163. });
  164.  
  165. it('should logout', () => {
  166. dashboardPage.clickUser();
  167. dashboardPage.clickLogout();
  168.  
  169. commonHelper.waitUntilElementVisible(signInPage.btnLogin);
  170. });
  171.  
  172. it('should login as edited user', () => {
  173. signInPage.login(editUsername + time, password);
  174. commonHelper.waitUntilElementPresent(dashboardPage.menu);
  175.  
  176. expect(dashboardPage.pageTitle()).toEqual(dashboardData.title);
  177. });
  178. });
  179. });
  180.  
  181. --------------------------------------------------------------------
  182. add_profile.po
  183.  
  184. 'use strict';
  185.  
  186. class AddProfilePage {
  187. constructor() {
  188. this.txtFirstName = element(by.model('contact.first_name'));
  189. this.txtLastName = element(by.model('contact.last_name'));
  190. this.txtTitle = element(by.model('contact.title'));
  191. this.txtEmail = element(by.model('contact.email'));
  192. this.txtPhoneNumber = element(by.model('contact.phone_number'));
  193. this.txtUsername = element(by.model('user.username'));
  194. this.txtPassword = element(by.model('user.new_password'));
  195. this.txtPasswordConfirm = element(by.model('user.new_password2'))
  196. }
  197.  
  198. fillFirstName(value){
  199. this.txtFirstName.clear()
  200. this.txtFirstName.sendKeys(value);
  201. }
  202.  
  203. fillLastName (value){
  204. this.txtLastName .clear()
  205. this.txtLastName .sendKeys(value);
  206. }
  207.  
  208. fillTitle(value){
  209. this.txtTitle.clear()
  210. this.txtTitle.sendKeys(value);
  211. }
  212.  
  213. fillEmail(value){
  214. this.txtEmail.clear()
  215. this.txtEmail.sendKeys(value);
  216. }
  217.  
  218. fillPhoneNumber(value){
  219. this.txtPhoneNumber.clear()
  220. this.txtPhoneNumber.sendKeys(value);
  221. }
  222.  
  223. fillUsername(value){
  224. this.txtUsername.clear()
  225. this.txtUsername.sendKeys(value);
  226. }
  227.  
  228. fillPassword(value){
  229. this.txtPassword.clear()
  230. this.txtPassword.sendKeys(value);
  231. }
  232.  
  233. fillPasswordConfirm(value){
  234. this.txtPasswordConfirm.clear()
  235. this.txtPasswordConfirm.sendKeys(value);
  236. }
  237. }
  238. module.exports = AddProfilePage;
  239. -----------------------------------------------------------------
  240. data/profile/index
  241.  
  242. 'use strict';
  243.  
  244. module.exports = {
  245. link: browser.baseUrl + '/profiles/',
  246. editProfile: {
  247. firstName: 'Teddy',
  248. lastName: 'Bear',
  249. title: 'CEO',
  250. email: 'teddy@mailinator.com',
  251. phoneNumber: '0123456789',
  252. username: 'newuser',
  253. password: 'password'
  254. },
  255. profile: {
  256. firstName: 'Tom',
  257. lastName: 'Panda',
  258. title: 'Testing',
  259. email: '@mailinator.com',
  260. phoneNumber: '89657432',
  261. username: 'user'
  262. },
  263. };
  264. ---------------------------------------------------------------------------
  265. profile.po
  266.  
  267. 'use strict';
  268.  
  269. class ProfilePage {
  270. constructor() {
  271. this.btnAddUser = $('[href="/profiles/add/"]');
  272. this.btnEdit = element(by.css('material-icons icon-stroke'));
  273. }
  274.  
  275. clickAddUser(){
  276. this.btnAddUser.click();
  277. }
  278. }
  279. module.exports = ProfilePage;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement