diff --git a/e2e/components/breadcrumb/breadcrumb.ts b/e2e/components/breadcrumb/breadcrumb.ts index 2d50185b9..662e72743 100755 --- a/e2e/components/breadcrumb/breadcrumb.ts +++ b/e2e/components/breadcrumb/breadcrumb.ts @@ -23,7 +23,7 @@ * along with Alfresco. If not, see . */ -import { ElementFinder, ElementArrayFinder, by, promise } from 'protractor'; +import { ElementFinder, ElementArrayFinder, by } from 'protractor'; import { Component } from '../component'; export class Breadcrumb extends Component { diff --git a/e2e/components/datetime-picker/datetime-picker.ts b/e2e/components/datetime-picker/datetime-picker.ts index d819ef11b..9b746a520 100755 --- a/e2e/components/datetime-picker/datetime-picker.ts +++ b/e2e/components/datetime-picker/datetime-picker.ts @@ -26,7 +26,7 @@ import { ElementFinder, by, browser, ExpectedConditions as EC } from 'protractor'; import { BROWSER_WAIT_TIMEOUT } from '../../configs'; import { Component } from '../component'; -import moment = require('moment'); +import * as moment from 'moment'; export class DateTimePicker extends Component { private static selectors = { diff --git a/e2e/components/header/header.ts b/e2e/components/header/header.ts index f4340216f..b14777c06 100755 --- a/e2e/components/header/header.ts +++ b/e2e/components/header/header.ts @@ -26,48 +26,30 @@ import { ElementFinder, by, browser } from 'protractor'; import { Component } from '../component'; import { UserInfo } from './user-info'; -import { protractor } from 'protractor'; -import { Utils } from '../../utilities/utils'; import { Menu } from '../menu/menu'; import { Toolbar } from './../toolbar/toolbar'; +import { SearchInput } from '../search/search-input'; export class Header extends Component { private locators = { root: 'app-header', logoLink: by.css('.app-menu__title'), userInfo: by.css('aca-current-user'), - searchButton: by.css('.app-search-button'), - searchBar: by.css('#app-control-input'), moreActions: by.id('app.header.more') }; logoLink: ElementFinder = this.component.element(this.locators.logoLink); userInfo: UserInfo = new UserInfo(this.component); - searchButton: ElementFinder = this.component.element(this.locators.searchButton); - searchBar: ElementFinder = browser.element(this.locators.searchBar); moreActions: ElementFinder = browser.element(this.locators.moreActions); menu: Menu = new Menu(); toolbar: Toolbar = new Toolbar(); + searchInput: SearchInput = new SearchInput(); constructor(ancestor?: ElementFinder) { super('adf-layout-header', ancestor); } - async searchForText(text: string) { - await this.searchBar.clear(); - await this.searchBar.sendKeys(text); - await this.searchBar.sendKeys(protractor.Key.ENTER); - } - - async waitForSearchButton() { - await Utils.waitUntilElementClickable(this.searchButton); - } - - async waitForSearchBar() { - await Utils.waitUntilElementClickable(this.searchBar); - } - async openMoreMenu() { await this.moreActions.click(); await this.menu.waitForMenuToOpen(); diff --git a/e2e/components/search/search-input.ts b/e2e/components/search/search-input.ts new file mode 100755 index 000000000..121a640e1 --- /dev/null +++ b/e2e/components/search/search-input.ts @@ -0,0 +1,115 @@ +/*! + * @license + * Alfresco Example Content Application + * + * Copyright (C) 2005 - 2018 Alfresco Software Limited + * + * This file is part of the Alfresco Example Content Application. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * The Alfresco Example Content Application is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Alfresco Example Content Application is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ + +import { ElementFinder, browser, by, until, protractor } from 'protractor'; +import { BROWSER_WAIT_TIMEOUT } from '../../configs'; +import { Component } from '../component'; + +export class SearchInput extends Component { + private static selectors = { + root: 'aca-search-input', + searchContainer: '.app-search-container', + searchButton: '.app-search-button', + searchControl: '.app-search-control', + searchInput: 'app-control-input', + searchOptionsArea: 'search-options', + optionCheckbox: '.mat-checkbox' + }; + + searchButton: ElementFinder = browser.element(by.css(SearchInput.selectors.searchButton)); + searchContainer: ElementFinder = browser.element(by.css(SearchInput.selectors.searchContainer)); + searchBar: ElementFinder = browser.element(by.id(SearchInput.selectors.searchInput)); + searchOptionsArea: ElementFinder = browser.element(by.id(SearchInput.selectors.searchOptionsArea)); + searchFilesOption: ElementFinder = this.searchOptionsArea.element(by.cssContainingText(SearchInput.selectors.optionCheckbox, 'Files')); + searchFoldersOption: ElementFinder = this.searchOptionsArea.element(by.cssContainingText(SearchInput.selectors.optionCheckbox, 'Folders')); + searchLibrariesOption: ElementFinder = this.searchOptionsArea.element(by.cssContainingText(SearchInput.selectors.optionCheckbox, 'Libraries')); + + constructor(ancestor?: ElementFinder) { + super(SearchInput.selectors.root, ancestor); + } + + async isSearchContainerDisplayed() { + return (await this.searchContainer.isDisplayed()) && (await this.searchButton.isDisplayed()); + } + + async clickSearchContainer() { + return await this.searchContainer.click(); + } + + async isOptionsAreaDisplayed() { + await browser.wait(until.elementLocated(by.css(SearchInput.selectors.searchControl)), BROWSER_WAIT_TIMEOUT); + return await browser.isElementPresent(this.searchOptionsArea); + } + + async clickFilesOption() { + return await this.searchFilesOption.click(); + } + + async clickFoldersOption() { + return await this.searchFoldersOption.click(); + } + + async clickLibrariesOption() { + return await this.searchLibrariesOption.click(); + } + + async isFilesOptionEnabled() { + const optClass = await this.searchFilesOption.getAttribute('class'); + return !optClass.includes('mat-checkbox-disabled'); + } + + async isFoldersOptionEnabled() { + const optClass = await this.searchFoldersOption.getAttribute('class'); + return !optClass.includes('mat-checkbox-disabled'); + } + + async isLibrariesOptionEnabled() { + const optClass = await this.searchLibrariesOption.getAttribute('class'); + return !optClass.includes('mat-checkbox-disabled'); + } + + async isFilesOptionChecked() { + const optClass = await this.searchFilesOption.getAttribute('class'); + return optClass.includes('mat-checkbox-checked'); + } + + async isFoldersOptionChecked() { + const optClass = await this.searchFoldersOption.getAttribute('class'); + return optClass.includes('mat-checkbox-checked'); + } + + async isLibrariesOptionChecked() { + const optClass = await this.searchLibrariesOption.getAttribute('class'); + return optClass.includes('mat-checkbox-checked'); + } + + + + async searchForText(text: string) { + await this.searchBar.clear(); + await this.searchBar.sendKeys(text); + await this.searchBar.sendKeys(protractor.Key.ENTER); + } +} diff --git a/e2e/suites/application/page-titles.test.ts b/e2e/suites/application/page-titles.test.ts index ac3c6136a..8b740413e 100755 --- a/e2e/suites/application/page-titles.test.ts +++ b/e2e/suites/application/page-titles.test.ts @@ -24,7 +24,6 @@ */ import { browser } from 'protractor'; - import { SIDEBAR_LABELS, PAGE_TITLES } from '../../configs'; import { LoginPage, BrowsingPage } from '../../pages/pages'; import { RepoClient } from '../../utilities/repo-client/repo-client'; @@ -37,7 +36,7 @@ describe('Page titles', () => { const adminApi = new RepoClient(); const { nodes: nodesApi } = adminApi; const file = `file-${Utils.random()}.txt`; let fileId; - const header = page.header; + const { searchInput } = page.header; xit(''); @@ -124,11 +123,8 @@ describe('Page titles', () => { }); it('Search Results page - [C280413]', async () => { - await header.waitForSearchButton(); - await header.searchButton.click(); - await page.dataTable.waitForHeader(); - await header.waitForSearchBar(); - await header.searchForText(file); + await searchInput.clickSearchContainer(); + await searchInput.searchForText(file); expect(await browser.getTitle()).toContain(PAGE_TITLES.SEARCH); }); }); diff --git a/e2e/suites/search/search-input.test.ts b/e2e/suites/search/search-input.test.ts new file mode 100644 index 000000000..ac1c497ad --- /dev/null +++ b/e2e/suites/search/search-input.test.ts @@ -0,0 +1,88 @@ +/*! + * @license + * Alfresco Example Content Application + * + * Copyright (C) 2005 - 2018 Alfresco Software Limited + * + * This file is part of the Alfresco Example Content Application. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * The Alfresco Example Content Application is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Alfresco Example Content Application is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ + +import { BrowsingPage, LoginPage } from '../../pages/pages'; +// import { Utils } from '../../utilities/utils'; +import { browser } from 'protractor'; + +describe('Search input', () => { + const loginPage = new LoginPage(); + const page = new BrowsingPage(); + const { searchInput } = page.header; + + beforeAll(async (done) => { + await loginPage.loginWithAdmin(); + done(); + }); + + beforeEach(async (done) => { + // await Utils.pressEscape(); + await browser.actions().mouseMove(browser.$('body'), { x: 0, y: 0 }).click().perform(); + done(); + }); + + it('Search input is displayed in the app header - [C289847]', async () => { + expect(await searchInput.isSearchContainerDisplayed()).toBe(true, 'search controls not displayed'); + }); + + it('Search options are displayed when clicking in the search input - [C289848]', async () => { + await searchInput.clickSearchContainer(); + expect(await searchInput.isOptionsAreaDisplayed()).toBe(true, '1. Search options not displayed'); + expect(await searchInput.isFilesOptionEnabled()).toBe(true, '2. Files option not enabled'); + expect(await searchInput.isFoldersOptionEnabled()).toBe(true, '3. Folders option not enabled'); + expect(await searchInput.isLibrariesOptionEnabled()).toBe(true, '4. Libraries option not enabled'); + expect(await searchInput.isFilesOptionChecked()).toBe(false, '5. Files option is checked'); + expect(await searchInput.isFoldersOptionChecked()).toBe(false, '6. Folders option is checked'); + expect(await searchInput.isLibrariesOptionChecked()).toBe(false, '7. Libraries option is checked'); + }); + + it('Search options are correctly enabled / disabled - [C289849]', async () => { + await searchInput.clickSearchContainer(); + + await searchInput.clickFilesOption(); + expect(await searchInput.isFoldersOptionEnabled()).toBe(true, 'Folders option not enabled'); + expect(await searchInput.isLibrariesOptionEnabled()).toBe(false, 'Libraries option not disabled'); + + await searchInput.clickFilesOption(); + expect(await searchInput.isFoldersOptionEnabled()).toBe(true, 'Folders option not enabled'); + expect(await searchInput.isLibrariesOptionEnabled()).toBe(true, 'Folders option not enabled'); + + await searchInput.clickFoldersOption(); + expect(await searchInput.isFilesOptionEnabled()).toBe(true, 'Files option not enabled'); + expect(await searchInput.isLibrariesOptionEnabled()).toBe(false, 'Libraries option not disabled'); + + await searchInput.clickFoldersOption(); + expect(await searchInput.isFilesOptionEnabled()).toBe(true, 'Files option not enabled'); + expect(await searchInput.isLibrariesOptionEnabled()).toBe(true, 'Libraries option not enabled'); + + await searchInput.clickLibrariesOption(); + expect(await searchInput.isFilesOptionEnabled()).toBe(false, 'Files option not disabled'); + expect(await searchInput.isFoldersOptionEnabled()).toBe(false, 'Folders option not disabled'); + + await searchInput.clickLibrariesOption(); + expect(await searchInput.isFilesOptionEnabled()).toBe(true, 'Files option not enabled'); + expect(await searchInput.isFoldersOptionEnabled()).toBe(true, 'Folders option not enabled'); + }); +}); diff --git a/e2e/utilities/utils.ts b/e2e/utilities/utils.ts index db6e0aca5..97d5fdacf 100755 --- a/e2e/utilities/utils.ts +++ b/e2e/utilities/utils.ts @@ -35,7 +35,7 @@ export class Utils { static string513 = 'great indirect brain tune other expectation fun silver drain tumble rhythm harmful wander picture distribute opera complication copyright \ explosion snack ride pool machinery pair frog joint wrestle video referee drive window cage falsify happen tablet horror thank conception \ extension decay dismiss platform respect ceremony applaud absorption presentation dominate race courtship soprano body \ - lighter track cinema tread tick climate lend summit singer radical flower visual negotiation promises cooperative dead'; + lighter track cinema tread tick climate lend summit singer radical flower visual negotiation promises cooperative live'; // generate a random value static random() { diff --git a/protractor.conf.js b/protractor.conf.js index 31ad25610..336b17908 100755 --- a/protractor.conf.js +++ b/protractor.conf.js @@ -44,6 +44,7 @@ exports.config = { './e2e/suites/application/*.test.ts', './e2e/suites/navigation/*.test.ts', './e2e/suites/pagination/*.test.ts', + './e2e/suites/search/*.test.ts', './e2e/suites/actions/*.test.ts', './e2e/suites/viewer/*.test.ts', './e2e/suites/info-drawer/*.test.ts',