commit 3a4cfa9b7aeae350ecf492954e21e0f0754c50eb
Author: hlavja <hlavjah@gmail.com>
Date:   Wed May 19 01:03:49 2021 +0200

    Re #8858 - Testování aplikace
    
    + login actions tests
    + navbar actions tests

diff --git a/e2e/protractor.conf.js b/e2e/protractor.conf.js
index 361e7f0..aa21feb 100644
--- a/e2e/protractor.conf.js
+++ b/e2e/protractor.conf.js
@@ -8,20 +8,24 @@ const { SpecReporter, StacktraceOption } = require('jasmine-spec-reporter');
  * @type { import("protractor").Config }
  */
 exports.config = {
-  allScriptsTimeout: 11000,
+  allScriptsTimeout: 51000,
   specs: [
     './src/**/*.e2e-spec.ts'
   ],
   capabilities: {
-    browserName: 'chrome'
+    browserName: 'chrome',
+    chromeOptions: {
+      args: ['--window-size=1920,870']
+    }
   },
+  restartBrowserBetweenTests: false,
   directConnect: true,
   SELENIUM_PROMISE_MANAGER: false,
   baseUrl: 'http://localhost:4200/',
   framework: 'jasmine',
   jasmineNodeOpts: {
     showColors: true,
-    defaultTimeoutInterval: 30000,
+    defaultTimeoutInterval: 50000,
     print: function() {}
   },
   onPrepare() {
@@ -34,4 +38,4 @@ exports.config = {
       }
     }));
   }
-};
\ No newline at end of file
+};
diff --git a/e2e/src/app.e2e-spec.ts b/e2e/src/app.e2e-spec.ts
index 8094937..e69de29 100644
--- a/e2e/src/app.e2e-spec.ts
+++ b/e2e/src/app.e2e-spec.ts
@@ -1,23 +0,0 @@
-import { browser, logging } from 'protractor';
-import { AppPage } from './app.po';
-
-describe('workspace-project App', () => {
-  let page: AppPage;
-
-  beforeEach(() => {
-    page = new AppPage();
-  });
-
-  it('should display welcome message', async () => {
-    await page.navigateTo();
-    expect(await page.getTitleText()).toEqual('SensLog app is running!');
-  });
-
-  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,
-    } as logging.Entry));
-  });
-});
diff --git a/e2e/src/app.po.ts b/e2e/src/app.po.ts
index c9c85ab..e69de29 100644
--- a/e2e/src/app.po.ts
+++ b/e2e/src/app.po.ts
@@ -1,11 +0,0 @@
-import { browser, by, element } from 'protractor';
-
-export class AppPage {
-  async navigateTo(): Promise<unknown> {
-    return browser.get(browser.baseUrl);
-  }
-
-  async getTitleText(): Promise<string> {
-    return element(by.css('app-root .content span')).getText();
-  }
-}
diff --git a/e2e/src/dashboard/dashboard.e2e-spec.ts b/e2e/src/dashboard/dashboard.e2e-spec.ts
new file mode 100644
index 0000000..ecd53af
--- /dev/null
+++ b/e2e/src/dashboard/dashboard.e2e-spec.ts
@@ -0,0 +1,33 @@
+import {DashboardPo} from './dashboard.po';
+import {LoginPo} from '../login/login.po';
+import {browser} from 'protractor';
+
+
+describe('Login Module', () => {
+  let dashboardPo: DashboardPo;
+  let loginPo: LoginPo
+
+  beforeEach(() => {
+    dashboardPo = new DashboardPo();
+    loginPo = new LoginPo();
+  });
+
+  it('Add user!', async () => {
+    await loginPo.navigateTo();
+    await loginPo.processForm();
+    await dashboardPo.showUserInsert();
+    expect(await dashboardPo.popupShown()).toEqual(true);
+    await dashboardPo.sendUserForm();
+    expect(await dashboardPo.success()).toEqual(true);
+  });
+
+  it('Add unit!', async () => {
+    await loginPo.navigateTo();
+    await loginPo.processForm();
+    await dashboardPo.showUnitInsert();
+    expect(await dashboardPo.popupShown()).toEqual(true);
+    await dashboardPo.sendUnitForm();
+    expect(await dashboardPo.success()).toEqual(true);
+  });
+
+});
diff --git a/e2e/src/dashboard/dashboard.po.ts b/e2e/src/dashboard/dashboard.po.ts
new file mode 100644
index 0000000..bfbb5f0
--- /dev/null
+++ b/e2e/src/dashboard/dashboard.po.ts
@@ -0,0 +1,50 @@
+import { browser, by, element } from 'protractor';
+import * as moment from 'moment-timezone';
+
+export class DashboardPo {
+  async navigateTo(): Promise<unknown> {
+    return browser.get(browser.baseUrl);
+  }
+
+  async showUserInsert(): Promise<unknown> {
+    return element(by.id('addUser')).click();
+  }
+
+  async popupShown(): Promise<boolean> {
+    return element(by.className('p-dialog-resizable')).isPresent();
+  }
+
+  async sendUserForm(): Promise<unknown> {
+    const today = moment().format('YYYYMMDDHHMMSS').toString();
+    element(by.id('username')).sendKeys(today);
+    element(by.id('password')).sendKeys('testuser');
+    element(by.id('userRealName')).sendKeys('testuser');
+    element(by.cssContainingText('option', 'testing units')).click();
+    element(by.cssContainingText('option', 'General user')).click();
+    return element(by.buttonText('Save')).click();
+  }
+
+  async success(): Promise<boolean> {
+    return element(by.cssContainingText('.p-toast-summary', 'Success')).isPresent();
+  }
+
+  async showUnitInsert(): Promise<unknown> {
+    return element(by.id('addUnit')).click();
+  }
+
+  async sendUnitForm() {
+    const today = moment().format('YYYYMMDDHHMMSS').toString();
+    element(by.id('unitId')).sendKeys(today);
+    element(by.id('unitDescription')).sendKeys(today);
+    element(by.id('unitId')).sendKeys(today);
+    element(by.id('lat')).sendKeys(10);
+    element(by.id('lon')).sendKeys('10');
+    element(by.buttonText('Add sensor')).click();
+    await browser.sleep(2000);
+    element(by.id('sensorId')).sendKeys(today);
+    element(by.id('sensorName')).sendKeys(today)
+    element(by.cssContainingText('option', 'test')).click();
+    element(by.cssContainingText('option', 'Strikes (  )')).click();
+    return element(by.buttonText('Save')).click();
+  }
+}
diff --git a/e2e/src/login/login.e2e-spec.ts b/e2e/src/login/login.e2e-spec.ts
new file mode 100644
index 0000000..cb15229
--- /dev/null
+++ b/e2e/src/login/login.e2e-spec.ts
@@ -0,0 +1,22 @@
+import {LoginPo} from './login.po';
+
+
+describe('Login Module', () => {
+  let loginPo: LoginPo;
+
+  beforeEach(() => {
+    loginPo = new LoginPo();
+  });
+
+  it('Check if login form displayed!', async () => {
+    await loginPo.navigateTo();
+    expect(await loginPo.getTitleText()).toEqual('Sign in');
+  });
+
+  it('Process login form!', async () => {
+    await loginPo.navigateTo();
+    await loginPo.processForm();
+    expect(await loginPo.dashboardPresent()).toEqual(true);
+    expect(await loginPo.loggedUser()).toEqual(' TESTINS');
+  });
+});
diff --git a/e2e/src/login/login.po.ts b/e2e/src/login/login.po.ts
new file mode 100644
index 0000000..6452926
--- /dev/null
+++ b/e2e/src/login/login.po.ts
@@ -0,0 +1,25 @@
+import { browser, by, element } from 'protractor';
+
+export class LoginPo {
+  async navigateTo(): Promise<unknown> {
+    return browser.get(browser.baseUrl);
+  }
+
+  async getTitleText(): Promise<string> {
+    return element(by.className('login-heading')).getText();
+  }
+
+  async processForm(): Promise<unknown> {
+    element(by.id('username')).sendKeys('testins');
+    element(by.id('password')).sendKeys('insert');
+    return element(by.id('loginButton')).click();
+  }
+
+  async dashboardPresent(): Promise<unknown> {
+    return element(by.className('dashboard')).isPresent();
+  }
+
+  async loggedUser(): Promise<string> {
+    return element(by.id('loggedUser')).getText();
+  }
+}
diff --git a/src/app/dashboard/components/dashboard.component.html b/src/app/dashboard/components/dashboard.component.html
index 3b1bcb6..0312bff 100644
--- a/src/app/dashboard/components/dashboard.component.html
+++ b/src/app/dashboard/components/dashboard.component.html
@@ -31,4 +31,4 @@
 <app-position-insert-popup *ngIf="showInsertPositionPopup" [unitId]="editedUnit.unitId" [(isVisible)]="showInsertPositionPopup"></app-position-insert-popup>
 
 
-<p-confirmDialog [style]="{width: '50vw'}" key="positionDialog" [position]="position" [baseZIndex]="10000" rejectButtonStyleClass="p-button-outlined"></p-confirmDialog>
+<p-confirmDialog [style]="{width: '50vw'}" key="positionDialog" [position]="position" [baseZIndex]="10000" rejectButtonStyleClass="p-button-outlined" [closable]="false"></p-confirmDialog>
diff --git a/src/app/login/components/login.component.html b/src/app/login/components/login.component.html
index e4975a6..f79281b 100644
--- a/src/app/login/components/login.component.html
+++ b/src/app/login/components/login.component.html
@@ -26,7 +26,7 @@
               <input type="password" formControlName="password" class="form-control" id="password" placeholder="Password"/>
             </div>
             <div class="form-group text-center mt-4">
-              <p-button type="submit" label="Login"><i class="fas fa-sign-in-alt"></i></p-button>
+              <p-button id="loginButton" type="submit" label="Login"><i class="fas fa-sign-in-alt"></i></p-button>
             </div>
           </form>
         </div>
diff --git a/src/app/shared/nav-bar/components/nav-bar.component.html b/src/app/shared/nav-bar/components/nav-bar.component.html
index 98e4fd1..dbe0e6b 100644
--- a/src/app/shared/nav-bar/components/nav-bar.component.html
+++ b/src/app/shared/nav-bar/components/nav-bar.component.html
@@ -11,10 +11,10 @@
               <a class="nav-link" [routerLink]="['/dashboard']"><h2>Dashboard</h2></a>
             </li>
             <li *ngIf="loggedUser?.userInfo?.rightsId == 0" class="nav-item">
-              <a class="nav-link" (click)="addUser()"><h2><i class="fas fa-user-plus"></i>&nbsp;Add user</h2></a>
+              <a class="nav-link" id="addUser" (click)="addUser()"><h2><i class="fas fa-user-plus"></i>&nbsp;Add user</h2></a>
             </li>
             <li *ngIf="loggedUser?.userInfo?.rightsId == 0 || loggedUser?.userInfo?.rightsId == 1" class="nav-item">
-              <a class="nav-link" (click)="insertUnitPopup()"><h2><i class="fas fa-folder-plus"></i>&nbsp;Add unit</h2></a>
+              <a class="nav-link" id="addUnit" (click)="insertUnitPopup()"><h2><i class="fas fa-folder-plus"></i>&nbsp;Add unit</h2></a>
             </li>
           </ul>
           <a class="navbar-brand" href="/">
@@ -23,7 +23,7 @@
           </a>
           <ul class="navbar-nav right">
             <li class="nav-item">
-              <h2 class="nav-link"><i class="fas fa-user"></i>&nbsp;<strong>{{loggedUser?.userInfo?.userName.toUpperCase()}}</strong></h2>
+              <h2 class="nav-link" id="loggedUser"><i class="fas fa-user"></i>&nbsp;<strong>{{loggedUser?.userInfo?.userName.toUpperCase()}}</strong></h2>
             </li>
             <li class="nav-item">
               <a class='nav-link' [routerLink]="['/login']" (click)="logOut()"><h2><i class="fas fa-sign-out-alt"></i>&nbsp;Logout</h2></a>
diff --git a/src/app/shared/nav-bar/components/user-insert-popup/user-insert-popup.component.ts b/src/app/shared/nav-bar/components/user-insert-popup/user-insert-popup.component.ts
index b5ec099..b6d5c12 100644
--- a/src/app/shared/nav-bar/components/user-insert-popup/user-insert-popup.component.ts
+++ b/src/app/shared/nav-bar/components/user-insert-popup/user-insert-popup.component.ts
@@ -78,6 +78,7 @@ export class UserInsertPopupComponent implements OnInit, OnDestroy {
         map((response: HttpResponse<any>) => {
           if (response.status === 200) {
             this.close();
+            this.toastService.showSuccess();
           } else {
             this.toastService.showError(null);
           }
