From 8d4dcb4d2bd7c0b14efd009afbc1ff443d1901fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grand?= <francois.grand@inrae.fr> Date: Mon, 11 Apr 2022 17:24:02 +0200 Subject: [PATCH] fix: remove CdWSL (Larinier weir) from fields not to be emptied with "empty fields on calculator creation" option To force user to fill CdWSL input refs #515 --- e2e/ouvrages-empty-fields.e2e-spec.ts | 17 +++++++++++++++++ e2e/predam-empty-fields.e2e-spec.ts | 10 ++++++++-- src/app/formulaire/elements/formulaire-node.ts | 6 +++--- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/e2e/ouvrages-empty-fields.e2e-spec.ts b/e2e/ouvrages-empty-fields.e2e-spec.ts index 9e8f1b576..096393e60 100644 --- a/e2e/ouvrages-empty-fields.e2e-spec.ts +++ b/e2e/ouvrages-empty-fields.e2e-spec.ts @@ -112,4 +112,21 @@ describe("ngHyd - check that created/cloned structures have empty fields - ", () const emptys = [true, true, true, false]; await checkFields(inputIds, emptys); }); + + it("except for discharge coefficient when a Larinier weir is used", async () => { + // change 1st structure type to rectangular weir + const structSelect = calcPage.getSelectById("select_structure"); + await calcPage.changeSelectValue(structSelect, 1); + await browser.sleep(200); + + // change discharge law to Larinier + const dischargeSelect = calcPage.getSelectById("select_loidebit"); + await calcPage.changeSelectValue(dischargeSelect, 3); + await browser.sleep(200); + + // check empty fields + const inputIds = ["0_ZDV", "0_L", "0_CdWSL"]; + const emptys = [true, true, true]; + await checkFields(inputIds, emptys); + }); }); diff --git a/e2e/predam-empty-fields.e2e-spec.ts b/e2e/predam-empty-fields.e2e-spec.ts index b434bd81d..68db87689 100644 --- a/e2e/predam-empty-fields.e2e-spec.ts +++ b/e2e/predam-empty-fields.e2e-spec.ts @@ -67,9 +67,15 @@ describe("ngHyd − check that predam fields are empty on creation", () => { let txt = await inp.getAttribute("value"); expect(txt).toEqual(""); - // check CdWSL input is NOT empty + // check L input is empty + inp = calcPage.getInputById("0_L"); + txt = await inp.getAttribute("value"); + expect(txt).toEqual(""); + + // check CdWSL input is empty (in this case, the structure happens to be a Larinier weir + // which discharge coefficient must be empty) inp = calcPage.getInputById("0_CdWSL"); txt = await inp.getAttribute("value"); - expect(txt === "").toBe(false); + expect(txt).toEqual(""); }); }); diff --git a/src/app/formulaire/elements/formulaire-node.ts b/src/app/formulaire/elements/formulaire-node.ts index 4d48607af..4ce064883 100644 --- a/src/app/formulaire/elements/formulaire-node.ts +++ b/src/app/formulaire/elements/formulaire-node.ts @@ -12,7 +12,7 @@ export abstract class FormulaireNode implements IObservable { /** * fields in fieldset that must not be empty due to enableEmptyFieldsOnFormInit option */ - public static readonly NeverEmptyFields = ["Cd0", "CdWS", "CdGR", "CdGRS", "CdCunge", "CdWR", "CdO", "CdT", "CdWSL"]; + public static readonly NeverEmptyFields = ["Cd0", "CdWS", "CdGR", "CdGRS", "CdCunge", "CdWR", "CdO", "CdT"]; /** aide en ligne */ protected _helpLink: string; @@ -155,8 +155,8 @@ export abstract class FormulaireNode implements IObservable { for (const p of this.allFormElements) { if (p instanceof NgParameter) { if ( - [ ParamValueMode.SINGLE, ParamValueMode.CALCUL ].includes(p.valueMode) - && ! except.includes(p.id) + [ParamValueMode.SINGLE, ParamValueMode.CALCUL].includes(p.valueMode) + && !except.includes(p.id) ) { if (p.valueMode === ParamValueMode.CALCUL) { calcP = p; -- GitLab