An error occurred while loading the file. Please try again.
-
dkuhlman authorede45e59ee
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);
async function doTheJob(filename: string, topMostId: string, bottomMostId: string) {
// load session file
await startPage.navigateTo();
await navbar.clickMenuButton();
await browser.sleep(200);
await sidenav.clickLoadSessionButton();
await browser.sleep(200);
await sidenav.loadSessionFile(filename);
await browser.sleep(500);
expect(await navbar.getAllCalculatorTabs().count()).toBe(3);
// 1. get top most module
await navbar.clickCalculatorTabForUid(topMostId);
// check that "compute" button is active
const calcButton = calcPage.getCalculateButton();
const disabledState = await calcButton.getAttribute("disabled");
expect(disabledState).not.toBe("disabled");
// click "compute" button
await calcButton.click();
// check all 3 modules for results
for (let i = 0; i < 3; i++) {
await navbar.clickCalculatorTab(i);
const hasResults = await calcPage.hasResults();
expect(hasResults).toBe(true);
}
// 2. get bottom-most module
await navbar.clickCalculatorTabForUid(bottomMostId);
// 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);
const hasResults = await calcPage.hasResults();
expect(hasResults).toBe(false);
}
}
7172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
it("when loading session-cascade-params.json, computation should not be chained, but results reset should", 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-cascade-params.json");
await browser.sleep(500);
expect(await navbar.getAllCalculatorTabs().count()).toBe(3);
// 1. get top most module
await navbar.clickCalculatorTabForUid("dWs5bm");
// check that "compute" button is active
const calcButton = calcPage.getCalculateButton();
const disabledState = await calcButton.getAttribute("disabled");
expect(disabledState).not.toBe("disabled");
// click "compute" button
await calcButton.click();
// only top-most module should have results
let hasResults = await calcPage.hasResults();
// other two should not
await navbar.clickCalculatorTabForUid("OGFzOH");
hasResults = await calcPage.hasResults();
expect(hasResults).toBe(false);
await navbar.clickCalculatorTabForUid("NWp1a3");
hasResults = await calcPage.hasResults();
expect(hasResults).toBe(false);
// 2. get bottom-most module
await navbar.clickCalculatorTabForUid("OGFzOH");
// 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);
}
});
it("when loading session-cascade-results.json, computation and results reset should be chained", 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-cascade-results.json");
await browser.sleep(500);
expect(await navbar.getAllCalculatorTabs().count()).toBe(3);
// 1. get top most module
await navbar.clickCalculatorTabForUid("YWFqMD");
// check that "compute" button is active
const calcButton = calcPage.getCalculateButton();
const disabledState = await calcButton.getAttribute("disabled");
expect(disabledState).not.toBe("disabled");
// click "compute" button
await calcButton.click();
// check all 3 modules for results
for (let i = 0; i < 3; i++) {
await navbar.clickCalculatorTab(i);