From 59c6168d1be3b078b5cda4be91d909a8c9d61a91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grand?= <francois.grand@inrae.fr> Date: Fri, 7 Oct 2022 14:44:04 +0200 Subject: [PATCH 1/5] refactor(e2e): move empty input checking functions to calculator.po refs #569 --- e2e/calculator.po.ts | 27 +++++++++++++++++++- e2e/examples-empty-fields.e2e-spec.ts | 17 +------------ e2e/ouvrages-empty-fields.e2e-spec.ts | 31 ++++++----------------- e2e/pab-cloisons-empty-fields.e2e-spec.ts | 19 ++------------ e2e/predam-empty-fields.e2e-spec.ts | 22 ++++++---------- 5 files changed, 45 insertions(+), 71 deletions(-) diff --git a/e2e/calculator.po.ts b/e2e/calculator.po.ts index cb46ead62..5fc98c54e 100644 --- a/e2e/calculator.po.ts +++ b/e2e/calculator.po.ts @@ -329,10 +329,35 @@ export class CalculatorPage { if (!hasDot && !hasExponent && !isN) { keys = "." + keys; } - if (! isOb && await i.getAttribute("disabled") === null) { + if (!isOb && await i.getAttribute("disabled") === null) { await i.sendKeys(keys); } } }); } + + /** + * check that an input is empty + * @param id input id (parameter name) + */ + async checkEmptyInput(id: string) { + const inp = this.getInputById(id); + const val = await inp.getAttribute("value"); + expect(val).toEqual(""); + } + + /** + * check that a input set is in a given (empty/filled) state + * @param inputIds id of the inputs to check + * @param emptys empty/not empty state array + */ + async checkEmptyOrFilledFields(inputIds: string[], emptys: boolean[]) { + let n = 0; + for (const id of inputIds) { + const inp = await this.getInputById(id); + const txt = await inp.getAttribute("value"); + expect(txt === "").toEqual(emptys[n]); + n++; + } + } } diff --git a/e2e/examples-empty-fields.e2e-spec.ts b/e2e/examples-empty-fields.e2e-spec.ts index 4356743a2..08f40c467 100644 --- a/e2e/examples-empty-fields.e2e-spec.ts +++ b/e2e/examples-empty-fields.e2e-spec.ts @@ -24,21 +24,6 @@ describe("ngHyd - Check that examples fields are not empty with 'empty fields on await browser.sleep(200); }); - /** - * check that a input set is in a given (empty/filled) state - * @param inputIds id of the inputs to check - * @param emptys empty/not empty state array - */ - async function checkFields(inputIds: string[], emptys: boolean[]) { - let n = 0; - for (const id of inputIds) { - const inp = await calcPage.getInputById(id); - const txt = await inp.getAttribute("value"); - expect(txt === "").toEqual(emptys[n]); - n++; - } - } - it("when a standard fish ladder calculator is created", async () => { // start page await navBar.clickNewCalculatorButton(); @@ -56,7 +41,7 @@ describe("ngHyd - Check that examples fields are not empty with 'empty fields on // check fields are not empty const inputIds = ["Z1", "LB", "PB", "0_L", "0_CdWSL"]; const emptys = [false, false, false, false, false]; - await checkFields(inputIds, emptys); + await calcPage.checkEmptyOrFilledFields(inputIds, emptys); }); it("calculated parameter initial value when discharge law is modified", async () => { diff --git a/e2e/ouvrages-empty-fields.e2e-spec.ts b/e2e/ouvrages-empty-fields.e2e-spec.ts index d653ecbc3..60f2512f6 100644 --- a/e2e/ouvrages-empty-fields.e2e-spec.ts +++ b/e2e/ouvrages-empty-fields.e2e-spec.ts @@ -41,28 +41,13 @@ describe("ngHyd - check that created/cloned structures have empty fields - ", () await browser.sleep(200); } - /** - * check that a input set is in a given (empty/filled) state - * @param inputIds id of the inputs to check - * @param emptys empty/not empty state array - */ - async function checkFields(inputIds: string[], emptys: boolean[]) { - let n = 0; - for (const id of inputIds) { - const inp = await calcPage.getInputById(id); - const txt = await inp.getAttribute("value"); - expect(txt === "").toEqual(emptys[n]); - n++; - } - } - it("when a structure calculator is created", async () => { await setup(); // check 1st structure empty fields const inputIds = ["Q", "Z1", "Z2", "0_ZDV", "0_L", "0_W", "0_CdGR"]; const emptys = [true, true, true, true, true, true, false]; - await checkFields(inputIds, emptys); + await calcPage.checkEmptyOrFilledFields(inputIds, emptys); // change 1st structure type to rectangular weir const structSelect = calcPage.getSelectById("select_structure"); @@ -72,7 +57,7 @@ describe("ngHyd - check that created/cloned structures have empty fields - ", () // check 1st structure empty fields const inputIds2 = ["Q", "Z1", "Z2", "0_ZDV", "0_L", "0_CdWR"]; const emptys2 = [true, true, true, true, true, false]; - await checkFields(inputIds2, emptys2); + await calcPage.checkEmptyOrFilledFields(inputIds2, emptys2); }); it("when a structure is added", async () => { @@ -85,7 +70,7 @@ describe("ngHyd - check that created/cloned structures have empty fields - ", () // check 2nd structure empty fields const inputIds = ["1_ZDV", "1_L", "1_W", "1_CdGR"]; const emptys = [true, true, true, false]; - await checkFields(inputIds, emptys); + await calcPage.checkEmptyOrFilledFields(inputIds, emptys); }); it("when a structure is copied", async () => { @@ -98,7 +83,7 @@ describe("ngHyd - check that created/cloned structures have empty fields - ", () // check 2nd structure empty fields const inputIds = ["1_ZDV", "1_L", "1_W", "1_CdGR"]; const emptys = [true, true, true, false]; - await checkFields(inputIds, emptys); + await calcPage.checkEmptyOrFilledFields(inputIds, emptys); }); it("when a modified structure is copied (type)", async () => { @@ -123,7 +108,7 @@ describe("ngHyd - check that created/cloned structures have empty fields - ", () // check empty fields const inputIds = ["1_ZDV", "1_L", "1_W", "1_CdGR"]; const emptys = [true, true, true, false]; - await checkFields(inputIds, emptys); + await calcPage.checkEmptyOrFilledFields(inputIds, emptys); }); it("when a modified structure is copied (input)", async () => { @@ -142,7 +127,7 @@ describe("ngHyd - check that created/cloned structures have empty fields - ", () // check empty fields const inputIds = ["1_ZDV", "1_L", "1_W", "1_CdGR"]; const emptys = [false, true, true, false]; - await checkFields(inputIds, emptys); + await calcPage.checkEmptyOrFilledFields(inputIds, emptys); }); it("except for discharge coefficient when a Larinier weir is used", async () => { @@ -161,7 +146,7 @@ describe("ngHyd - check that created/cloned structures have empty fields - ", () // check empty fields const inputIds = ["0_ZDV", "0_L", "0_CdWSL"]; const emptys = [true, true, true]; - await checkFields(inputIds, emptys); + await calcPage.checkEmptyOrFilledFields(inputIds, emptys); }); it("when a structure is modified (input) and then a structure is added", async () => { @@ -180,6 +165,6 @@ describe("ngHyd - check that created/cloned structures have empty fields - ", () // check empty fields const inputIds = ["1_ZDV", "1_L", "1_W", "1_CdGR"]; const emptys = [true, true, true, false]; - await checkFields(inputIds, emptys); + await calcPage.checkEmptyOrFilledFields(inputIds, emptys); }); }); diff --git a/e2e/pab-cloisons-empty-fields.e2e-spec.ts b/e2e/pab-cloisons-empty-fields.e2e-spec.ts index 7e99a7de4..6b19d4c3e 100644 --- a/e2e/pab-cloisons-empty-fields.e2e-spec.ts +++ b/e2e/pab-cloisons-empty-fields.e2e-spec.ts @@ -15,21 +15,6 @@ async function enableEmptyFieldsOption(prefPage: PreferencesPage) { await browser.sleep(200); } -/** - * check that a input set is in a given (empty/filled) state - * @param inputIds id of the inputs to check - * @param emptys empty/not empty state array - */ -async function checkFields(calcPage: CalculatorPage, inputIds: string[], emptys: boolean[]) { - let n = 0; - for (const id of inputIds) { - const inp = await calcPage.getInputById(id); - const txt = await inp.getAttribute("value"); - expect(txt === "").toEqual(emptys[n]); - n++; - } -} - async function fillInput(calcPage: CalculatorPage, symbol: string) { const inp = calcPage.getInputById(symbol); await inp.clear(); @@ -84,7 +69,7 @@ describe("ngHyd - check the cross walls calculator has empty fields - ", () => { await genButton.click(); await browser.sleep(200); - await checkFields(calcPage, ["generatePabNbBassins"], [true]); + await calcPage.checkEmptyOrFilledFields(["generatePabNbBassins"], [true]); }); }); @@ -130,6 +115,6 @@ describe("ngHyd - check the cross walls calculator has no empty field - ", () => await calcButton.click(); await browser.sleep(200); - await checkFields(calcPage, ["Z1", "LB", "BB", "PB", "DH", "0_h1", "0_L", "0_CdWSL"], [false, false, false, false, false, false, false, false]); + await calcPage.checkEmptyOrFilledFields(["Z1", "LB", "BB", "PB", "DH", "0_h1", "0_L", "0_CdWSL"], [false, false, false, false, false, false, false, false]); }); }); diff --git a/e2e/predam-empty-fields.e2e-spec.ts b/e2e/predam-empty-fields.e2e-spec.ts index 6618d97cb..8c1cfb79b 100644 --- a/e2e/predam-empty-fields.e2e-spec.ts +++ b/e2e/predam-empty-fields.e2e-spec.ts @@ -26,12 +26,6 @@ describe("ngHyd − check that predam fields are empty", () => { await browser.sleep(200); }); - async function checkEmptyInput(id: string) { - const inp = calcPage.getInputById(id); - const val = await inp.getAttribute("value"); - expect(val).toEqual(""); - } - it("on creation", async () => { //browser.manage().window().setPosition(2000, 30); // open predam calculator @@ -40,16 +34,16 @@ describe("ngHyd − check that predam fields are empty", () => { await browser.sleep(200); // check upstream inputs - await checkEmptyInput("Q"); + await calcPage.checkEmptyInput("Q"); // Z1 is calculated - await checkEmptyInput("Z2"); + await calcPage.checkEmptyInput("Z2"); // check basin 1 inputs let node = element(by.css("g.node.basin")); await node.click(); await browser.sleep(200); - await checkEmptyInput("0_S"); - await checkEmptyInput("0_ZF"); + await calcPage.checkEmptyInput("0_S"); + await calcPage.checkEmptyInput("0_ZF"); // check walls inputs const walls = element.all(by.css("g.node.wall")); @@ -57,17 +51,17 @@ describe("ngHyd − check that predam fields are empty", () => { await walls.each(async (w) => { await w.click(); await browser.sleep(200); - await checkEmptyInput("0_ZDV"); - await checkEmptyInput("0_L"); + await calcPage.checkEmptyInput("0_ZDV"); + await calcPage.checkEmptyInput("0_L"); }); // check downstream basin inputs node = element(by.css("g[id^='flowchart-aval-']")); // Mermaid generated id await node.click(); await browser.sleep(200); - checkEmptyInput("Q"); + calcPage.checkEmptyInput("Q"); // Z1 is calculated - checkEmptyInput("Z2"); + calcPage.checkEmptyInput("Z2"); }); it("when a basin is added", async () => { -- GitLab From 7bd754064b8cc00f0443fdc005b7f90eadbaf93f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grand?= <francois.grand@inrae.fr> Date: Fri, 7 Oct 2022 15:29:56 +0200 Subject: [PATCH 2/5] test(e2e): check empty fields in parametric section, backwater curves, uniform flow, reach calculators refs #569 --- e2e/bief-empty-fields.e2e-spec.ts | 36 ++++++++++++++++++++ e2e/courbe-remous-empty-fields.e2e-spec.ts | 36 ++++++++++++++++++++ e2e/regime-uniforme-empty-fields.e2e-spec.ts | 35 +++++++++++++++++++ e2e/section-empty-fields.e2e-spec.ts | 35 +++++++++++++++++++ 4 files changed, 142 insertions(+) create mode 100644 e2e/bief-empty-fields.e2e-spec.ts create mode 100644 e2e/courbe-remous-empty-fields.e2e-spec.ts create mode 100644 e2e/regime-uniforme-empty-fields.e2e-spec.ts create mode 100644 e2e/section-empty-fields.e2e-spec.ts diff --git a/e2e/bief-empty-fields.e2e-spec.ts b/e2e/bief-empty-fields.e2e-spec.ts new file mode 100644 index 000000000..fd9fc0a44 --- /dev/null +++ b/e2e/bief-empty-fields.e2e-spec.ts @@ -0,0 +1,36 @@ +import { ListPage } from "./list.po"; +import { Navbar } from "./navbar.po"; +import { browser } from "protractor"; +import { CalculatorPage } from "./calculator.po"; +import { PreferencesPage } from "./preferences.po"; + +describe("Check fields are empty in 'up/downstream elevations of a reach' calculator when created with 'empty fields' option", () => { + let listPage: ListPage; + let navBar: Navbar; + let calcPage: CalculatorPage; + let prefPage: PreferencesPage; + + beforeAll(async () => { + listPage = new ListPage(); + navBar = new Navbar(); + calcPage = new CalculatorPage(); + prefPage = new PreferencesPage(); + }); + + beforeEach(async () => { + // enable evil option "empty fields on module creation" + await prefPage.navigateTo(); + await prefPage.enableEvilEmptyFields(); + await browser.sleep(200); + }); + + it("", async () => { + // open "up/downstream elevations of a reach" calculator + await navBar.clickNewCalculatorButton(); + await listPage.clickMenuEntryForCalcType(21); + await browser.sleep(200); + + expect(calcPage.checkEmptyOrFilledFields(["LargeurBerge", "Ks", "Long", "YB", "ZF1", "ZF2", "Q", "Z1", "Z2", "Dx"], + [true, true, true, true, true, true, true, true, true, true])) + }); +}); diff --git a/e2e/courbe-remous-empty-fields.e2e-spec.ts b/e2e/courbe-remous-empty-fields.e2e-spec.ts new file mode 100644 index 000000000..392075ce5 --- /dev/null +++ b/e2e/courbe-remous-empty-fields.e2e-spec.ts @@ -0,0 +1,36 @@ +import { ListPage } from "./list.po"; +import { Navbar } from "./navbar.po"; +import { browser } from "protractor"; +import { CalculatorPage } from "./calculator.po"; +import { PreferencesPage } from "./preferences.po"; + +describe("Check fields are empty in 'backwater curves' calculator when created with 'empty fields' option", () => { + let listPage: ListPage; + let navBar: Navbar; + let calcPage: CalculatorPage; + let prefPage: PreferencesPage; + + beforeAll(async () => { + listPage = new ListPage(); + navBar = new Navbar(); + calcPage = new CalculatorPage(); + prefPage = new PreferencesPage(); + }); + + beforeEach(async () => { + // enable evil option "empty fields on module creation" + await prefPage.navigateTo(); + await prefPage.enableEvilEmptyFields(); + await browser.sleep(200); + }); + + it("", async () => { + // open "backwater curves" calculator + await navBar.clickNewCalculatorButton(); + await listPage.clickMenuEntryForCalcType(4); + await browser.sleep(200); + + expect(calcPage.checkEmptyOrFilledFields(["LargeurBerge", "Ks", "Long", "YB", "ZF1", "ZF2", "Q", "Z1", "Z2", "Dx"], + [true, true, true, true, true, true, true, true, true, true])) + }); +}); diff --git a/e2e/regime-uniforme-empty-fields.e2e-spec.ts b/e2e/regime-uniforme-empty-fields.e2e-spec.ts new file mode 100644 index 000000000..ce60476f2 --- /dev/null +++ b/e2e/regime-uniforme-empty-fields.e2e-spec.ts @@ -0,0 +1,35 @@ +import { ListPage } from "./list.po"; +import { Navbar } from "./navbar.po"; +import { browser } from "protractor"; +import { CalculatorPage } from "./calculator.po"; +import { PreferencesPage } from "./preferences.po"; + +describe("Check fields are empty in 'uniform flow' calculator when created with 'empty fields' option", () => { + let listPage: ListPage; + let navBar: Navbar; + let calcPage: CalculatorPage; + let prefPage: PreferencesPage; + + beforeAll(async () => { + listPage = new ListPage(); + navBar = new Navbar(); + calcPage = new CalculatorPage(); + prefPage = new PreferencesPage(); + }); + + beforeEach(async () => { + // enable evil option "empty fields on module creation" + await prefPage.navigateTo(); + await prefPage.enableEvilEmptyFields(); + await browser.sleep(200); + }); + + it("", async () => { + // open "uniform flow" calculator + await navBar.clickNewCalculatorButton(); + await listPage.clickMenuEntryForCalcType(3); + await browser.sleep(200); + + expect(calcPage.checkEmptyOrFilledFields(["LargeurBerge", "Ks", "If", "YB", "Q", "Y"], [true, true, true, true, true, true])) + }); +}); diff --git a/e2e/section-empty-fields.e2e-spec.ts b/e2e/section-empty-fields.e2e-spec.ts new file mode 100644 index 000000000..2a336e916 --- /dev/null +++ b/e2e/section-empty-fields.e2e-spec.ts @@ -0,0 +1,35 @@ +import { ListPage } from "./list.po"; +import { Navbar } from "./navbar.po"; +import { browser } from "protractor"; +import { CalculatorPage } from "./calculator.po"; +import { PreferencesPage } from "./preferences.po"; + +describe("Check fields are empty in 'parametric section' calculator when created with 'empty fields' option", () => { + let listPage: ListPage; + let navBar: Navbar; + let calcPage: CalculatorPage; + let prefPage: PreferencesPage; + + beforeAll(async () => { + listPage = new ListPage(); + navBar = new Navbar(); + calcPage = new CalculatorPage(); + prefPage = new PreferencesPage(); + }); + + beforeEach(async () => { + // enable evil option "empty fields on module creation" + await prefPage.navigateTo(); + await prefPage.enableEvilEmptyFields(); + await browser.sleep(200); + }); + + it("", async () => { + // open "parametric section" calculator + await navBar.clickNewCalculatorButton(); + await listPage.clickMenuEntryForCalcType(2); + await browser.sleep(200); + + expect(calcPage.checkEmptyOrFilledFields(["LargeurBerge", "Ks", "If", "YB", "Q", "Y"], [true, true, true, true, true, true])); + }); +}); -- GitLab From 4be52fe5c8fc0df0cb2be0e2052c00fc5436efe5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grand?= <francois.grand@inrae.fr> Date: Fri, 7 Oct 2022 15:30:45 +0200 Subject: [PATCH 3/5] fix: parameters not empty in parametric section, backwater curves, uniform flow, reach with empty fields option refs #569 --- src/app/formulaire/definition/form-definition.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/app/formulaire/definition/form-definition.ts b/src/app/formulaire/definition/form-definition.ts index bacf4f4d1..814db2e70 100644 --- a/src/app/formulaire/definition/form-definition.ts +++ b/src/app/formulaire/definition/form-definition.ts @@ -128,6 +128,7 @@ export abstract class FormulaireDefinition extends FormulaireNode implements Obs const propsSection = new Props(); propsSection.setPropValue("calcType", CalculatorType.Section); propsSection.setPropValue("nodeType", this._defaultNodeType); + propsSection.setPropValue(Prop_NullParameters, ServiceFactory.applicationSetupService.enableEmptyFieldsOnFormInit); const section = Session.getInstance().createNub(propsSection); this.currentNub.setSection(section as acSection); } -- GitLab From 06ec8a1981412e9b76dcccab24b1e11d7b4178e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grand?= <francois.grand@inrae.fr> Date: Mon, 10 Oct 2022 08:18:00 +0200 Subject: [PATCH 4/5] fix: uniform flow: crash when computing flow with a varying a parameter see https://gitlab.irstea.fr/cassiopee/nghyd/-/merge_requests/172#note_68298 refs #569 --- src/locale/messages.en.json | 3 +++ src/locale/messages.fr.json | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/locale/messages.en.json b/src/locale/messages.en.json index 56a2f105b..47688d87d 100755 --- a/src/locale/messages.en.json +++ b/src/locale/messages.en.json @@ -230,6 +230,9 @@ "INFO_CHILD_TYPE_PUISSANCE": "power", "INFO_CHILD_TYPE_PUISSANCE_PLUR": "powers", "INFO_CHILD_TYPE_PUISSANCE_SHORT": "P", + "INFO_CHILD_TYPE_SECTION": "section", + "INFO_CHILD_TYPE_SECTION_PLUR": "sections", + "INFO_CHILD_TYPE_SECTION_SHORT": "S", "INFO_DIALOG_PARSIM_DESC": "Choose a combination of values to generate the simulation", "INFO_FIELDSET_ADD": "Add", "INFO_FIELDSET_COPY": "Copy", diff --git a/src/locale/messages.fr.json b/src/locale/messages.fr.json index 225b0751e..edbbcf847 100755 --- a/src/locale/messages.fr.json +++ b/src/locale/messages.fr.json @@ -230,6 +230,9 @@ "INFO_CHILD_TYPE_PUISSANCE": "puissance", "INFO_CHILD_TYPE_PUISSANCE_PLUR": "puissances", "INFO_CHILD_TYPE_PUISSANCE_SHORT": "P", + "INFO_CHILD_TYPE_SECTION": "section", + "INFO_CHILD_TYPE_SECTION_PLUR": "sections", + "INFO_CHILD_TYPE_SECTION_SHORT": "S", "INFO_DIALOG_PARSIM_DESC": "Choisir une combinaison de valeurs pour générer la simulation", "INFO_FIELDSET_ADD": "Ajouter", "INFO_FIELDSET_COPY": "Copier", @@ -760,4 +763,4 @@ "ERROR_VERIF_PAB_WALL_NOT_CROSSABLE": "La cloison n°%N% n'est pas franchissable", "ERROR_VERIF_PAB_DW_NOT_CROSSABLE": "La cloison aval n'est pas franchissable", "WARNING_VERIF_PAR_SPECIES_GROUP": "Les groupes d'espèces 3a, 3b et 7b sont déconseillés pour ce type de passe" -} +} \ No newline at end of file -- GitLab From 69bb4e7c278caa1d2eab4aae7321394f890e385c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grand?= <francois.grand@inrae.fr> Date: Mon, 10 Oct 2022 08:32:31 +0200 Subject: [PATCH 5/5] update jalhyd_branch to 327 issue refs #569 --- jalhyd_branch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jalhyd_branch b/jalhyd_branch index 626e97d71..5327f921c 100644 --- a/jalhyd_branch +++ b/jalhyd_branch @@ -1 +1 @@ -devel \ No newline at end of file +327-module-avec-une-section-le-mode-champs-vide-ne-fonctionne-pas -- GitLab