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

test(e2e): check pre-dams calculate button/schema items validity

refs #544
parent 178fd968
No related branches found
No related tags found
1 merge request!144Resolve "PréBarrages: les changements de couleur du schéma ne sont pas instantanées"
import { ListPage } from "./list.po";
import { CalculatorPage } from "./calculator.po";
import { Navbar } from "./navbar.po";
import { browser } from "protractor";
import { browser, by, element } from "protractor";
import { PreferencesPage } from "./preferences.po";
describe("Calculate button - ", () => {
......@@ -71,4 +71,75 @@ describe("Calculate button - ", () => {
disabledStateClone = await calcButtonClone.getAttribute("disabled");
expect(disabledStateClone).toBe("true");
});
describe("check button status in prébarrages - ", () => {
it("invalid data in Q input", async () => {
// start page
await navBar.clickNewCalculatorButton();
await browser.sleep(200);
// open prébarrages calculator
await listPage.clickMenuEntryForCalcType(30);
await browser.sleep(200);
// Q input
const inputQ = element(by.id("Q"));
await inputQ.clear();
await browser.sleep(200);
await inputQ.sendKeys("-1");
await browser.sleep(200);
calcPage.checkCalcButtonEnabled(false);
// upstream item
const upstream = element(by.id("amont"));
// should be displayed in error
expect(await upstream.getAttribute('class')).toContain("node-error");
});
it("add basin, invalid data in Q input", async () => {
// start page
await navBar.clickNewCalculatorButton();
await browser.sleep(200);
// open prébarrages calculator
await listPage.clickMenuEntryForCalcType(30);
await browser.sleep(200);
// "add basin" button
const addBasinBtn = element(by.id("add-basin"));
await addBasinBtn.click();
await browser.sleep(200);
// upstream item
const upstream = element(by.id("amont"));
await upstream.click();
await browser.sleep(200);
// invalid data in Q input
const inputQ = element(by.id("Q"));
await inputQ.clear();
await browser.sleep(200);
await inputQ.sendKeys("-1");
await browser.sleep(200);
// calculate button disabled ?
calcPage.checkCalcButtonEnabled(false);
// upstream item displayed in error ?
expect(await upstream.getAttribute('class')).toContain("node-error");
// valid data in Q input
await inputQ.clear();
await browser.sleep(200);
await inputQ.sendKeys("1");
await browser.sleep(200);
// calculate button still disabled ? (the basin is not connected to anything)
calcPage.checkCalcButtonEnabled(false);
// upstream item displayed not in error ?
expect(await upstream.getAttribute('class')).not.toContain("node-error");
});
});
});
......@@ -221,6 +221,13 @@ export class CalculatorPage {
return await cloneButton.click();
}
// check that "compute" button is in given enabled/disabled state
checkCalcButtonEnabled(enabled: boolean) {
const calcButton = this.getCalculateButton();
expect(calcButton.isEnabled()).toBe(enabled);
return calcButton;
}
async changeSelectValue(elt: ElementFinder, index: number) {
await elt.click();
const optionId = ".cdk-overlay-container mat-option:nth-of-type(" + (index + 1) + ")";
......
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