An error occurred while loading the file. Please try again.
-
Mathias Chouet authoredf4a7d0d3
import { ListPage } from "./list.po";
import { CalculatorPage } from "./calculator.po";
import { Navbar } from "./navbar.po";
/**
* For all calculators, try to calculate every parameter: check that only one parameter
* is set to CAL mode, trigger the calculation, check that result is not empty
*/
describe("ngHyd − calculate all parameters of all calculators", () => {
let listPage: ListPage;
let calcPage: CalculatorPage;
let navBar: Navbar;
beforeEach(() => {
listPage = new ListPage();
calcPage = new CalculatorPage();
navBar = new Navbar();
});
// get calculators list (IDs) @TODO read it from config, but can't import jalhyd here :/
const calcTypes = [ 0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 15, 17, 18, 19, 20, 21 ];
// for each calculator
for (const ct of calcTypes) {
describe(" − calculate all parameters of calculator type [" + ct + "]", async () => {
it("", async () => {
// go to list page
await listPage.navigateTo();
// click calculator button (instanciate)
await listPage.clickMenuEntryForCalcType(ct);
// get all parameters IDs
const inputs = await calcPage.getParamInputsHavingCalcMode();
if (inputs.length > 0) {
// for each param
for (const input of inputs) {
// click "calc" mode button for this parameter
await calcPage.setParamMode(input, "cal");
// check that only 1 button is in "calc" state
const nbParamsCalc = await calcPage.getCheckedCalcModeButtons().count();
expect(nbParamsCalc).toBe(1);
// 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);
}
} else {
// module has no calculable params, just click the "compute" button
// 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);
}
});
});
}
});