From 0aea540f1139c7f477fe81aaad176addc11e3c23 Mon Sep 17 00:00:00 2001 From: "mathias.chouet" <mathias.chouet@irstea.fr> Date: Wed, 27 Mar 2019 17:24:10 +0100 Subject: [PATCH] Fix #184 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit plus mise à jour test e2e --- e2e/calculator.po.ts | 8 +++++ e2e/load-linked-params.e2e-spec.ts | 31 ++++++++++++++++++- .../field-set/field-set.component.html | 2 +- .../param-field-line.component.ts | 4 +-- 4 files changed, 41 insertions(+), 4 deletions(-) diff --git a/e2e/calculator.po.ts b/e2e/calculator.po.ts index c9276cad4..b47d2ef68 100644 --- a/e2e/calculator.po.ts +++ b/e2e/calculator.po.ts @@ -50,6 +50,14 @@ export class CalculatorPage { return element.all(by.css('mat-button-toggle.radio_cal[ng-reflect-checked="true"]')); } + getAddStructureButton() { + return element(by.css("fieldset-container .hyd-window-btns button.add-structure")); + } + + getAllLinkButtons() { + return element.all(by.css("mat-button-toggle.radio_link")); + } + scrollTo(elt: ElementFinder) { browser.controlFlow().execute(function() { browser.executeScript("arguments[0].scrollIntoView(true)", elt.getWebElement()); diff --git a/e2e/load-linked-params.e2e-spec.ts b/e2e/load-linked-params.e2e-spec.ts index 56f84364a..2d6e91a20 100644 --- a/e2e/load-linked-params.e2e-spec.ts +++ b/e2e/load-linked-params.e2e-spec.ts @@ -1,4 +1,5 @@ import { AppPage } from "./app.po"; +import { ListPage } from "./list.po"; import { CalculatorPage } from "./calculator.po"; import { Navbar } from "./navbar.po"; import { SideNav } from "./sidenav.po"; @@ -11,6 +12,7 @@ import { browser } from "protractor"; */ describe("ngHyd − load session with multiple linked parameters", () => { let startPage: AppPage; + let listPage: ListPage; let calcPage: CalculatorPage; let navbar: Navbar; let sidenav: SideNav; @@ -20,10 +22,11 @@ describe("ngHyd − load session with multiple linked parameters", () => { calcPage = new CalculatorPage(); navbar = new Navbar(); sidenav = new SideNav(); + listPage = new ListPage(); } beforeEach(init); - it("when loading session-liens-spaghetti.json, all links should point to the right target", async () => { + it("when loading session-liens-spaghetti.json, all links should point to the right target", async () => { await startPage.navigateTo(); await navbar.clickMenuButton(); @@ -94,4 +97,30 @@ describe("ngHyd − load session with multiple linked parameters", () => { expect(lo_brv).toEqual("LargeurBerge (Sec. param.)"); }); + it("when creating parallel structures, devices should be linkabke to one another", async () => { + + // 1. check Lois d'ouvrages + await startPage.navigateTo(); + await listPage.clickMenuEntryForCalcType(8); + await calcPage.getAddStructureButton().click(); + const nb1 = await calcPage.getAllLinkButtons().count(); + expect(nb1).toBe(8); // link buttons on children but not on parent + + // 2. check Passe à bassin: Cloisons + await startPage.navigateTo(); + await listPage.clickMenuEntryForCalcType(10); + await calcPage.getAddStructureButton().click(); + const nb2 = await calcPage.getAllLinkButtons().count(); + expect(nb2).toBe(4); // link buttons on children but not on parent + + + // 3. check Lois de déversoirs dénoyés + await startPage.navigateTo(); + await listPage.clickMenuEntryForCalcType(9); + await calcPage.getAddStructureButton().click(); + const nb3 = await calcPage.getAllLinkButtons().count(); + expect(nb3).toBe(6); // link buttons on children but not on parent + + }); + }); diff --git a/src/app/components/field-set/field-set.component.html b/src/app/components/field-set/field-set.component.html index 444001156..b87bbe724 100644 --- a/src/app/components/field-set/field-set.component.html +++ b/src/app/components/field-set/field-set.component.html @@ -3,7 +3,7 @@ {{ title }} </mat-card-title> <div *ngIf="showButtons" class="hyd-window-btns"> - <button type="button" mat-icon-button (click)="onAddClick()"> + <button type="button" mat-icon-button (click)="onAddClick()" class="add-structure"> <mat-icon>add_box</mat-icon> </button> <button type="button" mat-icon-button [disabled]="! enableRemoveButton" (click)="onRemoveClick()"> diff --git a/src/app/components/param-field-line/param-field-line.component.ts b/src/app/components/param-field-line/param-field-line.component.ts index e147f1f9f..47a79d393 100644 --- a/src/app/components/param-field-line/param-field-line.component.ts +++ b/src/app/components/param-field-line/param-field-line.component.ts @@ -203,8 +203,8 @@ export class ParamFieldLineComponent implements OnChanges { } // ou un seul module de calcul "ouvrages parallèles" - if (this._formService.formulaires[0].calculatorType === CalculatorType.ParallelStructure) { - const ps: ParallelStructure = this._formService.formulaires[0].currentNub as ParallelStructure; + if (this._formService.formulaires[0].currentNub instanceof ParallelStructure) { + const ps: ParallelStructure = this._formService.formulaires[0].currentNub; if (ps.structures.length > 1) { return this._formService.getLinkableValues(this.param).length > 0; } -- GitLab