diff --git a/e2e/calculator.po.ts b/e2e/calculator.po.ts index 5fc98c54e65318a0b00a090f7f54e22c20f324a5..400f4b0abbc88cf80c09be86d6a159f9362823ea 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/link-to-deleted-module.e2e-spec.ts b/e2e/link-to-deleted-module.e2e-spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..380f97354a3171d49af6d3064b1605bd11a39f2e --- /dev/null +++ b/e2e/link-to-deleted-module.e2e-spec.ts @@ -0,0 +1,96 @@ +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"; + +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 () => { + // 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); + }); + + 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); + }); +}); 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 0000000000000000000000000000000000000000..b42c13d0f8ad8249514e3880592938bd726888bb --- /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); + }); +}); diff --git a/e2e/navbar.po.ts b/e2e/navbar.po.ts index 2c498a4bd9d4adcfb97f7d8283d750f5c59a843f..4fd34062accddf803373854bdaa30e18aa968298 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(); diff --git a/jalhyd_branch b/jalhyd_branch index 1f7391f92b6a3792204e07e99f71f643cc35e7e1..a210a99efcff6820e3d5434a264295a12e87646a 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 diff --git a/src/app/components/param-link/param-link.component.ts b/src/app/components/param-link/param-link.component.ts index 8e03ffeb2f39f59a2654949b2b702cf184f3deff..b62fc1cbc12093aaacc2e99c243e2e561cd576b3 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; + } } }