Skip to content
Snippets Groups Projects
Commit 59c6168d authored by François Grand's avatar François Grand
Browse files

refactor(e2e): move empty input checking functions to calculator.po

refs #569
parent cfd9c237
No related branches found
No related tags found
1 merge request!172Resolve "Module avec une section: le mode champs vide ne fonctionne pas"
......@@ -329,10 +329,35 @@ export class CalculatorPage {
if (!hasDot && !hasExponent && !isN) {
keys = "." + keys;
}
if (! isOb && await i.getAttribute("disabled") === null) {
if (!isOb && await i.getAttribute("disabled") === null) {
await i.sendKeys(keys);
}
}
});
}
/**
* check that an input is empty
* @param id input id (parameter name)
*/
async checkEmptyInput(id: string) {
const inp = this.getInputById(id);
const val = await inp.getAttribute("value");
expect(val).toEqual("");
}
/**
* 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 checkEmptyOrFilledFields(inputIds: string[], emptys: boolean[]) {
let n = 0;
for (const id of inputIds) {
const inp = await this.getInputById(id);
const txt = await inp.getAttribute("value");
expect(txt === "").toEqual(emptys[n]);
n++;
}
}
}
......@@ -24,21 +24,6 @@ describe("ngHyd - Check that examples fields are not empty with 'empty fields on
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++;
}
}
it("when a standard fish ladder calculator is created", async () => {
// start page
await navBar.clickNewCalculatorButton();
......@@ -56,7 +41,7 @@ describe("ngHyd - Check that examples fields are not empty with 'empty fields on
// check fields are not empty
const inputIds = ["Z1", "LB", "PB", "0_L", "0_CdWSL"];
const emptys = [false, false, false, false, false];
await checkFields(inputIds, emptys);
await calcPage.checkEmptyOrFilledFields(inputIds, emptys);
});
it("calculated parameter initial value when discharge law is modified", async () => {
......
......@@ -41,28 +41,13 @@ describe("ngHyd - check that created/cloned structures have empty fields - ", ()
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++;
}
}
it("when a structure calculator is created", async () => {
await setup();
// check 1st structure empty fields
const inputIds = ["Q", "Z1", "Z2", "0_ZDV", "0_L", "0_W", "0_CdGR"];
const emptys = [true, true, true, true, true, true, false];
await checkFields(inputIds, emptys);
await calcPage.checkEmptyOrFilledFields(inputIds, emptys);
// change 1st structure type to rectangular weir
const structSelect = calcPage.getSelectById("select_structure");
......@@ -72,7 +57,7 @@ describe("ngHyd - check that created/cloned structures have empty fields - ", ()
// check 1st structure empty fields
const inputIds2 = ["Q", "Z1", "Z2", "0_ZDV", "0_L", "0_CdWR"];
const emptys2 = [true, true, true, true, true, false];
await checkFields(inputIds2, emptys2);
await calcPage.checkEmptyOrFilledFields(inputIds2, emptys2);
});
it("when a structure is added", async () => {
......@@ -85,7 +70,7 @@ describe("ngHyd - check that created/cloned structures have empty fields - ", ()
// check 2nd structure empty fields
const inputIds = ["1_ZDV", "1_L", "1_W", "1_CdGR"];
const emptys = [true, true, true, false];
await checkFields(inputIds, emptys);
await calcPage.checkEmptyOrFilledFields(inputIds, emptys);
});
it("when a structure is copied", async () => {
......@@ -98,7 +83,7 @@ describe("ngHyd - check that created/cloned structures have empty fields - ", ()
// check 2nd structure empty fields
const inputIds = ["1_ZDV", "1_L", "1_W", "1_CdGR"];
const emptys = [true, true, true, false];
await checkFields(inputIds, emptys);
await calcPage.checkEmptyOrFilledFields(inputIds, emptys);
});
it("when a modified structure is copied (type)", async () => {
......@@ -123,7 +108,7 @@ describe("ngHyd - check that created/cloned structures have empty fields - ", ()
// check empty fields
const inputIds = ["1_ZDV", "1_L", "1_W", "1_CdGR"];
const emptys = [true, true, true, false];
await checkFields(inputIds, emptys);
await calcPage.checkEmptyOrFilledFields(inputIds, emptys);
});
it("when a modified structure is copied (input)", async () => {
......@@ -142,7 +127,7 @@ describe("ngHyd - check that created/cloned structures have empty fields - ", ()
// check empty fields
const inputIds = ["1_ZDV", "1_L", "1_W", "1_CdGR"];
const emptys = [false, true, true, false];
await checkFields(inputIds, emptys);
await calcPage.checkEmptyOrFilledFields(inputIds, emptys);
});
it("except for discharge coefficient when a Larinier weir is used", async () => {
......@@ -161,7 +146,7 @@ describe("ngHyd - check that created/cloned structures have empty fields - ", ()
// check empty fields
const inputIds = ["0_ZDV", "0_L", "0_CdWSL"];
const emptys = [true, true, true];
await checkFields(inputIds, emptys);
await calcPage.checkEmptyOrFilledFields(inputIds, emptys);
});
it("when a structure is modified (input) and then a structure is added", async () => {
......@@ -180,6 +165,6 @@ describe("ngHyd - check that created/cloned structures have empty fields - ", ()
// check empty fields
const inputIds = ["1_ZDV", "1_L", "1_W", "1_CdGR"];
const emptys = [true, true, true, false];
await checkFields(inputIds, emptys);
await calcPage.checkEmptyOrFilledFields(inputIds, emptys);
});
});
......@@ -15,21 +15,6 @@ async function enableEmptyFieldsOption(prefPage: PreferencesPage) {
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();
......@@ -84,7 +69,7 @@ describe("ngHyd - check the cross walls calculator has empty fields - ", () => {
await genButton.click();
await browser.sleep(200);
await checkFields(calcPage, ["generatePabNbBassins"], [true]);
await calcPage.checkEmptyOrFilledFields(["generatePabNbBassins"], [true]);
});
});
......@@ -130,6 +115,6 @@ describe("ngHyd - check the cross walls calculator has no empty field - ", () =>
await calcButton.click();
await browser.sleep(200);
await checkFields(calcPage, ["Z1", "LB", "BB", "PB", "DH", "0_h1", "0_L", "0_CdWSL"], [false, false, false, false, false, false, false, false]);
await calcPage.checkEmptyOrFilledFields(["Z1", "LB", "BB", "PB", "DH", "0_h1", "0_L", "0_CdWSL"], [false, false, false, false, false, false, false, false]);
});
});
......@@ -26,12 +26,6 @@ describe("ngHyd − check that predam fields are empty", () => {
await browser.sleep(200);
});
async function checkEmptyInput(id: string) {
const inp = calcPage.getInputById(id);
const val = await inp.getAttribute("value");
expect(val).toEqual("");
}
it("on creation", async () => {
//browser.manage().window().setPosition(2000, 30);
// open predam calculator
......@@ -40,16 +34,16 @@ describe("ngHyd − check that predam fields are empty", () => {
await browser.sleep(200);
// check upstream inputs
await checkEmptyInput("Q");
await calcPage.checkEmptyInput("Q");
// Z1 is calculated
await checkEmptyInput("Z2");
await calcPage.checkEmptyInput("Z2");
// check basin 1 inputs
let node = element(by.css("g.node.basin"));
await node.click();
await browser.sleep(200);
await checkEmptyInput("0_S");
await checkEmptyInput("0_ZF");
await calcPage.checkEmptyInput("0_S");
await calcPage.checkEmptyInput("0_ZF");
// check walls inputs
const walls = element.all(by.css("g.node.wall"));
......@@ -57,17 +51,17 @@ describe("ngHyd − check that predam fields are empty", () => {
await walls.each(async (w) => {
await w.click();
await browser.sleep(200);
await checkEmptyInput("0_ZDV");
await checkEmptyInput("0_L");
await calcPage.checkEmptyInput("0_ZDV");
await calcPage.checkEmptyInput("0_L");
});
// check downstream basin inputs
node = element(by.css("g[id^='flowchart-aval-']")); // Mermaid generated id
await node.click();
await browser.sleep(200);
checkEmptyInput("Q");
calcPage.checkEmptyInput("Q");
// Z1 is calculated
checkEmptyInput("Z2");
calcPage.checkEmptyInput("Z2");
});
it("when a basin is added", async () => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment