Commit 16502913 authored by Grand Francois's avatar Grand Francois
Browse files

test: check cross walls calculator has no empty field after calculation

refs #516
Showing with 87 additions and 35 deletions
+87 -35
...@@ -5,6 +5,37 @@ import { CalculatorPage } from "./calculator.po"; ...@@ -5,6 +5,37 @@ import { CalculatorPage } from "./calculator.po";
import { AppPage } from "./app.po"; import { AppPage } from "./app.po";
import { Navbar } from "./navbar.po"; import { Navbar } from "./navbar.po";
/**
* enable evil option "empty fields on module creation"
*/
async function enableEmptyFieldsOption(prefPage: PreferencesPage) {
await prefPage.navigateTo();
await browser.sleep(200);
await prefPage.enableEvilEmptyFields();
await browser.sleep(200);
}
/**
* check that a input set is in a given (empty/filled) state
* @param inputIds id of the inputs to check
* @param emptys empty/not empty state array
*/
async function checkFields(calcPage: CalculatorPage, inputIds: string[], emptys: boolean[]) {
let n = 0;
for (const id of inputIds) {
const inp = await calcPage.getInputById(id);
const txt = await inp.getAttribute("value");
expect(txt === "").toEqual(emptys[n]);
n++;
}
}
async function fillInput(calcPage: CalculatorPage, symbol: string) {
const inp = calcPage.getInputById(symbol);
await inp.clear();
await inp.sendKeys("1");
}
/** /**
* Check that when "empty fields on calculator creation" is enabled * Check that when "empty fields on calculator creation" is enabled
* fields are empty in the "generate fish ladder" dialog of the * fields are empty in the "generate fish ladder" dialog of the
...@@ -24,34 +55,9 @@ describe("ngHyd - check the cross walls calculator has empty fields - ", () => { ...@@ -24,34 +55,9 @@ describe("ngHyd - check the cross walls calculator has empty fields - ", () => {
}); });
beforeEach(async () => { beforeEach(async () => {
// enable evil option "empty fields on module creation" await enableEmptyFieldsOption(prefPage);
await prefPage.navigateTo();
await browser.sleep(200);
await prefPage.enableEvilEmptyFields();
await browser.sleep(200);
}); });
/**
* check that a input set is in a given (empty/filled) state
* @param inputIds id of the inputs to check
* @param emptys empty/not empty state array
*/
async function checkFields(inputIds: string[], emptys: boolean[]) {
let n = 0;
for (const id of inputIds) {
const inp = await calcPage.getInputById(id);
const txt = await inp.getAttribute("value");
expect(txt === "").toEqual(emptys[n]);
n++;
}
}
async function fillInput(symbol: string) {
const inp = calcPage.getInputById(symbol);
await inp.clear();
await inp.sendKeys("1");
}
it("in the 'generate fish ladder' dialog", async () => { it("in the 'generate fish ladder' dialog", async () => {
// open cross walls calculator // open cross walls calculator
await navBar.clickNewCalculatorButton(); await navBar.clickNewCalculatorButton();
...@@ -59,14 +65,14 @@ describe("ngHyd - check the cross walls calculator has empty fields - ", () => { ...@@ -59,14 +65,14 @@ describe("ngHyd - check the cross walls calculator has empty fields - ", () => {
await browser.sleep(200); await browser.sleep(200);
// fill inputs // fill inputs
await fillInput("Q"); await fillInput(calcPage, "Q");
await fillInput("Z1"); await fillInput(calcPage, "Z1");
await fillInput("LB"); await fillInput(calcPage, "LB");
await fillInput("BB"); await fillInput(calcPage, "BB");
await fillInput("PB"); await fillInput(calcPage, "PB");
await fillInput("0_h1"); await fillInput(calcPage, "0_h1");
await fillInput("0_L"); await fillInput(calcPage, "0_L");
await fillInput("0_CdWSL"); await fillInput(calcPage, "0_CdWSL");
// calculate // calculate
const calcButton = calcPage.getCalculateButton(); const calcButton = calcPage.getCalculateButton();
...@@ -78,6 +84,52 @@ describe("ngHyd - check the cross walls calculator has empty fields - ", () => { ...@@ -78,6 +84,52 @@ describe("ngHyd - check the cross walls calculator has empty fields - ", () => {
await genButton.click(); await genButton.click();
await browser.sleep(200); await browser.sleep(200);
await checkFields(["generatePabNbBassins"], [true]); await checkFields(calcPage, ["generatePabNbBassins"], [true]);
});
});
/**
* Check that when "empty fields on calculator creation" is enabled
* fields are not empty after calculation
*/
describe("ngHyd - check the cross walls calculator has no empty field - ", () => {
let prefPage: PreferencesPage;
let listPage: ListPage;
let calcPage: CalculatorPage;
let navBar: Navbar;
beforeAll(() => {
prefPage = new PreferencesPage();
listPage = new ListPage();
calcPage = new CalculatorPage();
navBar = new Navbar();
});
beforeEach(async () => {
await enableEmptyFieldsOption(prefPage);
});
it("after calculation", async () => {
// open cross walls calculator
await navBar.clickNewCalculatorButton();
await listPage.clickMenuEntryForCalcType(10);
await browser.sleep(200);
// fill inputs
await fillInput(calcPage, "Q");
await fillInput(calcPage, "Z1");
await fillInput(calcPage, "LB");
await fillInput(calcPage, "BB");
await fillInput(calcPage, "PB");
await fillInput(calcPage, "0_h1");
await fillInput(calcPage, "0_L");
await fillInput(calcPage, "0_CdWSL");
// calculate
const calcButton = calcPage.getCalculateButton();
await calcButton.click();
await browser.sleep(200);
await checkFields(calcPage, ["Q", "Z1", "LB", "BB", "PB", "0_h1", "0_L", "0_CdWSL"], [false, false, false, false, false, false, false, false]);
}); });
}); });
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment