@@ -17,7 +17,6 @@
* under the License.
*/
import { browser , by , element } from 'protractor' ;
import { randomize } from "../config" ;
import { BasePage } from './BasePage.po' ;
import { SideNavigationPage } from './SideNavigationPage.po' ;
@@ -33,6 +32,7 @@ interface CDN {
interface UpdateCDN {
description : string ;
Name : string ;
NewName : string ;
validationMessage ?: string ;
}
@@ -61,7 +61,6 @@ export class CDNPage extends BasePage {
}
public async CreateCDN ( cdn : CDN ) : Promise < boolean > {
let result = false ;
let snp = new SideNavigationPage ( ) ;
let basePage = new BasePage ( ) ;
await snp . NavigateToCDNPage ( ) ;
@@ -70,14 +69,7 @@ export class CDNPage extends BasePage {
await this . txtDomain . sendKeys ( cdn . Domain ) ;
await this . selectDNSSEC . sendKeys ( cdn . DNSSEC ) ;
await basePage . ClickCreate ( ) ;
result = await basePage . GetOutputMessage ( ) . then ( function ( value ) {
if ( cdn . validationMessage === value ) {
return true ;
} else {
return false ;
}
} )
return result ;
return await basePage . GetOutputMessage ( ) . then ( value => cdn . validationMessage === value ) ;
}
async SearchCDN ( nameCDN : string ) {
@@ -99,31 +91,35 @@ export class CDNPage extends BasePage {
switch ( cdn . description ) {
case 'perform snapshot' :
await this . btnDiffSnapshot . click ( ) ;
if ( await browser . isElementPresent ( element ( by . xpath ( '//button[@title="Perform ' + cdn . Name + this . randomize + ' Snapshot"]' ) ) ) ) {
if ( await browser . isElementPresent ( element ( by . xpath ( '//button[@title="Perform ' + cdn . Name + this . randomize + ' Snapshot"]' ) ) ) ) {
await element ( by . xpath ( '//button[@title="Perform ' + cdn . Name + this . randomize + ' Snapshot"]' ) ) . click ( ) ;
} else {
} else {
throw new Error ( "Cannot find Perform Snapshot button" )
}
await this . btnYes . click ( ) ;
break ;
case 'queue CDN updates' :
await this . btnQueueUpdates . click ( ) ;
if ( await browser . isElementPresent ( element ( by . linkText ( 'Queue ' + cdn . Name + this . randomize + ' Server Updates' ) ) ) ) {
if ( await browser . isElementPresent ( element ( by . linkText ( 'Queue ' + cdn . Name + this . randomize + ' Server Updates' ) ) ) ) {
await element ( by . linkText ( 'Queue ' + cdn . Name + this . randomize + ' Server Updates' ) ) . click ( ) ;
} else {
} else {
throw new Error ( "Cannot find Queue CDN updates button" )
}
await this . btnYes . click ( ) ;
break ;
case 'clear CDN updates' :
await this . btnQueueUpdates . click ( ) ;
if ( await browser . isElementPresent ( element ( by . linkText ( 'Clear ' + cdn . Name + this . randomize + ' Server Updates' ) ) ) ) {
if ( await browser . isElementPresent ( element ( by . linkText ( 'Clear ' + cdn . Name + this . randomize + ' Server Updates' ) ) ) ) {
await element ( by . linkText ( 'Clear ' + cdn . Name + this . randomize + ' Server Updates' ) ) . click ( ) ;
} else {
} else {
throw new Error ( "Cannot find Clear CDN updates button" )
}
await this . btnYes . click ( ) ;
break ;
case 'update cdn name' :
await this . txtCDNName . clear ( ) ;
await this . txtCDNName . sendKeys ( cdn . NewName + this . randomize ) ;
await this . ClickUpdate ( ) ;
default :
result = undefined ;
}
@@ -139,18 +135,18 @@ export class CDNPage extends BasePage {
public async DeleteCDN ( cdn : DeleteCDN ) : Promise < boolean > {
let name = cdn . Name + this . randomize ;
let result = false ;
let basePage = new BasePage ( ) ;
await this . btnDelete . click ( ) ;
await this . txtConfirmName . sendKeys ( name ) ;
await basePage . ClickDeletePermanently ( ) ;
result = await basePage . GetOutputMessage ( ) . then ( function ( value ) {
if ( cdn . validationMessage == value ) {
return true ;
} else {
return false ;
}
} )
return await basePage . GetOutputMessage ( ) . then ( value => cdn . validationMessage === value ) ;
}
public async CheckCSV ( name :string ) : Promise < boolean > {
let result = false ;
let linkName = name ;
if ( await browser . isElementPresent ( element ( by . xpath ( "//span[text()='" + linkName + "']" ) ) ) == true ) {
result = true ;
}
return result ;
}
}