import 'codeceptjs'; import { CommonKeyword } from "../components/commonKeyword"; import { lmt } from '../Helpers/readI18NProp'; import { logger } from "../Logger/logger"; import { DewFileUpload } from './dewFileUpload'; import { DewElement } from './element'; import { TextField } from './textfield'; /** * Profile related class */ export class ManageProfile { /** * Function is use to Navigate To Manage Profile page * * ```js * ManageProfile.navigateToManageProfile(); * ``` */ static async navigateToManageProfile() { try { await CommonKeyword.clickElement(`//dew-dropdown[contains(@class,'profile')]`); await CommonKeyword.clickElement(`//div[contains(@class,'dropdown-item') and text()[normalize-space()='${await lmt.getLabel(`Manage Profile`)}']]`); await DewElement.verifyIfISeeElement(`//user-profile`); // z.seeElement(`//user-profile`); await CommonKeyword.clickLabel(await lmt.getLabel(`User Details`)); } catch (error) { logger.info(`Issue while performing operation in DDCC: Error while navigating to Manage Profile`); throw error; } } /** * Function is use to upload Profile Picture in Manage Profile Page * * ```js * ManageProfile.uploadProfilePicture(); * ``` */ static async uploadProfilePicture() { try { await CommonKeyword.clickElement(`//button[@aria-label='Upload']`); await DewElement.verifyIfISeeText(await lmt.getLabel(`Upload Image`)); // z.see(await lmt.getLabel(`Upload_Image`)); await DewFileUpload.uploadFile(`//*[contains(@class,'modal-content')]//div[@class='upload-btn-wrapper']/input`, `./resources/branch300.jpg`); await CommonKeyword.clickElement(`//*[contains(@class,'modal-content')]//button[@aria-label='Set Profile Photo']`); } catch (error) { logger.log(`Issue while performing operation in DDCC: Error while uploading profile picture`); throw error; } } /** * Function is use to verify whether Profile Picture in uploaded in Manage Profile page * * ```js * * ManageProfile.verifyUploadedProfilePicture(); * ``` */ static async verifyUploadedProfilePicture() { await DewElement.verifyIfISeeElement(`//img[@class='media-object' and contains(@src,'base64')]`); // z.seeElement(`//img[@class='media-object' and contains(@src,'base64')]`); } /** * Function is use to reset Profile Picture in Manage Profile page * * ```js * * ManageProfile.resetProfilePicture(); * ``` */ static async resetProfilePicture() { await CommonKeyword.clickElement(`//button[@aria-label='Reset Profile Picture']`); await DewElement.verifyIfISeeElement(`//button[@aria-label='Reset Profile Picture' and @disabled]`); } /** * Function is use to change password for the user * * ```js * * ManageProfile.changePassword(); * ``` */ static async changePassword() { try { this.navigateToManageProfile(); await CommonKeyword.clickElement(`//button[@aria-label='Change Password']`); await TextField.enterTextUsingLocator(`//input[@formcontrolname='currentPassword']`, `YoDeHaCoPoBiBaIoAiWiYeQe8&7`); await TextField.enterTextUsingLocator(`//input[@formcontrolname='newPassword']`, `YoDeHaCoPoBiBaIoAiWiYeQe8&71`); await TextField.enterTextUsingLocator(`//input[@formcontrolname='confirmPassword']`, `YoDeHaCoPoBiBaIoAiWiYeQe8&71`); await CommonKeyword.clickElement(`//dew-modal-footer//button[@aria-label='Save' and not(@disabled)]`); } catch (error) { logger.log(`Issue while performing operation in DDCC: Error while changing password`); throw error; } } /** * Function is use to verify password is updated * * ```js * * ManageProfile.verifyIfPasswordUpdated(); * ``` */ static async verifyIfPasswordUpdated() { await DewElement.verifyIfISeeText(await lmt.getLabel(`Password Updated`)); // z.see(await lmt.getLabel(`Password_Updated`)); } /** * Function is use to change pin for user * * ```js * * ManageProfile.changePin(); * ``` */ static async changePin() { try { await CommonKeyword.clickElement(`//button[@aria-label='Change Pin']`); logger.info(`Qw` + generateRandomNumber()); const pin = `Qw` + generateRandomNumber(); await TextField.enterTextUsingLocator(`//input[@formcontrolname='newMobilePin']`, pin); await TextField.enterTextUsingLocator(`//input[@formcontrolname='confirmMobilePin']`, pin); await CommonKeyword.clickElement(`//dew-modal-footer//button[@aria-label='Save' and not(@disabled)]`); } catch (error) { logger.log(`Issue while performing operation in DDCC: Error while changing pin`); throw error; } } /** * Function is use to verify if pin is updated * * ```js * * ManageProfile.verifyIfPinUpdated(); * ``` */ static async verifyIfPinUpdated() { await DewElement.verifyIfISeeText(await lmt.getLabel(`Pin Updated`)); // z.see(await lmt.getLabel(`Pin_Updated`)); } } /** * Generates random series of numbers * @return {number} */ function generateRandomNumber() { return Math.floor(Math.random() * 9000); }