This is an automated email from the ASF dual-hosted git repository.

zrhoffman pushed a commit to branch 6.0.x
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git

commit aa3fa79988d89b089d5e306ae59f3146dc2d3a6d
Author: dpham <[email protected]>
AuthorDate: Thu Aug 26 15:28:39 2021 -0600

    Migrate Profiles test from E2E to integrate test suite TP (#6071)
    
    * Add test
    
    * Add function type
    
    * Using aftereach and after all for profiles
    
    * Retest
    
    * Add before all and fix functions
    
    * Fixing aftereach
    
    * Fixing clean up and setup
    
    * Remove after each and after all
    
    * Retest after each
    
    * Add new line
    
    * Make the spec file clean
    
    * Refix the structure
    
    * Retest
    
    * Change clean up back and add before all
    
    * Test new structure
    
    * Change back to normal remove beforeall
    
    * Refix format
    
    Co-authored-by: Pham, Dandy (Contractor) <[email protected]>
    (cherry picked from commit 012960b74c495376ee442bfd2bb9e4174fb5e1da)
---
 traffic_portal/test/integration/Data/profiles.ts   | 32 +++++++++
 .../integration/PageObjects/ProfilesPage.po.ts     | 39 +++++++----
 .../test/integration/specs/Profiles.spec.ts        | 79 +++++++++++++++-------
 3 files changed, 111 insertions(+), 39 deletions(-)

diff --git a/traffic_portal/test/integration/Data/profiles.ts 
b/traffic_portal/test/integration/Data/profiles.ts
index 61c1494..aebd6c5 100644
--- a/traffic_portal/test/integration/Data/profiles.ts
+++ b/traffic_portal/test/integration/Data/profiles.ts
@@ -107,6 +107,22 @@ export const profiles = {
                                        password: "pa$$word"
                                }
                        ],
+                       check: [
+                               {
+                                       description: "check CSV link from 
Profiles page",
+                                       Name: "Export as CSV"
+                               }
+                       ],
+                       toggle:[
+                               {
+                                       description: "hide first table column",
+                                       Name: "CDN"
+                               },
+                               {
+                                       description: "redisplay first table 
column",
+                                       Name: "CDN"
+                               }
+                       ],
                        add: [
                                {
                                        description: "create a Profiles",
@@ -142,6 +158,22 @@ export const profiles = {
                                        password: "pa$$word"
                                }
                        ],
+                       check: [
+                               {
+                                       description: "check CSV link from 
Profiles page",
+                                       Name: "Export as CSV"
+                               }
+                       ],
+                       toggle:[
+                               {
+                                       description: "hide first table column",
+                                       Name: "CDN"
+                               },
+                               {
+                                       description: "redisplay first table 
column",
+                                       Name: "CDN"
+                               }
+                       ],
                        add: [
                                {
                                        description: "create a Profiles",
diff --git a/traffic_portal/test/integration/PageObjects/ProfilesPage.po.ts 
b/traffic_portal/test/integration/PageObjects/ProfilesPage.po.ts
index fc186bf..bd9613f 100644
--- a/traffic_portal/test/integration/PageObjects/ProfilesPage.po.ts
+++ b/traffic_portal/test/integration/PageObjects/ProfilesPage.po.ts
@@ -59,22 +59,23 @@ export class ProfilesPage extends BasePage {
     private txtCompareDropdown2 = element(by.name('compareDropdown2'));
     private btnCompareSubmit = element(by.name('compareSubmit'));
     private mnuCompareTable = 
element(by.id('profilesParamsCompareTable_wrapper'));
+    private btnTableColumn = element(by.className("caret"))
     private randomize = randomize;
 
-    async OpenProfilesPage() {
-        let snp = new SideNavigationPage();
+    public async OpenProfilesPage() {
+        const snp = new SideNavigationPage();
         await snp.NavigateToProfilesPage();
     }
 
-    async OpenConfigureMenu() {
-        let snp = new SideNavigationPage();
+    public async OpenConfigureMenu() {
+        const snp = new SideNavigationPage();
         await snp.ClickConfigureMenu();
     }
 
     public async CreateProfile(profile: CreateProfile): Promise<boolean> {
         let result = false;
-        let basePage = new BasePage();
-        let snp = new SideNavigationPage();
+        const basePage = new BasePage();
+        const snp = new SideNavigationPage();
         await snp.NavigateToProfilesPage();
         await this.btnCreateNewProfile.click();
         await this.txtName.sendKeys(profile.Name + this.randomize);
@@ -94,7 +95,7 @@ export class ProfilesPage extends BasePage {
     }
 
     public async SearchProfile(nameProfiles: string): Promise<boolean> {
-        let snp = new SideNavigationPage();
+        const snp = new SideNavigationPage();
         let name = nameProfiles + this.randomize;
         await snp.NavigateToProfilesPage();
         await this.txtSearch.clear();
@@ -106,9 +107,9 @@ export class ProfilesPage extends BasePage {
         return false;
     }
 
-    async CompareProfile(profile1: string, profile2: string) {
+    public async CompareProfile(profile1: string, profile2: string) {
         let result = false;
-        let snp = new SideNavigationPage();
+        const snp = new SideNavigationPage();
         await snp.NavigateToProfilesPage();
         await this.btnMore.click();
         await this.btnCompareProfile.click();
@@ -121,22 +122,22 @@ export class ProfilesPage extends BasePage {
         }
     }
 
-    public async UpdateProfile(profile: UpdateProfile): Promise<boolean | 
undefined> {
-        let basePage = new BasePage();
+    public async UpdateProfile(profile: UpdateProfile): Promise<boolean> {
+        const basePage = new BasePage();
         switch (profile.description) {
             case "update profile type":
                 await this.txtType.sendKeys(profile.Type);
                 await basePage.ClickUpdate();
                 break;
             default:
-                return undefined;
+                return false;
         }
         return await basePage.GetOutputMessage().then(value => 
profile.validationMessage === value);
     }
 
     public async DeleteProfile(profile: DeleteProfile): Promise<boolean> {
         let result = false;
-        let basePage = new BasePage();
+        const basePage = new BasePage();
         await this.btnDelete.click();
         await this.txtConfirmName.sendKeys(profile.Name + this.randomize);
         await basePage.ClickDeletePermanently();
@@ -149,4 +150,16 @@ export class ProfilesPage extends BasePage {
         })
         return result;
     }
+
+    public async CheckCSV(name: string): Promise<boolean> {
+        return element(by.cssContainingText("span", name)).isPresent();
+    }
+
+    public async ToggleTableColumn(name: string): Promise<boolean> {
+        await this.btnTableColumn.click();
+        const result = await element(by.cssContainingText("th", 
name)).isPresent();
+        await element(by.cssContainingText("label", name)).click();
+        await this.btnTableColumn.click();
+        return !result;
+    }
 }
diff --git a/traffic_portal/test/integration/specs/Profiles.spec.ts 
b/traffic_portal/test/integration/specs/Profiles.spec.ts
index f415db0..02c7d4b 100644
--- a/traffic_portal/test/integration/specs/Profiles.spec.ts
+++ b/traffic_portal/test/integration/specs/Profiles.spec.ts
@@ -24,6 +24,7 @@ import { TopNavigationPage } from 
'../PageObjects/TopNavigationPage.po';
 import { api } from "../config";
 import { profiles } from "../Data";
 
+
 const loginPage = new LoginPage();
 const topNavigation = new TopNavigationPage();
 const profilesPage = new ProfilesPage();
@@ -33,46 +34,72 @@ describe('Setup API for Profiles', () => {
         await api.UseAPI(profiles.setup);
     });
 });
+
 profiles.tests.forEach(async profilesData => {
     profilesData.logins.forEach(login => {
         describe(`Traffic Portal - Profiles - ${login.description}`, () => {
+            afterEach(async function () {
+                await profilesPage.OpenProfilesPage();
+            });
+            afterAll(async function () {
+                expect(await topNavigation.Logout()).toBeTruthy();
+            })
             it('can login', async () => {
                 browser.get(browser.params.baseUrl);
                 await loginPage.Login(login);
                 expect(await loginPage.CheckUserName(login)).toBeTruthy();
-            });
-            it('can open profiles page', async () => {
                 await profilesPage.OpenConfigureMenu();
-                await profilesPage.OpenProfilesPage();
             });
-            profilesData.add.forEach(add => {
-                it(add.description, async () => {
-                    expect(await profilesPage.CreateProfile(add)).toBeTruthy();
-                    await profilesPage.OpenProfilesPage();
+            it('can perform check test suits', async () => {
+                profilesData.check.forEach(check => {
+                    it(check.description, async () => {
+                        expect(await 
profilesPage.CheckCSV(check.Name)).toBe(true);
+                    });
                 });
-            });
-            profilesData.update.forEach(update => {
-                it(update.description, async () => {
-                    await profilesPage.SearchProfile(update.Name);
-                    expect(await 
profilesPage.UpdateProfile(update)).toBeTruthy();
-                    await profilesPage.OpenProfilesPage();
+            })
+            it('can perform toggle test suits', async () => {
+                profilesData.toggle.forEach(toggle => {
+                    it(toggle.description, async () => {
+                        if (toggle.description.includes('hide')) {
+                            expect(await 
profilesPage.ToggleTableColumn(toggle.Name)).toBe(false);
+                        } else {
+                            expect(await 
profilesPage.ToggleTableColumn(toggle.Name)).toBe(true);
+                        }
+                    });
+                })
+            })
+            it('can perform add test suits', async () => {
+                profilesData.add.forEach(add => {
+                    it(add.description, async () => {
+                        expect(await 
profilesPage.CreateProfile(add)).toBeTruthy();
+                    });
                 });
-            });
-            profilesData.remove.forEach(remove => {
-                it(remove.description, async () => {
-                    await profilesPage.SearchProfile(remove.Name);
-                    expect(await 
profilesPage.DeleteProfile(remove)).toBeTruthy();
-                    await profilesPage.OpenProfilesPage();
+            })
+            it('can perform update test suits', async () => {
+                profilesData.update.forEach(update => {
+                    it(update.description, async () => {
+                        await profilesPage.SearchProfile(update.Name);
+                        expect(await 
profilesPage.UpdateProfile(update)).toBeTruthy();
+                    });
                 });
-            });
-            it('can logout', async () => {
-                expect(await topNavigation.Logout()).toBeTruthy();
-            });
+            })
+            it('can perform remove test suits', async () => {
+                profilesData.remove.forEach(remove => {
+                    it(remove.description, async () => {
+                        await profilesPage.SearchProfile(remove.Name);
+                        expect(await 
profilesPage.DeleteProfile(remove)).toBeTruthy();
+                    });
+                });
+            })
         });
     });
 });
+
 describe('Clean up API for Profiles', () => {
-    it('Cleanup', async () => {
-        await api.UseAPI(profiles.cleanup);
-    });
+    afterAll(async function () {
+        it('Cleanup', async () => {
+            await api.UseAPI(profiles.cleanup);
+        });
+    })
 });
+

Reply via email to