import { Button, Input, WebElement } from '@contour/fet/lib/elements'; import { ContourBasePage } from '../../base/basePage'; import { ContourAlert } from '../../elements/contourAlert'; import scenarioContext from '../../util/scenarioContext'; import locator from './templateList.locator'; export default class TemplateList extends ContourBasePage { templateName: string; templateLoc: string; managedTemplateLoc: string; constructor(templateName?: string, url?: string) { super(locator, url); if (templateName) { this.templateName = templateName; this.templateLoc = this.locators.savedTemplate.replace('#TEMPLATE_NAME#', this.templateName); this.managedTemplateLoc = this.locators.managedTemplate.replace('#TEMPLATE_NAME#', this.templateName); } } getTemplateName(rowNum: number) { return new WebElement(this.getLocatorAsString('templateName').replace('#TEMPLATE_NO#', rowNum.toString())); } getCreateBlankDcButton() { return new Button(this.getLocatorAsString('createBlankDcButton')); } getMoreTemplateBtn() { return new Button(this.getLocatorAsString('moreTemplatesBtn')); } getManagedTemplate(rowNum: number) { return new WebElement(this.getLocatorAsString('managedTemplate').replace('#TEMPLATE_NO#', rowNum.toString())); } getTemplateCreationDate(rowNum: number) { return new WebElement(this.getLocatorAsString('templateCreationDate').replace('#TEMPLATE_NO#', rowNum.toString())); } async openManagedTemplate(templateName?: string) { await new WebElement( this.locators.managedTemplate.replace('#TEMPLATE_NAME#', templateName || this.templateName) ).clickElement(); } async openTemplate(): Promise { await new WebElement(this.templateLoc).clickElement(); } async isTemplateStarred(falseCase: boolean) { await new WebElement(this.locators.starred.replace('#TEMPLATE_NAME#', this.templateName)).checkIsDisplayed( falseCase ); } async starTemplate() { await new WebElement(this.locators.unStarred.replace('#TEMPLATE_NAME#', this.templateName)).clickElement(); } async deleteTemplate() { await new WebElement(this.locators.deleteTemplateIcon, this.managedTemplateLoc).clickElement(); } async openRecentDC(): Promise { await new WebElement(this.locators.recentDcByUUID.replace('#UUID#', scenarioContext().dc.uuid)).clickElement(); } async saveTemplate(templateName: string, prioritize: boolean): Promise { await new Input(this.locators.templateTitle).setInputField(templateName); prioritize && new WebElement(this.locators.prioritizeChkBox).clickElement(); await browser.pause(1000); await new ContourAlert().clickButtonByLabelTxt('Save'); } async searchTemplate(templateName?: string): Promise { await new Input(this.locators.searchTemplateInput).setInputField(templateName || this.templateName); await new Button(this.locators.searchSubmitBtn).clickElement(); await browser.pause(3000); } async isTemplateDisplayed(falseCase: boolean): Promise { await new WebElement(this.locators.savedTemplate.replace('#TEMPLATE_NAME#', this.templateName)).checkIsDisplayed( falseCase ); } async checkTemplateOrder(templateName: string, order: any): Promise { await new WebElement(this.locators.templateOrder.replace('#ORDER#', order + 1)).checkIsDisplayed(); } }