diff --git a/e2e/bief-empty-fields.e2e-spec.ts b/e2e/bief-empty-fields.e2e-spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..fd9fc0a449086ced16e0b67183c2ccb3856a56f3 --- /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/calculator.po.ts b/e2e/calculator.po.ts index cb46ead62327610f042b9b62afa357e44d36fb81..5fc98c54e65318a0b00a090f7f54e22c20f324a5 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/courbe-remous-empty-fields.e2e-spec.ts b/e2e/courbe-remous-empty-fields.e2e-spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..392075ce58b5949070ab5d8b3c147561ee19ae8c --- /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/examples-empty-fields.e2e-spec.ts b/e2e/examples-empty-fields.e2e-spec.ts index 4356743a2d98050163a0d6ac2295f0a680e262b7..08f40c467f44678244027dbcd7487e56c16dc6aa 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 d653ecbc3060cdf96944682a3f710676ef299a29..60f2512f61631479c1f06d3ffd50072033ff5a20 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 7e99a7de489e6eb9effcb0da652816bed78fbbb4..6b19d4c3e901ed6d6a0fd2a13743c82d17b00a6b 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 6618d97cbf47d8470aed0a208a773f36b5434cb9..8c1cfb79b5c2ff8309cae6e1814b9c0408dfb02c 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 () => { 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 0000000000000000000000000000000000000000..ce60476f2ff67af159fd68fb5b825a4e1003e5e7 --- /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 0000000000000000000000000000000000000000..2a336e916256a8e954fe69ff51df6a5b2dbe80e4 --- /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])); + }); +}); diff --git a/src/app/formulaire/definition/form-definition.ts b/src/app/formulaire/definition/form-definition.ts index bacf4f4d1ee97117db288b0ac8188008fc68b6ca..814db2e708fde90832361c51d496bf8a6c0531c2 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); } diff --git a/src/locale/messages.en.json b/src/locale/messages.en.json index 80c1a982ce9683d9fce6e7d7ea56814cdea0a99e..4416adeefc9d8d8fd7f01f41a3cbef17676693aa 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 77a92907f461fbc5f0771b1fbdf5f43f6e28b21a..4161aea6c0d2697cff2267b91eeb73ed698299ed 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", @@ -761,4 +764,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