From a2376afe3ddb46e6a0a9ee38123663f967854287 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grand?= <francois.grand@inrae.fr> Date: Wed, 13 Apr 2022 13:23:21 +0200 Subject: [PATCH] test: check field 'number of falls' of the 'generate fish ladder' dialog is empty with the 'enable empty fields on new calculators' option refs #516 --- e2e/pab-cloisons-empty-fields.e2e-spec.ts | 83 +++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 e2e/pab-cloisons-empty-fields.e2e-spec.ts diff --git a/e2e/pab-cloisons-empty-fields.e2e-spec.ts b/e2e/pab-cloisons-empty-fields.e2e-spec.ts new file mode 100644 index 000000000..1782869db --- /dev/null +++ b/e2e/pab-cloisons-empty-fields.e2e-spec.ts @@ -0,0 +1,83 @@ +import { ListPage } from "./list.po"; +import { PreferencesPage } from "./preferences.po"; +import { browser, by, element } from "protractor"; +import { CalculatorPage } from "./calculator.po"; +import { AppPage } from "./app.po"; +import { Navbar } from "./navbar.po"; + +/** + * Check that when "empty fields on calculator creation" is enabled + * fields are empty in the "generate fish ladder" dialog of the + * cross walls calculator + */ +describe("ngHyd - check the cross walls calculator has empty fields - ", () => { + 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 () => { + // enable evil option "empty fields on module creation" + 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 () => { + // open cross walls calculator + await navBar.clickNewCalculatorButton(); + await listPage.clickMenuEntryForCalcType(10); + await browser.sleep(200); + + // fill inputs + await fillInput("Q"); + await fillInput("Z1"); + await fillInput("LB"); + await fillInput("BB"); + await fillInput("PB"); + await fillInput("0_h1"); + await fillInput("0_L"); + await fillInput("0_CdWSL"); + + // calculate + const calcButton = calcPage.getCalculateButton(); + await calcButton.click(); + await browser.sleep(200); + + // click "generate PAB" button + const genButton = calcPage.getGeneratePabButton(); + await genButton.click(); + await browser.sleep(200); + + await checkFields(["generatePabNbBassins"], [true]); + }); +}); -- GitLab