From 3691cf15fab05aba7720897c8e93cd3c36fbe154 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grand?= <francois.grand@inrae.fr> Date: Tue, 25 Oct 2022 14:26:48 +0200 Subject: [PATCH 1/5] test(e2e): check that a linked parameter is set to fixed mode after deleting target module refs #571 --- e2e/link-to-deleted-module.e2e-spec.ts | 55 ++++++++++++++++++++++++++ e2e/navbar.po.ts | 15 ++++++- 2 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 e2e/link-to-deleted-module.e2e-spec.ts diff --git a/e2e/link-to-deleted-module.e2e-spec.ts b/e2e/link-to-deleted-module.e2e-spec.ts new file mode 100644 index 000000000..a5b7566ca --- /dev/null +++ b/e2e/link-to-deleted-module.e2e-spec.ts @@ -0,0 +1,55 @@ +import { browser, by, element } from "protractor"; +import { CalculatorPage } from "./calculator.po"; +import { Navbar } from "./navbar.po"; +import { PreferencesPage } from "./preferences.po"; + +describe("linked parameter - ", () => { + let calcPage: CalculatorPage; + let prefPage: PreferencesPage; + let navBar: Navbar; + + beforeAll(() => { + calcPage = new CalculatorPage(); + prefPage = new PreferencesPage(); + navBar = new Navbar(); + }); + + beforeEach(async () => { + // browser.manage().window().setPosition(2000, 30); + + // disable evil option "empty fields on module creation" + await prefPage.navigateTo(); + await prefPage.disableEvilEmptyFields(); + await browser.sleep(200); + + await navBar.clickNewCalculatorButton(); + }); + + it("delete linked module", async () => { + // open "channel flow with hydraulic structures" example + const examples = await element.all(by.css("#examples-list .load-example")); + await examples[1].click(); + await browser.sleep(500); + + // select "up/downstream elevations of a reach" tab + await navBar.clickCalculatorTab(1); + await browser.sleep(500); + + // close "solver" calculator + await navBar.middleClickCalculatorTab(3); + + // reselect "up/downstream elevations of a reach" tab + await navBar.clickCalculatorTab(1); + await browser.sleep(500); + + // close second "parallel structures" calculator + await navBar.middleClickCalculatorTab(2); + + // close first "parallel structures" calculator + await navBar.middleClickCalculatorTab(0); + + // check Z2 input is in "fixed" state in remaining calculator + const inpZ2 = calcPage.getInputById("Z2"); + expect(await calcPage.inputIsInFixedMode(inpZ2)).toBe(true); + }); +}); diff --git a/e2e/navbar.po.ts b/e2e/navbar.po.ts index 2c498a4bd..4fd34062a 100644 --- a/e2e/navbar.po.ts +++ b/e2e/navbar.po.ts @@ -1,4 +1,4 @@ -import { by, element, protractor } from "protractor"; +import { browser, Button, by, element, protractor } from "protractor"; export class Navbar { getAllCalculatorTabs() { @@ -69,6 +69,19 @@ export class Navbar { await tabs.get(r).click(); } + /** + * close nth calculator by clicking with middle mouse button + * @param confirmCloseDialog true to confirm opening dialog and indeed close calculator + */ + async middleClickCalculatorTab(n: number, confirmCloseDialog: boolean = true) { + const calcTabs = this.getAllCalculatorTabs(); + await browser.actions().click(calcTabs.get(n), Button.MIDDLE).perform(); + if (confirmCloseDialog) { + const btns = element.all(by.css("dialog-confirm-close-calc .mat-dialog-actions button")); + await btns.get(1).click(); + } + } + async clickNewCalculatorButton() { const ncb = this.getNewCalculatorButton(); await ncb.click(); -- GitLab From 0b2021b206c8efc00e37c0a4fc15ef313c5ed3c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grand?= <francois.grand@inrae.fr> Date: Tue, 25 Oct 2022 16:43:41 +0200 Subject: [PATCH 2/5] fix: a linked parameter remains linked after deleting target module (fixed in cassiopee/jalhyd#329) refs #571 --- jalhyd_branch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jalhyd_branch b/jalhyd_branch index 1f7391f92..a210a99ef 100644 --- a/jalhyd_branch +++ b/jalhyd_branch @@ -1 +1 @@ -master +329-un-parametre-lie-ne-change-pas-d-etat-apres-la-suppression-du-module-cible -- GitLab From e45bdf023e5da8a043951759f9da4fd359911000 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grand?= <francois.grand@inrae.fr> Date: Tue, 25 Oct 2022 15:36:05 +0200 Subject: [PATCH 3/5] test(e2e): check that a linked parameter in a parametric section calculator remains linked after changing section type refs #572 --- e2e/calculator.po.ts | 11 ++++ e2e/linked-parameter-section-type.e2e-spec.ts | 50 +++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 e2e/linked-parameter-section-type.e2e-spec.ts diff --git a/e2e/calculator.po.ts b/e2e/calculator.po.ts index 5fc98c54e..400f4b0ab 100644 --- a/e2e/calculator.po.ts +++ b/e2e/calculator.po.ts @@ -145,6 +145,17 @@ export class CalculatorPage { return await button.getAttribute("ng-reflect-checked") === "true"; } + /** + * @returns true if "linked mode" button linked to an input is selected + */ + async inputIsInLinkedMode(input: ElementFinder): Promise<boolean> { + // get parent (div.container) + const container = await this.findParentContainer(input); + // find calc radio button + const button: ElementFinder = container.element(by.css("mat-button-toggle.radio_link")); + return await button.getAttribute("ng-reflect-checked") === "true"; + } + async hasResults() { return ( await this.presentAndVisible("fixedvar-results fixed-results > .fixed-results-container") diff --git a/e2e/linked-parameter-section-type.e2e-spec.ts b/e2e/linked-parameter-section-type.e2e-spec.ts new file mode 100644 index 000000000..b42c13d0f --- /dev/null +++ b/e2e/linked-parameter-section-type.e2e-spec.ts @@ -0,0 +1,50 @@ +import { browser } from "protractor"; +import { ListPage } from "./list.po"; +import { Navbar } from "./navbar.po"; +import { PreferencesPage } from "./preferences.po"; +import { CalculatorPage } from "./calculator.po"; + +describe("linked parameter in calculator with section - ", () => { + 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 () => { + // disable evil option "empty fields on module creation" + await prefPage.navigateTo(); + await prefPage.disableEvilEmptyFields(); + await browser.sleep(200); + }); + + it("modify section type", async () => { + browser.manage().window().setPosition(2000, 30); + + // open first "parametric section" calculator + await navBar.clickNewCalculatorButton(); + await listPage.clickMenuEntryForCalcType(2); + await browser.sleep(200); + + // open second "parametric section" calculator + await navBar.clickNewCalculatorButton(); + await listPage.clickMenuEntryForCalcType(2); + await browser.sleep(200); + + // set Q parameter to linked mode + const inputQ = calcPage.getInputById("Q"); + await calcPage.setParamMode(inputQ, "link"); + + // change section type + await calcPage.changeSelectValue(calcPage.getSelectById("select_section"), 3); // mode "parabolique" + + // check Q is still in linked mode + expect(await calcPage.inputIsInLinkedMode(inputQ)).toBe(true); + }); +}); -- GitLab From 3b982a50a0e8c1b43baea2050cab48d47eddcff2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grand?= <francois.grand@inrae.fr> Date: Wed, 26 Oct 2022 10:37:29 +0200 Subject: [PATCH 4/5] test(e2e): duplicate module, link parameter, close 1st module, duplicate refs #571 --- e2e/link-to-deleted-module.e2e-spec.ts | 41 ++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/e2e/link-to-deleted-module.e2e-spec.ts b/e2e/link-to-deleted-module.e2e-spec.ts index a5b7566ca..380f97354 100644 --- a/e2e/link-to-deleted-module.e2e-spec.ts +++ b/e2e/link-to-deleted-module.e2e-spec.ts @@ -1,5 +1,6 @@ import { browser, by, element } from "protractor"; import { CalculatorPage } from "./calculator.po"; +import { ListPage } from "./list.po"; import { Navbar } from "./navbar.po"; import { PreferencesPage } from "./preferences.po"; @@ -7,11 +8,13 @@ describe("linked parameter - ", () => { let calcPage: CalculatorPage; let prefPage: PreferencesPage; let navBar: Navbar; + let listPage: ListPage; beforeAll(() => { calcPage = new CalculatorPage(); prefPage = new PreferencesPage(); navBar = new Navbar(); + listPage = new ListPage(); }); beforeEach(async () => { @@ -52,4 +55,42 @@ describe("linked parameter - ", () => { const inpZ2 = calcPage.getInputById("Z2"); expect(await calcPage.inputIsInFixedMode(inpZ2)).toBe(true); }); + + it("delete linked module and duplicate remaining one", async () => { + // open "fish ladder: fall" calculator + await listPage.clickMenuEntryForCalcType(12); + await browser.sleep(200); + + // clone calculator + await calcPage.clickCloneCalcButton(); + await browser.sleep(200); + + // set DH in link mode + let inpDH = calcPage.getInputById("DH"); + await calcPage.setParamMode(inpDH, "link"); + await browser.sleep(200); + + // close 1st calculator + await navBar.middleClickCalculatorTab(0); + await browser.sleep(200); + + // check DH input is in "fixed" state in remaining calculator (not the aim of this test) + inpDH = calcPage.getInputById("DH"); + expect(await calcPage.inputIsInFixedMode(inpDH)).toBe(true); + + // set DH to calculated mode + await calcPage.setParamMode(inpDH, "cal"); + + // clone calculator + await calcPage.clickCloneCalcButton(); + await browser.sleep(200); + + // select 1st tab + await navBar.clickCalculatorTab(0); + await browser.sleep(500); + + // check DH input is in "calc" mode + inpDH = calcPage.getInputById("DH"); + expect(await calcPage.inputIsInCalculatedMode(inpDH)).toBe(true); + }); }); -- GitLab From d6999f08cd480b4032dbe8796030915955209764 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grand?= <francois.grand@inrae.fr> Date: Wed, 26 Oct 2022 15:25:17 +0200 Subject: [PATCH 5/5] fix: linked parameter incorrectly reset to fixed on form creation refs #571 --- src/app/components/param-link/param-link.component.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/app/components/param-link/param-link.component.ts b/src/app/components/param-link/param-link.component.ts index 8e03ffeb2..b62fc1cbc 100644 --- a/src/app/components/param-link/param-link.component.ts +++ b/src/app/components/param-link/param-link.component.ts @@ -259,9 +259,11 @@ export class ParamLinkComponent implements OnChanges, Observer, OnDestroy { } public updateParamList() { + let noMoreTarget = false; // liste des paramètres liables if (this.param.valueMode === ParamValueMode.LINK) { this._linkableParams = this.formService.getLinkableValues(this.param); + noMoreTarget = this._linkableParams.length === 0; } else { this._linkableParams = []; } @@ -286,8 +288,10 @@ export class ParamLinkComponent implements OnChanges, Observer, OnDestroy { } } else { this._currentIndex = -1; - // back to SINGLE mode by default - this.param.valueMode = ParamValueMode.SINGLE; + // back to SINGLE mode by default if no more target module available + if (noMoreTarget) { + this.param.valueMode = ParamValueMode.SINGLE; + } } } -- GitLab