/* eslint-disable linebreak-style */ import 'codeceptjs'; import { DewElement } from "./element"; import { TextFilter } from "./textFilter"; import { logger } from "../Logger/logger"; import { CommonKeyword } from './commonKeyword'; import { TextField } from './textfield'; // import { Wait } from './dewWait'; import { DewLoader } from './dewLoader'; import { ReadLocators } from "../readLocators"; const locators:any = ReadLocators.readJson(); /** * Filter Class */ export class Filter { /** * Click on Filter Button in Listing grid and search for the column name * * ```js * Filter.applyFilter("Status"); * * ``` * * @param {*} columnName Column Name to filter */ static async applyFilter(columnName: string) { try { await CommonKeyword.clickElement(locators.applyFilterXpath); await CommonKeyword.clickElement(locators.filterSearchBoxXpath); await TextField.enterTextUsingLocator(locators.filterSearchBoxXpath, columnName); } catch (error) { logger.log(`Issue while performing operation in DDCC: Error while searching column name in filter`); throw error; } } /** * This function apply text filter in Grid Filter Popup * * ```js * Filter.applyTextFiler("Status","Active"); * ``` * @param {String} columnName Column Name to apply filter * @param {String} dataToFilter Data to filter */ static async applyTextFiler(columnName: string, dataToFilter: string) { await TextFilter.filterByText(columnName, dataToFilter); } /** * This function click on clearAll button in filter popup to clear the filters applied * * ```js * Filter.clearAllFilters(); * ``` */ static async clearAllFilters() { try { await CommonKeyword.clickElement(locators.applyFilterXpath); await DewLoader.waitForSpinner(); /* await Wait.waitForDefaultTimeout(4); await Wait.waitForElement(locators.clearAllFiltersXpath) */ const flag = await DewElement.getListOfElements(locators.clearAllFiltersXpath); logger.info(flag.length); if (flag.length == 1) { await CommonKeyword.clickElement(locators.clearAllFiltersXpath); } else { await CommonKeyword.clickElement(locators.filterCloseModalXpath); } } catch (error) { logger.log(`Issue while performing operation in DDCC: Error while clearing all filter`); throw error; } } }