compute-reset-chained-links.e2e-spec.ts 4.06 KiB
import { AppPage } from "./app.po";
import { CalculatorPage } from "./calculator.po";
import { Navbar } from "./navbar.po";
import { SideNav } from "./sidenav.po";
import { browser } from "protractor";
/**
 * Load a session containing 3 calculators, having linked parameters
 * from one to another, triggers computation from the top-most, triggers
 * results reset from the bottom-most.
 * Does it once with parameters linked to parameters, once with parameters
 * linked to results.
describe("ngHyd − compute then reset chained results", () => {
  let startPage: AppPage;
  let calcPage: CalculatorPage;
  let navbar: Navbar;
  let sidenav: SideNav;
  function init() {
      startPage = new AppPage();
      calcPage = new CalculatorPage();
      navbar = new Navbar();
      sidenav = new SideNav();
  beforeEach(init);
  it("when loading session-cascade-params.json, computation should not be chained, but results reset should be", 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-cascade-params.json");
    await browser.sleep(500);
    expect(await navbar.getAllCalculatorTabs().count()).toBe(3);
    // 1. get down-most module
    await navbar.clickCalculatorTabForUid("Y2l2Y3");
    // check that "compute" button is active
    const calcButton = calcPage.getCalculateButton();
    const disabledState = await calcButton.getAttribute("disabled");
    // expect(disabledState).not.toBe("true"); // for whatever reason the button is disabled, but clicking it works anyway
    // click "compute" button
    await calcButton.click();
    // only down-most module should have results
    let hasResults = await calcPage.hasResults();
    // other two should not
    await navbar.clickCalculatorTabForUid("ZTFxeW");
    hasResults = await calcPage.hasResults();
    expect(hasResults).toBe(false);
    await navbar.clickCalculatorTabForUid("Z3EwY2");
    hasResults = await calcPage.hasResults();
    expect(hasResults).toBe(true);
    // 2. get up-most module
    await navbar.clickCalculatorTabForUid("ZTFxeW");
    // modify any input (for ex. "Ks")
    await calcPage.getInputById("Ks").clear();
    await calcPage.getInputById("Ks").sendKeys("42");
    // check all 3 modules for absence of results
    for (let i = 0; i < 3; i++) {
      await navbar.clickCalculatorTab(i);
      hasResults = await calcPage.hasResults();
      expect(hasResults).toBe(false);