• Mathias Chouet's avatar
    Fix #329 · a00f5cda
    Mathias Chouet authored
    when changing language, recalculating Nub that already had results was breaking chained results
    a00f5cda
calculate-linked-params.e2e-spec.ts 11.19 KiB
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";
import { browser, by } from "protractor";
/**
 * Uses an example configuration to calculate :
 *  - with a parameter linked to a single parameter
 *  - with a parameter linked to a single parameter, plus local variated parameter
 *  - with a parameter linked to a variated parameter
 *  - with a parameter linked to a single result
 *  - with a parameter linked to a single result, plus local variated parameter
 *  - with a parameter linked to a variated result
 *  - with a parameter linked to a single extra result
 *  - with a parameter linked to a single extra result, plus local variated parameter
 *  - with a parameter linked to a variated extra result
 *  => plus all those combinations in indeirect link mode (linked parameter target
 *     is also a linked parameter)
describe("ngHyd − calculate with linked parameters", () => {
  let listPage: ListPage;
  let calcPage: CalculatorPage;
  let navBar: Navbar;
  let startPage: AppPage;
  let sidenav: SideNav;
  beforeEach(() => {
    listPage = new ListPage();
    calcPage = new CalculatorPage();
    navBar = new Navbar();
    startPage = new AppPage();
    sidenav = new SideNav();
  });
  async function computeAndCheckPresenceOfResults() {
    // check that "compute" button is active
    const calcButton = calcPage.getCalculateButton();
    const disabledState = await calcButton.getAttribute("disabled");
    expect(disabledState).not.toBe("true");
    // click "compute" button
    await calcButton.click();
    // check that result is not empty
    const hasResults = await calcPage.hasResults();
    expect(hasResults).toBe(true);
  it(" − direct links : parameter linked to a single parameter", async () => {
    // create a Régime uniforme
    await startPage.navigateTo();
    await listPage.clickMenuEntryForCalcType(3);
    // create a PAB : dimensions
    await navBar.clickNewCalculatorButton();
    await listPage.clickMenuEntryForCalcType(5);
    // link Y to Y (R uniforme)
    const Y = calcPage.getInputById("Y");
    await calcPage.setParamMode(Y, "link");
    const sel = await calcPage.getLinkedValueSelect(Y);
    await calcPage.changeSelectValue(sel, 0);
    await computeAndCheckPresenceOfResults();
  });
  it(" − direct links : parameter linked to a single parameter, plus local variated parameter", async () => {
    // create a Régime uniforme
    await startPage.navigateTo();
7172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
await listPage.clickMenuEntryForCalcType(3); // create a PAB : dimensions await navBar.clickNewCalculatorButton(); await listPage.clickMenuEntryForCalcType(5); // link Y to Y (R uniforme) const Y = calcPage.getInputById("Y"); await calcPage.setParamMode(Y, "link"); const sel = await calcPage.getLinkedValueSelect(Y); await calcPage.changeSelectValue(sel, 0); // vary W const W = calcPage.getInputById("W"); await calcPage.setParamMode(W, "var"); await computeAndCheckPresenceOfResults(); }); it(" − direct links : parameter linked to a variated parameter", async () => { // create a Régime uniforme await startPage.navigateTo(); await listPage.clickMenuEntryForCalcType(3); // vary Y const Y1 = calcPage.getInputById("Y"); await calcPage.setParamMode(Y1, "var"); // create a PAB : dimensions await navBar.clickNewCalculatorButton(); await listPage.clickMenuEntryForCalcType(5); // link Y to Y (R uniforme) const Y2 = calcPage.getInputById("Y"); await calcPage.setParamMode(Y2, "link"); const sel = await calcPage.getLinkedValueSelect(Y2); await calcPage.changeSelectValue(sel, 0); await computeAndCheckPresenceOfResults(); }); it(" − direct links : parameter linked to a single result", async () => { // create a Régime uniforme await startPage.navigateTo(); await listPage.clickMenuEntryForCalcType(3); // calculate Y const Y1 = calcPage.getInputById("Y"); await calcPage.setParamMode(Y1, "cal"); // create a PAB : dimensions await navBar.clickNewCalculatorButton(); await listPage.clickMenuEntryForCalcType(5); // link Y to Y (R uniforme) const Y2 = calcPage.getInputById("Y"); await calcPage.setParamMode(Y2, "link"); const sel = await calcPage.getLinkedValueSelect(Y2); await calcPage.changeSelectValue(sel, 0); await computeAndCheckPresenceOfResults(); }); it(" − direct links : parameter linked to a single result, plus local variated parameter", async () => { // create a Régime uniforme await startPage.navigateTo(); await listPage.clickMenuEntryForCalcType(3); // calculate Y const Y1 = calcPage.getInputById("Y"); await calcPage.setParamMode(Y1, "cal"); // create a PAB : dimensions await navBar.clickNewCalculatorButton(); await listPage.clickMenuEntryForCalcType(5); // link Y to Y (R uniforme) const Y2 = calcPage.getInputById("Y");
141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
await calcPage.setParamMode(Y2, "link"); const sel = await calcPage.getLinkedValueSelect(Y2); await calcPage.changeSelectValue(sel, 0); // vary W const W = calcPage.getInputById("W"); await calcPage.setParamMode(W, "var"); await computeAndCheckPresenceOfResults(); }); it(" − direct links : parameter linked to a variated result", async () => { // create a Régime uniforme await startPage.navigateTo(); await listPage.clickMenuEntryForCalcType(3); // vary Q const Q = calcPage.getInputById("Q"); await calcPage.setParamMode(Q, "var"); // calculate Y const Y1 = calcPage.getInputById("Y"); await calcPage.setParamMode(Y1, "cal"); // create a PAB : dimensions await navBar.clickNewCalculatorButton(); await listPage.clickMenuEntryForCalcType(5); // link Y to Y (R uniforme) const Y2 = calcPage.getInputById("Y"); await calcPage.setParamMode(Y2, "link"); const sel = await calcPage.getLinkedValueSelect(Y2); await calcPage.changeSelectValue(sel, 0); await computeAndCheckPresenceOfResults(); }); it(" − direct links : parameter linked to a single extra result", async () => { // create a Déversoirs dénoyés await startPage.navigateTo(); await listPage.clickMenuEntryForCalcType(9); // create a Régime uniforme await navBar.clickNewCalculatorButton(); await listPage.clickMenuEntryForCalcType(3); // link Q to CvQT (Déversoirs dénoyés) const Q = calcPage.getInputById("Q"); await calcPage.setParamMode(Q, "link"); const sel = await calcPage.getLinkedValueSelect(Q); await calcPage.changeSelectValue(sel, 1); await computeAndCheckPresenceOfResults(); }); it(" − direct links : parameter linked to a single extra result, plus local variated parameter", async () => { // create a Déversoirs dénoyés await startPage.navigateTo(); await listPage.clickMenuEntryForCalcType(9); // create a Régime uniforme await navBar.clickNewCalculatorButton(); await listPage.clickMenuEntryForCalcType(3); // link Q to CvQT (Déversoirs dénoyés) const Q = calcPage.getInputById("Q"); await calcPage.setParamMode(Q, "link"); const sel = await calcPage.getLinkedValueSelect(Q); await calcPage.changeSelectValue(sel, 1); // vary YB const YB = calcPage.getInputById("YB"); await calcPage.setParamMode(YB, "var"); await computeAndCheckPresenceOfResults(); });
211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
it(" − direct links : parameter linked to a variated extra result", async () => { // create a Déversoirs dénoyés await startPage.navigateTo(); await listPage.clickMenuEntryForCalcType(9); // vary BR const BR = calcPage.getInputById("BR"); await calcPage.setParamMode(BR, "var"); // create a Régime uniforme await navBar.clickNewCalculatorButton(); await listPage.clickMenuEntryForCalcType(3); // link Q to CvQT (Déversoirs dénoyés) const Q = calcPage.getInputById("Q"); await calcPage.setParamMode(Q, "link"); const sel = await calcPage.getLinkedValueSelect(Q); await calcPage.changeSelectValue(sel, 1); await computeAndCheckPresenceOfResults(); }); it(" − multiple variated parameters, including a linked one (#253)", async () => { // load session file await startPage.navigateTo(); await navBar.clickMenuButton(); await browser.sleep(200); await sidenav.clickLoadSessionButton(); await browser.sleep(200); await sidenav.loadSessionFile("./session/session-multivar-link.json"); await browser.sleep(500); expect(await navBar.getAllCalculatorTabs().count()).toBe(2); // calculate await navBar.clickCalculatorTab(0); const calcButton = calcPage.getCalculateButton(); await calcButton.click(); // check that result is not empty const hasResults = await calcPage.hasResults(); expect(hasResults).toBe(true); // check that there are 6 parameters columns in the variated results table : // Q, Z2, Z1, + 4 for device #1 expect(await calcPage.getAllVariatedResultsTableHeaders().count()).toBe(7); // check that number of rows in the variated results table equals number of variated values const varRows = calcPage.getAllVariatedResultsRows(); const nbRows = await varRows.count(); expect(nbRows).toBe(191); // boundaries are included // check that all parameters have values for all iterations (Z2 might miss some if repeat strategy is not applied) const lastRow = varRows.get(nbRows - 1); const tds = await lastRow.all(by.css("td")); tds.forEach((td) => { expect(td.getText()).not.toBe(""); }); }); it(" − bug nghyd#329 : unexpected ERR in results table", async () => { await startPage.navigateTo(); // load session await navBar.clickMenuButton(); await browser.sleep(200); await sidenav.clickLoadSessionButton(); await browser.sleep(200); await sidenav.loadSessionFile("./session/session-pab-chain-nghyd-329.json"); await browser.sleep(200); expect(await navBar.getAllCalculatorTabs().count()).toBe(3); // calculate PAB-Dimensions await navBar.clickCalculatorTab(2);
281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
await browser.sleep(200); // click "compute" button const calcButton = calcPage.getCalculateButton(); await calcButton.click(); // check that result is not empty expect(await calcPage.hasResults()).toBe(true); // check that ERR is not present in Volume line of results table let frt = calcPage.getFixedResultsTable(); let volumeRow = calcPage.getNthRow(frt, 3); let volumeCol = calcPage.getNthColumn(volumeRow, 2); let volume = await volumeCol.getText(); console.log(">> found volume (1)", volume); expect(Number(volume)).toBeCloseTo(44.565, 3); // click PAB-Nombre tab await navBar.clickCalculatorTab(0); await browser.sleep(200); // go back to PAB-Dimensions await navBar.clickCalculatorTab(2); await browser.sleep(200); // check that ERR is not present in Volume line of results table frt = calcPage.getFixedResultsTable(); volumeRow = calcPage.getNthRow(frt, 3); volumeCol = calcPage.getNthColumn(volumeRow, 2); volume = await volumeCol.getText(); console.log(">> found volume (2)", volume); expect(Number(volume)).toBeCloseTo(44.565, 3); }); });