From 8fa2f3024cfa3071ca49680da62e3212578d0c57 Mon Sep 17 00:00:00 2001
From: "mathias.chouet" <mathias.chouet@irstea.fr>
Date: Fri, 4 Sep 2020 15:48:50 +0200
Subject: [PATCH] Update e2e for Prebarrage

---
 e2e/calculate-all-params.e2e-spec.ts    | 19 ++++++++++++++++---
 e2e/calculate-linked-params.e2e-spec.ts |  4 ++--
 e2e/calculator.po.ts                    |  8 +++++---
 e2e/tested_calctypes.ts                 |  3 ++-
 src/app/config.json                     |  2 +-
 src/locale/messages.en.json             |  1 +
 src/locale/messages.fr.json             |  1 +
 7 files changed, 28 insertions(+), 10 deletions(-)

diff --git a/e2e/calculate-all-params.e2e-spec.ts b/e2e/calculate-all-params.e2e-spec.ts
index 18a2f844b..a74e4e138 100644
--- a/e2e/calculate-all-params.e2e-spec.ts
+++ b/e2e/calculate-all-params.e2e-spec.ts
@@ -2,7 +2,7 @@ import { ListPage } from "./list.po";
 import { CalculatorPage } from "./calculator.po";
 import { Navbar } from "./navbar.po";
 import { PreferencesPage } from "./preferences.po";
-import { browser, element, by, ElementFinder } from "protractor";
+import { browser, element, by } from "protractor";
 import { testedCalcTypes } from "./tested_calctypes";
 
 /**
@@ -36,8 +36,13 @@ describe("ngHyd − calculate all parameters of all calculators", async () => {
 
     // for each calculator
     for (const ct of calcTypes) {
-        if (ct === 22) {
-            // omit 22 - Solveur is not calculated here because it is not independent
+        if ([ 22, 31, 32, 33, 34 ].includes(ct)) {
+            // omit 22 - Solveur
+            // omit 31 - PbCloison
+            // omit 32 - PbBassin
+            // omit 33 - Espece
+            // omit 34 - Verificateur
+            // (not calculated here because they are not independent)
             continue;
         }
         describe(" − calculate all parameters of calculator type [" + ct + "]", async () => {
@@ -53,6 +58,14 @@ describe("ngHyd − calculate all parameters of all calculators", async () => {
                 if (inputs.length > 0) {
                     // for each param
                     for (let i = 0; i < inputs.length; i++) {
+                        // for PreBarrage, switch back to "input" after calculating, so
+                        // that the calculable parameters are shown
+                        if (ct === 30 && i > 0) {
+                            // prevents "Element is not clickable at point"
+                            await browser.executeScript("window.scrollTo(0, 0);");
+                            const inputLink = element(by.css("#pb-data-results-selector .drs-item a"));
+                            await inputLink.click();
+                        }
                         // grab input again because calculating the module just refreshed all the fieldsets
                         const input = (await calcPage.getParamInputsHavingCalcMode())[i];
                         // click "calc" mode button for this parameter
diff --git a/e2e/calculate-linked-params.e2e-spec.ts b/e2e/calculate-linked-params.e2e-spec.ts
index 443e7939b..3436c8092 100644
--- a/e2e/calculate-linked-params.e2e-spec.ts
+++ b/e2e/calculate-linked-params.e2e-spec.ts
@@ -287,7 +287,7 @@ describe("ngHyd − calculate with linked parameters", () => {
         let frt = calcPage.getFixedResultsTable();
         let volumeRow = calcPage.getNthRow(frt, 3);
         let volumeCol = calcPage.getNthColumn(volumeRow, 2);
-        let volume = await volumeCol.getText();
+        let volume = await volumeCol.getAttribute("textContent");
         expect(Number(volume)).toBeCloseTo(44.565, 3);
 
         // click PAB-Nombre tab
@@ -302,7 +302,7 @@ describe("ngHyd − calculate with linked parameters", () => {
         frt = calcPage.getFixedResultsTable();
         volumeRow = calcPage.getNthRow(frt, 3);
         volumeCol = calcPage.getNthColumn(volumeRow, 2);
-        volume = await volumeCol.getText();
+        volume = await volumeCol.getAttribute("textContent");
         expect(Number(volume)).toBeCloseTo(44.565, 3);
     });
 
diff --git a/e2e/calculator.po.ts b/e2e/calculator.po.ts
index 6053029af..1194295c9 100644
--- a/e2e/calculator.po.ts
+++ b/e2e/calculator.po.ts
@@ -80,11 +80,11 @@ export class CalculatorPage {
     }
 
     getAllVariatedResultsTableHeaders() {
-        return element.all(by.css("var-results table thead th"));
+        return element.all(by.css("fixedvar-results var-results table thead th"));
     }
 
     getAllVariatedResultsRows() {
-        return element.all(by.css("var-results table tbody tr"));
+        return element.all(by.css("fixedvar-results var-results table tbody tr"));
     }
 
     scrollTo(elt: ElementFinder) {
@@ -131,6 +131,8 @@ export class CalculatorPage {
             ||
             await this.presentAndVisible("pab-results pab-results-table")
             ||
+            await this.presentAndVisible("pb-results pb-results-table")
+            ||
             await this.presentAndVisible("macrorugo-compound-results macrorugo-compound-results-table")
             ||
             await this.presentAndVisible("jet-results .fixed-results-container")
@@ -294,7 +296,7 @@ export class CalculatorPage {
                 if (!hasDot && !hasExponent && !isN) {
                     keys = "." + keys;
                 }
-                if (! isOb) {
+                if (! isOb && await i.getAttribute("disabled") === null) {
                     await i.sendKeys(keys);
                 }
             }
diff --git a/e2e/tested_calctypes.ts b/e2e/tested_calctypes.ts
index 49b141aac..cdd1fc766 100644
--- a/e2e/tested_calctypes.ts
+++ b/e2e/tested_calctypes.ts
@@ -9,6 +9,7 @@ export const testedCalcTypes = [
     // omit 16 - CloisonAval
     17, 18, 19, 20, 21, 22, 23, 24, 25,
     // omit 26 - YAXN
-    27, 28, 29, 30
+    27, 28, 29, 30,
     // omit 31 - PbCloison and 32 - PbBassin
+    33, 34
 ];
diff --git a/src/app/config.json b/src/app/config.json
index 6a7b7f921..97f3c60d6 100644
--- a/src/app/config.json
+++ b/src/app/config.json
@@ -39,7 +39,7 @@
                 "path": "verification.jpg",
                 "credits": "S. Richard / OFB"
             },
-            "calculators": [ 31, 30 ]
+            "calculators": [ 34, 33 ]
         },
         {
             "name": "DEVALAISON",
diff --git a/src/locale/messages.en.json b/src/locale/messages.en.json
index c0e3e9e1a..2e3202b0d 100644
--- a/src/locale/messages.en.json
+++ b/src/locale/messages.en.json
@@ -536,6 +536,7 @@
     "INFO_PB_NEW_WALL_DOWN_BASIN": "Downstream basin",
     "INFO_PB_SCHEMA": "Basins layout",
     "INFO_PREBARRAGE_TITRE": "Pre-dams",
+    "INFO_PREBARRAGE_DESCRIPTION": "fishes basins cross-walls barrages",
     "INFO_PREBARRAGE_TITRE_COURT": "Pre-dams",
     "INFO_QUICKNAV_CHARTS": "charts",
     "INFO_QUICKNAV_INPUT": "input",
diff --git a/src/locale/messages.fr.json b/src/locale/messages.fr.json
index e83b62b87..ac6778e51 100644
--- a/src/locale/messages.fr.json
+++ b/src/locale/messages.fr.json
@@ -537,6 +537,7 @@
     "INFO_PB_NEW_WALL_DOWN_BASIN": "Bassin aval",
     "INFO_PB_SCHEMA": "Organisation des bassins",
     "INFO_PREBARRAGE_TITRE": "Prébarrages",
+    "INFO_PREBARRAGE_DESCRIPTION": "poissons cloisons bassins",
     "INFO_PREBARRAGE_TITRE_COURT": "Prébarrages",
     "INFO_QUICKNAV_CHARTS": "graphiques",
     "INFO_QUICKNAV_INPUT": "données",
-- 
GitLab