Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • cassiopee/nghyd
1 result
Show changes
Commits on Source (27)
Showing
with 616 additions and 523 deletions
......@@ -39,6 +39,21 @@
"${workspaceRoot}/dist/out-tsc-e2e/*.js"
],
"skipSourceMapSupport": true
},
{
"name": "WDIO select spec",
"type": "node",
"request": "launch",
"args": ["wdio.conf.ts", "--spec", "${file}"],
"cwd": "${workspaceFolder}",
"autoAttachChildProcesses": true,
"program": "${workspaceRoot}/node_modules/@wdio/cli/bin/wdio.js",
"console": "integratedTerminal",
"skipFiles": [
"${workspaceFolder}/node_modules/**/*.js",
"${workspaceFolder}/lib/**/*.js",
"<node_internals>/**/*.js"
]
}
]
}
import { AppPage } from "./app.po";
import { browser } from "protractor";
/**
* Start app
......@@ -13,7 +12,7 @@ describe("ngHyd − start page", () => {
it("when app starts, user should be redirected to /list page", async () => {
await page.navigateTo();
const url = await browser.driver.getCurrentUrl();
const url = await browser.getUrl();
expect(url).toContain("/list");
});
});
import { browser } from "protractor";
export class AppPage {
navigateTo() {
return browser.get("/");
return browser.url("/");
}
}
import { ListPage } from "./list.po";
import { Navbar } from "./navbar.po";
import { browser } from "protractor";
import { CalculatorPage } from "./calculator.po";
import { PreferencesPage } from "./preferences.po";
import { browser, $, $$, expect } from '@wdio/globals'
describe("Check fields are empty in 'up/downstream elevations of a reach' calculator when created with 'empty fields' option", () => {
let listPage: ListPage;
......@@ -21,16 +21,16 @@ describe("Check fields are empty in 'up/downstream elevations of a reach' calcul
// enable evil option "empty fields on module creation"
await prefPage.navigateTo();
await prefPage.enableEvilEmptyFields();
await browser.sleep(200);
await browser.pause(200);
});
it("", async () => {
// open "up/downstream elevations of a reach" calculator
await navBar.clickNewCalculatorButton();
await listPage.clickMenuEntryForCalcType(21);
await browser.sleep(200);
await browser.pause(200);
expect(calcPage.checkEmptyOrFilledFields(["LargeurBerge", "Ks", "Long", "YB", "ZF1", "ZF2", "Q", "Z1", "Z2", "Dx"],
[true, true, true, true, true, true, true, true, true, true]))
await calcPage.checkEmptyOrFilledFields(["LargeurBerge", "Ks", "Long", "YB", "ZF1", "ZF2", "Q", "Z1", "Z2", "Dx"],
[true, true, true, true, true, true, true, true, true, true])
});
});
import { CalculatorPage } from "./calculator.po";
import { Navbar } from "./navbar.po";
import { browser, by, element } from "protractor";
import { PreferencesPage } from "./preferences.po";
import { SideNav } from "./sidenav.po";
import { browser, $, $$, expect } from '@wdio/globals'
import { newSession } from "./util.po";
/**
* Calculate all modules of all examples
......@@ -10,28 +11,25 @@ import { SideNav } from "./sidenav.po";
describe("ngHyd − example sessions −", () => {
let calcPage: CalculatorPage;
let navbar: Navbar;
let navBar: Navbar;
let prefPage: PreferencesPage;
let sideNav: SideNav;
beforeAll(() => {
jasmine.DEFAULT_TIMEOUT_INTERVAL = 100 * 1000;
// increase timeout to avoid "Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL" message
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10 * 60 * 1000; // 10 min
calcPage = new CalculatorPage();
navbar = new Navbar();
navBar = new Navbar();
prefPage = new PreferencesPage();
sideNav = new SideNav();
});
beforeEach(() => {
// increase timeout to avoid "Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL" message
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10 * 60 * 1000; // 10 min
});
it("calcul de tous les modules de tous les exemples −", async () => {
// disable evil option "empty fields on module creation"
await prefPage.navigateTo();
await prefPage.disableEvilEmptyFields();
await browser.sleep(200);
await browser.pause(200);
// for each calculator
let lastExampleFound = true;
......@@ -39,32 +37,33 @@ describe("ngHyd − example sessions −", () => {
while (lastExampleFound) {
if (i == 0) {
// start page
await navbar.clickNewCalculatorButton();
await browser.sleep(200);
await navBar.clickNewCalculatorButton();
await browser.pause(200);
}
else {
// empty session
await navbar.clickMenuButton();
await browser.sleep(200);
await sideNav.clickNewSessionButton();
await browser.sleep(1000);
await newSession(navBar, sideNav);
}
const examples = await element.all(by.css("#examples-list .load-example"));
await browser.sleep(200);
const examples = await $$("#examples-list .load-example");
await browser.pause(200);
if (examples.length > i) {
// click example #i
await examples[i].click();
await browser.sleep(200);
await browser.pause(200);
const nbModules = await navbar.getCalculatorEntriesCount();
await browser.sleep(200);
const nbModules = await navBar.getCalculatorEntriesCount();
await browser.pause(200);
for (let j = 0; j < nbModules; j++) {
// select module
await navbar.openNthCalculator(j);
await browser.sleep(50);
await navBar.openNthCalculator(j);
await browser.pause(300);
await calcPage.closeSnackBars(5, 500); // opening a calculator can trigger a snackbar with "results invalidated for..."
await browser.pause(500);
// calculate module
await calcPage.getCalculateButton().click();
const calcBtn = await calcPage.getCalculateButton();
await calcBtn.click();
await browser.pause(300);
// check results
const hasResults = await calcPage.hasValidResults();
expect(hasResults).toBe(true, `example ${i + 1}, module ${j + 1} (starting at 1)`);
......
......@@ -2,9 +2,11 @@ import { ListPage } from "./list.po";
import { CalculatorPage } from "./calculator.po";
import { Navbar } from "./navbar.po";
import { PreferencesPage } from "./preferences.po";
import { browser, element, by } from "protractor";
import { testedCalcTypes } from "./tested_calctypes";
import { scrollPageToTop } from "./util.po";
import { openCalculator, scrollPageToTop } from "./util.po";
import { browser, $, $$, expect } from '@wdio/globals'
import { newSession } from "./util.po";
import { SideNav } from "./sidenav.po";
/**
* For all calculators, try to calculate every parameter: check that only one parameter
......@@ -15,17 +17,19 @@ describe("ngHyd − calculate all parameters of all calculators", () => {
let calcPage: CalculatorPage;
let navBar: Navbar;
let prefPage: PreferencesPage;
let sideNav: SideNav;
beforeAll(async () => {
listPage = new ListPage();
calcPage = new CalculatorPage();
prefPage = new PreferencesPage();
navBar = new Navbar();
sideNav = new SideNav();
// disable evil option "empty fields on module creation"
await prefPage.navigateTo();
await prefPage.disableEvilEmptyFields();
await browser.sleep(200);
await browser.pause(200);
// increase timeout to avoid "Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL" message
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10 * 60 * 1000; // 10 min
......@@ -47,11 +51,9 @@ describe("ngHyd − calculate all parameters of all calculators", () => {
}
describe(" − calculate all parameters of calculator type [" + ct + "]", () => {
it("", async () => {
// go to list page
await navBar.clickNewCalculatorButton();
await newSession(navBar, sideNav);
await openCalculator(ct, navBar, listPage);
// click calculator button (instanciate)
await listPage.clickMenuEntryForCalcType(ct);
// get all parameters IDs
const inputs = await calcPage.getParamInputsHavingCalcMode();
......@@ -63,7 +65,7 @@ describe("ngHyd − calculate all parameters of all calculators", () => {
if (ct === 30 && i > 0) {
// prevents "Element is not clickable at point"
await scrollPageToTop();
const inputLink = element(by.css("#pb-data-results-selector .drs-item a"));
const inputLink = await $("#pb-data-results-selector .drs-item a");
await inputLink.click();
}
// grab input again because calculating the module just refreshed all the fieldsets
......@@ -71,12 +73,13 @@ describe("ngHyd − calculate all parameters of all calculators", () => {
// click "calc" mode button for this parameter
await calcPage.setParamMode(input, "cal");
// check that only 1 button is in "calc" state
const nbParamsCalc = await calcPage.getCheckedCalcModeButtons().count();
const nbParamsCalc = await calcPage.getCheckedCalcModeButtons().length;
expect(nbParamsCalc).toBe(1);
// check that "compute" button is active
const calcButton = await calcPage.checkCalcButtonEnabled(true);
// click "compute" button
await calcButton.click();
await browser.pause(500);
// check that result is not empty
const hasResults = await calcPage.hasResults();
expect(hasResults).toBe(true);
......@@ -87,6 +90,7 @@ describe("ngHyd − calculate all parameters of all calculators", () => {
const calcButton = await calcPage.checkCalcButtonEnabled(true);
// click "compute" button
await calcButton.click();
await browser.pause(500);
// check that result is not empty
const hasResults = await calcPage.hasResults();
expect(hasResults).toBe(true);
......
import { ListPage } from "./list.po";
import { CalculatorPage } from "./calculator.po";
import { Navbar } from "./navbar.po";
import { browser, by, element } from "protractor";
import { PreferencesPage } from "./preferences.po";
import { browser, $, $$, expect } from '@wdio/globals'
describe("Calculate button - ", () => {
let listPage: ListPage;
......@@ -21,46 +21,46 @@ describe("Calculate button - ", () => {
await prefPage.navigateTo();
// disable evil option "empty fields on module creation"
await prefPage.disableEvilEmptyFields();
await browser.sleep(200);
await browser.pause(200);
});
it("check button status only depends on calculator (no link between calculators)", async () => {
// start page
await navBar.clickNewCalculatorButton();
await browser.sleep(200);
await browser.pause(200);
// open PAB: chute calculator
await listPage.clickMenuEntryForCalcType(12);
await browser.sleep(200);
await browser.pause(200);
// start page
await navBar.clickNewCalculatorButton();
await browser.sleep(200);
await browser.pause(200);
// open PAB: dimensions
await listPage.clickMenuEntryForCalcType(5);
await browser.sleep(200);
await browser.pause(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);
const inputW = await calcPage.getInputById("W");
await inputW.clearValue();
await browser.pause(20);
await inputW.setValue("-1");
await browser.pause(200);
// check that "compute" button is inactive
await calcPage.checkCalcButtonEnabled(false);
// back to PAB: chute
await navBar.clickCalculatorTab(0);
await browser.sleep(200);
await browser.pause(200);
// check that "compute" button is active
await calcPage.checkCalcButtonEnabled(true);
// back to PAB: dimensions
await navBar.clickCalculatorTab(1);
await browser.sleep(200);
await browser.pause(200);
// check that "compute" button is inactive
await calcPage.checkCalcButtonEnabled(false);
......@@ -70,25 +70,25 @@ describe("Calculate button - ", () => {
it("invalid data in Q input", async () => {
// start page
await navBar.clickNewCalculatorButton();
await browser.sleep(200);
await browser.pause(200);
// open prébarrages calculator
await listPage.clickMenuEntryForCalcType(30);
await browser.sleep(200);
await browser.pause(200);
// Q input
const inputQ = element(by.id("Q"));
await inputQ.clear();
await browser.sleep(200);
await inputQ.sendKeys("-1");
await browser.sleep(200);
const inputQ = await $("#Q");
await inputQ.clearValue();
await browser.pause(200);
await inputQ.setValue("-1");
await browser.pause(200);
await calcPage.checkCalcButtonEnabled(false);
// upstream item
// look for g element with id starting by "flowchart-amont-"
// Mermaid changed the way ids are generated, it preprends "flowchart-" and appends a number to the id given in the graph description
const upstream = element(by.css("g[id^='flowchart-amont-']"));
const upstream = await $("g[id^='flowchart-amont-']");
// should be displayed in error
expect(await upstream.getAttribute('class')).toContain("node-highlighted-error"); // upstream item is now selected by default (was 'node-error')
});
......@@ -96,28 +96,28 @@ describe("Calculate button - ", () => {
it("add basin, invalid data in Q input", async () => {
// start page
await navBar.clickNewCalculatorButton();
await browser.sleep(200);
await browser.pause(200);
// open prébarrages calculator
await listPage.clickMenuEntryForCalcType(30);
await browser.sleep(200);
await browser.pause(200);
// "add basin" button
const addBasinBtn = element(by.id("add-basin"));
const addBasinBtn = await $("#add-basin");
await addBasinBtn.click();
await browser.sleep(200);
await browser.pause(200);
// upstream item
const upstream = element(by.css("g[id^='flowchart-amont-']")); // Mermaid generated id
const upstream = await $("g[id^='flowchart-amont-']"); // Mermaid generated id
await upstream.click();
await browser.sleep(200);
await browser.pause(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);
const inputQ = await $("#Q");
await inputQ.clearValue();
await browser.pause(200);
await inputQ.setValue("-1");
await browser.pause(200);
// calculate button disabled ?
await calcPage.checkCalcButtonEnabled(false);
......@@ -126,10 +126,10 @@ describe("Calculate button - ", () => {
expect(await upstream.getAttribute('class')).toContain("node-highlighted-error"); // upstream item is now selected by default (was 'node-error')
// valid data in Q input
await inputQ.clear();
await browser.sleep(200);
await inputQ.sendKeys("1");
await browser.sleep(200);
await inputQ.clearValue();
await browser.pause(200);
await inputQ.setValue("1");
await browser.pause(200);
// calculate button still disabled ? (the basin is not connected to anything)
await calcPage.checkCalcButtonEnabled(false);
......@@ -143,29 +143,27 @@ describe("Calculate button - ", () => {
// open calculator
await navBar.clickNewCalculatorButton();
await listPage.clickMenuEntryForCalcType(calcType);
await browser.sleep(200);
await browser.pause(200);
// for each input, set empty and check calculate button is not active
const inputs = calcPage.getParamInputs();
const ninp = await inputs.count();
for (let i = 0; i < ninp; i++) {
const inp = inputs.get(i);
const inputs = await calcPage.getParamInputs();
for (const inp of inputs) {
// set input to fixed mode
await calcPage.setParamMode(inp, "fix");
await browser.sleep(100);
await browser.pause(100);
// clear input
await calcPage.clearInput(inp);
await browser.sleep(10);
await browser.pause(10);
// check calculate button is disabled
await calcPage.checkCalcButtonEnabled(false);
await browser.sleep(100);
await browser.pause(100);
// refill input
await inp.sendKeys("1");
await browser.sleep(100);
await browser.keys("1");
await browser.pause(100);
}
}
......
......@@ -2,9 +2,9 @@ import { ListPage } from "./list.po";
import { CalculatorPage } from "./calculator.po";
import { Navbar } from "./navbar.po";
import { SideNav } from "./sidenav.po";
import { browser, by } from "protractor";
import { PreferencesPage } from "./preferences.po";
import { changeSelectValue } from "./util.po";
import { changeSelectValue, loadSession, newSession } from "./util.po";
import { browser, $, $$, expect } from '@wdio/globals'
/**
* Uses an example configuration to calculate :
......@@ -25,7 +25,7 @@ describe("ngHyd − calculate with linked parameters", () => {
let listPage: ListPage;
let calcPage: CalculatorPage;
let navBar: Navbar;
let sidenav: SideNav;
let sideNav: SideNav;
let prefPage: PreferencesPage;
beforeAll(() => {
......@@ -33,14 +33,17 @@ describe("ngHyd − calculate with linked parameters", () => {
calcPage = new CalculatorPage();
navBar = new Navbar();
prefPage = new PreferencesPage();
sidenav = new SideNav();
sideNav = new SideNav();
});
beforeEach(async () => {
await newSession(navBar, sideNav);
// disable evil option "empty fields on module creation"
await prefPage.navigateTo();
await browser.pause(200);
await prefPage.disableEvilEmptyFields();
await browser.sleep(200);
await browser.pause(100);
});
async function computeAndCheckPresenceOfResults() {
......@@ -48,6 +51,7 @@ describe("ngHyd − calculate with linked parameters", () => {
const calcButton = await calcPage.checkCalcButtonEnabled(true);
// click "compute" button
await calcButton.click();
await browser.pause(200);
// check that result is not empty
const hasResults = await calcPage.hasResults();
expect(hasResults).toBe(true);
......@@ -62,7 +66,7 @@ describe("ngHyd − calculate with linked parameters", () => {
await navBar.clickNewCalculatorButton();
await listPage.clickMenuEntryForCalcType(5);
// link Y to Y (R uniforme)
const Y = calcPage.getInputById("Y");
const Y = await calcPage.getInputById("Y");
await calcPage.setParamMode(Y, "link");
const sel = await calcPage.getLinkedValueSelect(Y);
await changeSelectValue(sel, 0);
......@@ -79,12 +83,12 @@ describe("ngHyd − calculate with linked parameters", () => {
await navBar.clickNewCalculatorButton();
await listPage.clickMenuEntryForCalcType(5);
// link Y to Y (R uniforme)
const Y = calcPage.getInputById("Y");
const Y = await calcPage.getInputById("Y");
await calcPage.setParamMode(Y, "link");
const sel = await calcPage.getLinkedValueSelect(Y);
await changeSelectValue(sel, 0);
// vary W
const W = calcPage.getInputById("W");
const W = await calcPage.getInputById("W");
await calcPage.setParamMode(W, "var");
await computeAndCheckPresenceOfResults();
......@@ -95,14 +99,14 @@ describe("ngHyd − calculate with linked parameters", () => {
await navBar.clickNewCalculatorButton();
await listPage.clickMenuEntryForCalcType(3);
// vary Y
const Y1 = calcPage.getInputById("Y");
const Y1 = await calcPage.getInputById("Y");
await calcPage.setParamMode(Y1, "var");
// create a PAB : dimensions
await navBar.clickNewCalculatorButton();
await listPage.clickMenuEntryForCalcType(5);
// link Y to Y (R uniforme)
const Y2 = calcPage.getInputById("Y");
const Y2 = await calcPage.getInputById("Y");
await calcPage.setParamMode(Y2, "link");
const sel = await calcPage.getLinkedValueSelect(Y2);
await changeSelectValue(sel, 0);
......@@ -115,14 +119,14 @@ describe("ngHyd − calculate with linked parameters", () => {
await navBar.clickNewCalculatorButton();
await listPage.clickMenuEntryForCalcType(3);
// calculate Y
const Y1 = calcPage.getInputById("Y");
const Y1 = await calcPage.getInputById("Y");
await calcPage.setParamMode(Y1, "cal");
// create a PAB : dimensions
await navBar.clickNewCalculatorButton();
await listPage.clickMenuEntryForCalcType(5);
// link Y to Y (R uniforme)
const Y2 = calcPage.getInputById("Y");
const Y2 = await calcPage.getInputById("Y");
await calcPage.setParamMode(Y2, "link");
const sel = await calcPage.getLinkedValueSelect(Y2);
await changeSelectValue(sel, 0);
......@@ -135,19 +139,19 @@ describe("ngHyd − calculate with linked parameters", () => {
await navBar.clickNewCalculatorButton();
await listPage.clickMenuEntryForCalcType(3);
// calculate Y
const Y1 = calcPage.getInputById("Y");
const Y1 = await calcPage.getInputById("Y");
await calcPage.setParamMode(Y1, "cal");
// create a PAB : dimensions
await navBar.clickNewCalculatorButton();
await listPage.clickMenuEntryForCalcType(5);
// link Y to Y (R uniforme)
const Y2 = calcPage.getInputById("Y");
const Y2 = await calcPage.getInputById("Y");
await calcPage.setParamMode(Y2, "link");
const sel = await calcPage.getLinkedValueSelect(Y2);
await changeSelectValue(sel, 0);
// vary W
const W = calcPage.getInputById("W");
const W = await calcPage.getInputById("W");
await calcPage.setParamMode(W, "var");
await computeAndCheckPresenceOfResults();
......@@ -158,17 +162,17 @@ describe("ngHyd − calculate with linked parameters", () => {
await navBar.clickNewCalculatorButton();
await listPage.clickMenuEntryForCalcType(3);
// vary Q
const Q = calcPage.getInputById("Q");
const Q = await calcPage.getInputById("Q");
await calcPage.setParamMode(Q, "var");
// calculate Y
const Y1 = calcPage.getInputById("Y");
const Y1 = await calcPage.getInputById("Y");
await calcPage.setParamMode(Y1, "cal");
// create a PAB : dimensions
await navBar.clickNewCalculatorButton();
await listPage.clickMenuEntryForCalcType(5);
// link Y to Y (R uniforme)
const Y2 = calcPage.getInputById("Y");
const Y2 = await calcPage.getInputById("Y");
await calcPage.setParamMode(Y2, "link");
const sel = await calcPage.getLinkedValueSelect(Y2);
await changeSelectValue(sel, 0);
......@@ -185,7 +189,7 @@ describe("ngHyd − calculate with linked parameters", () => {
await navBar.clickNewCalculatorButton();
await listPage.clickMenuEntryForCalcType(18);
// link V0 to V (Régime uniforme)
const V0 = calcPage.getInputById("V0");
const V0 = await calcPage.getInputById("V0");
await calcPage.setParamMode(V0, "link");
await computeAndCheckPresenceOfResults();
......@@ -200,10 +204,10 @@ describe("ngHyd − calculate with linked parameters", () => {
await navBar.clickNewCalculatorButton();
await listPage.clickMenuEntryForCalcType(18);
// link V0 to V (Régime uniforme)
const V0 = calcPage.getInputById("V0");
const V0 = await calcPage.getInputById("V0");
await calcPage.setParamMode(V0, "link");
// vary ZJ
const ZJ = calcPage.getInputById("ZJ");
const ZJ = await calcPage.getInputById("ZJ");
await calcPage.setParamMode(ZJ, "var");
await computeAndCheckPresenceOfResults();
......@@ -214,14 +218,14 @@ describe("ngHyd − calculate with linked parameters", () => {
await navBar.clickNewCalculatorButton();
await listPage.clickMenuEntryForCalcType(3);
// vary LargeurBerge
const LargeurBerge = calcPage.getInputById("LargeurBerge");
const LargeurBerge = await calcPage.getInputById("LargeurBerge");
await calcPage.setParamMode(LargeurBerge, "var");
// create a Jet
await navBar.clickNewCalculatorButton();
await listPage.clickMenuEntryForCalcType(18);
// link V0 to V (Régime uniforme)
const V0 = calcPage.getInputById("V0");
const V0 = await calcPage.getInputById("V0");
await calcPage.setParamMode(V0, "link");
await computeAndCheckPresenceOfResults();
......@@ -230,18 +234,17 @@ describe("ngHyd − calculate with linked parameters", () => {
it(" − multiple variated parameters, including a linked one (#253)", async () => {
// load session file
await navBar.clickNewCalculatorButton();
await navBar.clickMenuButton();
await browser.sleep(200);
await sidenav.clickLoadSessionButton();
await browser.sleep(200);
await sidenav.loadSessionFile("./session/session-multivar-link.json");
await browser.sleep(500);
expect(await navBar.getAllCalculatorTabs().count()).toBe(2);
await browser.pause(200);
await loadSession(navBar, sideNav, "./session/session-multivar-link.json");
expect(await navBar.getAllCalculatorTabs().length).toBe(2);
// calculate
await navBar.clickCalculatorTab(0);
const calcButton = calcPage.getCalculateButton();
const calcButton = await calcPage.getCalculateButton();
await calcButton.click();
await browser.pause(200);
// check that result is not empty
const hasResults = await calcPage.hasResults();
......@@ -249,16 +252,15 @@ describe("ngHyd − calculate with linked parameters", () => {
// check that there are 6 parameters columns in the variated results table :
// Q, Z2, Z1, + 4 for device #1
expect(await calcPage.getAllVariatedResultsTableHeaders().count()).toBe(7);
expect(await calcPage.getAllVariatedResultsTableHeaders().length).toBe(7);
// check that number of rows in the variated results table equals number of variated values
const varRows = calcPage.getAllVariatedResultsRows();
const nbRows = await varRows.count();
expect(nbRows).toBe(191); // boundaries are included
const varRows = await calcPage.getAllVariatedResultsRows();
expect(varRows.length).toBe(191); // boundaries are included
// check that all parameters have values for all iterations (Z2 might miss some if repeat strategy is not applied)
const lastRow = varRows.get(nbRows - 1);
const tds = await lastRow.all(by.css("td"));
const lastRow = varRows[varRows.length - 1];
const tds = await lastRow.$$("td");
tds.forEach((td) => {
expect(td.getText()).not.toBe("");
});
......@@ -266,82 +268,80 @@ describe("ngHyd − calculate with linked parameters", () => {
it(" − bug nghyd#329 : unexpected ERR in results table", async () => {
await navBar.clickNewCalculatorButton();
await browser.pause(200);
// load session
await navBar.clickMenuButton();
await browser.sleep(200);
await sidenav.clickLoadSessionButton();
await browser.sleep(200);
await sidenav.loadSessionFile("./session/session-pab-chain-nghyd-329.json");
await browser.sleep(200);
expect(await navBar.getAllCalculatorTabs().count()).toBe(3);
await loadSession(navBar, sideNav, "./session/session-pab-chain-nghyd-329.json");
expect(await navBar.getAllCalculatorTabs().length).toBe(3);
// calculate PAB-Dimensions
await navBar.clickCalculatorTab(2);
await browser.sleep(200);
await browser.pause(200);
// click "compute" button
const calcButton = calcPage.getCalculateButton();
const calcButton = await calcPage.getCalculateButton();
await calcButton.click();
await browser.pause(300);
// check that result is not empty
expect(await calcPage.hasResults()).toBe(true);
// check that ERR is not present in Volume line of results table
let frt = calcPage.getFixedResultsTable();
let volumeRow = calcPage.getNthRow(frt, 3);
let volumeCol = calcPage.getNthColumn(volumeRow, 2);
let volume = await volumeCol.getAttribute("textContent");
let frt = await calcPage.getFixedResultsTable();
let volumeRow = await calcPage.getNthRow(frt, 3);
let volumeCol = await calcPage.getNthColumn(volumeRow, 2);
let volume = await volumeCol.getText();
expect(Number(volume)).toBeCloseTo(44.565, 3);
// click PAB-Nombre tab
await navBar.clickCalculatorTab(0);
await browser.sleep(200);
await browser.pause(200);
// go back to PAB-Dimensions
await navBar.clickCalculatorTab(2);
await browser.sleep(200);
await browser.pause(200);
// check that ERR is not present in Volume line of results table
frt = calcPage.getFixedResultsTable();
volumeRow = calcPage.getNthRow(frt, 3);
volumeCol = calcPage.getNthColumn(volumeRow, 2);
volume = await volumeCol.getAttribute("textContent");
frt = await calcPage.getFixedResultsTable();
volumeRow = await calcPage.getNthRow(frt, 3);
volumeCol = await calcPage.getNthColumn(volumeRow, 2);
volume = await volumeCol.getText();
expect(Number(volume)).toBeCloseTo(44.565, 3);
});
it(" − a link target parameter should not be able to link to another parameter", async () => {
// create 1st PAB-Chute
await navBar.clickNewCalculatorButton();
await browser.sleep(200);
await browser.pause(200);
await listPage.clickMenuEntryForCalcType(12);
await browser.sleep(200);
await browser.pause(200);
// upstream water level should not have link mode (only one calculator)
const Z1_1 = calcPage.getInputById("Z1");
const Z1_1 = await calcPage.getInputById("Z1");
expect(await calcPage.inputHasLinkModeButton(Z1_1)).toBe(false);
// create 2nd PAB-Chute
await navBar.clickNewCalculatorButton();
await browser.sleep(200);
await browser.pause(200);
await listPage.clickMenuEntryForCalcType(12);
await browser.sleep(200);
await browser.pause(200);
// back to 1st calculator
await navBar.clickCalculatorTab(0);
await browser.sleep(200);
await browser.pause(200);
// upstream water level should have link mode (now there are 2 calculators)
expect(await calcPage.inputHasLinkModeButton(Z1_1)).toBe(true);
// back to 2nd calculator
await navBar.clickCalculatorTab(1);
await browser.sleep(200);
await browser.pause(200);
// link upstream water level in 2nd calculator to upstream water level in 1st one
const Z1_2 = calcPage.getInputById("Z1");
const Z1_2 = await calcPage.getInputById("Z1");
await calcPage.setParamMode(Z1_2, "link");
// back to 1st calculator
await navBar.clickCalculatorTab(0);
await browser.sleep(200);
await browser.pause(200);
// upstream water level should not have link mode (already a link target)
expect(await calcPage.inputHasLinkModeButton(Z1_1)).toBe(false);
......
......@@ -21,10 +21,10 @@ describe("ngHyd − calculator page", () => {
});
it("when a calculator is open, no active label should be empty", async () => {
const labels = page.getInputLabels();
await labels.each(async (l) => {
const labels = await page.getInputLabels();
for (const l of labels) {
const label = await l.getText();
expect(label.length).toBeGreaterThan(0);
});
}
});
});
This diff is collapsed.
......@@ -2,9 +2,9 @@ import { ListPage } from "./list.po";
import { CalculatorPage } from "./calculator.po";
import { Navbar } from "./navbar.po";
import { PreferencesPage } from "./preferences.po";
import { browser } from "protractor";
import { SideNav } from "./sidenav.po";
import { testedCalcTypes } from "./tested_calctypes";
import { browser, $, $$, expect } from '@wdio/globals'
/**
* For all calculators, try to calculate every parameter: check that only one parameter
......@@ -39,7 +39,7 @@ describe("ngHyd − check translation of all calculators", () => {
beforeAll(async () => {
await prefPage.navigateTo();
await prefPage.changeLanguage(i);
await browser.sleep(200);
await browser.pause(200);
await navBar.clickNewCalculatorButton();
});
......@@ -67,24 +67,26 @@ describe("ngHyd − check translation of all calculators", () => {
// just click the "compute" button with default values
// check that "compute" button is active
const calcButton = calcPage.getCalculateButton();
const calcButton = await calcPage.getCalculateButton();
const disabledState = await calcButton.getAttribute("disabled");
if (!disabledState) {
// click "compute" button
await calcButton.click();
await browser.pause(200);
// check that result is not empty
const hasResults = await calcPage.hasResults();
expect(hasResults).toBe(true);
}
// check absence of "*** message not found" in whole DOM
expect(await browser.getPageSource()).not.toContain("*** message not found", "missing translations found");
const source = await browser.execute("return document.body.innerHTML");
expect(source).not.toContain("*** message not found", "missing translations found");
// empty session
await navBar.clickMenuButton();
await browser.sleep(200);
await browser.pause(200);
await sideNav.clickNewSessionButton();
browser.sleep(200);
browser.pause(200);
});
}
});
......
import { ListPage } from "./list.po";
import { CalculatorPage } from "./calculator.po";
import { browser } from "protractor";
import { Navbar } from "./navbar.po";
import { PreferencesPage } from "./preferences.po";
import { changeSelectValue } from "./util.po";
import { browser, $, $$, expect } from '@wdio/globals'
/**
* Cloisons - différents tests qui n'ont pas tant de rapport que ça avec les cloisons :)
......@@ -25,7 +25,7 @@ describe("ngHyd − cloisons", () => {
// disable evil option "empty fields on module creation"
await prefPage.navigateTo();
await prefPage.disableEvilEmptyFields();
await browser.sleep(200);
await browser.pause(200);
});
it("when all parent Nub parameters are linked, Structure parameter modes should be alterable without problem", async () => {
......@@ -33,29 +33,31 @@ describe("ngHyd − cloisons", () => {
// 1. create target module for linked parameters
await listPage.clickMenuEntryForCalcType(10); // Cloisons
await browser.sleep(300);
await browser.pause(300);
// 2. create module to test
await calcPage.clickCloneCalcButton();
await browser.sleep(300);
await browser.pause(300);
// 3. link every parameter except Structure ones
await calcPage.setParamMode(calcPage.getInputById("calc_Q"), "link");
await calcPage.setParamMode(calcPage.getInputById("Z1"), "link");
await calcPage.setParamMode(calcPage.getInputById("LB"), "link");
await calcPage.setParamMode(calcPage.getInputById("BB"), "link");
await calcPage.setParamMode(calcPage.getInputById("PB"), "link");
await calcPage.setParamMode(calcPage.getInputById("DH"), "link");
await browser.sleep(300);
await calcPage.setParamMode(await calcPage.getInputById("calc_Q"), "link");
await calcPage.setParamMode(await calcPage.getInputById("Z1"), "link");
await calcPage.setParamMode(await calcPage.getInputById("LB"), "link");
await calcPage.setParamMode(await calcPage.getInputById("BB"), "link");
await calcPage.setParamMode(await calcPage.getInputById("PB"), "link");
await calcPage.setParamMode(await calcPage.getInputById("DH"), "link");
await browser.pause(300);
// 4. change LoiDebit
await changeSelectValue(calcPage.getSelectById("select_loidebit"), 1);
await browser.sleep(300);
await changeSelectValue(await calcPage.getSelectById("select_loidebit"), 1);
await browser.pause(300);
// 5. check number of inputs in CALC mode
expect(await calcPage.getCheckedCalcModeButtons().count()).toBe(1);
expect(await calcPage.getCheckedCalcModeButtons().length).toBe(1);
// 6. try calculating the module
await calcPage.getCalculateButton().click();
expect(calcPage.hasResults()).toBe(true);
const btn = await calcPage.getCalculateButton()
await btn.click();
await browser.pause(200);
expect(await calcPage.hasResults()).toBe(true);
});
});
import { ListPage } from "./list.po";
import { CalculatorPage } from "./calculator.po";
import { Navbar } from "./navbar.po";
import { browser } from "protractor";
import { PreferencesPage } from "./preferences.po";
import { testedCalcTypes } from "./tested_calctypes";
import { scrollPageToTop } from "./util.po";
import { newSession, scrollPageToTop } from "./util.po";
import { browser, $, $$, expect } from '@wdio/globals'
import { SideNav } from "./sidenav.po";
/**
* Clone calculators
......@@ -12,21 +13,25 @@ import { scrollPageToTop } from "./util.po";
describe("ngHyd − clone all calculators with all possible <select> values", () => {
let listPage: ListPage;
let calcPage: CalculatorPage;
let navbar: Navbar;
let navBar: Navbar;
let prefPage: PreferencesPage;
let sideNav: SideNav;
beforeAll(async () => {
listPage = new ListPage();
calcPage = new CalculatorPage();
navbar = new Navbar();
navBar = new Navbar();
prefPage = new PreferencesPage();
sideNav = new SideNav();
});
beforeEach(async () => {
// disable evil option "empty fields on module creation"
await prefPage.navigateTo();
await browser.pause(200);
await prefPage.disableEvilEmptyFields();
await browser.sleep(200);
await browser.pause(200);
await navBar.clickNewCalculatorButton();
});
describe("", () => {
......@@ -41,9 +46,11 @@ describe("ngHyd − clone all calculators with all possible <select> values", ()
}
describe(" − clone all variations of calculator type [" + ct + "]", () => {
it("", async () => {
await navbar.clickNewCalculatorButton();
await newSession(navBar, sideNav);
// click calculator button (instanciate)
await listPage.clickMenuEntryForCalcType(ct);
await browser.pause(200);
// get all select IDs outside Structures
// get select IDs inside Structures
......@@ -56,10 +63,10 @@ describe("ngHyd − clone all calculators with all possible <select> values", ()
// clone calculator
await scrollPageToTop();
await calcPage.clickCloneCalcButton();
await browser.sleep(300);
await browser.pause(300);
// check existence of the cloned module
expect(await navbar.getAllCalculatorTabs().count()).toBe(2);
expect(await navBar.getAllCalculatorTabs().length).toBe(2);
// @TODO check <select> values
......
import { ListPage } from "./list.po";
import { CalculatorPage } from "./calculator.po";
import { Navbar } from "./navbar.po";
import { browser } from "protractor";
import { PreferencesPage } from "./preferences.po";
import { changeSelectValue, scrollPageToTop } from "./util.po";
import { browser, $, $$, expect } from '@wdio/globals'
/**
* Clone calculators
......@@ -25,60 +25,63 @@ describe("ngHyd − clone a calculator", () => {
// disable evil option "empty fields on module creation"
await prefPage.navigateTo();
await prefPage.disableEvilEmptyFields();
await browser.sleep(200);
await browser.pause(200);
});
it("when cloning a calculator, the clone should have the same values for all parameters", async () => {
await navbar.clickNewCalculatorButton();
// 1. create target modules for linked parameter
await listPage.clickMenuEntryForCalcType(3); // Régime uniforme
await browser.sleep(500);
const debitRU = calcPage.getInputById("calc_Q"); // "Débit" is calculated by default
await browser.pause(500);
const debitRU = await calcPage.getInputById("calc_Q"); // "Débit" is calculated by default
await calcPage.setParamMode(debitRU, "fix");
await browser.sleep(500);
await browser.pause(500);
await navbar.clickNewCalculatorButton();
await listPage.clickMenuEntryForCalcType(4); // Courbe de remous
await browser.sleep(500);
await browser.pause(500);
// 2. create source module to clone
await navbar.clickNewCalculatorButton();
await listPage.clickMenuEntryForCalcType(2); // Section paramétrée
await browser.sleep(500);
await browser.pause(500);
// 3. change and store source parameter values
const sourceValues = {
k: 0.6,
Ks: 42
};
await changeSelectValue(calcPage.getSelectById("select_section"), 3); // mode "parabolique"
await calcPage.getInputById("k").clear();
await calcPage.getInputById("k").sendKeys(sourceValues["k"]);
await calcPage.getInputById("Ks").clear();
await calcPage.getInputById("Ks").sendKeys(sourceValues["Ks"]);
const selSection = await calcPage.getSelectById("select_section");
await changeSelectValue(selSection, 3); // mode "parabolique"
await calcPage.getInputById("k").clearValue();
await calcPage.getInputById("k").setValue(sourceValues["k"]);
await calcPage.getInputById("Ks").clearValue();
await calcPage.getInputById("Ks").setValue(sourceValues["Ks"]);
// link "Débit" to "Courbe de remous"
const debitSP = calcPage.getInputById("Q");
const debitSP = await calcPage.getInputById("Q");
await calcPage.setParamMode(debitSP, "link");
await browser.sleep(500);
await changeSelectValue(calcPage.getSelectById("linked_Q"), 1); // "Courbe de remous"
await browser.sleep(500);
await browser.pause(500);
const selQ = await calcPage.getSelectById("linked_Q");
await changeSelectValue(selQ, 1); // "Courbe de remous"
await browser.pause(500);
// otherwise clickCloneCalcButton() fails with "Element is not clickable at point"
await scrollPageToTop();
await calcPage.clickCloneCalcButton();
await browser.sleep(500);
await browser.pause(500);
// 4. check existence of the cloned module
expect(await navbar.getAllCalculatorTabs().count()).toBe(4);
expect(await navbar.getAllCalculatorTabs().length).toBe(4);
await navbar.clickCalculatorTab(3); // n°3 should be the latest
await browser.sleep(500);
await browser.pause(500);
// 5. compare values
Object.keys(sourceValues).forEach(async (k) => {
for (const k in sourceValues) {
const v = sourceValues[k];
const displayedVal = await calcPage.getInputById(k).getAttribute("value");
const inp = await calcPage.getInputById(k);
const displayedVal = await inp.getValue();
expect(displayedVal).toBe("" + v);
});
};
// @TODO check linked value (see above)
});
......
......@@ -2,8 +2,9 @@ import { AppPage } from "./app.po";
import { CalculatorPage } from "./calculator.po";
import { Navbar } from "./navbar.po";
import { SideNav } from "./sidenav.po";
import { browser } from "protractor";
import { PreferencesPage } from "./preferences.po";
import { browser, $, $$, expect } from '@wdio/globals'
import { loadSession, newSession } from "./util.po";
/**
* Load a session containing 3 calculators, having linked parameters
......@@ -15,14 +16,14 @@ import { PreferencesPage } from "./preferences.po";
describe("ngHyd − compute then reset chained results − ", () => {
let startPage: AppPage;
let calcPage: CalculatorPage;
let navbar: Navbar;
let navBar: Navbar;
let sidenav: SideNav;
let prefPage: PreferencesPage;
beforeAll(() => {
startPage = new AppPage();
calcPage = new CalculatorPage();
navbar = new Navbar();
navBar = new Navbar();
sidenav = new SideNav();
prefPage = new PreferencesPage();
});
......@@ -30,57 +31,53 @@ describe("ngHyd − compute then reset chained results − ", () => {
it("when loading session-cascade-params.json, computation should not be chained, but results reset should be", async () => {
// load session file
await startPage.navigateTo();
await navbar.clickMenuButton();
await browser.sleep(200);
await sidenav.clickLoadSessionButton();
await browser.sleep(200);
await sidenav.loadSessionFile("./session/session-cascade-params.json");
await browser.sleep(500);
expect(await navbar.getAllCalculatorTabs().count()).toBe(3);
await loadSession(navBar, sidenav, "./session/session-cascade-params.json");
expect(await navBar.getAllCalculatorTabs().length).toBe(3);
// 1. get down-most module
await navbar.clickCalculatorTabForUid("Y2l2Y3");
await navBar.clickCalculatorTabForUid("Y2l2Y3");
// click "compute" button
const calcButton = calcPage.getCalculateButton();
const calcButton = await calcPage.getCalculateButton();
await calcButton.click();
await browser.pause(200);
// down-most module should have results
let hasResults = await calcPage.hasResults();
expect(hasResults).toBe(true);
// up-most should not
await navbar.clickCalculatorTabForUid("ZTFxeW");
await navBar.clickCalculatorTabForUid("ZTFxeW");
hasResults = await calcPage.hasResults();
expect(hasResults).toBe(false);
await navbar.clickCalculatorTabForUid("Z3EwY2");
await navBar.clickCalculatorTabForUid("Z3EwY2");
// middle one should
hasResults = await calcPage.hasResults();
expect(hasResults).toBe(true);
// 2. get up-most module
await navbar.clickCalculatorTabForUid("ZTFxeW");
await navBar.clickCalculatorTabForUid("ZTFxeW");
// modify an input that is not linked
await calcPage.getInputById("Ks").clear();
await calcPage.getInputById("Ks").sendKeys("42");
await calcPage.getInputById("Ks").clearValue();
await calcPage.getInputById("Ks").setValue("42");
// other 2 modules should still have their results
for (let i = 1; i < 3; i++) {
await navbar.clickCalculatorTab(i);
await navBar.clickCalculatorTab(i);
hasResults = await calcPage.hasResults();
expect(hasResults).toBe(true);
}
// 3. get up-most module again
await navbar.clickCalculatorTabForUid("ZTFxeW");
await navBar.clickCalculatorTabForUid("ZTFxeW");
// modify input that is linked
await calcPage.getInputById("LargeurBerge").clear();
await calcPage.getInputById("LargeurBerge").sendKeys("2.6");
await calcPage.getInputById("LargeurBerge").clearValue();
await calcPage.getInputById("LargeurBerge").setValue("2.6");
// check all 3 modules for absence of results
for (let i = 0; i < 3; i++) {
await navbar.clickCalculatorTab(i);
await navBar.clickCalculatorTab(i);
hasResults = await calcPage.hasResults();
expect(hasResults).toBe(false);
}
......@@ -89,102 +86,97 @@ describe("ngHyd − compute then reset chained results − ", () => {
it("when loading session-cascade-results.json, computation and results reset should be chained", async () => {
// load session file
await startPage.navigateTo();
await navbar.clickMenuButton();
await browser.sleep(200);
await sidenav.clickLoadSessionButton();
await browser.sleep(200);
await sidenav.loadSessionFile("./session/session-cascade-results.json");
await browser.sleep(500);
expect(await navbar.getAllCalculatorTabs().count()).toBe(3);
await loadSession(navBar, sidenav, "./session/session-cascade-results.json");
expect(await navBar.getAllCalculatorTabs().length).toBe(3);
// 1. get down-most module (PAB Dimensions)
await navbar.clickCalculatorTabForUid("eHh5YX");
await navBar.clickCalculatorTabForUid("eHh5YX");
// click "compute" button
const calcButton = calcPage.getCalculateButton();
const calcButton = await calcPage.getCalculateButton();
await calcButton.click();
await browser.pause(200);
// check all 3 modules for results
for (let i = 0; i < 3; i++) {
await navbar.clickCalculatorTab(i);
await navBar.clickCalculatorTab(i);
const hasResults = await calcPage.hasResults();
expect(hasResults).toBe(true);
}
// 2. get up-most module (Macro-rugo)
await navbar.clickCalculatorTabForUid("MGg5OH");
await navBar.clickCalculatorTabForUid("MGg5OH");
// modify any input (for ex. "Ks")
await calcPage.getInputById("Ks").clear();
await calcPage.getInputById("Ks").sendKeys("42");
await calcPage.getInputById("Ks").clearValue();
await calcPage.getInputById("Ks").setValue("42");
// check all 3 modules for absence of results
for (let i = 0; i < 3; i++) {
await navbar.clickCalculatorTab(i);
await navBar.clickCalculatorTab(i);
const hasResults = await calcPage.hasResults();
expect(hasResults).toBe(false);
}
});
it("when loading session-results-invalidation.json, results reset should not be triggered on calculation", async () => {
await newSession(navBar, sidenav);
// disable evil option "empty fields on module creation"
await prefPage.navigateTo();
await prefPage.disableEvilEmptyFields();
await browser.sleep(200);
await browser.pause(200);
// start page
await navbar.clickNewCalculatorButton();
await browser.sleep(200);
await navBar.clickNewCalculatorButton();
await browser.pause(200);
// load session file
await navbar.clickMenuButton();
await browser.sleep(200);
await sidenav.clickLoadSessionButton();
await browser.sleep(200);
await sidenav.loadSessionFile("./session/session-results-invalidation.json");
await browser.sleep(500);
expect(await navbar.getAllCalculatorTabs().count()).toBe(2);
await loadSession(navBar, sidenav, "./session/session-results-invalidation.json");
expect(await navBar.getAllCalculatorTabs().length).toBe(2);
// get down-most module (Ouvrages)
await navbar.clickCalculatorTabForUid("amd2OG");
await navBar.clickCalculatorTabForUid("amd2OG");
// click "compute" button
const calcButton = calcPage.getCalculateButton();
const calcButton = await calcPage.getCalculateButton();
await calcButton.click();
await browser.pause(200);
const hasResults = await calcPage.hasResults();
expect(hasResults).toBe(true);
// 2. get up-most module (Ouvrages 1)
await navbar.clickCalculatorTabForUid("aTgwMm");
await navBar.clickCalculatorTabForUid("aTgwMm");
// modify an input that is not linked
await calcPage.getInputById("Z2").clear();
await calcPage.getInputById("Z2").sendKeys("101.8");
await calcPage.getInputById("Z2").clearValue();
await calcPage.getInputById("Z2").setValue("101.8");
// the down-most module should still have its results
await navbar.clickCalculatorTabForUid("amd2OG");
await navBar.clickCalculatorTabForUid("amd2OG");
const hasResults2 = await calcPage.hasResults();
expect(hasResults2).toBe(true);
// calculate the upmost module
await navbar.clickCalculatorTabForUid("aTgwMm");
const calcButton2 = calcPage.getCalculateButton();
await navBar.clickCalculatorTabForUid("aTgwMm");
const calcButton2 = await calcPage.getCalculateButton();
await calcButton2.click();
await browser.pause(200);
// the down-most module should still have its results
await navbar.clickCalculatorTabForUid("amd2OG");
await navBar.clickCalculatorTabForUid("amd2OG");
const hasResults3 = await calcPage.hasResults();
expect(hasResults3).toBe(true);
// modify an input that is linked
await navbar.clickCalculatorTabForUid("aTgwMm");
await calcPage.getInputById("0_ZDV").clear();
await calcPage.getInputById("0_ZDV").sendKeys("101");
await navBar.clickCalculatorTabForUid("aTgwMm");
const inpZDV = await calcPage.getInputById("0_ZDV");
await inpZDV.clearValue();
await inpZDV.setValue("101");
// the down-most module should not have its results anymore
await navbar.clickCalculatorTabForUid("amd2OG");
await navBar.clickCalculatorTabForUid("amd2OG");
const hasResults4 = await calcPage.hasResults();
expect(hasResults4).toBe(false);
});
});
import { browser, by, element } from "protractor";
import { PreferencesPage } from "./preferences.po"
import { Navbar } from "./navbar.po";
import { ListPage } from "./list.po";
import { CalculatorPage } from "./calculator.po";
import { browser, $, $$, expect } from '@wdio/globals'
import { newSession } from "./util.po";
import { SideNav } from "./sidenav.po";
describe("ngHyd − up/downstream elevations of a reach", () => {
let prefPage: PreferencesPage;
let navBar: Navbar;
let listPage: ListPage;
let calcPage: CalculatorPage;
let sideNav: SideNav;
beforeAll(() => {
prefPage = new PreferencesPage();
listPage = new ListPage();
navBar = new Navbar();
calcPage = new CalculatorPage();
sideNav = new SideNav();
});
beforeEach(async () => {
// disable evil option "empty fields on module creation"
await prefPage.navigateTo();
await browser.sleep(200);
await browser.pause(200);
await prefPage.disableEvilEmptyFields();
await browser.sleep(200);
await browser.pause(200);
});
it("check hydraulic details availability - flow calculation", async () => {
// open "up/downstream elevations of a reach" calculator
await navBar.clickNewCalculatorButton();
await browser.pause(200);
await listPage.clickMenuEntryForCalcType(21);
await browser.sleep(200);
await browser.pause(200);
// set upstream flow in calculate mode
const flowCalcBtn = element(by.xpath("//field-set[4]/mat-card-content/param-field-line[1]/div/div[2]/mat-button-toggle-group/mat-button-toggle[3]"));
const flowCalcBtn = await $(
"//field-set[4]/mat-card-content/param-field-line[1]/div/div[2]/mat-button-toggle-group/mat-button-toggle[3]"
);
await flowCalcBtn.click();
// check details buttons are disabled
const upDetailsBtn = element(by.id("generate-sp-aval"));
expect(upDetailsBtn.isEnabled()).toBe(false);
const downDetailsBtn = element(by.id("generate-sp-amont"));
expect(downDetailsBtn.isEnabled()).toBe(false);
const upDetailsBtn = await $("#generate-sp-aval");
expect(await upDetailsBtn.isEnabled()).toBe(false);
const downDetailsBtn = await $("#generate-sp-amont");
expect(await downDetailsBtn.isEnabled()).toBe(false);
// set value to upstream water elevation so that flow calculation leads to no error
const upWEinput = calcPage.getInputById("Z1");
await upWEinput.clear();
await upWEinput.sendKeys("100.664");
const upWEinput = await calcPage.getInputById("Z1");
await upWEinput.clearValue();
await upWEinput.setValue("100.664");
// run calculation
const calcButton = calcPage.getCalculateButton();
const calcButton = await calcPage.getCalculateButton();
await calcButton.click();
await browser.sleep(2000);
await browser.pause(300);
// check details buttons are enabled
expect(upDetailsBtn.isEnabled()).toBe(true);
expect(downDetailsBtn.isEnabled()).toBe(true);
expect(await upDetailsBtn.isEnabled()).toBe(true);
expect(await downDetailsBtn.isEnabled()).toBe(true);
// click upstream hydraulic details button
await upDetailsBtn.click();
await browser.sleep(500);
await browser.pause(500);
// a second calculator should be created
let calcs = navBar.getAllCalculatorTabs();
expect((await calcs).length).toEqual(2);
let calcs = await navBar.getAllCalculatorTabs();
expect(calcs.length).toEqual(2);
// click downstream hydraulic details button
await navBar.openNthCalculator(0);
await upDetailsBtn.click();
await browser.sleep(500);
await browser.pause(500);
// a third calculator should be created
calcs = navBar.getAllCalculatorTabs();
expect((await calcs).length).toEqual(3);
calcs = await navBar.getAllCalculatorTabs();
expect(calcs.length).toEqual(3);
});
it("check hydraulic details availability - upstream water elevation calculation", async () => {
await newSession(navBar, sideNav);
// open "up/downstream elevations of a reach" calculator
await navBar.clickNewCalculatorButton();
// await navBar.clickNewCalculatorButton();
await listPage.clickMenuEntryForCalcType(21);
await browser.sleep(200);
await browser.pause(200);
// check details buttons status
const upDetailsBtn = element(by.id("generate-sp-aval"));
expect(upDetailsBtn.isEnabled()).toBe(true);
const downDetailsBtn = element(by.id("generate-sp-amont"));
expect(downDetailsBtn.isEnabled()).toBe(false);
const upDetailsBtn = await $("#generate-sp-aval");
expect(await upDetailsBtn.isEnabled()).toBe(true);
const downDetailsBtn = await $("#generate-sp-amont");
expect(await downDetailsBtn.isEnabled()).toBe(false);
// run calculation
const calcButton = calcPage.getCalculateButton();
const calcButton = await calcPage.getCalculateButton();
await calcButton.click();
await browser.sleep(2000);
await browser.pause(300);
// check details buttons are enabled
expect(upDetailsBtn.isEnabled()).toBe(true);
expect(downDetailsBtn.isEnabled()).toBe(true);
expect(await upDetailsBtn.isEnabled()).toBe(true);
expect(await downDetailsBtn.isEnabled()).toBe(true);
// click upstream hydraulic details button
await upDetailsBtn.click();
await browser.sleep(500);
await browser.pause(500);
// a second calculator should be created
let calcs = navBar.getAllCalculatorTabs();
expect((await calcs).length).toEqual(2);
let calcs = await navBar.getAllCalculatorTabs();
expect(calcs.length).toEqual(2);
// click downstream hydraulic details button
await navBar.openNthCalculator(0);
await upDetailsBtn.click();
await browser.sleep(500);
await browser.pause(500);
// a third calculator should be created
calcs = navBar.getAllCalculatorTabs();
expect((await calcs).length).toEqual(3);
calcs = await navBar.getAllCalculatorTabs();
expect(calcs.length).toEqual(3);
});
});
import { ListPage } from "./list.po";
import { Navbar } from "./navbar.po";
import { browser } from "protractor";
import { CalculatorPage } from "./calculator.po";
import { PreferencesPage } from "./preferences.po";
import { browser, $, $$, expect } from '@wdio/globals'
describe("Check fields are empty in 'backwater curves' calculator when created with 'empty fields' option", () => {
let listPage: ListPage;
......@@ -21,16 +21,16 @@ describe("Check fields are empty in 'backwater curves' calculator when created w
// enable evil option "empty fields on module creation"
await prefPage.navigateTo();
await prefPage.enableEvilEmptyFields();
await browser.sleep(200);
await browser.pause(200);
});
it("", async () => {
// open "backwater curves" calculator
await navBar.clickNewCalculatorButton();
await listPage.clickMenuEntryForCalcType(4);
await browser.sleep(200);
await browser.pause(200);
expect(calcPage.checkEmptyOrFilledFields(["LargeurBerge", "Ks", "Long", "YB", "ZF1", "ZF2", "Q", "Z1", "Z2", "Dx"],
[true, true, true, true, true, true, true, true, true, true]))
await calcPage.checkEmptyOrFilledFields(["LargeurBerge", "Ks", "Long", "YB", "ZF1", "ZF2", "Q", "Z1", "Z2", "Dx"],
[true, true, true, true, true, true, true, true, true, true]);
});
});
import { browser, by, element } from "protractor";
import { Navbar } from "./navbar.po";
import { ListPage } from "./list.po";
import { SideNav } from "./sidenav.po";
import { PreferencesPage } from "./preferences.po";
import { browser, $, $$, expect } from '@wdio/globals'
/**
* convert Mermaid formatted id ("flowchat-id-xx") to id
......@@ -40,23 +40,23 @@ describe("modules diagram", () => {
// open predam calculator
await navBar.clickNewCalculatorButton();
await listPage.clickMenuEntryForCalcType(30);
await browser.sleep(200);
await browser.pause(200);
// open modules diagram
await navBar.clickMenuButton();
await browser.sleep(200);
await browser.pause(500);
await sideNav.clickDiagramButton();
await browser.sleep(200);
await browser.pause(200);
// click first module
const nodes = element.all(by.css("g.node.default"));
const node0 = nodes.get(0);
const nodes = await $$("g.node.default");
const node0 = nodes[0];
const n0id = removeMermaidIdFormat(await node0.getAttribute("id"));
await node0.click();
await browser.sleep(200);
await browser.pause(200);
// check calculator is open
const url = await browser.driver.getCurrentUrl();
const url = await browser.getUrl();
expect(url).toContain("/#/calculator/" + n0id);
});
});
import { ListPage } from "./list.po";
import { CalculatorPage } from "./calculator.po";
import { Navbar } from "./navbar.po";
import { browser, by, element } from "protractor";
import { PreferencesPage } from "./preferences.po";
import { browser, $, $$, expect } from '@wdio/globals'
describe("documentation − ", () => {
let listPage: ListPage;
let calcPage: CalculatorPage;
let prefPage: PreferencesPage;
let navbar: Navbar;
let navBar: Navbar;
beforeAll(() => {
calcPage = new CalculatorPage();
prefPage = new PreferencesPage();
navbar = new Navbar();
navBar = new Navbar();
listPage = new ListPage();
// browser.manage().window().setPosition(2000, 30);
......@@ -22,55 +22,44 @@ describe("documentation − ", () => {
async function checkMathjaxInHelp(lang: number) {
// change language setup
await prefPage.navigateTo();
await browser.sleep(200);
await browser.pause(200);
await prefPage.changeLanguage(lang);
await browser.sleep(200);
await browser.pause(200);
// start page
await navbar.clickNewCalculatorButton();
await browser.sleep(200);
await navBar.clickNewCalculatorButton();
await browser.pause(200);
// open "fish ladder: fall" calculator
await listPage.clickMenuEntryForCalcType(12);
await browser.sleep(200);
await browser.pause(200);
// click help
await calcPage.getCalculatorHelpButton().click();
await browser.sleep(200);
await browser.pause(200);
browser.getAllWindowHandles().then(async (handles) => {
const old = browser.ignoreSynchronization
browser.ignoreSynchronization = true; // deprecated but the only solution to work in the newly opened tab
const handles = await browser.getWindowHandles();
// switch to help tab
browser.switchTo().window(handles[1]).then(async () => {
await browser.sleep(200);
// check Mathjax element is present
expect(await element(by.css("mjx-container")).isPresent()).toBe(true);
}).then(async () => {
// close help tab
// await browser.close();
// await browser.sleep(200);
// switch back to calculator (required to avoid failure of next language test)
await browser.switchTo().window(handles[0]);
await browser.sleep(200);
// browser.ignoreSynchronization = false;
}).then(async () => {
// switch back to calculator (required to avoid failure of next language test)
await browser.switchTo().window(handles[0]);
await browser.sleep(200);
// browser.ignoreSynchronization = false;
browser.ignoreSynchronization = old;
});
});
}
// switch to help tab
await browser.switchToWindow(handles[1])
await browser.pause(200);
// check Mathjax element is present
const cont = await $("mjx-container");
expect(await cont.isExisting()).toBe(true);
xit("check Mathjax formula are displayed in calculator French help", async () => {
debugger
// close help tab
await browser.execute("window.close()");
// switch back to calculator (required to avoid failure of next language test)
await browser.switchToWindow(handles[0]);
await browser.pause(200);
};
it("check Mathjax formula are displayed in calculator French help", async () => {
await checkMathjaxInHelp(1); // fr
});
xit("check Mathjax formula are displayed in calculator English help", async () => {
it("check Mathjax formula are displayed in calculator English help", async () => {
await checkMathjaxInHelp(0); // en
});
});
import { browser } from "protractor";
import { PreferencesPage } from "./preferences.po"
import { Navbar } from "./navbar.po";
import { ListPage } from "./list.po";
import { CalculatorPage } from "./calculator.po";
import { browser, $, $$, expect } from '@wdio/globals'
describe("ngHyd − check that results are not duplicated", () => {
let prefPage: PreferencesPage;
......@@ -20,24 +20,25 @@ describe("ngHyd − check that results are not duplicated", () => {
beforeEach(async () => {
// disable evil option "empty fields on module creation"
await prefPage.navigateTo();
await browser.sleep(200);
await browser.pause(200);
await prefPage.disableEvilEmptyFields();
await browser.sleep(200);
await browser.pause(200);
});
it("in 'baffle fishway: setup' calculator", async () => {
// open baffle fishway setup calculator
await navBar.clickNewCalculatorButton();
await listPage.clickMenuEntryForCalcType(28);
await browser.sleep(200);
await browser.pause(200);
// run calculation
const calcButton = calcPage.getCalculateButton();
const calcButton = await calcPage.getCalculateButton();
await calcButton.click();
await browser.pause(200);
// check result count
const fixRows = calcPage.getAllFixedResultsRows();
const nbRows = await fixRows.count();
const fixRows = await calcPage.getAllFixedResultsRows();
const nbRows = fixRows.length;
console.log(nbRows);
expect(nbRows).toBe(24); // boundaries are included
});
......