From 9bba20ed930e78e0a7902bbe576ec4a63ae65fb9 Mon Sep 17 00:00:00 2001 From: "mathias.chouet" <mathias.chouet@irstea.fr> Date: Wed, 24 Jul 2019 12:20:56 +0200 Subject: [PATCH] Fix jalhyd#98 : smarter results nivalidation stop updating UI parameters values before calculating (useless) updated e2e tests --- e2e/calculator.po.ts | 2 +- e2e/compute-reset-chained-links.e2e-spec.ts | 25 +++- e2e/session/session-results-invalidation.json | 141 +++++++++++++++++- .../calculator.component.ts | 1 - 4 files changed, 162 insertions(+), 7 deletions(-) diff --git a/e2e/calculator.po.ts b/e2e/calculator.po.ts index 71b6fe623..1cb6f0456 100644 --- a/e2e/calculator.po.ts +++ b/e2e/calculator.po.ts @@ -44,7 +44,7 @@ export class CalculatorPage { } getInputById(id: string) { - return element(by.css("input#" + id)); + return element(by.id(id)); } getSaveSessionButton() { diff --git a/e2e/compute-reset-chained-links.e2e-spec.ts b/e2e/compute-reset-chained-links.e2e-spec.ts index a6de5b5b8..97dd529d9 100644 --- a/e2e/compute-reset-chained-links.e2e-spec.ts +++ b/e2e/compute-reset-chained-links.e2e-spec.ts @@ -11,7 +11,7 @@ import { browser } from "protractor"; * Does it once with parameters linked to parameters, once with parameters * linked to results. */ -fdescribe("ngHyd − compute then reset chained results", () => { +describe("ngHyd − compute then reset chained results", () => { let startPage: AppPage; let calcPage: CalculatorPage; let navbar: Navbar; @@ -150,14 +150,31 @@ fdescribe("ngHyd − compute then reset chained results", () => { await calcPage.getInputById("Z2").clear(); await calcPage.getInputById("Z2").sendKeys("101.8"); - // calculate the module + // the down-most module should still have its results + await navbar.clickCalculatorTabForUid("amd2OG"); + const hasResults2 = await calcPage.hasResults(); + expect(hasResults2).toBe(true); + + // calculate the upmost module + await navbar.clickCalculatorTabForUid("aTgwMm"); const calcButton2 = calcPage.getCalculateButton(); await calcButton2.click(); // the down-most module should still have its results await navbar.clickCalculatorTabForUid("amd2OG"); - const hasResults2 = await calcPage.hasResults(); - expect(hasResults2).toBe(true); + const hasResults3 = await calcPage.hasResults(); + expect(hasResults3).toBe(true); + + // modify an input that is linked + await navbar.clickCalculatorTabForUid("aTgwMm"); + await calcPage.getInputById("0_ZDV").clear(); + await calcPage.getInputById("0_ZDV").sendKeys("101"); + + // the down-most module should not have its results anymore + await navbar.clickCalculatorTabForUid("amd2OG"); + const hasResults4 = await calcPage.hasResults(); + expect(hasResults4).toBe(false); + }); }); diff --git a/e2e/session/session-results-invalidation.json b/e2e/session/session-results-invalidation.json index 7bcbb2cec..b98c5c506 100644 --- a/e2e/session/session-results-invalidation.json +++ b/e2e/session/session-results-invalidation.json @@ -1 +1,140 @@ -{"header":{"source":"jalhyd","format_version":"1.0","created":"2019-06-03T12:45:20.774Z"},"session":[{"uid":"amd2OG","props":{"calcType":8,"nodeType":0},"meta":{"title":"Ouvrages"},"children":[{"uid":"YzNhaT","props":{"calcType":7,"nodeType":5,"structureType":0,"loiDebit":2},"children":[],"parameters":[{"symbol":"ZDV","mode":"LINK","targetNub":"anZjdD","targetParam":"ZDV"},{"symbol":"L","mode":"SINGLE","value":2},{"symbol":"Cd","mode":"SINGLE","value":0.4}]}],"parameters":[{"symbol":"Pr","mode":"SINGLE","value":0.0001},{"symbol":"Q","mode":"LINK","targetNub":"aTgwMm","targetParam":"Q"},{"symbol":"Z1","mode":"CALCUL"},{"symbol":"Z2","mode":"MINMAX","min":100,"max":102,"step":0.05}]},{"uid":"aTgwMm","props":{"calcType":8,"nodeType":0},"meta":{"title":"Ouvrages 1"},"children":[{"uid":"anZjdD","props":{"calcType":7,"nodeType":5,"structureType":0,"loiDebit":8},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":100},{"symbol":"L","mode":"SINGLE","value":2},{"symbol":"alpha","mode":"SINGLE","value":0.4},{"symbol":"beta","mode":"SINGLE","value":0.001},{"symbol":"ZRAM","mode":"SINGLE","value":100}]}],"parameters":[{"symbol":"Pr","mode":"SINGLE","value":0.0001},{"symbol":"Q","mode":"MINMAX","min":1,"max":20,"step":0.1},{"symbol":"Z1","mode":"CALCUL"},{"symbol":"Z2","mode":"SINGLE","value":101.5}]}]} \ No newline at end of file +{ + "header": { + "source": "jalhyd", + "format_version": "1.0", + "created": "2019-06-03T12:45:20.774Z" + }, + "session": [ + { + "uid": "amd2OG", + "props": { + "calcType": 8, + "nodeType": 0 + }, + "meta": { + "title": "Ouvrages" + }, + "children": [ + { + "uid": "YzNhaT", + "props": { + "calcType": 7, + "nodeType": 5, + "structureType": 0, + "loiDebit": 2 + }, + "children": [], + "parameters": [ + { + "symbol": "ZDV", + "mode": "LINK", + "targetNub": "anZjdD", + "targetParam": "ZDV" + }, + { + "symbol": "L", + "mode": "SINGLE", + "value": 2 + } + ] + } + ], + "parameters": [ + { + "symbol": "Pr", + "mode": "SINGLE", + "value": 0.0001 + }, + { + "symbol": "Q", + "mode": "LINK", + "targetNub": "aTgwMm", + "targetParam": "Q" + }, + { + "symbol": "Z1", + "mode": "CALCUL" + }, + { + "symbol": "Z2", + "mode": "MINMAX", + "min": 100, + "max": 102, + "step": 0.05 + } + ] + }, + { + "uid": "aTgwMm", + "props": { + "calcType": 8, + "nodeType": 0 + }, + "meta": { + "title": "Ouvrages 1" + }, + "children": [ + { + "uid": "anZjdD", + "props": { + "calcType": 7, + "nodeType": 5, + "structureType": 0, + "loiDebit": 8 + }, + "children": [], + "parameters": [ + { + "symbol": "ZDV", + "mode": "SINGLE", + "value": 100 + }, + { + "symbol": "L", + "mode": "SINGLE", + "value": 2 + }, + { + "symbol": "alpha", + "mode": "SINGLE", + "value": 0.4 + }, + { + "symbol": "beta", + "mode": "SINGLE", + "value": 0.001 + }, + { + "symbol": "ZRAM", + "mode": "SINGLE", + "value": 100 + } + ] + } + ], + "parameters": [ + { + "symbol": "Pr", + "mode": "SINGLE", + "value": 0.0001 + }, + { + "symbol": "Q", + "mode": "MINMAX", + "min": 1, + "max": 20, + "step": 0.1 + }, + { + "symbol": "Z1", + "mode": "CALCUL" + }, + { + "symbol": "Z2", + "mode": "SINGLE", + "value": 101.5 + } + ] + } + ] +} \ No newline at end of file diff --git a/src/app/components/generic-calculator/calculator.component.ts b/src/app/components/generic-calculator/calculator.component.ts index be369c0b5..305f1cd05 100644 --- a/src/app/components/generic-calculator/calculator.component.ts +++ b/src/app/components/generic-calculator/calculator.component.ts @@ -274,7 +274,6 @@ export class GenericCalculatorComponent extends BaseComponent implements OnInit, } public doCompute() { - this.updateParametersFromUI(); this._formulaire.doCompute(); this._computeClicked = true; } -- GitLab