import { browser , by , ElementFinder } from 'protractor' ; import * as ui from '../../ui' ; import { BaseElement } from './../base.element' ; import { WorkItemListEntry } from './workitem-list-entry' ; export class WorkItemList extends BaseElement { overlay = new BaseElement ( this . $ ( 'div.lock-overlay-list' ) , 'overlay' ) ; datatableHeaderdiv = new ui . BaseElement ( this . $ ( '.datatable-header' ) , 'datatable header div' ) ; datatableHeaderCell = new ui . BaseElementArray ( this . $$ ( 'datatable-header-cell' ) , 'datatable header cell' ) ; datatableHeaderCellLabel = new ui . BaseElementArray ( this . $$ ( 'datatable-header-cell-label' ) ) ; datatableRow = new ui . BaseElementArray ( this . $$ ( 'datatable-body-row' ) , 'datatable row' ) ; childWorkItemTypeDropdown = new ui . Dropdown ( this . $ ( '.f8-quick-add-inline .dropdown-toggle' ) , this . $ ( '.f8-quick-add-inline .dropdown-menu' ) , 'Child WorkItem Type dropdown' ) ; empty_template = new BaseElement ( this . $ ( '.blank-slate-pf' ) , 'Empty work item template' ) ; empty_workitem_list = new BaseElement ( this . empty_template . $ ( '#title' ) , 'No workitems available' ) ; constructor ( el , name = 'Work Item List' ) { super ( el , name ) ; } async ready ( ) { await super . ready ( ) ; await this . overlay . untilHidden ( ) ; } async clickWorkItem ( title ) { await this . overlay . untilHidden ( ) ; await this . workItem ( title ) . untilTextIsPresent ( title ) ; await this . workItem ( title ) . openQuickPreview ( ) ; } async hasWorkItem ( title , showCompleted = false ) { if ( ! showCompleted ) { await this . workItem ( title ) . untilTextIsPresent ( title ) ; } return this . workItem ( title ) . isPresent ( ) ; } workItem ( title ) { return new WorkItemListEntry ( this . element ( by . xpath ( "//datatable-body-row[.//p[text()='" + title + "']]" ) ) , 'Work Item - ' + title ) ; } async clickInlineQuickAdd ( title ) { await this . workItem ( title ) . clickInlineQuickAdd ( ) ; } async getInlineQuickAddClass ( title ) { return this . workItem ( title ) . getInlineQuickAddClass ( ) ; } async getDataTableHeaderCellCount ( ) { await this . datatableHeaderdiv . untilDisplayed ( ) ; return this . datatableHeaderCell . count ( ) ; } async selectChildWorkItemType ( type ) { await this . childWorkItemTypeDropdown . clickWhenReady ( ) ; await this . childWorkItemTypeDropdown . select ( type ) ; } async iterationText ( title ) { return this . workItem ( title ) . getIterationText ( ) ; } async clickWorkItemLabel ( title ) { await this . workItem ( title ) . clickLabel ( ) ; } async clickWorkItemDeleteIcon ( title ) { await browser . actions ( ) . mouseMove ( this . workItem ( title ) ) . perform ( ) ; await this . workItem ( title ) . clickDeleteIcon ( ) ; } async isTitleTextBold ( title ) { return this . workItem ( title ) . title . getAttribute ( 'className' ) ; } async openDetailPage ( title ) { await this . overlay . untilHidden ( ) ; await browser . actions ( ) . mouseMove ( this . workItem ( title ) ) . perform ( ) ; await this . workItem ( title ) . clickDetailIcon ( ) ; } async getUnassignedWorkItemCount ( assigneeName ) { let assignees = await this . $$ ( 'f8-assignee' ) . getAttribute ( 'innerText' ) ; let unassigned = assignees . filter ( ( assignee ) => assignee === assigneeName ) ; return unassigned . length ; } async emptyTemplateDisplayed ( ) { await this . empty_template . untilDisplayed ( ) ; await this . empty_workitem_list . untilDisplayed ( ) ; return this . empty_workitem_list . isDisplayed ( ) ; } }