diff --git a/e2e/pages/adf/card-view-component.page.ts b/e2e/pages/adf/card-view-component.page.ts index 566d579fe4..88a8f480cd 100644 --- a/e2e/pages/adf/card-view-component.page.ts +++ b/e2e/pages/adf/card-view-component.page.ts @@ -16,19 +16,19 @@ */ import { by, element, ElementFinder } from 'protractor'; -import { BrowserVisibility, BrowserActions, CardTextItemPage, DropdownPage } from '@alfresco/adf-testing'; +import { BrowserVisibility, BrowserActions, CardTextItemPage, DropdownPage, CardBooleanItemPage } from '@alfresco/adf-testing'; export class CardViewComponentPage { addButton: ElementFinder = element(by.className('adf-card-view__key-value-pairs__add-btn')); nameCardTextItem: CardTextItemPage = new CardTextItemPage('name'); + booleanCardBooleanItem: CardBooleanItemPage = new CardBooleanItemPage('boolean'); intField: ElementFinder = element(by.css(`input[data-automation-id='card-textitem-editinput-int']`)); floatField: ElementFinder = element(by.css(`input[data-automation-id='card-textitem-editinput-float']`)); valueInputField: ElementFinder = element(by.xpath(`//*[contains(@id,'input') and @placeholder='Value']`)); nameInputField: ElementFinder = element(by.xpath(`//*[contains(@id,'input') and @placeholder='Name']`)); consoleLog: ElementFinder = element(by.className('app-console')); deleteButton: ElementFinder = element.all(by.className('adf-card-view__key-value-pairs__remove-btn')).first(); - checkbox: ElementFinder = element(by.css(`mat-checkbox[data-automation-id='card-boolean-boolean']`)); resetButton: ElementFinder = element(by.css(`#adf-reset-card-log`)); editableSwitch: ElementFinder = element(by.id('app-toggle-editable')); clearDateSwitch: ElementFinder = element(by.id('app-toggle-clear-date')); @@ -155,7 +155,11 @@ export class CardViewComponentPage { } async checkboxClick(): Promise { - await BrowserActions.click(this.checkbox); + await this.booleanCardBooleanItem.checkboxClick(); + } + + async checkBooleanLabelIsPresent(): Promise { + await this.booleanCardBooleanItem.checkLabelIsPresent(); } async selectValueFromComboBox(index): Promise { diff --git a/lib/testing/src/lib/core/pages/card-view/card-view-boolean-item.page.ts b/lib/testing/src/lib/core/pages/card-view/card-view-boolean-item.page.ts new file mode 100644 index 0000000000..6b479fbd2f --- /dev/null +++ b/lib/testing/src/lib/core/pages/card-view/card-view-boolean-item.page.ts @@ -0,0 +1,39 @@ +/*! + * @license + * Copyright 2019 Alfresco Software, Ltd. + * + * 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 { element, by, ElementFinder, Locator } from 'protractor'; +import { BrowserActions, BrowserVisibility } from '../../utils/public-api'; + +export class CardBooleanItemPage { + + rootElement: ElementFinder; + labelLocator: Locator = by.css('div[data-automation-id*="card-boolean-label"]'); + checkbox: Locator = by.css('mat-checkbox[data-automation-id*="card-boolean"]'); + + constructor(label: string = 'assignee') { + this.rootElement = element(by.xpath(`//div[contains(@data-automation-id, "label-${label}")]/ancestor::adf-card-view-boolitem`)); + } + + async checkboxClick(): Promise { + await BrowserActions.click(this.rootElement.element(this.checkbox)); + } + + async checkLabelIsPresent(): Promise { + const labelElement: ElementFinder = this.rootElement.element(this.labelLocator); + await BrowserVisibility.waitUntilElementIsPresent(labelElement); + } +} diff --git a/lib/testing/src/lib/core/pages/card-view/public-api.ts b/lib/testing/src/lib/core/pages/card-view/public-api.ts index 18bf3c1db5..d4300d01bb 100644 --- a/lib/testing/src/lib/core/pages/card-view/public-api.ts +++ b/lib/testing/src/lib/core/pages/card-view/public-api.ts @@ -16,3 +16,4 @@ */ export * from './card-view-text-item.page'; +export * from './card-view-boolean-item.page';