Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- manage_users.spec
- 'use strict';
- const pageObject = require('./../../services').container.PageObject;
- const signInPage = pageObject.getSignInPage();
- const dashboardPage = pageObject.getDashboardPage();
- const profilePage = pageObject.getProfilePage();
- const addProfilePage = pageObject.getAddProfilePage();
- const addSkuPage = pageObject.getAddSkuPage();
- const editTicketPage = pageObject.getEditTicketPage();
- const addCompanyPage = pageObject.getAddCompanyPage();
- const addContactsPage = pageObject.getAddContactPage();
- const jobCodePage = pageObject.getJobCodePage();
- const signInData = require('./../../data/sign_in');
- const dashboardData = require('./../../data/dashboard');
- const profileData = require('./../../data/profile');
- const commonHelper = require('./../../services/helpers/common.helper');
- describe('Manage users', () => {
- var username = signInData.testAccount.username;
- var password = signInData.testAccount.password;
- var dashboardTitle = dashboardData.title;
- var firstName = profileData.profile.firstName;
- var lastName = profileData.profile.lastName;
- var title = profileData.profile.title;
- var email = profileData.profile.email;
- var phoneNumber = profileData.profile.phoneNumber;
- var usernameManager = profileData.profile.username;
- var passwordManager = profileData.profile.password;
- var editFirstName = profileData.editProfile.firstName;
- var editLastName = profileData.editProfile.lastName;
- var editTitle = profileData.editProfile.title;
- var editEmail = profileData.editProfile.email;
- var editPhoneNumber = profileData.editProfile.phoneNumber;
- var editUsername = profileData.editProfile.username;
- beforeAll(() => {
- browser.ignoreSynchronization = false;
- browser.driver.manage().window().setSize(1440, 900);
- });
- afterAll(() => {
- commonHelper.clearAllData();
- });
- describe('checking add user', () => {
- var time = commonHelper.uniqueValue();
- beforeAll(() => {
- browser.get(signInData.link);
- });
- afterAll(() => {
- commonHelper.clearAllData();
- });
- it('should open login page', () => {
- expect(signInPage.btnLogin.isDisplayed()).toBe(true);
- });
- it('should redirect on dashboard page after login', () => {
- signInPage.login(username, password);
- commonHelper.waitUntilElementPresent(dashboardPage.menu);
- expect(dashboardPage.pageTitle()).toEqual(dashboardTitle);
- });
- it('should click on manage users', () => {
- dashboardPage.clickUser();
- commonHelper.waitUntilElementVisible(dashboardPage.btnManageUsers);
- dashboardPage.clickManageUsers();
- expect(dashboardPage.pageTitle()).toEqual('Users');
- });
- it('should click on add user', () => {
- profilePage.clickAddUser();
- commonHelper.waitUntilElementVisible(addProfilePage.txtFirstName);
- });
- it('should add user', () => {
- addProfilePage.fillFirstName(firstName + time);
- addProfilePage.fillLastName(lastName + time);
- addProfilePage.fillTitle(title + time);
- addProfilePage.fillEmail(time + email);
- addProfilePage.fillPhoneNumber(phoneNumber);
- addProfilePage.fillUsername(usernameManager + time);
- addProfilePage.fillPassword(passwordManager);
- addProfilePage.fillPasswordConfirm(passwordManager);
- });
- it('should save user',() => {
- addCompanyPage.clickSave();
- expect(dashboardPage.pageTitle()).toEqual('Users');
- });
- it('should logout', () => {
- dashboardPage.clickUser();
- dashboardPage.clickLogout();
- commonHelper.waitUntilElementVisible(signInPage.btnLogin);
- });
- it('should login as new user', () => {
- signInPage.login(usernameManager + time, passwordManager);
- commonHelper.waitUntilElementPresent(dashboardPage.menu);
- expect(dashboardPage.pageTitle()).toEqual(dashboardData.title);
- });
- it('should logout', () => {
- dashboardPage.clickUser();
- dashboardPage.clickLogout();
- commonHelper.waitUntilElementVisible(signInPage.btnLogin);
- });
- it('should redirect on dashboard page after login', () => {
- signInPage.login(username, password);
- commonHelper.waitUntilElementPresent(dashboardPage.menu);
- expect(dashboardPage.pageTitle()).toEqual(dashboardData.title);
- });
- it('should click on manage users', () => {
- dashboardPage.clickUser();
- commonHelper.waitUntilElementVisible(dashboardPage.btnManageUsers);
- dashboardPage.clickManageUsers();
- expect(dashboardPage.pageTitle()).toEqual('Users');
- });
- it('should click edit user', () => {
- addContactsPage.fillSearchContacts(time);
- jobCodePage.clickDetails();
- commonHelper.waitUntilElementVisible(addProfilePage.txtFirstName);
- });
- it('should edit user', () => {
- addProfilePage.fillFirstName(editFirstName + time);
- addProfilePage.fillLastName(editLastName + time);
- addProfilePage.fillTitle(editTitle + time);
- addProfilePage.fillEmail(time + editEmail);
- addProfilePage.fillPhoneNumber(editPhoneNumber);
- addProfilePage.fillUsername(editUsername + time);
- addProfilePage.fillPassword(password);
- addProfilePage.fillPasswordConfirm(password);
- });
- it('should save edited user',() => {
- addCompanyPage.clickSave();
- expect(dashboardPage.pageTitle()).toEqual('Users');
- });
- it('should logout', () => {
- dashboardPage.clickUser();
- dashboardPage.clickLogout();
- commonHelper.waitUntilElementVisible(signInPage.btnLogin);
- });
- it('should login as edited user', () => {
- signInPage.login(editUsername + time, password);
- commonHelper.waitUntilElementPresent(dashboardPage.menu);
- expect(dashboardPage.pageTitle()).toEqual(dashboardData.title);
- });
- });
- });
- --------------------------------------------------------------------
- add_profile.po
- 'use strict';
- class AddProfilePage {
- constructor() {
- this.txtFirstName = element(by.model('contact.first_name'));
- this.txtLastName = element(by.model('contact.last_name'));
- this.txtTitle = element(by.model('contact.title'));
- this.txtEmail = element(by.model('contact.email'));
- this.txtPhoneNumber = element(by.model('contact.phone_number'));
- this.txtUsername = element(by.model('user.username'));
- this.txtPassword = element(by.model('user.new_password'));
- this.txtPasswordConfirm = element(by.model('user.new_password2'))
- }
- fillFirstName(value){
- this.txtFirstName.clear()
- this.txtFirstName.sendKeys(value);
- }
- fillLastName (value){
- this.txtLastName .clear()
- this.txtLastName .sendKeys(value);
- }
- fillTitle(value){
- this.txtTitle.clear()
- this.txtTitle.sendKeys(value);
- }
- fillEmail(value){
- this.txtEmail.clear()
- this.txtEmail.sendKeys(value);
- }
- fillPhoneNumber(value){
- this.txtPhoneNumber.clear()
- this.txtPhoneNumber.sendKeys(value);
- }
- fillUsername(value){
- this.txtUsername.clear()
- this.txtUsername.sendKeys(value);
- }
- fillPassword(value){
- this.txtPassword.clear()
- this.txtPassword.sendKeys(value);
- }
- fillPasswordConfirm(value){
- this.txtPasswordConfirm.clear()
- this.txtPasswordConfirm.sendKeys(value);
- }
- }
- module.exports = AddProfilePage;
- -----------------------------------------------------------------
- data/profile/index
- 'use strict';
- module.exports = {
- link: browser.baseUrl + '/profiles/',
- editProfile: {
- firstName: 'Teddy',
- lastName: 'Bear',
- title: 'CEO',
- email: 'teddy@mailinator.com',
- phoneNumber: '0123456789',
- username: 'newuser',
- password: 'password'
- },
- profile: {
- firstName: 'Tom',
- lastName: 'Panda',
- title: 'Testing',
- email: '@mailinator.com',
- phoneNumber: '89657432',
- username: 'user'
- },
- };
- ---------------------------------------------------------------------------
- profile.po
- 'use strict';
- class ProfilePage {
- constructor() {
- this.btnAddUser = $('[href="/profiles/add/"]');
- this.btnEdit = element(by.css('material-icons icon-stroke'));
- }
- clickAddUser(){
- this.btnAddUser.click();
- }
- }
- module.exports = ProfilePage;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement