close
The Wayback Machine - https://web.archive.org/web/20210514125534/https://github.com/apache/trafficcontrol/commit/b9772806a6ada4cd9a2afef9ad38dfe1616578d8
Skip to content
Permalink
Browse files
Migrate CDN test from E2E to integrate test suite (#5798)
* Add test and function

* Fix cannot download

* Fix check

* Fixed PR review

* Update check for primitive boolean type

Co-authored-by: Pham, Dandy (Contractor) <Dandy_Pham@comcast.com>
  • Loading branch information
dpham692 and Pham, Dandy (Contractor) committed May 12, 2021
1 parent d616500 commit b9772806a6ada4cd9a2afef9ad38dfe1616578d8
@@ -26,6 +26,12 @@ export const cdns = {
password: "pa$$word"
}
],
check: [
{
description: "check CSV link from CDN page",
Name: "Export as CSV"
}
],
add: [
{
description: "create a CDN",
@@ -53,23 +59,32 @@ export const cdns = {
{
description: "perform snapshot",
Name: "TPCDN1",
NewName: "",
validationMessage: "Snapshot performed"
},
{
description: "queue CDN updates",
Name: "TPCDN2",
NewName: "",
validationMessage: "Queued CDN server updates"
},
{
description: "clear CDN updates",
Name: "TPCDN2",
NewName: "",
validationMessage: "Cleared CDN server updates"
},
{
description: "update cdn name",
Name: "TPCDN1",
NewName: "TPNewCDN1",
validationMessage: "cdn was updated."
}
],
remove: [
{
description: "delete CDN",
Name: "TPCDN1",
Name: "TPNewCDN1",
validationMessage: "cdn was deleted."
}
]
@@ -83,6 +98,12 @@ export const cdns = {
password: "pa$$word"
}
],
check: [
{
description: "check CSV link from CDN page",
Name: "Export as CSV"
}
],
add: [
{
description: "create a CDN",
@@ -96,16 +117,25 @@ export const cdns = {
{
description: "perform snapshot",
Name: "TPCDN2",
NewName: "",
validationMessage: "Forbidden."
},
{
description: "queue CDN updates",
Name: "TPCDN2",
NewName: "",
validationMessage: "Forbidden."
},
{
description: "clear CDN updates",
Name: "TPCDN2",
NewName: "",
validationMessage: "Forbidden."
},
{
description: "update cdn name",
Name: "TPCDN2",
NewName: "TPNewCDN2",
validationMessage: "Forbidden."
}
],
@@ -125,6 +155,12 @@ export const cdns = {
password: "pa$$word"
}
],
check: [
{
description: "check CSV link from CDN page",
Name: "Export as CSV"
}
],
add: [
{
description: "create a CDN",
@@ -152,17 +188,26 @@ export const cdns = {
{
description: "perform snapshot",
Name: "TPCDN3",
NewName: "",
validationMessage: "Snapshot performed"
},
{
description: "queue CDN updates",
Name: "TPCDN4",
NewName: "",
validationMessage: "Queued CDN server updates"
},
{
description: "clear CDN updates",
Name: "TPCDN4",
NewName: "",
validationMessage: "Cleared CDN server updates"
},
{
description: "update cdn name",
Name: "TPCDN3",
NewName: "TPNewCDN3",
validationMessage: "cdn was updated."
}
],
remove: [
@@ -173,7 +218,7 @@ export const cdns = {
},
{
description: "delete CDN",
Name: "TPCDN3",
Name: "TPNewCDN3",
validationMessage: "cdn was deleted."
},
{
@@ -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;
}
}
@@ -39,7 +39,12 @@ cdns.tests.forEach(async cdnsData =>{
it('can open CDN page', async () => {
await cdnsPage.OpenCDNsPage();
});

cdnsData.check.forEach(check => {
it(check.description, async () => {
expect(await cdnsPage.CheckCSV(check.Name)).toBe(true);
await cdnsPage.OpenCDNsPage();
});
});
cdnsData.add.forEach(add => {
it(add.description, async () => {
expect(await cdnsPage.CreateCDN(add)).toBeTruthy();

0 comments on commit b977280

Please sign in to comment.