diff --git a/e2e/calculator.po.ts b/e2e/calculator.po.ts index 1194295c9979387c0b51149569b81ca4ca2d04e2..4be6378862b7589d86a2314e73a9f1a00ffa8b34 100644 --- a/e2e/calculator.po.ts +++ b/e2e/calculator.po.ts @@ -67,6 +67,10 @@ export class CalculatorPage { return element(by.css("fieldset-container .hyd-window-btns button.add-structure")); } + getCopyStructureButton() { + return element(by.css("fieldset-container .hyd-window-btns button.copy-structure")); + } + getAllLinkButtons() { return element.all(by.css("mat-button-toggle.radio_link")); } diff --git a/e2e/ouvrages-empty-fields.e2e-spec.ts b/e2e/ouvrages-empty-fields.e2e-spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..9e8f1b5761728a5a70c75ea7365249c132398285 --- /dev/null +++ b/e2e/ouvrages-empty-fields.e2e-spec.ts @@ -0,0 +1,115 @@ +import { ListPage } from "./list.po"; +import { browser, by, element } from "protractor"; +import { CalculatorPage } from "./calculator.po"; +import { AppPage } from "./app.po"; + +/** + * Check that created/cloned structures have empty fields when + * "empty fields on calculator creation" is enabled + */ +describe("ngHyd - check that created/cloned structures have empty fields - ", () => { + //let prefPage: PreferencesPage; + let startPage: AppPage; + let listPage: ListPage; + let calcPage: CalculatorPage; + + beforeAll(() => { + //prefPage = new PreferencesPage(); + startPage = new AppPage(); + listPage = new ListPage(); + calcPage = new CalculatorPage(); + }); + + beforeEach(async () => { + // enable evil option "empty fields on module creation" + // await prefPage.navigateTo(); + // await prefPage.enableEvilEmptyFields(); // message "stale element reference: element is not attached to the page document" + // await browser.sleep(200); + + // assume that "empty fields on module creation" is true by default + + // start page + await startPage.navigateTo(); + await browser.sleep(200); + + // open structures calculator + await listPage.clickMenuEntryForCalcType(8); + 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 () => { + // check 1st structure empty fields + const inputIds = ["Q", "calc_Z1", "Z2", "0_ZDV", "0_L", "0_W", "0_CdGR"]; + const emptys = [true, false, true, true, true, true, false]; + await checkFields(inputIds, emptys); + + // change 1st structure type to rectangular weir + const structSelect = calcPage.getSelectById("select_structure"); + await calcPage.changeSelectValue(structSelect, 1); + await browser.sleep(200); + + // check 1st structure empty fields + const inputIds2 = ["Q", "calc_Z1", "Z2", "0_ZDV", "0_L", "0_CdWR"]; + const emptys2 = [true, false, true, true, true, false]; + await checkFields(inputIds2, emptys2); + }); + + it("when a structure is added", async () => { + // add structure + const addStruct = calcPage.getAddStructureButton(); + await addStruct.click(); + + // 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); + }); + + it("when a structure is copied", async () => { + // copy structure + const addStruct = calcPage.getCopyStructureButton(); + await addStruct.click(); + + // 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); + }); + + it("when a modified structure is copied", async () => { + // change 1st structure type to rectangular weir + const structSelect = calcPage.getSelectById("select_structure"); + await calcPage.changeSelectValue(structSelect, 1); + await browser.sleep(200); + + // copy structure + const addStruct = calcPage.getCopyStructureButton(); + await addStruct.click(); + await browser.sleep(200); + + // change 2nd structure type to rectangular gate + const structSelect2 = element(by.className("ng-tns-c3-47")); + await calcPage.changeSelectValue(structSelect2, 4); + await browser.sleep(200); + + // check empty fields + const inputIds = ["1_ZDV", "1_L", "1_W", "1_CdGR"]; + const emptys = [true, true, true, false]; + await checkFields(inputIds, emptys); + }); +}); diff --git a/e2e/preferences.po.ts b/e2e/preferences.po.ts index 016d2da96c91a27e730c757f5382e60db283b088..ff9ff36aefb1f3b8297e9375816a013bcf7529d4 100644 --- a/e2e/preferences.po.ts +++ b/e2e/preferences.po.ts @@ -41,6 +41,14 @@ export class PreferencesPage { await option.click(); } + async enableEvilEmptyFields() { + const cb = this.getEmptyFieldsCheckbox(); + const underlyingCB = cb.element(by.css(`input.mat-checkbox-input`)); + if (!underlyingCB.isSelected()) { + await cb.click(); + } + } + async disableEvilEmptyFields() { const cb = this.getEmptyFieldsCheckbox(); const underlyingCB = cb.element(by.css(`input.mat-checkbox-input`)); diff --git a/jalhyd_branch b/jalhyd_branch index 084f9effbcaa415a70f40588672242db178649b2..626e97d71d9e3364f9abe16f7e3c8d70dea5a7fa 100644 --- a/jalhyd_branch +++ b/jalhyd_branch @@ -1 +1 @@ -300-supprimer-le-champ-_valuemode-dans-paramdefinition \ No newline at end of file +devel \ No newline at end of file