diff --git a/e2e/calculate-button-validation.e2e-spec.ts b/e2e/calculate-button-validation.e2e-spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..c6c29ec75f1ca2546274ac4415d6b98aea5bb9fa --- /dev/null +++ b/e2e/calculate-button-validation.e2e-spec.ts @@ -0,0 +1,74 @@ +import { ListPage } from "./list.po"; +import { CalculatorPage } from "./calculator.po"; +import { Navbar } from "./navbar.po"; +import { browser } from "protractor"; +import { PreferencesPage } from "./preferences.po"; + +describe("Calculate button - ", () => { + let listPage: ListPage; + let calcPage: CalculatorPage; + let navBar: Navbar; + let prefPage: PreferencesPage; + + beforeAll(async () => { + prefPage = new PreferencesPage(); + listPage = new ListPage(); + calcPage = new CalculatorPage(); + navBar = new Navbar(); + }); + + beforeEach(async () => { + await prefPage.navigateTo(); + // disable evil option "empty fields on module creation" + await prefPage.disableEvilEmptyFields(); + await browser.sleep(200); + }); + + it("check button status only depends on calculator (no link between calculators)", async () => { + // start page + await navBar.clickNewCalculatorButton(); + await browser.sleep(200); + + // open PAB: chute calculator + await listPage.clickMenuEntryForCalcType(12); + await browser.sleep(200); + + // start page + await navBar.clickNewCalculatorButton(); + await browser.sleep(200); + + // open PAB: dimensions + await listPage.clickMenuEntryForCalcType(5); + await browser.sleep(200); + + // fill width field with invalid data + const inputW = calcPage.getInputById("W"); + await inputW.clear(); + await browser.sleep(20); + await inputW.sendKeys("-1"); + await browser.sleep(200); + debugger + // check that "compute" button is inactive + let calcButtonClone = calcPage.getCalculateButton(); + let disabledStateClone = await calcButtonClone.getAttribute("disabled"); + expect(disabledStateClone).toBe("true"); + + // back to PAB: chute + await navBar.clickCalculatorTab(0); + await browser.sleep(200); + + // check that "compute" button is active + calcButtonClone = calcPage.getCalculateButton(); + disabledStateClone = await calcButtonClone.getAttribute("disabled"); + expect(disabledStateClone).not.toBe("true"); + + // back to PAB: dimensions + await navBar.clickCalculatorTab(1); + await browser.sleep(200); + + // check that "compute" button is inactive + calcButtonClone = calcPage.getCalculateButton(); + disabledStateClone = await calcButtonClone.getAttribute("disabled"); + expect(disabledStateClone).toBe("true"); + }); +});