lbathina commented on a change in pull request #3748: Add initial origins and 
users TP tests
URL: https://github.com/apache/trafficcontrol/pull/3748#discussion_r309821806
 
 

 ##########
 File path: traffic_portal/test/end_to_end/CDNs/cdns-spec.js
 ##########
 @@ -23,96 +23,93 @@ var cfunc = require('../common/commonFunctions.js');
 describe('Traffic Portal CDNs Test Suite', function() {
        const pageData = new pd();
        const commonFunctions = new cfunc();
-       const myNewCDN = 'cdn-' + 
commonFunctions.shuffle('abcdefghijklmonpqrstuvwxyz0123456789');
-       const myDomainName = myNewCDN + '.com';
-       const mydnssec = false;
-       const myKskDays = commonFunctions.random(365);
+       const shuffledText = 
commonFunctions.shuffle('abcdefghijklmonpqrstuvwxyz0123456789');
+       const myNewCDN = {
+               name : 'cdn-' + shuffledText,
+               domainName : 'cdn-' + shuffledText + '.com',
+               dnssecEnabled: false,
+               numKskDays: commonFunctions.random(365)
+       };
+       const repeater = 'cdn in ::cdns';
 
-       it('should go to the CDNs page', function() {
+       it('should go to the CDNs page', async () => {
                console.log("Go to the CDNs page");
-               browser.setLocation("cdns");
-               browser.getCurrentUrl().then(x => console.log(x));
+               await browser.setLocation("cdns");
                
expect(browser.getCurrentUrl().then(commonFunctions.urlPath)).toEqual(commonFunctions.urlPath(browser.baseUrl)+"#!/cdns");
        });
 
-       it('should open new CDN form page', function() {
+       it('should open new CDN form page', async () => {
                console.log("Open new CDN form page");
-               browser.driver.findElement(by.name('createCdnButton')).click();
+               await pageData.createCdnButton.click();
                
expect(browser.getCurrentUrl().then(commonFunctions.urlPath)).toEqual(commonFunctions.urlPath(browser.baseUrl)+"#!/cdns/new");
        });
 
-       it('should fill out form, create button is enabled and submit', 
function () {
+       it('should fill out form, create button is enabled and submit', async 
() => {
                console.log("Filling out form, check create button is enabled 
and submit");
                expect(pageData.createButton.isEnabled()).toBe(false);
-               pageData.dnssecEnabled.click();
-               pageData.dnssecEnabled.sendKeys(mydnssec.toString());
-               pageData.name.sendKeys(myNewCDN);
-               pageData.domainName.sendKeys(myDomainName);
+               await 
pageData.dnssecEnabled.sendKeys(myNewCDN.dnssecEnabled.toString());
+               await pageData.name.sendKeys(myNewCDN.name);
+               await pageData.domainName.sendKeys(myNewCDN.domainName);
                expect(pageData.createButton.isEnabled()).toBe(true);
-               pageData.createButton.click();
+               await pageData.createButton.click();
+               expect(pageData.successMsg.isPresent()).toBe(true);
+               expect(pageData.cdnCreatedText.isPresent()).toBe(true, 'Actual 
message does not match expected message');
                
expect(browser.getCurrentUrl().then(commonFunctions.urlPath)).toEqual(commonFunctions.urlPath(browser.baseUrl)+"#!/cdns");
        });
 
-       it('should verify the new CDN and then update CDN', function() {
+       it('should verify the new CDN and then update CDN', async () => {
                console.log("Verifying the new CDN and then updating CDN");
-               browser.sleep(250);
-               pageData.searchFilter.sendKeys(myNewCDN);
-               browser.sleep(250);
-               element.all(by.repeater('cdn in ::cdns')).filter(function(row){
-                       return 
row.element(by.name('name')).getText().then(function(val){
-                               return val === myNewCDN;
-                       });
-               }).get(0).click();
-               browser.sleep(1000);
-               pageData.domainName.clear();
-               pageData.domainName.sendKeys(myDomainName + 'updated.com');
-               pageData.dnssecEnabled.click();
-               pageData.dnssecEnabled.sendKeys((!mydnssec).toString());
-               pageData.updateButton.click();
-               
expect(pageData.domainName.getAttribute('value')).toEqual(myDomainName + 
'updated.com');
+               await commonFunctions.clickTableEntry(pageData.searchFilter, 
myNewCDN.name, repeater);
+               await pageData.domainName.clear();
+               await pageData.domainName.sendKeys(myNewCDN.domainName + 
'updated.com');
+               await 
pageData.dnssecEnabled.sendKeys((!myNewCDN.dnssecEnabled).toString());
+               await pageData.updateButton.click();
+               expect(pageData.successMsg.isPresent()).toBe(true);
+               expect(pageData.cdnUpdatedText.isPresent()).toBe(true, 'Actual 
message does not match expected message');
+               
expect(pageData.domainName.getAttribute('value')).toEqual(myNewCDN.domainName + 
'updated.com');
        });
 
-       it('should generate DNSSEC keys', async function() {
+       it('should generate DNSSEC keys', async () => {
                console.log("Generating DNSSEC keys for the new CDN and and 
verifying their expiration date");
                await pageData.moreButton.click();
                await pageData.manageDnssecKeysButton.click();
                
expect(pageData.expirationDate.getAttribute('value')).toEqual('');
                await pageData.generateDnssecKeysButton.click();
                await pageData.regenerateButton.click();
                expect(pageData.confirmButton.isEnabled()).toBe(false);
-               await pageData.confirmInput.sendKeys(myNewCDN);
+               await pageData.confirmInput.sendKeys(myNewCDN.name);
                expect(pageData.confirmButton.isEnabled()).toBe(true);
                await pageData.confirmButton.click();
                const expirationDate = 
pageData.expirationDate.getAttribute('value').then((expir) => {return 
Date.parse(expir + ' UTC');});
                const calculatedExpirationDate = Date.now() + 365*24*60*60*1000;
 
 Review comment:
   A comment on this logic would be nice

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to