You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by oc...@apache.org on 2021/10/04 18:01:38 UTC

[trafficcontrol] branch master updated: Migrate type test from TP E2E to TP integration test (#6232)

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

ocket8888 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git


The following commit(s) were added to refs/heads/master by this push:
     new 3be9933  Migrate type test from TP E2E to TP integration test (#6232)
3be9933 is described below

commit 3be99334f992df761001f2f8f6b7429cec416c45
Author: dpham <ph...@yahoo.com>
AuthorDate: Mon Oct 4 12:01:22 2021 -0600

    Migrate type test from TP E2E to TP integration test (#6232)
    
    * Add type test
    
    * Remove afterAll for profiles
    
    * Fix fail test
    
    * toggle function fix
    
    * Capitalize first letter check
    
    * Fix return
    
    * Fix clean up
    
    * Newline
    
    Co-authored-by: Pham, Dandy (Contractor) <Da...@comcast.com>
---
 traffic_portal/test/integration/Data/types.ts      | 32 ++++++++++++++++
 .../test/integration/PageObjects/Types.po.ts       | 11 ++++++
 .../test/integration/specs/Profiles.spec.ts        | 13 +++----
 .../test/integration/specs/Types.spec.ts           | 44 ++++++++++++++--------
 4 files changed, 78 insertions(+), 22 deletions(-)

diff --git a/traffic_portal/test/integration/Data/types.ts b/traffic_portal/test/integration/Data/types.ts
index 566a496..1465f35 100644
--- a/traffic_portal/test/integration/Data/types.ts
+++ b/traffic_portal/test/integration/Data/types.ts
@@ -65,6 +65,22 @@ export const types = {
 					password: "pa$$word"
 				}
 			],
+			toggle:[
+				{
+					description: "hide first table column",
+					Name: "description"
+				},
+				{
+					description: "redisplay first table column",
+					Name: "description"
+				}
+			],
+			check: [
+				{
+					description: "check CSV link from Type page",
+					Name: "Export as CSV"
+				}
+			],
 			add: [
 				{
 					description: "create a Type",
@@ -103,6 +119,22 @@ export const types = {
 					password: "pa$$word"
 				}
 			],
+			toggle:[
+				{
+					description: "hide first table column",
+					Name: "description"
+				},
+				{
+					description: "redisplay first table column",
+					Name: "description"
+				}
+			],
+			check: [
+				{
+					description: "check CSV link from Type page",
+					Name: "Export as CSV"
+				}
+			],
 			add: [
 				{
 					description: "create a Type",
diff --git a/traffic_portal/test/integration/PageObjects/Types.po.ts b/traffic_portal/test/integration/PageObjects/Types.po.ts
index 8d4f993..66e581f 100644
--- a/traffic_portal/test/integration/PageObjects/Types.po.ts
+++ b/traffic_portal/test/integration/PageObjects/Types.po.ts
@@ -46,6 +46,7 @@ export class TypesPage extends BasePage {
     private txtSearch = element(by.id('typesTable_filter')).element(by.css('label input'));
     private btnDelete = element(by.buttonText('Delete'));
     private txtConfirmName = element(by.name('confirmWithNameInput'));
+    private btnTableColumn = element(by.className("caret"))
     private randomize = randomize;
 
     async OpenTypesPage() {
@@ -118,6 +119,16 @@ export class TypesPage 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.charAt(0).toUpperCase() + name.slice(1))).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 02c7d4b..994b68a 100644
--- a/traffic_portal/test/integration/specs/Profiles.spec.ts
+++ b/traffic_portal/test/integration/specs/Profiles.spec.ts
@@ -94,12 +94,11 @@ profiles.tests.forEach(async profilesData => {
         });
     });
 });
-
 describe('Clean up API for Profiles', () => {
-    afterAll(async function () {
-        it('Cleanup', async () => {
-            await api.UseAPI(profiles.cleanup);
-        });
-    })
+    afterAll(async () => {
+        await api.UseAPI(profiles.cleanup);
+    });
+    it('Cleanup', async() => {
+      expect(true).toBeTruthy();
+    });
 });
-
diff --git a/traffic_portal/test/integration/specs/Types.spec.ts b/traffic_portal/test/integration/specs/Types.spec.ts
index b9fb5d6..32cae5c 100644
--- a/traffic_portal/test/integration/specs/Types.spec.ts
+++ b/traffic_portal/test/integration/specs/Types.spec.ts
@@ -36,44 +36,58 @@ describe('Setup API for Types Test', () => {
 types.tests.forEach(async typesData => {
     typesData.logins.forEach(login => {
         describe(`Traffic Portal - Types - ${login.description}`, () => {
+            afterEach(async function () {
+                await typesPage.OpenTypesPage();
+            });
+            afterAll(async function () {
+                expect(await topNavigation.Logout()).toBe(true);
+            })
             it('can login', async () => {
                 browser.get(browser.params.baseUrl);
                 await loginPage.Login(login);
-                expect(await loginPage.CheckUserName(login)).toBeTruthy();
-            });
-            it('can open types page', async () => {
+                expect(await loginPage.CheckUserName(login)).toBe(true);
                 await typesPage.OpenConfigureMenu();
-                await typesPage.OpenTypesPage();
             });
-
+            typesData.toggle.forEach(toggle => {
+                it(toggle.description, async () => {
+                    if(toggle.description.includes('hide')){
+                        expect(await typesPage.ToggleTableColumn(toggle.Name)).toBe(false);
+                    }else{
+                        expect(await typesPage.ToggleTableColumn(toggle.Name)).toBe(true);
+                    }
+                    
+                });
+            });
+            typesData.check.forEach(check => {
+                it(check.description, async () => {
+                    expect(await typesPage.CheckCSV(check.Name)).toBe(true);
+                });
+            });
             typesData.add.forEach(add => {
                 it(add.description, async () => {
-                    expect(await typesPage.CreateType(add)).toBeTruthy();
-                    await typesPage.OpenTypesPage();
+                    expect(await typesPage.CreateType(add)).toBe(true);
                 });
             });
             typesData.update.forEach(update => {
                 it(update.description, async () => {
                     await typesPage.SearchType(update.Name);
-                    expect(await typesPage.UpdateType(update)).toBeTruthy();
-                    await typesPage.OpenTypesPage();
+                    expect(await typesPage.UpdateType(update)).toBe(true);
                 });
             });
             typesData.remove.forEach(remove => {
                 it(remove.description, async () => {
                     await typesPage.SearchType(remove.Name);
-                    expect(await typesPage.DeleteTypes(remove)).toBeTruthy();
-                    await typesPage.OpenTypesPage();
+                    expect(await typesPage.DeleteTypes(remove)).toBe(true);
                 });
             });
-            it('can logout', async () => {
-                expect(await topNavigation.Logout()).toBeTruthy();
-            });
         });
     });
 });
 describe('Clean Up API for Types Test', () => {
-    it('Cleanup', async () => {
+    afterAll(async () => {
         await api.UseAPI(types.cleanup);
     });
+    it('Cleanup', async() => {
+      expect(true).toBeTruthy();
+    });
 });