Newer
Older
import { ListPage } from "./list.po";
import { CalculatorPage } from "./calculator.po";
import { Navbar } from "./navbar.po";
import { AppPage } from "./app.po";
import { SideNav } from "./sidenav.po";
import { PreferencesPage } from "./preferences.po";
François Grand
committed
import { changeSelectValue, loadSession, newSession, openCalculator, scrollPageToTop } from "./util.po";
import { browser, $, $$, expect } from '@wdio/globals'
/**
* Clone calculators
*/
describe("ngHyd − Passe à Bassins", () => {
let startPage: AppPage;
let listPage: ListPage;
let calcPage: CalculatorPage;
let navBar: Navbar;
let sideNav: SideNav;
startPage = new AppPage();
listPage = new ListPage();
calcPage = new CalculatorPage();
navBar = new Navbar();
sideNav = new SideNav();
beforeEach(async () => {
// disable evil option "empty fields on module creation"
await prefPage.navigateTo();
await prefPage.disableEvilEmptyFields();
});
it("when PAB is created from scratch", async () => {
// create PAB
François Grand
committed
await openCalculator(15, navBar, listPage);
const innerFieldsets = await $$(".pab-data-table");
expect(await innerFieldsets.length).toBe(1);
const calcButton = await calcPage.getCalculateButton();
await browser.pause(200);
// check that result is not empty
const hasResults = await calcPage.hasResults();
expect(hasResults).toBe(true);
// check absence of logs
expect(await calcPage.nbLogEntries()).toBe(0);
});
it("complete example of all PAB modules", async () => {
// PAB - chute
François Grand
committed
await openCalculator(12, navBar, listPage);
const c_Z1 = await calcPage.getInputById("Z1");
François Grand
committed
await openCalculator(13, navBar, listPage);
const n_DHT = await calcPage.getInputById("DHT");
const n_DH = await calcPage.getInputById("DH");
const n_N = await calcPage.getInputById("N");
await n_N.clearValue();
await n_N.setValue("15");
François Grand
committed
await openCalculator(5, navBar, listPage);
const d_V = await calcPage.getInputById("V");
const d_Y = await calcPage.getInputById("Y");
const d_L = await calcPage.getInputById("L");
const d_W = await calcPage.getInputById("W");
François Grand
committed
await openCalculator(6, navBar, listPage);
const p_DH = await calcPage.getInputById("DH");
const p_Q = await calcPage.getInputById("Q");
const p_V = await calcPage.getInputById("V");
const p_PV = await calcPage.getInputById("PV");
await p_PV.clearValue();
await p_PV.setValue("150");
François Grand
committed
await openCalculator(10, navBar, listPage);
const cl_LB = await calcPage.getInputById("LB");
const cl_BB = await calcPage.getInputById("BB");
const cl_DH = await calcPage.getInputById("DH");
const cl_Z1 = await calcPage.getInputById("Z1");
const cl_PB = await calcPage.getInputById("PB");
const calcButtonCl = await calcPage.getCalculateButton();
await browser.pause(200);
// make sure "Generate PAB" button is visible (it might be hidden behind navbar)
const genButton = await calcPage.getGeneratePabButton();
// await genButton.isExisting();
// await genButton.isDisplayed();
await browser.pause(1000);
const nbBassins = await calcPage.getInputById("generatePabNbBassins");
// await $("dialog-generate-pab button#do-generate").click();
const doGen = await $("dialog-generate-pab button#do-generate");
await doGen.click();
const calcButtonPAB = await calcPage.getCalculateButton();
await browser.pause(500);
// check that result is not empty
const hasResults = await calcPage.hasResults();
expect(hasResults).toBe(true);
});
mathias.chouet
committed
});
beforeEach(async () => {
// disable evil option "empty fields on module creation"
await prefPage.navigateTo();
await prefPage.disableEvilEmptyFields();
});
it("from a Cloisons among many", async () => {
await newSession(navBar, sideNav);
François Grand
committed
await openCalculator(10, navBar, listPage);
await openCalculator(10, navBar, listPage);
await openCalculator(10, navBar, listPage);
await navBar.clickCalculatorTab(1);
const Z1 = await calcPage.getInputById("Z1");
const LB = await calcPage.getInputById("LB");
const DH = await calcPage.getInputById("DH");
const calcButtonCl = await calcPage.getCalculateButton();
await browser.pause(200);
// make sure "Generate PAB" button is visible (it might be hidden behind navbar)
const genButton = await calcPage.getGeneratePabButton();
await browser.pause(1000);
const debit = await calcPage.getInputById("generatePabDebit");
expect(await debit.getValue()).toBe("1.128");
await debit.clearValue();
// send "1.6" in 3 movements, because "." triggers an error and Angular can't cope with the subsequent keys
await debit.addValue(".");
await debit.addValue("6");
const coteAmont = await calcPage.getInputById("generatePabCoteAmont");
expect(await coteAmont.getValue()).toBe("114");
const nbBassins = await calcPage.getInputById("generatePabNbBassins");
expect(await nbBassins.getValue()).toBe("6");
const btnGenerate = await $("dialog-generate-pab button#do-generate");
await btnGenerate.click();
const P_Q = await calcPage.getInputById("Q");
expect(await P_Q.getValue()).toBe("1.6");
const P_Z2 = await calcPage.getInputById("Z2");
expect(await P_Z2.getValue()).toBe("111.4");
const innerFieldsets = await $$("td.basin_number");
expect(innerFieldsets.length).toBe(5);
const calcButton = await calcPage.getCalculateButton();
await browser.pause(200);
// check that result is not empty
const hasResults = await calcPage.hasResults();
expect(hasResults).toBe(true);
});
it("complete example of all PAB modules", async () => {
await startPage.navigateTo();
// load
await loadSession(navBar, sideNav, "./session/session-pab-complete.json");
expect(await navBar.getAllCalculatorTabs().length).toBe(6);
await navBar.clickCalculatorTab(5);
const P_Q = await calcPage.getInputById("Q");
expect(await P_Q.getValue()).toBe("0.275");
const P_Z2 = await calcPage.getInputById("Z2");
expect(await P_Z2.getValue()).toBe("74.865");
const innerFieldsets = await $$("td.basin_number");
expect(await innerFieldsets.length).toBe(15);
const calcButton = await calcPage.getCalculateButton();
await browser.pause(200);
// check that result is not empty
const hasResults = await calcPage.hasResults();
expect(hasResults).toBe(true);
// check absence of logs
expect(await calcPage.nbLogEntries()).toBe(0);
});
describe("load regulated variated PAB with calc errors - ", () => {
it("should display logs", async () => {
await startPage.navigateTo();
await loadSession(navBar, sideNav, "./session/session-pab-regulee-variee.json");
expect(await navBar.getAllCalculatorTabs().length).toBe(1);
await navBar.clickCalculatorTab(0);
const calcButton = await calcPage.getCalculateButton();
await browser.pause(200);
// check that result is not empty
const hasResults = await calcPage.hasResults();
expect(hasResults).toBe(true);
// check presence of logs
expect(await calcPage.nbLogEntries()).toBe(2);
// change iteration
const pve = await calcPage.getSelectById("pab-variating-element");
await changeSelectValue(pve, 3);
expect(await calcPage.nbLogEntries()).toBe(1);