e2e testing using mocks

Change-Id: I38fd755308e37bd67d07510e341a088b2a2636ed
Issue-ID: NONRTRIC-516
Signed-off-by: maximesson <maxime.bonneau@est.tech>
diff --git a/webapp-frontend/e2e/src/app.e2e-spec.ts b/webapp-frontend/e2e/src/app.e2e-spec.ts
index fb7e14f..4e01075 100644
--- a/webapp-frontend/e2e/src/app.e2e-spec.ts
+++ b/webapp-frontend/e2e/src/app.e2e-spec.ts
@@ -1,3 +1,4 @@
+import { tick } from '@angular/core/testing';
 /*-
  * ========================LICENSE_START=================================
  * O-RAN-SC
@@ -19,16 +20,125 @@
  */
 import { browser, by, element, logging } from "protractor";
 
-describe("workspace-project App", () => {
+describe("Home page", () => {
 
   beforeEach(() => {
+    browser.get("http://localhost:4200/");
   });
 
   it("should display title", () => {
-    browser.get("http://localhost:4200/");
     expect(browser.getTitle()).toEqual("Non-RT RIC Control Panel");
   });
 
+  it("should reach policy types page when clicking on the policy types card", async () => {
+    await element(by.id('policyControlCard')).click();
+    expect(browser.getCurrentUrl()).toEqual("http://localhost:4200/policy");
+  });
+
+  it("should reach enrichment information coordinator page when clicking on the enrichment information coordinator card", async () => {
+    await element(by.id('eicCard')).click();
+    expect(browser.getCurrentUrl()).toEqual("http://localhost:4200/ei-coordinator");
+  });
+
+  afterEach(async () => {
+    // Assert that there are no errors emitted from the browser
+    const logs = await browser.manage().logs().get(logging.Type.BROWSER);
+    expect(logs).not.toContain(
+      jasmine.objectContaining({
+        level: logging.Level.SEVERE,
+      })
+    );
+  });
+});
+
+describe("Sidebar navigation", () => {
+
+  beforeEach(() => {
+    browser.get("http://localhost:4200/");
+    element(by.id('Menu_Burger_Icon')).click();
+  });
+
+  it("should reach policy types page when clicking in the side bar", async () => {
+    await element(by.id('policyToggle')).click();
+    await element(by.id('policyLink')).click();
+    expect(browser.getCurrentUrl()).toEqual("http://localhost:4200/policy");
+  });
+
+  it("should reach ric configuration page when clicking in the side bar", async () => {
+    await element(by.id('policyToggle')).click();
+    await element(by.id('ricConfigLink')).click();
+    expect(browser.getCurrentUrl()).toEqual("http://localhost:4200/ric-config");
+  });
+
+  it("should reach enrichment information coordinator page when clicking in the side bar", async () => {
+    await element(by.id('eicLink')).click();
+    expect(browser.getCurrentUrl()).toEqual("http://localhost:4200/ei-coordinator");
+  });
+
+  afterEach(async () => {
+    // Assert that there are no errors emitted from the browser
+    const logs = await browser.manage().logs().get(logging.Type.BROWSER);
+    expect(logs).not.toContain(
+      jasmine.objectContaining({
+        level: logging.Level.SEVERE,
+      })
+    );
+  });
+});
+
+describe("Policy types page", () => {
+
+  beforeEach(() => {
+    browser.get("http://localhost:4200/policy");
+  });
+
+  it("should reach back to home from policy types page when clicking in the side bar", async () => {
+    await element(by.id('Menu_Burger_Icon')).click();
+    await element(by.id('homeLink')).click();
+    expect(browser.getCurrentUrl()).toEqual("http://localhost:4200/");
+  });
+
+  it("should show types when clicking on expand button in policy types page", async () => {
+    await element(by.id('visible')).click();
+    expect(element(by.id('createButton'))).toBeTruthy();
+  });
+
+  it("should display a pop-up window when clicking on the create button for a policy instance", async () => {
+    await element(by.id('visible')).click();
+    await element(by.id('createButton')).click();
+    expect(element(by.id('closeButton'))).toBeTruthy();
+  });
+
+  it("should open a pop-up window when clicking on the data of a policy instance", async () => {
+    await element(by.id('visible')).click();
+    let instanceTable = element(by.id('policiesTable'));
+    await element(by.css('mat-cell')).click();
+    expect(element(by.id('closeButton'))).toBeTruthy();
+  });
+
+  afterEach(async () => {
+    // Assert that there are no errors emitted from the browser
+    const logs = await browser.manage().logs().get(logging.Type.BROWSER);
+    expect(logs).not.toContain(
+      jasmine.objectContaining({
+        level: logging.Level.SEVERE,
+      })
+    );
+  });
+});
+
+describe("Enrichment information coordinator page", () => {
+
+  beforeEach(() => {
+    browser.get("http://localhost:4200/ei-coordinator");
+  });
+
+  it("should reach back to home from enrichment information coordinator page when clicking in the side bar", async () => {
+    await element(by.id('Menu_Burger_Icon')).click();
+    await element(by.id('homeLink')).click();
+    expect(browser.getCurrentUrl()).toEqual("http://localhost:4200/");
+  });
+
   afterEach(async () => {
     // Assert that there are no errors emitted from the browser
     const logs = await browser.manage().logs().get(logging.Type.BROWSER);
diff --git a/webapp-frontend/src/app/app.component.html b/webapp-frontend/src/app/app.component.html
index 202afc5..6c930dd 100644
--- a/webapp-frontend/src/app/app.component.html
+++ b/webapp-frontend/src/app/app.component.html
@@ -43,7 +43,7 @@
       </div>
     </section>
     <section #sidenav class="menu-body">
-      <nrcp-sidenav-list (sidenavClose)="drawer.toggle()">></nrcp-sidenav-list>
+      <nrcp-sidenav-list id="sidenavlist" (sidenavClose)="drawer.toggle()">></nrcp-sidenav-list>
     </section>
     <section class="menu-footer">
 
diff --git a/webapp-frontend/src/app/ei-coordinator/ei-card/ei-card.component.html b/webapp-frontend/src/app/ei-coordinator/ei-card/ei-card.component.html
index bdbb604..f59e7c8 100644
--- a/webapp-frontend/src/app/ei-coordinator/ei-card/ei-card.component.html
+++ b/webapp-frontend/src/app/ei-coordinator/ei-card/ei-card.component.html
@@ -19,9 +19,8 @@
   -->
   <div class="ei__card" routerLink="/ei-coordinator" [ngClass]="{'add__card-dark': darkMode}">
     <div class="header__container">
-      <span class="card__title">Enrichment Information Coordinator</span>
+      <span id="eicCard" class="card__title">Enrichment Information Coordinator</span>
     <div class="body__container">
       <img src="assets/oran-logo.png" width="250px"/>
     </div>
   </div>
-  
\ No newline at end of file
diff --git a/webapp-frontend/src/app/navigation/sidenav-list/sidenav-list.component.html b/webapp-frontend/src/app/navigation/sidenav-list/sidenav-list.component.html
index 8a34a8f..09e0f47 100644
--- a/webapp-frontend/src/app/navigation/sidenav-list/sidenav-list.component.html
+++ b/webapp-frontend/src/app/navigation/sidenav-list/sidenav-list.component.html
@@ -21,23 +21,23 @@
 
 <!-- browse icons at https://material.io/tools/icons/?style=baseline -->
 <mat-nav-list [ngClass]="{'dark': darkMode}">
-  <a mat-list-item routerLink="/" (click)="onSidenavClose()">
+  <a mat-list-item id="homeLink" routerLink="/" (click)="onSidenavClose()">
     <mat-icon>home</mat-icon> <span class="nav-caption">Home</span>
   </a>
-  <a mat-list-item (click)="toggle()">
+  <a mat-list-item id="policyToggle" (click)="toggle()">
       <mat-icon>dashboard</mat-icon> <span class="nav-caption">Policy</span>
       <mat-icon *ngIf="showSubMenu">expand_more</mat-icon>
       <mat-icon *ngIf="!showSubMenu">chevron_right</mat-icon>
   </a>
   <mat-nav-list [ngClass]="{'dark': darkMode}" *ngIf="showSubMenu">
-    <a mat-list-item routerLink="/policy" (click)="onSidenavClose()">
+    <a mat-list-item id="policyLink" routerLink="/policy" (click)="onSidenavClose()">
       <mat-icon>dashboard</mat-icon> <span class="nav-caption">Policy Types</span>
     </a>
-    <a mat-list-item routerLink="/ric-config" (click)="onSidenavClose()">
+    <a mat-list-item id="ricConfigLink" routerLink="/ric-config" (click)="onSidenavClose()">
       <mat-icon>build</mat-icon> <span class="nav-caption">RIC Config</span>
     </a>
   </mat-nav-list>
-  <a mat-list-item routerLink="/ei-coordinator" (click)="onSidenavClose()">
+  <a mat-list-item id="eicLink" routerLink="/ei-coordinator" (click)="onSidenavClose()">
     <mat-icon>dashboard</mat-icon> <span class="nav-caption">Enrichment Information Coordinator</span>
 </a>
 </mat-nav-list>
diff --git a/webapp-frontend/src/app/policy/policy-card/policy-card.component.html b/webapp-frontend/src/app/policy/policy-card/policy-card.component.html
index a0cecdf..18d9d41 100644
--- a/webapp-frontend/src/app/policy/policy-card/policy-card.component.html
+++ b/webapp-frontend/src/app/policy/policy-card/policy-card.component.html
@@ -19,7 +19,7 @@
   -->
 <div class="policy__card" routerLink="/policy" [ngClass]="{'add__card-dark': darkMode}">
   <div class="header__container">
-    <span class="card__title">Policy Control</span><br><br><br>
+    <span id="policyControlCard" class="card__title">Policy Control</span><br><br><br>
     <div class="body__container">
     <img src="assets/oran-logo.png" width="250px"/>
   </div>