/*! * @license * Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { ElementFinder, protractor, $ } from 'protractor'; import { BrowserVisibility, BrowserActions, TestElement, materialLocators } from '@alfresco/adf-testing'; export class SearchBarPage { searchIcon = $(`button[class*='adf-search-button']`); searchBar = $(`adf-search-control input`); searchBarExpanded = TestElement.byCss(`adf-search-control ${materialLocators.Form.field.root}[class*="${materialLocators.Focused.root}"] input`); noResultMessage = $(`p[class*='adf-search-fixed-text']`); rowsAuthor = `${materialLocators.List.content.class} p[class*='adf-search-fixed-text']`; completeName = `h4[class*='adf-search-fixed-text']`; highlightName = `.adf-highlight`; searchBarPage = $(`${materialLocators.List.root}[id='autocomplete-search-result-list']`); getRowByRowName = (name: string): ElementFinder => $(`[data-automation-id='autocomplete_for_${name}']`); async clickOnSearchIcon(): Promise { await BrowserActions.click(this.searchIcon); } async checkSearchIconIsVisible(): Promise { await BrowserVisibility.waitUntilElementIsVisible(this.searchIcon); } async checkSearchBarIsVisible(): Promise { await BrowserVisibility.waitUntilElementIsVisible(this.searchBar); } async checkSearchBarIsNotVisible(): Promise { await this.searchBarExpanded.waitNotVisible(); } async checkNoResultMessageIsDisplayed(): Promise { await BrowserVisibility.waitUntilElementIsVisible(this.noResultMessage); } async checkNoResultMessageIsNotDisplayed(): Promise { await BrowserVisibility.waitUntilElementIsNotVisible(this.noResultMessage); } async enterText(text: string): Promise { await BrowserVisibility.waitUntilElementIsVisible(this.searchBar); await BrowserActions.clearSendKeys(this.searchBar, text); } async enterTextAndPressEnter(text: string): Promise { await BrowserVisibility.waitUntilElementIsVisible(this.searchBar); await BrowserActions.clearSendKeys(this.searchBar, text); await this.searchBar.sendKeys(protractor.Key.ENTER); } async resultTableContainsRow(name: string): Promise { await BrowserVisibility.waitUntilElementIsVisible(this.searchBarPage); await BrowserVisibility.waitUntilElementIsVisible(this.getRowByRowName(name)); } async clickOnSpecificRow(fileName: string): Promise { await this.resultTableContainsRow(fileName); await BrowserActions.click(this.getRowByRowName(fileName)); } async getSpecificRowsHighlightName(fileName: string): Promise { return BrowserActions.getText(this.getRowByRowName(fileName).$(this.highlightName)); } async getSpecificRowsCompleteName(fileName: string): Promise { return BrowserActions.getText(this.getRowByRowName(fileName).$(this.completeName)); } async getSpecificRowsAuthor(fileName: string): Promise { return BrowserActions.getText(this.getRowByRowName(fileName).$(this.rowsAuthor)); } async clearText(): Promise { await BrowserVisibility.waitUntilElementIsVisible(this.searchBar); await this.searchBar.clear(); } }