From f2bcc865237a031c3d837ff8257fddeffc5ca90e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois=20Grand?= <francois.grand@inrae.fr>
Date: Thu, 5 May 2022 11:05:52 +0200
Subject: [PATCH 1/3] test(e2e): check results are not duplicated in baffle
 fishway: setup calculator

refs #535
---
 e2e/duplicate-results.e2e-spec.ts | 42 +++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 e2e/duplicate-results.e2e-spec.ts

diff --git a/e2e/duplicate-results.e2e-spec.ts b/e2e/duplicate-results.e2e-spec.ts
new file mode 100644
index 000000000..f0c0c5707
--- /dev/null
+++ b/e2e/duplicate-results.e2e-spec.ts
@@ -0,0 +1,42 @@
+import { browser } from "protractor";
+import { PreferencesPage } from "./preferences.po"
+import { Navbar } from "./navbar.po";
+import { ListPage } from "./list.po";
+import { CalculatorPage } from "./calculator.po";
+
+describe("ngHyd − check that results are not duplicated", () => {
+    let prefPage: PreferencesPage;
+    let navBar: Navbar;
+    let listPage: ListPage;
+    let calcPage: CalculatorPage;
+
+    beforeEach(async () => {
+        prefPage = new PreferencesPage();
+        listPage = new ListPage();
+        navBar = new Navbar();
+        calcPage = new CalculatorPage();
+
+        // disable evil option "empty fields on module creation"
+        await prefPage.navigateTo();
+        await browser.sleep(200);
+        await prefPage.disableEvilEmptyFields();
+        await browser.sleep(200);
+    });
+
+    it("in 'baffle fishway: setup' calculator", async () => {
+        // open baffle fishway setup calculator
+        await navBar.clickNewCalculatorButton();
+        await listPage.clickMenuEntryForCalcType(28);
+        await browser.sleep(200);
+
+        // run calculation
+        const calcButton = calcPage.getCalculateButton();
+        await calcButton.click();
+
+        // check result count
+        const fixRows = calcPage.getAllFixedResultsRows();
+        const nbRows = await fixRows.count();
+        console.log(nbRows);
+        expect(nbRows).toBe(24); // boundaries are included
+    });
+});
-- 
GitLab


From ae1800d80eeaf915076faa75b54f07db7d52d484 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois=20Grand?= <francois.grand@inrae.fr>
Date: Thu, 5 May 2022 11:08:22 +0200
Subject: [PATCH 2/3] fix: remove duplicated results in calculators when
 variable order is provided

refs #535
---
 .../fixed-results.component.ts                | 24 -------------------
 .../formulaire/definition/form-fixedvar.ts    |  2 +-
 2 files changed, 1 insertion(+), 25 deletions(-)

diff --git a/src/app/components/fixedvar-results/fixed-results.component.ts b/src/app/components/fixedvar-results/fixed-results.component.ts
index debea3e40..7fb67ea7f 100644
--- a/src/app/components/fixedvar-results/fixed-results.component.ts
+++ b/src/app/components/fixedvar-results/fixed-results.component.ts
@@ -183,30 +183,6 @@ export class FixedResultsComponent extends ResultsComponentDirective {
                     }
                 }
             }
-
-            // 2) else, is it a fixed parameter ?
-            if (! resultFound) {
-                for (const fp of this.fixedParams) {
-                    if (fp.symbol === symbol) {
-                        let label = this.formattedLabel(fp);
-                        const nub = fp.paramDefinition.parentNub;
-                        // add child type and position before label
-                        if (nub && nub.parent && nub.parent.childrenType) {
-                            const pos = nub.findPositionInParent();
-                            // label = this.intlService.localizeText("INFO_OUVRAGE") + " n°" + (pos + 1) + ": " + label;
-                            const cn = capitalize(this.intlService.childName(nub));
-                            label = sprintf(this.intlService.localizeText("INFO_STUFF_N"), cn)
-                                + (pos + 1) + ": " + label;
-                        }
-                        label += this._fixedResults.getHelpLink(symbol);
-                        data.push({
-                            label: label,
-                            value: this.formattedValue(fp),
-                            isCalcResult: false // for CSS
-                        });
-                    }
-                }
-            }
         }
         return data;
     }
diff --git a/src/app/formulaire/definition/form-fixedvar.ts b/src/app/formulaire/definition/form-fixedvar.ts
index 7509e9bd5..7b596ffbf 100644
--- a/src/app/formulaire/definition/form-fixedvar.ts
+++ b/src/app/formulaire/definition/form-fixedvar.ts
@@ -108,7 +108,7 @@ export class FormulaireFixedVar extends FormulaireDefinition {
     protected compute() {
         this.runNubCalc(this.currentNub);
         this.refreshFieldsets(); // important: before reaffectResultComponents() or it will break results components localization
-        this.reaffectResultComponents();
+        // this.reaffectResultComponents();  // seems useless since called from runNubCalc()
     }
 
     protected reaffectResultComponents() {
-- 
GitLab


From 7f88752d711e8de01307c1ee4b5952dc297a01ab Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois=20Grand?= <francois.grand@inrae.fr>
Date: Fri, 6 May 2022 10:18:19 +0200
Subject: [PATCH 3/3] fix: PAB number of falls: display calculated parameter
 first, after variated parameters and before extra results

refs #534
---
 src/app/results/var-results.ts | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/app/results/var-results.ts b/src/app/results/var-results.ts
index 834853ba4..705d514fb 100644
--- a/src/app/results/var-results.ts
+++ b/src/app/results/var-results.ts
@@ -355,6 +355,7 @@ export class VarResults extends CalculatedParamResults implements PlottableData
         // result keys (extra or not) - some lines might miss some results, in case of an error;
         // use those keys to ensure all columns are filled
         if (this.resultKeys.length === 0) {
+            this.resultKeys.push(this.result.symbol);
             for (const re of this.result.resultElements) { // re:ResultElement
                 for (const erk in re.values) {
                     if (!this.resultKeys.includes(erk)) {
-- 
GitLab