diff --git a/e2e/bief-empty-fields.e2e-spec.ts b/e2e/bief-empty-fields.e2e-spec.ts index 6977ce3ee0b267fb47eaa0fc5fec910e20a90592..a828ffc0bfe22393b694ead22e03c28823a5c401 100644 --- a/e2e/bief-empty-fields.e2e-spec.ts +++ b/e2e/bief-empty-fields.e2e-spec.ts @@ -30,7 +30,7 @@ describe("Check fields are empty in 'up/downstream elevations of a reach' calcul await listPage.clickMenuEntryForCalcType(21); 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]) }); }); diff --git a/e2e/calc-all-examples.e2e-spec.ts b/e2e/calc-all-examples.e2e-spec.ts index 8f228a16795f2e0527ee0f0ad03713bb7424e57b..adb93e8f118778856e79f5b024946dfc4d436ec5 100644 --- a/e2e/calc-all-examples.e2e-spec.ts +++ b/e2e/calc-all-examples.e2e-spec.ts @@ -2,6 +2,8 @@ import { CalculatorPage } from "./calculator.po"; import { Navbar } from "./navbar.po"; 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 @@ -9,23 +11,20 @@ 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(); @@ -38,32 +37,39 @@ describe("ngHyd − example sessions −", () => { while (lastExampleFound) { if (i == 0) { // start page - await navbar.clickNewCalculatorButton(); + await navBar.clickNewCalculatorButton(); await browser.pause(200); } else { // empty session - await navbar.clickMenuButton(); - await browser.pause(200); - await sideNav.clickNewSessionButton(); - await browser.pause(1000); + // await navbar.clickMenuButton(); + // await browser.pause(200); + // await sideNav.clickNewSessionButton(); + // await browser.pause(1000); + await newSession(navBar, sideNav); } const examples = await $$("#examples-list .load-example"); await browser.pause(200); if (examples.length > i) { // click example #i - await (await examples.i).click(); + await examples[i].click(); await browser.pause(200); - const nbModules = await navbar.getCalculatorEntriesCount(); + const nbModules = await navBar.getCalculatorEntriesCount(); await browser.pause(200); for (let j = 0; j < nbModules; j++) { // select module - await navbar.openNthCalculator(j); - await browser.pause(50); + await navBar.openNthCalculator(j); + await browser.pause(300); + // await calcPage.closeSnackBar(); // opening a calculator can trigger a snackbar with "results invalidated for..." + // 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)`); diff --git a/e2e/calculate-all-params.e2e-spec.ts b/e2e/calculate-all-params.e2e-spec.ts index 83882f4e79363c9286f65bcc785f309c49bab748..0af1460ba8d35e8410f06cc5ac646bdb8fc63baf 100644 --- a/e2e/calculate-all-params.e2e-spec.ts +++ b/e2e/calculate-all-params.e2e-spec.ts @@ -3,7 +3,10 @@ import { CalculatorPage } from "./calculator.po"; import { Navbar } from "./navbar.po"; import { PreferencesPage } from "./preferences.po"; 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 @@ -14,12 +17,14 @@ 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(); @@ -32,6 +37,24 @@ describe("ngHyd − calculate all parameters of all calculators", () => { // get calculators list (IDs) @TODO read it from config, but can't import jalhyd here :/ const calcTypes = testedCalcTypes; + // const calcTypes = [0]; + // export const testedCalcTypes = [ + // 0, + // // omit 1 - LechaptCalmon + // 2, 3, 4, 5, 6, + // // omit 7 - Structure + // 8, 9, 10, 11, 12, 13, + // // omit 14 -Section + // 15, + // // omit 16 - CloisonAval + // 17, 18, 19, 20, 21, 22, 23, 24, 25, + // // omit 26 - YAXN + // 27, 28, 29, 30, + // // omit 31 - PbCloison and 32 - PbBassin + // 33, 34, 35 + // ]; + // const calcTypes =[30]; + // for each calculator for (const ct of calcTypes) { @@ -46,14 +69,22 @@ describe("ngHyd − calculate all parameters of all calculators", () => { } describe(" − calculate all parameters of calculator type [" + ct + "]", () => { it("", async () => { + await newSession(navBar, sideNav); + + //await browser.execute("window.moveTo(2000,30)") + // await browser.driver.moveTo(2000,30); + // go to list page - await navBar.clickNewCalculatorButton(); + // await navBar.clickNewCalculatorButton(); // click calculator button (instanciate) - await listPage.clickMenuEntryForCalcType(ct); + // await listPage.clickMenuEntryForCalcType(ct); + await openCalculator(ct, navBar, listPage); + // get all parameters IDs const inputs = await calcPage.getParamInputsHavingCalcMode(); + // if ((await inputs).length > 0) { if (inputs.length > 0) { // for each param for (let i = 0; i < inputs.length; i++) { @@ -68,7 +99,9 @@ describe("ngHyd − calculate all parameters of all calculators", () => { // grab input again because calculating the module just refreshed all the fieldsets const input = (await calcPage.getParamInputsHavingCalcMode())[i]; // click "calc" mode button for this parameter + // await browser.pause(50); await calcPage.setParamMode(input, "cal"); + // await browser.pause(50); // check that only 1 button is in "calc" state const nbParamsCalc = await calcPage.getCheckedCalcModeButtons().length; expect(nbParamsCalc).toBe(1); @@ -76,6 +109,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); @@ -86,11 +120,13 @@ 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); } }); }); + // break; } }); diff --git a/e2e/calculate-button-validation.e2e-spec.ts b/e2e/calculate-button-validation.e2e-spec.ts index ee17d4f6d80e68de3b13ed37c97a36dd5298f300..d11a3f9ece28ce2bf80e388de6919da50cd54bf1 100644 --- a/e2e/calculate-button-validation.e2e-spec.ts +++ b/e2e/calculate-button-validation.e2e-spec.ts @@ -2,6 +2,7 @@ import { ListPage } from "./list.po"; import { CalculatorPage } from "./calculator.po"; import { Navbar } from "./navbar.po"; import { PreferencesPage } from "./preferences.po"; +import { browser, $, $$, expect } from '@wdio/globals' describe("Calculate button - ", () => { let listPage: ListPage; @@ -142,29 +143,31 @@ 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 pfls = await calcPage.getParamfieldlines(); + const inputs = await calcPage.getParamInputs(); + // for (const pfl of pfls) { + for (const inp of inputs) { // set input to fixed mode + // await calcPage.setParamMode(pfl, "fix"); await calcPage.setParamMode(inp, "fix"); - await browser.sleep(100); + await browser.pause(100); // clear input + // const inp = await calcPage.getParamfieldlineInput(pfl); 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); } } diff --git a/e2e/calculate-linked-params.e2e-spec.ts b/e2e/calculate-linked-params.e2e-spec.ts index 0f26d5a0d1318a0b7219798735dacfab4481575f..ca07539408c9d2dc99073aff67a75571a51cb53c 100644 --- a/e2e/calculate-linked-params.e2e-spec.ts +++ b/e2e/calculate-linked-params.e2e-spec.ts @@ -3,7 +3,8 @@ import { CalculatorPage } from "./calculator.po"; import { Navbar } from "./navbar.po"; import { SideNav } from "./sidenav.po"; import { PreferencesPage } from "./preferences.po"; -import { changeSelectValue } from "./util.po"; +import { changeSelectValue, newSession } from "./util.po"; +import { browser, $, $$, expect } from '@wdio/globals' /** * Uses an example configuration to calculate : @@ -24,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(() => { @@ -32,27 +33,47 @@ 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 prefPage.disableEvilEmptyFields(); await browser.pause(200); + await prefPage.disableEvilEmptyFields(); + await browser.pause(100); + }); + + afterEach(async () => { + //await browser.reloadSession(); + // await browser.pause(500); }); + // describe('webdriver.io page', () => { + // it('should reload my session with current capabilities', () => { + // console.log(browser.sessionId) + // browser.reloadSession() + // console.log(browser.sessionId) + // }) + // }); + async function computeAndCheckPresenceOfResults() { // check that "compute" button is active 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); } it(" − direct links : parameter linked to a single parameter", async () => { + // await browser.reloadSession(); + // await browser.pause(1000); + // create a Régime uniforme await navBar.clickNewCalculatorButton(); await listPage.clickMenuEntryForCalcType(3); @@ -61,12 +82,14 @@ 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); await computeAndCheckPresenceOfResults(); + // await browser.reloadSession(); + // await browser.closeWindow(); }); it(" − direct links : parameter linked to a single parameter, plus local variated parameter", async () => { @@ -78,15 +101,16 @@ 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(); + // await browser.reloadSession(); }); it(" − direct links : parameter linked to a variated parameter", async () => { @@ -94,14 +118,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); @@ -114,14 +138,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); @@ -134,19 +158,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(); @@ -157,17 +181,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); @@ -184,7 +208,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(); @@ -199,10 +223,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(); @@ -213,14 +237,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(); @@ -231,16 +255,17 @@ describe("ngHyd − calculate with linked parameters", () => { await navBar.clickNewCalculatorButton(); await navBar.clickMenuButton(); await browser.pause(200); - await sidenav.clickLoadSessionButton(); + await sideNav.clickLoadSessionButton(); await browser.pause(200); - await sidenav.loadSessionFile("./session/session-multivar-link.json"); + await sideNav.loadSessionFile("./session/session-multivar-link.json"); await browser.pause(500); 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(); @@ -251,12 +276,12 @@ describe("ngHyd − calculate with linked parameters", () => { 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.length; - expect(nbRows).toBe(191); // boundaries are included + const varRows = await calcPage.getAllVariatedResultsRows(); + // const nbRows = await varRows.length; + 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 lastRow = varRows[varRows.length - 1]; const tds = await lastRow.$$("td"); tds.forEach((td) => { expect(td.getText()).not.toBe(""); @@ -268,9 +293,9 @@ describe("ngHyd − calculate with linked parameters", () => { // load session await navBar.clickMenuButton(); await browser.pause(200); - await sidenav.clickLoadSessionButton(); + await sideNav.clickLoadSessionButton(); await browser.pause(200); - await sidenav.loadSessionFile("./session/session-pab-chain-nghyd-329.json"); + await sideNav.loadSessionFile("./session/session-pab-chain-nghyd-329.json"); await browser.pause(200); expect(await navBar.getAllCalculatorTabs().length).toBe(3); @@ -278,16 +303,18 @@ describe("ngHyd − calculate with linked parameters", () => { await navBar.clickCalculatorTab(2); 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.getAttribute("textContent"); + let volume = await volumeCol.getText(); expect(Number(volume)).toBeCloseTo(44.565, 3); // click PAB-Nombre tab @@ -299,10 +326,11 @@ describe("ngHyd − calculate with linked parameters", () => { 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("textContent"); + volume = await volumeCol.getText(); expect(Number(volume)).toBeCloseTo(44.565, 3); }); @@ -314,7 +342,7 @@ describe("ngHyd − calculate with linked parameters", () => { 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 @@ -335,7 +363,7 @@ describe("ngHyd − calculate with linked parameters", () => { 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 diff --git a/e2e/calculator.e2e-spec.ts b/e2e/calculator.e2e-spec.ts index 841a5304767c87dad05a9bb2ca9b601f349cee13..5c41eba08c773569f5b2cd02d41dbdd1c4e8ab38 100644 --- a/e2e/calculator.e2e-spec.ts +++ b/e2e/calculator.e2e-spec.ts @@ -21,10 +21,11 @@ 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(); + // await labels.each(async (l) => { + for (const l of labels) { const label = await l.getText(); expect(label.length).toBeGreaterThan(0); - }); + } }); }); diff --git a/e2e/calculator.po.ts b/e2e/calculator.po.ts index 5d11fc5d9176c4738cfca4ae1c612286f0b29cfe..531b0e19555122359f2def9431e00a5565fb5e32 100644 --- a/e2e/calculator.po.ts +++ b/e2e/calculator.po.ts @@ -1,5 +1,6 @@ import { scrollPageToTop, scrollToElement } from "./util.po"; import { browser, $, $$, expect } from '@wdio/globals' +import { Key } from 'webdriverio' export class CalculatorPage { @@ -11,14 +12,58 @@ export class CalculatorPage { return $$("ngparam-input input.form-control"); } + // getParamfieldlines() { + // return $$("param-field-line"); + // } + + // getParamfieldlineInput(pfl) { + // return pfl.$("ngparam-input input.form-control"); + // } + + // async getParamInputsHavingCalcMode() { + // const ret = []; + // const inputs = await this.getParamInputs(); + // // await inputs.each(async (i) => { + // // if (await this.inputHasCalcModeButton(i)) { + // // ret.push(i); + // // } + // // }); + + // // for await (const img of $$('img')) { + // // console.log(await img.getAttribute('src)) + // // } + + // for await (const i of inputs) { + // if (await this.inputHasCalcModeButton(i)) { + // ret.push(i); + // } + // } + + // return ret; + // } async getParamInputsHavingCalcMode() { const ret = []; - const inputs = this.getParamInputs(); - await inputs.each(async (i) => { - if (await this.inputHasCalcModeButton(i)) { - ret.push(i); + const inputs = await $$("param-field-line"); + // await inputs.each(async (i) => { + // if (await this.inputHasCalcModeButton(i)) { + // ret.push(i); + // } + // }); + + // for await (const img of $$('img')) { + // console.log(await img.getAttribute('src)) + // } + + for (const inp of inputs) { + // if (await this.inputHasCalcModeButton(i)) { + // ret.push(i); + // } + const toggle = await inp.$("mat-button-toggle.radio_cal > button"); + if (await toggle.isExisting()) { + ret.push(inp); } - }); + } + return ret; } @@ -36,14 +81,16 @@ export class CalculatorPage { /** * get the option count of a select */ - async getMatselectOptionCount(select: string | Element) { - const sel = select instanceof Element ? select : $(`#${select}`); + async getMatselectOptionCount(select) { + const sel = typeof (select) === "string" ? $(`#${select}`) : select; await scrollToElement(sel); if ((await sel.isExisting()) && (await sel.isDisplayed())) { await sel.click(); const options = $$(".cdk-overlay-container mat-option"); // FIXME>>>>await sel.sendKeys(protractor.Key.ESCAPE); // close dropdown + //await sel.keys('Escape'); // close dropdown + await browser.keys(Key.Escape); // close dropdown return await options.length; } } @@ -51,21 +98,25 @@ export class CalculatorPage { /** * get the text of the all given select options */ - async getMatselectOptionsText(select: string | Element): Promise<string[]> { - const sel = select instanceof Element ? select : $(`#${select}`); + async getMatselectOptionsText(select) { + const sel = typeof (select) === "string" ? await $(`#${select}`) : select; await scrollToElement(sel); + await browser.pause(200); if ((await sel.isExisting()) && (await sel.isDisplayed())) { await sel.click(); - const options = $$(".cdk-overlay-container mat-option span"); + await browser.pause(500); + const options = await $$(".cdk-overlay-container mat-option span"); let res = []; - const nopt = await options.length; + const nopt = options.length; for (let o = 0; o < nopt; o++) { - const opt = options.get(o); + const opt = options[o]; res.push(await opt.getText()) } // FIXME>>>>await sel.sendKeys(protractor.Key.ESCAPE); // close dropdown - + // await sel.keys('Escape'); // close dropdown + await browser.keys(Key.Escape); // close dropdown + await browser.pause(500); return res; } } @@ -83,11 +134,18 @@ export class CalculatorPage { */ async getMatselectCurrentOptionText(select): Promise<string> { const currentOption = await this.getSelectCurrentOption(select); - return await currentOption.$("span span").getText(); + await browser.pause(100); + // return await currentOption.$("span span").getText(); + const opt = await currentOption.$("span span"); + await browser.pause(100); + const res = await opt.getText(); + await browser.pause(100); + return res; } getSelectById(id: string) { - return $(`#${id}`); + // return $(`#${id}`); + return $(`mat-select[id='${id}']`); // IDs cannot by a number, so use this query form } async isMatSelectPresent(id: string) { @@ -96,7 +154,8 @@ export class CalculatorPage { } async getSelectValueText(select) { - return await select.$(".mat-select-value-text > span").getText(); + const span = await select.$(".mat-select-value-text > span"); + return await span.getText(); } async isSelectEmpty(select) { @@ -110,7 +169,12 @@ export class CalculatorPage { } getInputById(id: string) { - return $(`#${id}`); + // return $(`#${id}`); + return $(`input[id='${id}']`); // IDs cannot by a number, so use this query form + } + + getNgInputById(id: string) { + return $(`ngparam-input input[id='${id}']`); // IDs cannot by a number, so use this query form } getSaveSessionButton() { @@ -130,11 +194,11 @@ export class CalculatorPage { } getAddStructureButton() { - return $("structure-fieldset-container .hyd-window-btns button.add-structure"); + return $("fieldset-container .hyd-window-btns button.add-structure"); } getCopyStructureButton() { - return $("structure-fieldset-container .hyd-window-btns button.copy-structure"); + return $("fieldset-container .hyd-window-btns button.copy-structure"); } getAllLinkButtons() { @@ -182,34 +246,74 @@ export class CalculatorPage { } async isNgParamPresent(id: string) { - const inp = $("ngparam-input input#" + id); + // const inp = $("ngparam-input input#" + id); + const inp = await this.getNgInputById(id); return await inp.isExisting(); } - async inputHasCalcModeButton(input) { + /** + * find parameter mode radio button linked to an input + */ + async getInputRadioButton(input, mode: string) { + const tag = await input.getTagName(); + // this function may not be called with an input but a param-field-line + const root = tag === "input" ? await this.findParentContainer(input) : input; // get parent (div.container) - const container = await this.findParentContainer(input); - // find radio buttons - const button = container.$("mat-button-toggle.radio_cal > button"); + // const container = ; + // find radio button + // return await root.$(`mat-button-toggle.radio_${mode} > button`); + return await root.$(`mat-button-toggle.radio_${mode}`); + } + + /** + * find parameter mode radio button linked to an input + */ + async getInputRadioButtonFromId(id, mode) { + const input = await this.getInputById(id); + // get parent (div.container) + // const container = await this.findParentContainer(input); + // // find radio button + // return await container.$(`mat-button-toggle.radio_${mode} > button`); + return await this.getInputRadioButton(input, mode); + } + + async inputHasCalcModeButton(input) { + // // get parent (div.container) + // const container = await this.findParentContainer(input); + // // find radio buttons + // const button = await container.$("mat-button-toggle.radio_cal > button"); + const button = await this.getInputRadioButton(input, "cal"); return await button.isExisting(); } async inputHasLinkModeButton(input) { - // get parent (div.container) - const container = await this.findParentContainer(input); - // find radio buttons - const button = container.$("mat-button-toggle.radio_link > button"); + // // get parent (div.container) + // const container = await this.findParentContainer(input); + // // find radio buttons + // const button = container.$("mat-button-toggle.radio_link > button"); + const button = await this.getInputRadioButton(input, "link"); return await button.isExisting(); } + async isRadioButtonChecked(radio) { + // return (await radio.getAttribute("ng-reflect-checked")) === "true"; + // if (await radio.getTagName() !== "mat-radio-button") { + if (await radio.getTagName() !== "mat-button-toggle") { + radio = await this.getParentElement(radio); + } + const a = await radio.getAttribute("ng-reflect-checked"); + return a === "true"; + } + /** * @returns true if "fixed mode" button linked to an input is selected */ async inputIsInFixedMode(input): Promise<boolean> { - // get parent (div.container) - const container = await this.findParentContainer(input); - // find fixed radio button - const button = container.$("mat-button-toggle.radio_fix"); + // // get parent (div.container) + // const container = await this.findParentContainer(input); + // // find fixed radio button + // const button = container.$("mat-button-toggle.radio_fix"); + const button = await this.getInputRadioButton(input, "fix"); return (await button.getAttribute("ng-reflect-checked")) === "true"; } @@ -217,10 +321,11 @@ export class CalculatorPage { * @returns true if "calculated mode" button linked to an input is selected */ async inputIsInCalculatedMode(input): Promise<boolean> { - // get parent (div.container) - const container = await this.findParentContainer(input); - // find calc radio button - const button = container.$("mat-button-toggle.radio_cal"); + // // get parent (div.container) + // const container = await this.findParentContainer(input); + // // find calc radio button + // const button = container.$("mat-button-toggle.radio_cal"); + const button = await this.getInputRadioButton(input, "cal"); return (await button.getAttribute("ng-reflect-checked")) === "true"; } @@ -228,32 +333,40 @@ export class CalculatorPage { * @returns true if "linked mode" button linked to an input is selected */ async inputIsInLinkedMode(input): Promise<boolean> { - // get parent (div.container) - const container = await this.findParentContainer(input); - // find calc radio button - const button = container.$("mat-button-toggle.radio_link"); + // // get parent (div.container) + // const container = await this.findParentContainer(input); + // // find calc radio button + // const button = container.$("mat-button-toggle.radio_link"); + const button = await this.getInputRadioButton(input, "link"); return (await button.getAttribute("ng-reflect-checked")) === "true"; } async hasResults() { - return ((await this.presentAndVisible("fixedvar-results fixed-results > .fixed-results-container")) - || - (await this.presentAndVisible("fixedvar-results results-chart > chart-results-container")) - || - (await this.presentAndVisible("section-results fixed-results > .fixed-results-container")) - || - (await this.presentAndVisible("remous-results #main-chart")) - || - (await this.presentAndVisible("pab-results pab-results-table")) - || - (await this.presentAndVisible("pb-results pb-results-table")) - || - (await this.presentAndVisible("macrorugo-compound-results macrorugo-compound-results-table")) || (await this.presentAndVisible("jet-results .fixed-results-container"))); - } - - async presentAndVisible(selector: string): Promise<boolean> { - const elt = $(selector); - return (await elt.isExisting()) && (await elt.isDisplayed()); + return (await (this.presentAndVisible("fixedvar-results fixed-results > .fixed-results-container")) + || + (await this.presentAndVisible("fixedvar-results results-chart > chart-results-container")) + || + (await this.presentAndVisible("section-results fixed-results > .fixed-results-container")) + || + (await this.presentAndVisible("remous-results #main-chart")) + || + (await this.presentAndVisible("pab-results pab-results-table")) + || + (await this.presentAndVisible("pb-results pb-results-table")) + || + (await this.presentAndVisible("macrorugo-compound-results macrorugo-compound-results-table")) + || + (await this.presentAndVisible("jet-results .fixed-results-container"))); + } + + async presentAndVisible(selector: string) { + const elt = await $(selector); + // return (await elt.isExisting()) && (await elt.isDisplayed()); + // console.log("presentAndVisible isExisting", selector, await elt.isExisting()) + // console.log("presentAndVisible isDisplayed", selector, await elt.isDisplayed()) + const res = (await elt.isExisting()) && (await elt.isDisplayed()); + // console.log("res", selector, res); + return res; } /** @@ -326,37 +439,89 @@ export class CalculatorPage { } async clickCloneCalcButton() { - const cloneButton = $("#clone-calc"); - return await cloneButton.click(); + const cloneButton = await $("#clone-calc"); + await scrollToElement(cloneButton); + await cloneButton.click(); } // check that "compute" button is in given enabled/disabled state async checkCalcButtonEnabled(enabled: boolean) { - const calcButton = this.getCalculateButton(); + const calcButton = await this.getCalculateButton(); expect(await calcButton.isEnabled()).toBe(enabled); return calcButton; } + async getParentElement(elt) { + return elt.$(".."); + } + // find parent element of elt having class "container" async findParentContainer(elt) { let i = 8; // garde fous while (((await elt.getAttribute("class")) !== "container") && (i >= 0)) { - elt = elt.$(".."); + // elt = await elt.$(".."); + elt = await this.getParentElement(elt) i--; } return elt; } + async logElement(elt, attr = undefined) { + console.log("ELT TAG", await elt.getTagName()); + console.log("ELT ID", await elt.getAttribute("id")); + console.log("ELT CLASS", await elt.getAttribute("class")); + // console.log("ELT VALUE '" + await elt.getAttribute("value") + "'"); + console.log("ELT VALUE '" + await elt.getValue() + "'"); + console.log("ELT TEXT '" + await elt.getText() + "'"); + if (attr !== undefined) { + console.log(`ELT ATTR '${attr}'='${await elt.getAttribute(attr)}'`); + } + } + + async logParamFieldLine(pfl) { + await this.logElement(pfl); + const inp = await pfl.$("ngparam-input input.form-control"); + await this.logElement(inp) + } + /** - * @param elt an <input> element + * @param paramFieldLine an <input> element * @param mode "fix", "var", "cal" or "link" */ async setParamMode(elt, mode: string) { + await scrollToElement(elt); + await browser.pause(100); + // // get parent (div.container) + // const container = await this.findParentContainer(elt); + // // find radio buttons + // const button = await container.$("mat-button-toggle.radio_" + mode + " > button"); + const button = await this.getInputRadioButton(elt, mode); + //await scrollPageToTop(); // sometimes button slides behind navbar and click() fails + await button.click(); + // for "var" mode, close the modal + if (mode === "var") { + await browser.pause(500); // wait for the modal to appear + //await element(by.css("dialog-edit-param-values .mat-dialog-actions button")).click(); // clique "annuler" et non "valider" : + const cancelBtn = await $("dialog-edit-param-values .mat-dialog-actions button.mat-warn"); + await cancelBtn.click(); + await browser.pause(500); // wait for the navbar to reappear after modal dismissal + } else { + await browser.pause(200); + } + } + + async setParamMode2(paramFieldLine, mode: string) { + // await elt.scrollIntoView({ block: 'center', inline: 'center' }); + // await paramFieldLine.waitForDisplayed(); + // await paramFieldLine.scrollIntoView({ block: 'center' }); + + // browser.executeScript("document.querySelector('#countries').scrollIntoView()") + //await browser.execute(e => { e.scrollIntoView({ block: 'center' }) }, paramFieldLine); + await scrollToElement(paramFieldLine); + // await browser.pause(100); // get parent (div.container) - const container = await this.findParentContainer(elt); - // find radio buttons - const button = container.$("mat-button-toggle.radio_" + mode + " > button"); - await scrollPageToTop(); // sometimes button slides behind navbar and click() fails + const button = await paramFieldLine.$("mat-button-toggle.radio_" + mode + " > button"); + //await scrollPageToTop(); // sometimes button slides behind navbar and click() fails await button.click(); // for "var" mode, close the modal if (mode === "var") { @@ -383,13 +548,14 @@ export class CalculatorPage { * by parameter ID */ async storeAllInputValues() { - const inputs = this.getParamInputs(); + const inputs = await this.getParamInputs(); const values = {}; - await inputs.each(async (i) => { + for (const i of inputs) { const inputId = await i.getAttribute("id"); - const inputValue = await i.getAttribute("value"); + // const inputValue = await i.getAttribute("value"); + const inputValue = await i.getValue(); values[inputId] = +inputValue; // cast to number to avoid false negative (integers starting with 0) - }); + }; return values; } @@ -397,24 +563,27 @@ export class CalculatorPage { * Modifies all the calculator's editable inputs values by adding a random digit other than 0 at the end */ async modifyAllInputValues() { - const inputs = this.getParamInputs(); - await inputs.each(async (i) => { + const inputs = await this.getParamInputs(); + for (const i of inputs) { if (await i.isDisplayed()) { // N in YAXN child of SPP module must not be float - const isN = (await i.getAttribute("id")).includes("_N"); // @TODO strengthen this clodo test + const id = await i.getAttribute("id"); + const isN = id.includes("_N"); // @TODO strengthen this clodo test // Ob in Grille is set to 0.5 but cannot exceed 0.58; do not touch it - const isOb = (await i.getAttribute("id")) === "Ob"; - const hasDot = (await i.getAttribute("value")).includes("."); - const hasExponent = (await i.getAttribute("value")).includes("e"); - let keys = "" + Math.floor(Math.random() * 9) + 1; + const isOb = id === "Ob"; + // const value = await i.getAttribute("value"); + const value = await i.getValue(); + const hasDot = value.includes("."); + const hasExponent = value.includes("e"); + let keys = "" + (Math.floor(Math.random() * 9) + 1); if (!hasDot && !hasExponent && !isN) { keys = "." + keys; } if (!isOb && (await i.getAttribute("disabled")) === null) { - await i.setValue(keys); + await i.addValue(keys); } } - }); + }; } /** @@ -423,8 +592,9 @@ export class CalculatorPage { * @param empty true to check input is empty, false to check it is NOT empty */ async checkEmptyInput(id: string, empty: boolean = true) { - const inp = this.getInputById(id); - const val = await inp.getAttribute("value"); + const inp = await this.getInputById(id); + // const val = inp.getAttribute("value"); + const val = await inp.getValue() if (empty) { expect(val).toEqual(""); } @@ -442,7 +612,8 @@ export class CalculatorPage { let n = 0; for (const id of inputIds) { const inp = await this.getInputById(id); - const txt = await inp.getAttribute("value"); + // const txt = await inp.getAttribute("value"); + const txt = await inp.getValue(); expect(txt === "").toEqual(emptys[n]); n++; } @@ -458,11 +629,31 @@ export class CalculatorPage { /** * reliable input clearing */ - async clearInput(inp: ElementFinder) { - const txt = await inp.getAttribute('value'); + async clearInput(inp) { + await inp.click(); // make input get focus for browser.keys() to send key sequence to it + const txt = await inp.getValue(); const len = txt.length; for (let n = 0; n < len; n++) { - await inp.sendKeys(Key.BACK_SPACE); + await browser.keys(Key.Backspace); } } + + async closeSnackBar() { + // const sb = $(".mat-simple-snackbar-action"); + const sb = $("simple-snack-bar button"); + if ((await sb.isExisting()) && (await sb.isDisplayed())) { + await sb.click(); + return true; + } + return false; + } + + async closeSnackBars(n: number, pause: number) { + let stop: boolean; + do { + stop = !await this.closeSnackBar(); + await browser.pause(pause); + n--; + } while (n > 0 && !stop); + } } diff --git a/e2e/check-translations.e2e-spec.ts b/e2e/check-translations.e2e-spec.ts index cd0493c6f66ab2d5deb1a67c663de43e92ef39b1..cd06561de0fb982381ba9561c4ab81c00d393176 100644 --- a/e2e/check-translations.e2e-spec.ts +++ b/e2e/check-translations.e2e-spec.ts @@ -4,6 +4,7 @@ import { Navbar } from "./navbar.po"; import { PreferencesPage } from "./preferences.po"; 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 @@ -71,13 +72,17 @@ describe("ngHyd − check translation of all calculators", () => { 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.getSource()).not.toContain("*** message not found", "missing translations found"); + // const source = document.body.innerHTML; + const source = await browser.execute("return document.body.innerHTML"); + // expect(await browser.getSource()).not.toContain("*** message not found", "missing translations found"); + expect(source).not.toContain("*** message not found", "missing translations found"); // empty session await navBar.clickMenuButton(); diff --git a/e2e/cloisons.e2e-spec.ts b/e2e/cloisons.e2e-spec.ts index f372175d1286d048ecf5ee1579f10240b9ccb9f1..b134960bfd240b05afadedcf7d3c30652146adbc 100644 --- a/e2e/cloisons.e2e-spec.ts +++ b/e2e/cloisons.e2e-spec.ts @@ -3,6 +3,7 @@ import { CalculatorPage } from "./calculator.po"; 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 :) @@ -38,23 +39,25 @@ describe("ngHyd − cloisons", () => { 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 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 changeSelectValue(await calcPage.getSelectById("select_loidebit"), 1); await browser.pause(300); - + // 5. check number of inputs in CALC mode 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); }); }); diff --git a/e2e/clone-all-calc.e2e-spec.ts b/e2e/clone-all-calc.e2e-spec.ts index f8a588fec772d3178644f12e350beeeda9366224..3520cd7d972da467fe2a9f333182dffcaf1268ec 100644 --- a/e2e/clone-all-calc.e2e-spec.ts +++ b/e2e/clone-all-calc.e2e-spec.ts @@ -3,7 +3,9 @@ import { CalculatorPage } from "./calculator.po"; import { Navbar } from "./navbar.po"; 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 @@ -11,14 +13,16 @@ 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 () => { @@ -26,6 +30,8 @@ describe("ngHyd − clone all calculators with all possible <select> values", () await prefPage.navigateTo(); await prefPage.disableEvilEmptyFields(); await browser.pause(200); + + await navBar.clickNewCalculatorButton(); }); describe("", () => { @@ -40,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,12 +64,12 @@ describe("ngHyd − clone all calculators with all possible <select> values", () await scrollPageToTop(); await calcPage.clickCloneCalcButton(); await browser.pause(300); - + // check existence of the cloned module - expect(await navbar.getAllCalculatorTabs().length).toBe(2); - + expect(await navBar.getAllCalculatorTabs().length).toBe(2); + // @TODO check <select> values - + // read all <input> values and compare them to stored ones const cloneValues = await calcPage.storeAllInputValues(); for (const k in cloneValues) { diff --git a/e2e/clone-calc.e2e-spec.ts b/e2e/clone-calc.e2e-spec.ts index 1fcb7dd4f172f247bc84b50313fecbd594529716..f52677838af1dc9d88aae730f8a5169b7f0c6032 100644 --- a/e2e/clone-calc.e2e-spec.ts +++ b/e2e/clone-calc.e2e-spec.ts @@ -3,6 +3,7 @@ import { CalculatorPage } from "./calculator.po"; import { Navbar } from "./navbar.po"; import { PreferencesPage } from "./preferences.po"; import { changeSelectValue, scrollPageToTop } from "./util.po"; +import { browser, $, $$, expect } from '@wdio/globals' /** * Clone calculators @@ -32,7 +33,7 @@ describe("ngHyd − clone a calculator", () => { // 1. create target modules for linked parameter await listPage.clickMenuEntryForCalcType(3); // Régime uniforme await browser.pause(500); - const debitRU = calcPage.getInputById("calc_Q"); // "Débit" is calculated by default + const debitRU = await calcPage.getInputById("calc_Q"); // "Débit" is calculated by default await calcPage.setParamMode(debitRU, "fix"); await browser.pause(500); @@ -50,16 +51,18 @@ describe("ngHyd − clone a calculator", () => { k: 0.6, Ks: 42 }; - await changeSelectValue(calcPage.getSelectById("select_section"), 3); // mode "parabolique" + 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.pause(500); - await changeSelectValue(calcPage.getSelectById("linked_Q"), 1); // "Courbe de remous" + 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" @@ -73,11 +76,15 @@ describe("ngHyd − clone a calculator", () => { await browser.pause(500); // 5. compare values - Object.keys(sourceValues).forEach(async (k) => { + // Object.keys(sourceValues).forEach(async (k) => { + // const v = sourceValues[k]; + for (const k in sourceValues) { const v = sourceValues[k]; - const displayedVal = await calcPage.getInputById(k).getAttribute("value"); + // 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) }); diff --git a/e2e/compute-reset-chained-links.e2e-spec.ts b/e2e/compute-reset-chained-links.e2e-spec.ts index 6152104ec32e4af7257caf2356a3c56eeb0d955a..73b01da871f6972af71fe40ba74e4a4e3858cf6b 100644 --- a/e2e/compute-reset-chained-links.e2e-spec.ts +++ b/e2e/compute-reset-chained-links.e2e-spec.ts @@ -3,6 +3,8 @@ import { CalculatorPage } from "./calculator.po"; import { Navbar } from "./navbar.po"; import { SideNav } from "./sidenav.po"; import { PreferencesPage } from "./preferences.po"; +import { browser, $, $$, expect } from '@wdio/globals' +import { newSession } from "./util.po"; /** * Load a session containing 3 calculators, having linked parameters @@ -14,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(); }); @@ -29,35 +31,36 @@ 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 navBar.clickMenuButton(); await browser.pause(200); await sidenav.clickLoadSessionButton(); await browser.pause(200); await sidenav.loadSessionFile("./session/session-cascade-params.json"); await browser.pause(500); - expect(await navbar.getAllCalculatorTabs().length).toBe(3); + 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(); 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").clearValue(); @@ -65,13 +68,13 @@ describe("ngHyd − compute then reset chained results − ", () => { // 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").clearValue(); @@ -79,7 +82,7 @@ describe("ngHyd − compute then reset chained results − ", () => { // 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); } @@ -88,30 +91,31 @@ 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 navBar.clickMenuButton(); await browser.pause(200); await sidenav.clickLoadSessionButton(); await browser.pause(200); await sidenav.loadSessionFile("./session/session-cascade-results.json"); await browser.pause(500); - expect(await navbar.getAllCalculatorTabs().length).toBe(3); + 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(); 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").clearValue(); @@ -119,71 +123,75 @@ describe("ngHyd − compute then reset chained results − ", () => { // 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.pause(200); // start page - await navbar.clickNewCalculatorButton(); + await navBar.clickNewCalculatorButton(); await browser.pause(200); // load session file - await navbar.clickMenuButton(); + await navBar.clickMenuButton(); await browser.pause(200); await sidenav.clickLoadSessionButton(); await browser.pause(200); await sidenav.loadSessionFile("./session/session-results-invalidation.json"); await browser.pause(500); - expect(await navbar.getAllCalculatorTabs().length).toBe(2); + 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(); 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").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"); + await navBar.clickCalculatorTabForUid("aTgwMm"); const calcButton2 = 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").clearValue(); - await calcPage.getInputById("0_ZDV").setValue("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); - }); }); diff --git a/e2e/cote-amont-aval-bief.e2e-spec.ts b/e2e/cote-amont-aval-bief.e2e-spec.ts index 294151d0f8308ef9d70454d143e296d8c79af5a5..cee4caaeef89233ffd40dde3633cb66f33eb07c8 100644 --- a/e2e/cote-amont-aval-bief.e2e-spec.ts +++ b/e2e/cote-amont-aval-bief.e2e-spec.ts @@ -2,18 +2,23 @@ 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 () => { @@ -37,32 +42,32 @@ describe("ngHyd − up/downstream elevations of a reach", () => { await flowCalcBtn.click(); // check details buttons are disabled - const upDetailsBtn = $("#generate-sp-aval"); - expect(upDetailsBtn.isEnabled()).toBe(false); - const downDetailsBtn = $("#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"); + const upWEinput = await calcPage.getInputById("Z1"); await upWEinput.clearValue(); await upWEinput.setValue("100.664"); // run calculation const calcButton = calcPage.getCalculateButton(); await calcButton.click(); - await browser.pause(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.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); @@ -70,38 +75,40 @@ describe("ngHyd − up/downstream elevations of a reach", () => { 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.pause(200); // check details buttons status - const upDetailsBtn = $("#generate-sp-aval"); - expect(upDetailsBtn.isEnabled()).toBe(true); - const downDetailsBtn = $("#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.pause(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.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); @@ -109,7 +116,7 @@ describe("ngHyd − up/downstream elevations of a reach", () => { 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); }); }); diff --git a/e2e/courbe-remous-empty-fields.e2e-spec.ts b/e2e/courbe-remous-empty-fields.e2e-spec.ts index 35dbdf61be9bb9d39cac63b862cad2d99a63aafa..39a08fd4c5ac6fb89200a4df93ba2280eb1abc88 100644 --- a/e2e/courbe-remous-empty-fields.e2e-spec.ts +++ b/e2e/courbe-remous-empty-fields.e2e-spec.ts @@ -2,6 +2,7 @@ import { ListPage } from "./list.po"; import { Navbar } from "./navbar.po"; 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; @@ -29,7 +30,7 @@ describe("Check fields are empty in 'backwater curves' calculator when created w await listPage.clickMenuEntryForCalcType(4); 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]); }); }); diff --git a/e2e/diagramme-modules.e2e-spec.ts b/e2e/diagramme-modules.e2e-spec.ts index a10251f05d967026e5efb8be7630453d8dd24f46..4d523a2bbce9a417d119600f6f5f83fe59503612 100644 --- a/e2e/diagramme-modules.e2e-spec.ts +++ b/e2e/diagramme-modules.e2e-spec.ts @@ -2,6 +2,7 @@ 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 @@ -48,8 +49,8 @@ describe("modules diagram", () => { await browser.pause(200); // click first module - const nodes = $$("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.pause(200); diff --git a/e2e/documentation.e2e-spec.ts b/e2e/documentation.e2e-spec.ts index b1e8d50cca1100ba8e92e31649a043116b3cb3eb..39ae0c60f025163f8c826bd5b5d6aab464b97ef4 100644 --- a/e2e/documentation.e2e-spec.ts +++ b/e2e/documentation.e2e-spec.ts @@ -2,17 +2,18 @@ import { ListPage } from "./list.po"; import { CalculatorPage } from "./calculator.po"; import { Navbar } from "./navbar.po"; 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); @@ -26,7 +27,7 @@ describe("documentation − ", () => { await browser.pause(200); // start page - await navbar.clickNewCalculatorButton(); + await navBar.clickNewCalculatorButton(); await browser.pause(200); // open "fish ladder: fall" calculator @@ -37,36 +38,28 @@ describe("documentation − ", () => { await calcPage.getCalculatorHelpButton().click(); await browser.pause(200); - browser.getWindowHandles().then(async (handles) => { - const old = browser.ignoreSynchronization + const handles = await browser.getWindowHandles(); - // switch to help tab - browser.switchToWindow(handles[1]).then(async () => { - await browser.pause(200); - // check Mathjax element is present - expect(await $("mjx-container").isExisting()).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.switchToWindow(handles[0]); - await browser.pause(200); - // browser.ignoreSynchronization = false; - }).then(async () => { - // switch back to calculator (required to avoid failure of next language test) - await browser.switchToWindow(handles[0]); - await browser.pause(200); - }); - }); - } + // 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); + + // 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); + }; - xit("check Mathjax formula are displayed in calculator French help", async () => { - debugger + 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 }); }); diff --git a/e2e/duplicate-results.e2e-spec.ts b/e2e/duplicate-results.e2e-spec.ts index aed31aaec14b569e498b0535e8e0b9dacd5ccf98..ae36dcc5414fd8d58c3d37d83aa878ba75e56fcc 100644 --- a/e2e/duplicate-results.e2e-spec.ts +++ b/e2e/duplicate-results.e2e-spec.ts @@ -2,6 +2,7 @@ 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; @@ -31,12 +32,13 @@ describe("ngHyd − check that results are not duplicated", () => { 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.length; + const fixRows = await calcPage.getAllFixedResultsRows(); + const nbRows = fixRows.length; console.log(nbRows); expect(nbRows).toBe(24); // boundaries are included }); diff --git a/e2e/examples-empty-fields.e2e-spec.ts b/e2e/examples-empty-fields.e2e-spec.ts index eb6b8c32afbff0df575d0c7d38e8305c85a53d7a..2c619e644376826a06b7bfc624c7c9cf75a4869e 100644 --- a/e2e/examples-empty-fields.e2e-spec.ts +++ b/e2e/examples-empty-fields.e2e-spec.ts @@ -1,7 +1,9 @@ import { CalculatorPage } from "./calculator.po"; import { Navbar } from "./navbar.po"; import { PreferencesPage } from "./preferences.po" -import { changeSelectValue } from "./util.po"; +import { SideNav } from "./sidenav.po"; +import { changeSelectValue, newSession } from "./util.po"; +import { browser, $, $$, expect } from '@wdio/globals' /** * check that fields are empty on creation @@ -10,11 +12,13 @@ describe("ngHyd - Check that examples fields are not empty with 'empty fields on let prefPage: PreferencesPage; let navBar: Navbar; let calcPage: CalculatorPage; + let sideNav: SideNav; beforeAll(() => { prefPage = new PreferencesPage(); navBar = new Navbar(); calcPage = new CalculatorPage(); + sideNav = new SideNav(); }); beforeEach(async () => { @@ -32,7 +36,7 @@ describe("ngHyd - Check that examples fields are not empty with 'empty fields on // open 1st example const examples = await $$("#examples-list .load-example"); - await (await examples)[0].click(); + await examples[0].click(); await browser.pause(50); // select wall module @@ -46,13 +50,15 @@ describe("ngHyd - Check that examples fields are not empty with 'empty fields on }); it("calculated parameter initial value when discharge law is modified", async () => { + await newSession(navBar, sideNav); + // start page - await navBar.clickNewCalculatorButton(); - await browser.pause(200); + // await navBar.clickNewCalculatorButton(); + // await browser.pause(200); // open 1st example const examples = await $$("#examples-list .load-example"); - await (await examples)[0].click(); + await examples[0].click(); await browser.pause(50); // select wall module @@ -60,19 +66,21 @@ describe("ngHyd - Check that examples fields are not empty with 'empty fields on await browser.pause(50); // modify 1st structure discharge law - const dischargeSelect = calcPage.getSelectById("select_loidebit"); + const dischargeSelect = await calcPage.getSelectById("select_loidebit"); await changeSelectValue(dischargeSelect, 1); await browser.pause(200); // open initial dialog - const initDlgButton = $(".param-computed-more"); + const initDlgButton = await $(".param-computed-more"); await initDlgButton.click(); await browser.pause(200); // check input value is not null - const input = calcPage.getInputById("initval-input"); - const underlyingInput = input.$("#0_h1"); - const txt = await underlyingInput.getAttribute("value"); + // const input = await calcPage.getInputById("initval-input"); + // const underlyingInput = await input.$("#0_h1"); + const underlyingInput = await $("ngparam-input input.form-control[id='0_h1']"); + // const txt = await underlyingInput.getAttribute("value"); + const txt = await underlyingInput.getValue(); expect(txt === "").toEqual(false); }); }); @@ -81,11 +89,13 @@ describe("ngHyd - Check that examples work with 'empty fields on calculator crea let prefPage: PreferencesPage; let navBar: Navbar; let calcPage: CalculatorPage; + let sideNav: SideNav; beforeAll(() => { prefPage = new PreferencesPage(); navBar = new Navbar(); calcPage = new CalculatorPage(); + sideNav = new SideNav(); }); beforeEach(async () => { @@ -97,13 +107,15 @@ describe("ngHyd - Check that examples work with 'empty fields on calculator crea }); it("when calculation is run on a generated fish ladder calculator", async () => { + await newSession(navBar, sideNav); + // start page - await navBar.clickNewCalculatorButton(); - await browser.pause(200); + // await navBar.clickNewCalculatorButton(); + // await browser.pause(200); // open 1st example const examples = await $$("#examples-list .load-example"); - await (await examples)[0].click(); + await examples[0].click(); await browser.pause(50); // select wall module @@ -111,17 +123,17 @@ describe("ngHyd - Check that examples work with 'empty fields on calculator crea await browser.pause(50); // run calculation - const calcButton = calcPage.getCalculateButton(); + const calcButton = await calcPage.getCalculateButton(); await calcButton.click(); await browser.pause(200); // click "generate PAB" button - const genButton = calcPage.getGeneratePabButton(); + const genButton = await calcPage.getGeneratePabButton(); await genButton.click(); - await browser.pause(200); + await browser.pause(1000); // write "6" in basin count input - const nbBassins = calcPage.getInputById("generatePabNbBassins"); + const nbBassins = await calcPage.getInputById("generatePabNbBassins"); await nbBassins.setValue("6"); await browser.pause(50); @@ -130,7 +142,7 @@ describe("ngHyd - Check that examples work with 'empty fields on calculator crea await browser.pause(1000); // calculate PAB - const calcButtonPAB = calcPage.getCalculateButton(); + const calcButtonPAB = await calcPage.getCalculateButton(); await calcButtonPAB.click(); await browser.pause(200); diff --git a/e2e/helpers/GremlinHelper.ts b/e2e/helpers/GremlinHelper.ts index 0da3f0619c7be0f1ecfc64319b2b23d2cfb5f57e..434ffd8607861575a5771dd8766fba2d37160168 100644 --- a/e2e/helpers/GremlinHelper.ts +++ b/e2e/helpers/GremlinHelper.ts @@ -18,7 +18,8 @@ function findFpsMessages(log: any[]) { } export function readGremlinsScript(): string { - return readFileSync(__dirname + "/gremlins.min.js", "UTF-8"); + // return readFileSync(__dirname + "/gremlins.min.js", "UTF-8"); + return readFileSync(__dirname + "/gremlins.min.js", "utf-8"); } export function unleashGremlins(callback: (args?: any) => void) { @@ -82,14 +83,14 @@ export function unleashGremlins(callback: (args?: any) => void) { // 2. <mat-icon> d'aide ? if ( element.tagName === "MAT-ICON" - && [ "help-calc", "help-fieldset", "help-fieldset-container", "help-input", "help-select" ].includes(element.id) + && ["help-calc", "help-fieldset", "help-fieldset-container", "help-input", "help-select"].includes(element.id) ) { return false; } else { // 3. file input ? let isFileInput = false; let curElem = element; - while (! isFileInput && curElem) { + while (!isFileInput && curElem) { isFileInput = ( curElem.tagName === "MAT-FORM-FIELD" && curElem.classList.contains("file-input-field") @@ -141,7 +142,7 @@ export function unleashGremlins(callback: (args?: any) => void) { // tslint:disable-next-line:quotemark 'input[type="text"]': function fillTextElement(element: HTMLInputElement) { // only send numbers in form fields - const num = [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ][ Math.floor(Math.random() * 10) ]; + const num = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"][Math.floor(Math.random() * 10)]; element.value += num; element.dispatchEvent(new Event("input")); // so that the model is updated @TODO check that it works // @TODO wait before returning, needs async/await @@ -158,13 +159,13 @@ export function unleashGremlins(callback: (args?: any) => void) { ) .gremlin(Gremlins.species.toucher()) // OK // custom gremlin : click side menu, then an entry of the menu - .gremlin(function() { + .gremlin(function () { clickElementCenter("#open-menu"); const menuLinks = document.querySelectorAll("mat-sidenav .links-container > a"); const idx = Math.floor(Math.random() * menuLinks.length); const link = menuLinks.item(idx); // exclude links that would make us leave the app - if (! [ "side-nav-help", "side-nav-bug-report" ].includes(link.id)) { + if (!["side-nav-help", "side-nav-bug-report"].includes(link.id)) { doClickElementCenter(link); logs.log.push([ "gremlin", @@ -176,11 +177,11 @@ export function unleashGremlins(callback: (args?: any) => void) { } }) // custom gremlin : click new module button - .gremlin(function() { + .gremlin(function () { clickElementCenter("#new-calculator"); }) // custom gremlin : click calculate button - .gremlin(function() { + .gremlin(function () { clickElementCenter("#trigger-calculate"); }) @@ -193,7 +194,7 @@ export function unleashGremlins(callback: (args?: any) => void) { .strategy(Gremlins.strategies.distribution() .delay(delay) // default: 10 // .nb(100) // default: 100 - .distribution([ 0.62, 0.05, 0.05, 0.1, 0.02, 0.03, 0.03, 0.1 ]) + .distribution([0.62, 0.05, 0.05, 0.1, 0.02, 0.03, 0.03, 0.1]) // .distribution([ 0.72, 0.05, 0.05, 0.02, 0.03, 0.03, 0.1 ]) // same as above, without formFiller // .distribution([ 0.5, 0, 0, 0, 0, 0.5, 0, 0 ]) // only "open menu" and "click" ) @@ -230,7 +231,7 @@ export function unleashGremlins(callback: (args?: any) => void) { function doClickElementCenter(targetElement: Element): boolean { if (targetElement) { const evt = document.createEvent("MouseEvents"); - const [ posX, posY ] = getElementCenter(targetElement); + const [posX, posY] = getElementCenter(targetElement); evt.initMouseEvent("click", true, true, window, 0, 0, 0, posX, posY, false, false, false, false, 0, null); targetElement.dispatchEvent(evt); return true; @@ -242,21 +243,21 @@ export function unleashGremlins(callback: (args?: any) => void) { const rect = element.getBoundingClientRect(); const posX = rect.left + window.scrollX + (rect.width / 2); const posY = rect.top + window.scrollY + (rect.height / 2); - return [ posX, posY ]; + return [posX, posY]; } function getRandomPositionInsideElement(element: Element, modal: boolean = false) { const rect = element.getBoundingClientRect(); let minX = rect.left; - if (! modal) { + if (!modal) { minX += window.scrollX; } let minY = rect.top; - if (! modal) { + if (!modal) { minY += window.scrollY; } const posX = minX + Math.floor(Math.random() * rect.width); const posY = minY + Math.floor(Math.random() * rect.height); - return [ posX, posY ]; + return [posX, posY]; } } diff --git a/e2e/lechapt-calmon.e2e-spec.ts b/e2e/lechapt-calmon.e2e-spec.ts index 7a0f68dddd6132f8e64380f3fd7580e89deb237c..3d4eaf9b90f5e739f9336df426d5f31cccc6fd3e 100644 --- a/e2e/lechapt-calmon.e2e-spec.ts +++ b/e2e/lechapt-calmon.e2e-spec.ts @@ -3,6 +3,7 @@ import { CalculatorPage } from "./calculator.po"; import { PreferencesPage } from "./preferences.po"; import { Navbar } from "./navbar.po"; import { changeSelectValue } from "./util.po"; +import { browser, $, $$, expect } from '@wdio/globals' /** * Check that created/cloned structures have empty fields when @@ -43,17 +44,18 @@ describe("Lechapt&Calmon - ", () => { await setup(); // select last material type - const materialSelect = calcPage.getSelectById("select_material"); + const materialSelect = await calcPage.getSelectById("select_material"); await changeSelectValue(materialSelect, 8); await browser.pause(200); // run calculation - const calcButton = calcPage.getCalculateButton(); + const calcButton = await calcPage.getCalculateButton(); await calcButton.click(); await browser.pause(200); // store total pressure loss result - const res1 = calcPage.getAllFixedResultsRows().get(4); + const rows = await calcPage.getAllFixedResultsRows(); + const res1 = rows[4]; const pl1 = await res1.$$("td")[1].getText(); // select first material type @@ -65,7 +67,8 @@ describe("Lechapt&Calmon - ", () => { await browser.pause(200); // compare total pressure loss result with first calculaiotn - const res2 = calcPage.getAllFixedResultsRows().get(4); + const rows2 = await calcPage.getAllFixedResultsRows(); + const res2 = rows2[4]; const pl2 = await res2.$$("td")[1].getText(); expect(pl1).not.toEqual(pl2); diff --git a/e2e/link-parallel-devices.e2e-spec.ts b/e2e/link-parallel-devices.e2e-spec.ts index 845ccfdad901bc93c3b63b776e189e87c3307d2f..b4d62ae25c73c531f65a1928ac838c70defe129c 100644 --- a/e2e/link-parallel-devices.e2e-spec.ts +++ b/e2e/link-parallel-devices.e2e-spec.ts @@ -2,18 +2,23 @@ import { ListPage } from "./list.po"; import { CalculatorPage } from "./calculator.po"; import { PreferencesPage } from "./preferences.po"; import { Navbar } from "./navbar.po"; +import { browser, $, $$, expect } from '@wdio/globals' +import { newSession } from "./util.po"; +import { SideNav } from "./sidenav.po"; describe("ngHyd − parallel structures with multiple linked parameters − ", () => { let listPage: ListPage; let calcPage: CalculatorPage; let prefPage: PreferencesPage; let navBar: Navbar; + let sideNav: SideNav; beforeAll(() => { calcPage = new CalculatorPage(); listPage = new ListPage(); prefPage = new PreferencesPage(); navBar = new Navbar(); + sideNav = new SideNav(); }); beforeEach(async () => { @@ -26,23 +31,34 @@ describe("ngHyd − parallel structures with multiple linked parameters − ", ( it("when creating Parallel Structures, devices should be linkable to one another", async () => { await navBar.clickNewCalculatorButton(); await listPage.clickMenuEntryForCalcType(8); - await calcPage.getAddStructureButton().click(); + await browser.pause(200); + const addBtn = await calcPage.getAddStructureButton(); + await addBtn.click(); + await browser.pause(200); const nb1 = await calcPage.getAllLinkButtons().length; expect(nb1).toBe(8); // link buttons on children but not on parent }); - + it("when creating Cloisons, devices should be linkable to one another", async () => { - await navBar.clickNewCalculatorButton(); + await newSession(navBar, sideNav); + // await navBar.clickNewCalculatorButton(); await listPage.clickMenuEntryForCalcType(10); - await calcPage.getAddStructureButton().click(); + await browser.pause(200); + const addBtn = await calcPage.getAddStructureButton(); + await addBtn.click(); + await browser.pause(200); const nb2 = await calcPage.getAllLinkButtons().length; expect(nb2).toBe(6); // link buttons on children but not on parent }); - + it("when creating Dever, devices should be linkable to one another", async () => { - await navBar.clickNewCalculatorButton(); + await newSession(navBar, sideNav); + // await navBar.clickNewCalculatorButton(); await listPage.clickMenuEntryForCalcType(9); - await calcPage.getAddStructureButton().click(); + await browser.pause(200); + const addBtn = await calcPage.getAddStructureButton(); + await addBtn.click(); + await browser.pause(200); const nb3 = await calcPage.getAllLinkButtons().length; expect(nb3).toBe(6); // link buttons on children but not on parent }); diff --git a/e2e/link-to-deleted-module.e2e-spec.ts b/e2e/link-to-deleted-module.e2e-spec.ts index da428de9849c482eb5f993dfff79f944665a338f..fe62a73bcf039b92bf1828087f6b85f5a38c62ba 100644 --- a/e2e/link-to-deleted-module.e2e-spec.ts +++ b/e2e/link-to-deleted-module.e2e-spec.ts @@ -2,18 +2,23 @@ import { CalculatorPage } from "./calculator.po"; import { ListPage } from "./list.po"; import { Navbar } from "./navbar.po"; import { PreferencesPage } from "./preferences.po"; +import { browser, $, $$, expect } from '@wdio/globals' +import { newSession } from "./util.po"; +import { SideNav } from "./sidenav.po"; describe("linked parameter - ", () => { let calcPage: CalculatorPage; let prefPage: PreferencesPage; let navBar: Navbar; let listPage: ListPage; + let sideNav: SideNav; beforeAll(() => { calcPage = new CalculatorPage(); prefPage = new PreferencesPage(); navBar = new Navbar(); listPage = new ListPage(); + sideNav = new SideNav(); }); beforeEach(async () => { @@ -30,7 +35,7 @@ describe("linked parameter - ", () => { it("delete linked module", async () => { // open "channel flow with hydraulic structures" example const examples = await $$("#examples-list .load-example"); - await (await examples)[1].click(); + await examples[1].click(); await browser.pause(500); // select "up/downstream elevations of a reach" tab @@ -51,11 +56,13 @@ describe("linked parameter - ", () => { await navBar.middleClickCalculatorTab(0); // check Z2 input is in "fixed" state in remaining calculator - const inpZ2 = calcPage.getInputById("Z2"); + const inpZ2 = await calcPage.getInputById("Z2"); expect(await calcPage.inputIsInFixedMode(inpZ2)).toBe(true); }); it("delete linked module and duplicate remaining one", async () => { + await newSession(navBar, sideNav); + // open "fish ladder: fall" calculator await listPage.clickMenuEntryForCalcType(12); await browser.pause(200); @@ -65,7 +72,7 @@ describe("linked parameter - ", () => { await browser.pause(200); // set DH in link mode - let inpDH = calcPage.getInputById("DH"); + let inpDH = await calcPage.getInputById("DH"); await calcPage.setParamMode(inpDH, "link"); await browser.pause(200); @@ -74,11 +81,12 @@ describe("linked parameter - ", () => { await browser.pause(200); // check DH input is in "fixed" state in remaining calculator (not the aim of this test) - inpDH = calcPage.getInputById("DH"); + inpDH = await calcPage.getInputById("DH"); expect(await calcPage.inputIsInFixedMode(inpDH)).toBe(true); // set DH to calculated mode await calcPage.setParamMode(inpDH, "cal"); + await browser.pause(100); // clone calculator await calcPage.clickCloneCalcButton(); @@ -89,7 +97,7 @@ describe("linked parameter - ", () => { await browser.pause(500); // check DH input is in "calc" mode - inpDH = calcPage.getInputById("DH"); + inpDH = await calcPage.getInputById("DH"); expect(await calcPage.inputIsInCalculatedMode(inpDH)).toBe(true); }); }); diff --git a/e2e/linked-parameter-section-type.e2e-spec.ts b/e2e/linked-parameter-section-type.e2e-spec.ts index e663ff009c6926332ae7be57395ad0784fca5c40..d663d2d9e281a030700de7322a4887e77b1a9e6c 100644 --- a/e2e/linked-parameter-section-type.e2e-spec.ts +++ b/e2e/linked-parameter-section-type.e2e-spec.ts @@ -3,6 +3,7 @@ import { Navbar } from "./navbar.po"; import { PreferencesPage } from "./preferences.po"; import { CalculatorPage } from "./calculator.po"; import { changeSelectValue } from "./util.po"; +import { browser } from "@wdio/globals"; describe("linked parameter in calculator with section - ", () => { let listPage: ListPage; @@ -10,7 +11,7 @@ describe("linked parameter in calculator with section - ", () => { let calcPage: CalculatorPage; let prefPage: PreferencesPage; - beforeAll( () => { + beforeAll(() => { listPage = new ListPage(); navBar = new Navbar(); calcPage = new CalculatorPage(); @@ -38,11 +39,11 @@ describe("linked parameter in calculator with section - ", () => { await browser.pause(200); // set Q parameter to linked mode - const inputQ = calcPage.getInputById("Q"); + const inputQ = await calcPage.getInputById("Q"); await calcPage.setParamMode(inputQ, "link"); // change section type - await changeSelectValue(calcPage.getSelectById("select_section"), 3); // mode "parabolique" + await changeSelectValue(await calcPage.getSelectById("select_section"), 3); // mode "parabolique" // check Q is still in linked mode expect(await calcPage.inputIsInLinkedMode(inputQ)).toBe(true); diff --git a/e2e/list.e2e-spec.ts b/e2e/list.e2e-spec.ts index c89367c949f1e395f7043708d77695e34ecb3595..955247a9719362541560497ad52f7377853a6973 100644 --- a/e2e/list.e2e-spec.ts +++ b/e2e/list.e2e-spec.ts @@ -1,4 +1,5 @@ import { ListPage } from "./list.po"; +import { browser, $, $$, expect } from '@wdio/globals' /** * Show calculators list (home page) @@ -12,13 +13,13 @@ describe("ngHyd − list page", () => { it("when list is open, user should see the list of available compute nodes", async () => { await page.navigateTo(); - expect(page.getThemesCardsLength()).toBeGreaterThan(4); - expect(page.getCalculatorsMenuLength()).toBeGreaterThan(8); + expect(await page.getThemesCardsLength()).toBeGreaterThan(4); + expect(await page.getCalculatorsMenuLength()).toBeGreaterThan(8); }); it("when list is open, link to doc should be well-formed (2-letter language code)", async () => { await page.navigateTo(); - const docLink = $("a#header-doc"); + const docLink = await $("a#header-doc"); const href = await docLink.getAttribute("href"); const re = new RegExp("assets/docs/[a-z]{2}/index.html"); expect(re.test(href)).toBe(true); diff --git a/e2e/list.po.ts b/e2e/list.po.ts index bfe96bb1468e18d57027408e8c349bd5ad0bf077..83e65b63ec2be3e24fc2b1946fc7286ccb48fc88 100644 --- a/e2e/list.po.ts +++ b/e2e/list.po.ts @@ -23,8 +23,8 @@ export class ListPage { async getAvailableCalcTypes() { const ids = []; - const menuEntries = this.getCalculatorsMenuEntries(); - await menuEntries.each(async (elt, i) => { + const menuEntries = await this.getCalculatorsMenuEntries(); + for (const elt of menuEntries) { const eltid = await elt.getAttribute("id"); const ct = eltid.replace("create-calc-", ""); const nct = Number(ct); @@ -32,20 +32,21 @@ export class ListPage { if (!ids.includes(nct)) { ids.push(nct); } - }); + }; return ids; } async clickRandomCalculatorMenuEntry() { - const menuEntries = this.getCalculatorsMenuEntries(); - const l = await menuEntries.length; + const menuEntries = await this.getCalculatorsMenuEntries(); + const l = menuEntries.length; const r = Math.min((Math.floor(Math.random() * l)), (l - 1)); - return menuEntries[r].click(); + return await menuEntries[r].click(); } async clickMenuEntryForCalcType(type: number) { - const but = $("#create-calc-" + type); - return but.click(); + const but = await $("#create-calc-" + type); + return await but.click(); + // await browser.execute(e => { e.click() }, but); // await but.click() fails with "element not interactable" error } async getCalcMenuTextForCalcType(type: number): Promise<string> { diff --git a/e2e/load-linked-params.e2e-spec.ts b/e2e/load-linked-params.e2e-spec.ts index dbeb39faf325fc2d864890fcaf56206f1baae30d..02d856f7ffc5c743e98783cdbd763da5b8573552 100644 --- a/e2e/load-linked-params.e2e-spec.ts +++ b/e2e/load-linked-params.e2e-spec.ts @@ -2,6 +2,7 @@ import { CalculatorPage } from "./calculator.po"; import { Navbar } from "./navbar.po"; import { SideNav } from "./sidenav.po"; import { PreferencesPage } from "./preferences.po"; +import { browser, $, $$, expect } from '@wdio/globals' /** * Load a session containing 5 calculators, having multiple linked parameters @@ -14,7 +15,7 @@ describe("ngHyd − load session with multiple linked parameters − ", () => { let navbar: Navbar; let sidenav: SideNav; - beforeAll(()=> { + beforeAll(() => { calcPage = new CalculatorPage(); prefPage = new PreferencesPage(); navbar = new Navbar(); @@ -50,7 +51,7 @@ describe("ngHyd − load session with multiple linked parameters − ", () => { await browser.pause(500); // check target params values - const sp_lb = calcPage.getSelectById("linked_LargeurBerge"); + const sp_lb = await calcPage.getSelectById("linked_LargeurBerge"); const sp_lbv = await calcPage.getSelectValueText(sp_lb); expect(sp_lbv).toContain("Largeur du déversoir (Ouvrages, ouvrage 3)"); @@ -59,11 +60,11 @@ describe("ngHyd − load session with multiple linked parameters − ", () => { await browser.pause(500); // check target params values - const mr_zf1 = calcPage.getSelectById("linked_ZF1"); + const mr_zf1 = await calcPage.getSelectById("linked_ZF1"); const mr_zf1v = await calcPage.getSelectValueText(mr_zf1); expect(mr_zf1v).toContain("Cote de l'eau amont (Ouvrages)"); - const mr_q = calcPage.getSelectById("linked_Q"); + const mr_q = await calcPage.getSelectById("linked_Q"); const mr_qv = await calcPage.getSelectValueText(mr_q); expect(mr_qv).toContain("Débit (Sec. param., section)"); @@ -82,16 +83,18 @@ describe("ngHyd − load session with multiple linked parameters − ", () => { * jalhyd#289/adf6009 * nghyd#551 */ - const inpZ2 = calcPage.getInputById("Z2"); - expect(await inpZ2.getAttribute("value")).toEqual(""); + const inpZ2 = await calcPage.getInputById("Z2"); + // expect(await inpZ2.getAttribute("value")).toEqual(""); + expect(await inpZ2.getValue()).toEqual(""); // const lo_l = calcPage.getSelectById("1_linked_L"); // const lo_lv = await calcPage.getSelectValueText(lo_l); // expect(lo_lv).toContain("Largeur au miroir (Sec. param.)"); - const inpL = calcPage.getInputById("1_L"); - expect(await inpL.getAttribute("value")).toEqual(""); + const inpL = await calcPage.getInputById("1_L"); + // expect(await inpL.getAttribute("value")).toEqual(""); + expect(await inpL.getValue()).toEqual(""); - const lo_w = calcPage.getSelectById("2_linked_W"); + const lo_w = await calcPage.getSelectById("2_linked_W"); const lo_wv = await calcPage.getSelectValueText(lo_w); expect(lo_wv).toContain("Ouverture de vanne (Ouvrages, ouvrage 2)"); @@ -103,7 +106,8 @@ describe("ngHyd − load session with multiple linked parameters − ", () => { // const lo_br = calcPage.getSelectById("linked_BR"); // const lo_brv = await calcPage.getSelectValueText(lo_br); // expect(lo_brv).toContain("Largeur au miroir (Sec. param.)"); - const inpBR = calcPage.getInputById("BR"); - expect(await inpBR.getAttribute("value")).toEqual(""); + const inpBR = await calcPage.getInputById("BR"); + // expect(await inpBR.getAttribute("value")).toEqual(""); + expect(await inpBR.getValue()).toEqual(""); }); }); diff --git a/e2e/load-malformed-files.e2e-spec.ts b/e2e/load-malformed-files.e2e-spec.ts index f8ad8dc992f29036d5a6cc42e0fc790330a4abfd..344f4102a10d7ebfaf6137092c7e9d9553169057 100644 --- a/e2e/load-malformed-files.e2e-spec.ts +++ b/e2e/load-malformed-files.e2e-spec.ts @@ -1,6 +1,7 @@ import { Navbar } from "./navbar.po"; import { SideNav } from "./sidenav.po"; import { PreferencesPage } from "./preferences.po"; +import { browser, $, $$, expect } from '@wdio/globals' /** * Load 4 malformed session files : @@ -37,7 +38,7 @@ describe("ngHyd − load malformed session files − ", () => { await browser.pause(200); await sidenav.loadSessionFile("./session/session-bad-syntax.json"); - const err = $(".file-problem .mat-list-item-content"); + const err = await $(".file-problem .mat-list-item-content"); expect(await err.getText()).toContain("La syntaxe du fichier semble incorrecte"); }); @@ -49,7 +50,7 @@ describe("ngHyd − load malformed session files − ", () => { await browser.pause(200); await sidenav.loadSessionFile("./session/session-missing-info.json"); - const err = $(".file-problem .mat-list-item-content"); + const err = await $(".file-problem .mat-list-item-content"); expect(await err.getText()).toContain("La syntaxe du fichier semble incorrecte"); }); @@ -61,7 +62,7 @@ describe("ngHyd − load malformed session files − ", () => { await browser.pause(200); await sidenav.loadSessionFile("./session/session-empty-modules-list.json"); - const err = $(".file-problem .mat-list-item-content"); + const err = await $(".file-problem .mat-list-item-content"); expect(await err.getText()).toContain("Le fichier ne contient aucun module"); }); @@ -73,7 +74,7 @@ describe("ngHyd − load malformed session files − ", () => { await browser.pause(200); await sidenav.loadSessionFile("./session/session-format-too-old.json", false); - const err = $(".file-problem .mat-list-item-content"); + const err = await $(".file-problem .mat-list-item-content"); expect(await err.getText()).toContain("Mauvaise version du format de fichier"); }); }); diff --git a/e2e/load-save-session.e2e-spec.ts b/e2e/load-save-session.e2e-spec.ts index 7bce10834cc77ea99c5b491cc17ada374dc074fa..3ddf46ce759b00782f1b27f1c0e8e644c305df34 100644 --- a/e2e/load-save-session.e2e-spec.ts +++ b/e2e/load-save-session.e2e-spec.ts @@ -5,6 +5,7 @@ import { Navbar } from "./navbar.po"; import { SideNav } from "./sidenav.po"; import { PreferencesPage } from "./preferences.po"; import { changeSelectValue, expectNumber } from "./util.po"; +import { browser, $, $$, expect } from '@wdio/globals' const fs = require("fs"); const path = require("path"); @@ -18,9 +19,9 @@ let sidenav: SideNav; let prefPage: PreferencesPage; function findDownloadedFile(filename: string): string { - const downloadDirs = ["Téléchargements", "Downloads", "/tmp"]; + const downloadDirs = ["Téléchargements", "Downloads", "/tmp", "."]; for (const d of downloadDirs) { - const download_prefix = d.charAt(0) === "/" ? d : path.resolve(os.homedir(), d); + const download_prefix = (d.charAt(0) === "/" || (d.length === 1 && d.charAt(0) === ".")) ? d : path.resolve(os.homedir(), d); const fp = path.resolve(download_prefix, filename); if (fs.existsSync(fp)) { return fp; @@ -38,50 +39,18 @@ function deleteDownloadedFile(filename: string) { } async function saveSession(): Promise<string> { - const sessionFile = "session.json"; + const sessionFile = "session-e2e-tests.json"; deleteDownloadedFile(sessionFile); await calcPage.clickSaveCalcButton(); - await browser.pause(500); - - // cf. protractor.conf.fs, exports.config.capabilities.chromeOptions.prefs.download.default_directory - // protractor.conf.fs/exports.config.capabilities.chromeOptions.prefs.download.default_directory DOES NOT WORK ! - - // Le code laissé en commentaire tente de corriger un bug : - // il s'écoule 40 secondes entre le clic sur le bouton menu (en haut à gauche) et l'ouverture du sidenav. - // Ceci ne se produit que lorsqu'on sauve effectivement la session : si on annule la sauvegarde, il n'y a pas de délai. - // https://stackoverflow.com/questions/75235558/delay-after-downloading-a-file-in-protractor-test - - //browser.manage().timeouts().implicitlyWait(100); - //browser.ignoreSynchronization = true; - // await browser.waitForAngularEnabled(false); - - if (true) { - await calcPage.getSaveSessionButton().click(); - } else { - const cancel = $("dialog-save-session button.mat-primary"); - await cancel.click(); - } - await browser.pause(200); - // browser.ignoreSynchronization = false; - // await browser.waitForAngularEnabled(true); - - // browser.executeScript('window.stop();'); - - // const wins = await browser.driver.getAllWindowHandles(); - // await browser.switchTo().window(wins[0]); - - // await browser.switchTo().activeElement(); + await browser.pause(300); - // const bd = element(by.css("body")); - // await browser.actions().mouseMove(bd, { x: 0, y: 0 }).click().perform(); + const inpName = await $("dialog-save-session input.mat-input-element"); + await inpName.setValue(sessionFile); - // await navbar.clickCalculatorTab(0); - // await browser.sleep(200); - - // browser.actions().sendKeys(protractor.Key.ESCAPE).perform(); + await calcPage.getSaveSessionButton().click(); + await browser.pause(500); - console.log("saveSession() saved to ", findDownloadedFile(sessionFile)); return findDownloadedFile(sessionFile); } @@ -110,7 +79,7 @@ describe("ngHyd − save and load sessions", () => { beforeEach(() => { jasmine.DEFAULT_TIMEOUT_INTERVAL = 45 * 60 * 1000; // 45 min - browser.manage().window().setPosition(2000, 30); + // browser.manage().window().setPosition(2000, 30); }); it("when loading session-6-calc.test.json file from home page, 6 calculators should be loaded", async () => { @@ -139,14 +108,15 @@ describe("ngHyd − save and load sessions", () => { await navbar.clickNewCalculatorButton(); await listPage.clickMenuEntryForCalcType(2); // Section paramétrée - await browser.pause(500); + await browser.pause(200); - await changeSelectValue(calcPage.getSelectById("select_section"), 2); // mode "trapezoidal" + await changeSelectValue(await calcPage.getSelectById("select_section"), 2); // mode "trapezoidal" - await calcPage.getInputById("Ks").clearValue(); // coefficient de Strickler - await browser.pause(200); - await calcPage.getInputById("Ks").setValue("42"); - await browser.pause(200); + const inpKs = await calcPage.getInputById("Ks"); + // await inpKs.clearValue(); // coefficient de Strickler + // await browser.pause(200); + await inpKs.setValue("42"); + // await browser.pause(200); const filename = await saveSession(); await browser.pause(500); @@ -155,14 +125,17 @@ describe("ngHyd − save and load sessions", () => { expect(fileContent).toContain(`"nodeType":"SectionTrapeze"`); expect(fileContent).toContain(`{"symbol":"Ks","mode":"SINGLE","value":42}`); + + deleteDownloadedFile(filename); }); - xit("select value must be recovered when loading a session file", async () => { + it("select value must be recovered when loading a session file", async () => { // start page await startPage.navigateTo(); await browser.pause(200); const calcTypes = await listPage.getAvailableCalcTypes(); + // const calcTypes = [10]; const excludedCalculators = [ 34, // vérificateur (nécessite d'ouvrir plusieurs calculettes) @@ -194,10 +167,11 @@ describe("ngHyd − save and load sessions", () => { await browser.pause(200); // detect selects - const selects = calcPage.getAllCalculatorSelects(); - const nsel = await selects.length; - for (let s = 0; s < nsel; s++) { // /!\ ElementArrayFinder.each() is ASYNCHRONOUS !! https://www.protractortest.org/#/api?view=ElementArrayFinder.prototype.each - const sel = selects.get(s); + const selects = await calcPage.getAllCalculatorSelects(); + const nsel = selects.length; + for (let s = 0; s < nsel; s++) { + // const sel = selects.get(s); + const sel = selects[s]; const selId = await sel.getAttribute("id"); const options = await calcPage.getMatselectOptionsText(sel); @@ -215,24 +189,23 @@ describe("ngHyd − save and load sessions", () => { // save session const filename = await saveSession(); - await browser.pause(200); + await browser.pause(500); // load session await loadSession(filename); // bug here : the click on the menu button (top left) takes 40s to take effect and open the side nav!) - await browser.pause(200); + await browser.pause(500); // the displayed calculator is now the loaded one // check the calculator has been loaded expectNumber(`calc ${ct} select ${selId} : num calcs`, await navbar.getCalculatorEntriesCount(), 2); // check the select in the loaded session points to the same option - const sel2 = calcPage.getSelectById(selId); + const sel2 = await calcPage.getSelectById(selId); // check the same option is in the select const optTxt2 = await calcPage.getMatselectCurrentOptionText(sel2); - await browser.pause(100); const ind2 = options.indexOf(optTxt2); - expectNumber(`calc ${ct} select ${selId} : opt index`, ind2, nextInd); + expectNumber(`calc ${ct} select ${selId} : opt '${optTxt2}' index`, ind2, nextInd); // close last calculator (the loaded one) await navbar.middleClickCalculatorTab(1); @@ -240,6 +213,8 @@ describe("ngHyd − save and load sessions", () => { // check last calculator has been closed expectNumber(`calc ${ct} select ${selId} : num calcs(2)`, await navbar.getCalculatorEntriesCount(), 1); + + deleteDownloadedFile(filename); } } } diff --git a/e2e/monkey-test/monkey.e2e-spec.ts b/e2e/monkey-test/monkey.e2e-spec.ts index 7166aca40e0287b9dfd41537191c7b4614fa3d50..27313fdf47cd320fc130573c9c4e25b57fe2216d 100644 --- a/e2e/monkey-test/monkey.e2e-spec.ts +++ b/e2e/monkey-test/monkey.e2e-spec.ts @@ -1,51 +1,50 @@ -import { browser } from "protractor"; - -import { readGremlinsScript, getFpsResults, unleashGremlins } from "../helpers/GremlinHelper"; - -import { PreferencesPage } from "../preferences.po"; -import { Navbar } from "../navbar.po"; - -let prefPage: PreferencesPage; -let navBar: Navbar; - -describe("Monkey test with Gremlins.js −", async () => { - - beforeEach(() => { - prefPage = new PreferencesPage(); - navBar = new Navbar(); - }); - - // keep greater than setTimeout() in GremlinHelper.ts (twice as much sounds good) - const specificLongTimeout = 120 * 1000; - - it("bennes-y tout là -bas d'dans !", async () => { - // disable evil option "empty fields on module creation" - await prefPage.navigateTo(); - await prefPage.disableEvilEmptyFields(); - await browser.sleep(200); - // go to list page - await navBar.clickNewCalculatorButton(); - - // unleash the gremlins ! - await browser.executeScript((readGremlinsScript())); - const logs: any = await browser.executeAsyncScript(unleashGremlins); - - /* console.log("----------- ERRORS -----------"); - console.log(logs.error); - console.log("----------- WARNINGS -----------"); - console.log(logs.warn); - console.log("----------- INFO -----------"); - console.log(logs.info); - console.log("----------- FPS -----------"); - console.log(getFpsResults(logs)); - console.log("----------- ACTIONS -----------"); - console.log(logs.log); - - browser.manage().logs().get("browser").then(function(browserLog) { - console.log("log: " + require("util").inspect(browserLog)); - }); */ - - expect(logs.error.length).toBe(0, logs.error); - - }, specificLongTimeout); -}); +// import { readGremlinsScript, getFpsResults, unleashGremlins } from "../helpers/GremlinHelper"; + +// import { PreferencesPage } from "../preferences.po"; +// import { Navbar } from "../navbar.po"; +// import { browser, $, $$, expect } from '@wdio/globals' + +// let prefPage: PreferencesPage; +// let navBar: Navbar; + +// describe("Monkey test with Gremlins.js −", async () => { + +// beforeEach(() => { +// prefPage = new PreferencesPage(); +// navBar = new Navbar(); +// }); + +// // keep greater than setTimeout() in GremlinHelper.ts (twice as much sounds good) +// const specificLongTimeout = 120 * 1000; + +// it("bennes-y tout là -bas d'dans !", async () => { +// // disable evil option "empty fields on module creation" +// await prefPage.navigateTo(); +// await prefPage.disableEvilEmptyFields(); +// await browser.pause(200); +// // go to list page +// await navBar.clickNewCalculatorButton(); + +// // unleash the gremlins ! +// await browser.executeScript(readGremlinsScript()); +// const logs: any = await browser.executeAsyncScript(unleashGremlins); + +// /* console.log("----------- ERRORS -----------"); +// console.log(logs.error); +// console.log("----------- WARNINGS -----------"); +// console.log(logs.warn); +// console.log("----------- INFO -----------"); +// console.log(logs.info); +// console.log("----------- FPS -----------"); +// console.log(getFpsResults(logs)); +// console.log("----------- ACTIONS -----------"); +// console.log(logs.log); + +// browser.manage().logs().get("browser").then(function(browserLog) { +// console.log("log: " + require("util").inspect(browserLog)); +// }); */ + +// expect(logs.error.length).toBe(0, logs.error); + +// }, specificLongTimeout); +// }); diff --git a/e2e/navbar.po.ts b/e2e/navbar.po.ts index aa2c8630d7bacf005d5506a7b237235e653c13ae..3e9d2ceea81cf3f271e939956a38a38fc1362c38 100644 --- a/e2e/navbar.po.ts +++ b/e2e/navbar.po.ts @@ -1,4 +1,6 @@ import { browser, $, $$, expect } from '@wdio/globals' +import { Key } from 'webdriverio' +import { scrollToElement } from './util.po'; export class Navbar { getAllCalculatorTabs() { @@ -11,14 +13,18 @@ export class Navbar { */ async getCalculatorEntriesCount() { // if dropDown calculators select is visible - const dropDown = $("mat-select#selectCalculator"); + const dropDown = await $("mat-select#selectCalculator"); if ((await dropDown.isExisting()) && (await dropDown.isDisplayed())) { await dropDown.click(); - const options = $$(".cdk-overlay-container mat-option"); + browser.pause(100); + const options = await $$(".cdk-overlay-container mat-option"); // FIXME>>>>await dropDown.sendKeys(protractor.Key.ESCAPE); // close dropdown - return await options.length; + //await dropDown.keys('Escape'); // close dropdown + await browser.keys(Key.Escape); // close dropdown + return options.length; } else { - return (await $$("#tabs-container button.calculator-button")).length; + // return (await $$("#tabs-container button.calculator-button")).length; + return (await this.getAllCalculatorTabs()).length; } } @@ -33,13 +39,13 @@ export class Navbar { await dropDown.click(); // 1st option is not necessarly "mat-option-0"... - const options = $$(".cdk-overlay-container mat-option"); - const option = options.get(n); + const options = await $$(".cdk-overlay-container mat-option"); + const option = options[n]; await option.click(); } else { - const tabs = this.getAllCalculatorTabs(); - await (await tabs.n).click(); + const tabs = await this.getAllCalculatorTabs(); + await tabs[n].click(); } } @@ -56,8 +62,11 @@ export class Navbar { } async clickCalculatorTab(n: number) { - const tabs = this.getAllCalculatorTabs(); - await (await tabs.n).click(); + const tabs = await this.getAllCalculatorTabs(); + // await (await tabs.n).click(); + + // await tabs[n].click(); + await browser.execute(e => { e.click() }, tabs[n]); // await tabs[n].click() fails with "element not interactable" error } async clickCalculatorTabForUid(uid: string) { @@ -66,10 +75,12 @@ export class Navbar { } async clickRandomCalculatorTab(n: number) { - const tabs = this.getAllCalculatorTabs(); - const l = await tabs.length; + const tabs = await this.getAllCalculatorTabs(); + const l = tabs.length; const r = Math.min((Math.floor(Math.random() * l)), (l - 1)); - await (await tabs.r).click(); + + //await tabs[r].click(); + await browser.execute(e => { e.click() }, tabs[r]); // await tabs[r].click() fails with "element not interactable" error } /** @@ -77,11 +88,12 @@ export class Navbar { * @param confirmCloseDialog true to confirm opening dialog and indeed close calculator */ async middleClickCalculatorTab(n: number, confirmCloseDialog: boolean = true) { - const calcTabs = this.getAllCalculatorTabs(); + const calcTabs = await this.getAllCalculatorTabs(); // FIXME>>>> await browser.actions().click(calcTabs.get(n), Button.MIDDLE).perform(); + await calcTabs[n].click({ button: 'middle' }); if (confirmCloseDialog) { - const btns = $$("dialog-confirm-close-calc .mat-dialog-actions button"); - await (await btns)[1].click(); + const btns = await $$("dialog-confirm-close-calc .mat-dialog-actions button"); + await btns[1].click(); } } @@ -91,7 +103,7 @@ export class Navbar { } async clickMenuButton() { - const ncb = this.getMenuButton(); + const ncb = await this.getMenuButton(); await ncb.click(); } } diff --git a/e2e/navigate-through-calculators.e2e-spec.ts b/e2e/navigate-through-calculators.e2e-spec.ts index e7631f47fa72278a0a052dadfd93e398959529cf..85f0d0c5384858947298a50abf5d287cbcba3444 100644 --- a/e2e/navigate-through-calculators.e2e-spec.ts +++ b/e2e/navigate-through-calculators.e2e-spec.ts @@ -1,6 +1,7 @@ import { ListPage } from "./list.po"; import { Navbar } from "./navbar.po"; import { CalculatorPage } from "./calculator.po"; +import { browser, $, $$, expect } from '@wdio/globals' /** * Use navbar buttons to navigate from one open calculator to another @@ -25,16 +26,19 @@ describe("ngHyd − create calculators and navigate among them", () => { await browser.pause(200); } await listPage.clickRandomCalculatorMenuEntry(); + await browser.pause(200); } // navigate among them for (let i = 0; i < 10; i++) { await navbar.clickRandomCalculatorTab(i); + await browser.pause(200); // test all form labels - const labels = calculatorPage.getInputLabels(); - await labels.each(async (l) => { + const labels = await calculatorPage.getInputLabels(); + //await labels.each(async (l) => { + for (const l of labels) { const label = await l.getText(); expect(label.length).toBeGreaterThan(0); - }); + }; } // expect no error ? }); diff --git a/e2e/notes.e2e-spec.ts b/e2e/notes.e2e-spec.ts index 40bf8caa10c8603457350e3bcc9544d799cc3165..9704016ece42f136dc83141f83dd1547ef337f90 100644 --- a/e2e/notes.e2e-spec.ts +++ b/e2e/notes.e2e-spec.ts @@ -2,6 +2,7 @@ import { AppPage } from "./app.po"; import { Navbar } from "./navbar.po"; import { ListPage } from "./list.po"; import { SideNav } from "./sidenav.po"; +import { browser, $, $$, expect } from '@wdio/globals' describe("check calculator notes", () => { let startPage: AppPage; @@ -31,7 +32,7 @@ describe("check calculator notes", () => { await browser.pause(200); // input some text - const ta = $("textarea"); + const ta = await $("textarea"); await ta.clearValue(); await ta.setValue("azerty123"); await browser.pause(200); @@ -47,7 +48,7 @@ describe("check calculator notes", () => { await browser.pause(200); // check text - const md = $("markdown p"); + const md = await $("markdown p"); await browser.pause(200); expect(await md.getText()).toEqual("azerty123"); }); @@ -67,7 +68,7 @@ describe("check calculator notes", () => { await browser.pause(200); // input some text - const ta = $("textarea"); + const ta = await $("textarea"); await ta.clearValue(); await ta.setValue("azerty123"); await browser.pause(200); @@ -79,12 +80,12 @@ describe("check calculator notes", () => { await browser.pause(200); // open notes - const notesLink = $("#show-notes a"); + const notesLink = await $("#show-notes a"); notesLink.click(); await browser.pause(200); // check text - const md = $("markdown p"); + const md = await $("markdown p"); await browser.pause(200); expect(await md.getText()).toEqual("azerty123"); }); diff --git a/e2e/ouvrages-empty-fields.e2e-spec.ts b/e2e/ouvrages-empty-fields.e2e-spec.ts index 2b7e3620bc48b1ebc8041b30a7bef6d1fce7f772..24078502a66f73fe9559fde6eee826a9fc10b755 100644 --- a/e2e/ouvrages-empty-fields.e2e-spec.ts +++ b/e2e/ouvrages-empty-fields.e2e-spec.ts @@ -3,6 +3,7 @@ import { CalculatorPage } from "./calculator.po"; import { PreferencesPage } from "./preferences.po"; import { Navbar } from "./navbar.po"; import { changeSelectValue } from "./util.po"; +import { browser, $, $$, expect } from '@wdio/globals' /** * Check that created/cloned structures have empty fields when @@ -49,7 +50,7 @@ describe("ngHyd - check that created/cloned structures have empty fields - ", () await calcPage.checkEmptyOrFilledFields(inputIds, emptys); // change 1st structure type to rectangular weir - const structSelect = calcPage.getSelectById("select_structure"); + const structSelect = await calcPage.getSelectById("select_structure"); await changeSelectValue(structSelect, 1); await browser.pause(200); @@ -63,8 +64,9 @@ describe("ngHyd - check that created/cloned structures have empty fields - ", () await setup(); // add structure - const addStruct = calcPage.getAddStructureButton(); + const addStruct = await calcPage.getAddStructureButton(); await addStruct.click(); + await browser.pause(200); // check 2nd structure empty fields const inputIds = ["1_ZDV", "1_L", "1_W", "1_CdGR"]; @@ -76,8 +78,9 @@ describe("ngHyd - check that created/cloned structures have empty fields - ", () await setup(); // copy structure - const addStruct = calcPage.getCopyStructureButton(); + const addStruct = await calcPage.getCopyStructureButton(); await addStruct.click(); + await browser.pause(200); // check 2nd structure empty fields const inputIds = ["1_ZDV", "1_L", "1_W", "1_CdGR"]; @@ -89,12 +92,12 @@ describe("ngHyd - check that created/cloned structures have empty fields - ", () await setup(); // change 1st structure type to rectangular weir - const structSelect = calcPage.getSelectById("select_structure"); + const structSelect = await calcPage.getSelectById("select_structure"); await changeSelectValue(structSelect, 1); await browser.pause(200); // copy structure - const addStruct = calcPage.getCopyStructureButton(); + const addStruct = await calcPage.getCopyStructureButton(); await addStruct.click(); await browser.pause(200); @@ -114,12 +117,12 @@ describe("ngHyd - check that created/cloned structures have empty fields - ", () await setup(); // fill - const inp = calcPage.getInputById("0_ZDV"); + const inp = await calcPage.getInputById("0_ZDV"); await inp.clearValue(); await inp.setValue("1"); // copy structure - const addStruct = calcPage.getCopyStructureButton(); + const addStruct = await calcPage.getCopyStructureButton(); await addStruct.click(); await browser.pause(200); @@ -133,12 +136,12 @@ describe("ngHyd - check that created/cloned structures have empty fields - ", () await setup(); // change 1st structure type to rectangular weir - const structSelect = calcPage.getSelectById("select_structure"); + const structSelect = await calcPage.getSelectById("select_structure"); await changeSelectValue(structSelect, 1); await browser.pause(200); // change discharge law to Larinier - const dischargeSelect = calcPage.getSelectById("select_loidebit"); + const dischargeSelect = await calcPage.getSelectById("select_loidebit"); await changeSelectValue(dischargeSelect, 3); await browser.pause(200); @@ -152,12 +155,12 @@ describe("ngHyd - check that created/cloned structures have empty fields - ", () await setup(); // fill - const inp = calcPage.getInputById("0_ZDV"); + const inp = await calcPage.getInputById("0_ZDV"); await inp.clearValue(); await inp.setValue("1"); // copy structure - const addStruct = calcPage.getAddStructureButton(); + const addStruct = await calcPage.getAddStructureButton(); await addStruct.click(); await browser.pause(200); diff --git a/e2e/pab-cloisons-empty-fields.e2e-spec.ts b/e2e/pab-cloisons-empty-fields.e2e-spec.ts index 1885d8fe60c553e5da0cb1816c381134a6e72236..8f1d76c557957118b22ea0f5c0084c060158cb15 100644 --- a/e2e/pab-cloisons-empty-fields.e2e-spec.ts +++ b/e2e/pab-cloisons-empty-fields.e2e-spec.ts @@ -2,6 +2,7 @@ import { ListPage } from "./list.po"; import { PreferencesPage } from "./preferences.po"; import { CalculatorPage } from "./calculator.po"; import { Navbar } from "./navbar.po"; +import { browser, $, $$, expect } from '@wdio/globals' /** * enable evil option "empty fields on module creation" @@ -65,7 +66,7 @@ describe("ngHyd - check the cross walls calculator has empty fields - ", () => { // click "generate PAB" button const genButton = calcPage.getGeneratePabButton(); await genButton.click(); - await browser.pause(200); + await browser.pause(1000); await calcPage.checkEmptyOrFilledFields(["generatePabNbBassins"], [true]); }); diff --git a/e2e/pab.e2e-spec.ts b/e2e/pab.e2e-spec.ts index 2bf3c72b2bd9f8a4c03ab20dded074754b5ab954..21b75dac92344d863fecae2a72679538b40870ef 100644 --- a/e2e/pab.e2e-spec.ts +++ b/e2e/pab.e2e-spec.ts @@ -4,7 +4,8 @@ import { Navbar } from "./navbar.po"; import { AppPage } from "./app.po"; import { SideNav } from "./sidenav.po"; import { PreferencesPage } from "./preferences.po"; -import { changeSelectValue, scrollPageToTop } from "./util.po"; +import { changeSelectValue, newSession, scrollPageToTop } from "./util.po"; +import { browser, $, $$, expect } from '@wdio/globals' /** * Clone calculators @@ -13,16 +14,16 @@ describe("ngHyd − Passe à Bassins", () => { let startPage: AppPage; let listPage: ListPage; let calcPage: CalculatorPage; - let navbar: Navbar; - let sidenav: SideNav; + let navBar: Navbar; + let sideNav: SideNav; let prefPage: PreferencesPage; beforeAll(() => { startPage = new AppPage(); listPage = new ListPage(); calcPage = new CalculatorPage(); - navbar = new Navbar(); - sidenav = new SideNav(); + navBar = new Navbar(); + sideNav = new SideNav(); prefPage = new PreferencesPage(); }); @@ -36,15 +37,17 @@ describe("ngHyd − Passe à Bassins", () => { it("when PAB is created from scratch", async () => { // create PAB - await navbar.clickNewCalculatorButton(); + await navBar.clickNewCalculatorButton(); await listPage.clickMenuEntryForCalcType(15); // check that pab-table is present - const innerFieldsets = $$(".pab-data-table"); + const innerFieldsets = await $$(".pab-data-table"); expect(await innerFieldsets.length).toBe(1); // calculate PAB - 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(); expect(hasResults).toBe(true); @@ -55,82 +58,84 @@ describe("ngHyd − Passe à Bassins", () => { it("complete example of all PAB modules", async () => { // PAB - chute - await navbar.clickNewCalculatorButton(); + await navBar.clickNewCalculatorButton(); await listPage.clickMenuEntryForCalcType(12); - const c_Z1 = calcPage.getInputById("Z1"); - await c_Z1.clearValue(); + const c_Z1 = await calcPage.getInputById("Z1"); + // await c_Z1.clearValue(); await c_Z1.setValue("78.27"); - const c_Z2 = calcPage.getInputById("Z1"); - await c_Z2.clearValue(); + const c_Z2 = await calcPage.getInputById("Z1"); + // await c_Z2.clearValue(); await c_Z2.setValue("74.86"); // PAB - nombre - await navbar.clickNewCalculatorButton(); + await navBar.clickNewCalculatorButton(); await listPage.clickMenuEntryForCalcType(13); - const n_DHT = calcPage.getInputById("DHT"); + const n_DHT = await calcPage.getInputById("DHT"); await calcPage.setParamMode(n_DHT, "link"); - const n_DH = calcPage.getInputById("DH"); + const n_DH = await calcPage.getInputById("DH"); await calcPage.setParamMode(n_DH, "cal"); - const n_N = calcPage.getInputById("N"); + const n_N = await calcPage.getInputById("N"); await n_N.clearValue(); await n_N.setValue("15"); // PAB - dimensions - await navbar.clickNewCalculatorButton(); + await navBar.clickNewCalculatorButton(); await listPage.clickMenuEntryForCalcType(5); - const d_V = calcPage.getInputById("V"); + const d_V = await calcPage.getInputById("V"); await calcPage.setParamMode(d_V, "cal"); - const d_Y = calcPage.getInputById("Y"); - await d_Y.clearValue(); + const d_Y = await calcPage.getInputById("Y"); + // await d_Y.clearValue(); await d_Y.setValue("1.5"); - const d_L = calcPage.getInputById("L"); - await d_L.clearValue(); + const d_L = await calcPage.getInputById("L"); + // await d_L.clearValue(); await d_L.setValue("3.100"); - const d_W = calcPage.getInputById("W"); - await d_W.clearValue(); + const d_W = await calcPage.getInputById("W"); + // await d_W.clearValue(); await d_W.setValue("2.5"); // PAB - puissance dissipée (volume) - await navbar.clickNewCalculatorButton(); + await navBar.clickNewCalculatorButton(); await listPage.clickMenuEntryForCalcType(6); - const p_DH = calcPage.getInputById("DH"); + const p_DH = await calcPage.getInputById("DH"); await calcPage.setParamMode(p_DH, "link"); - const p_Q = calcPage.getInputById("Q"); + const p_Q = await calcPage.getInputById("Q"); await calcPage.setParamMode(p_Q, "cal"); - const p_V = calcPage.getInputById("V"); + const p_V = await calcPage.getInputById("V"); await calcPage.setParamMode(p_V, "link"); - const p_PV = calcPage.getInputById("PV"); + const p_PV = await calcPage.getInputById("PV"); await p_PV.clearValue(); await p_PV.setValue("150"); // PAB - cloisons - await navbar.clickNewCalculatorButton(); + await navBar.clickNewCalculatorButton(); await listPage.clickMenuEntryForCalcType(10); - const cl_LB = calcPage.getInputById("LB"); + const cl_LB = await calcPage.getInputById("LB"); await calcPage.setParamMode(cl_LB, "link"); - const cl_BB = calcPage.getInputById("BB"); + const cl_BB = await calcPage.getInputById("BB"); await calcPage.setParamMode(cl_BB, "link"); - const cl_DH = calcPage.getInputById("DH"); + const cl_DH = await calcPage.getInputById("DH"); await calcPage.setParamMode(cl_DH, "link"); - const cl_Z1 = calcPage.getInputById("Z1"); + const cl_Z1 = await calcPage.getInputById("Z1"); await calcPage.setParamMode(cl_Z1, "link"); - const cl_PB = calcPage.getInputById("PB"); - await cl_PB.clearValue(); + const cl_PB = await calcPage.getInputById("PB"); + // await cl_PB.clearValue(); await cl_PB.setValue("1.5"); // calculate Cloisons - const calcButtonCl = calcPage.getCalculateButton(); + const calcButtonCl = await calcPage.getCalculateButton(); await calcButtonCl.click(); + await browser.pause(200); // make sure "Generate PAB" button is visible (it might be hidden behind navbar) await scrollPageToTop(); // generate PAB - const genButton = calcPage.getGeneratePabButton(); + const genButton = await calcPage.getGeneratePabButton(); await genButton.isExisting(); await genButton.isDisplayed(); await genButton.click(); - const nbBassins = calcPage.getInputById("generatePabNbBassins"); - await nbBassins.clearValue(); + await browser.pause(1000); + const nbBassins = await calcPage.getInputById("generatePabNbBassins"); + // await nbBassins.clearValue(); await nbBassins.setValue("9"); // click "Generate" @@ -138,8 +143,10 @@ describe("ngHyd − Passe à Bassins", () => { await browser.pause(1000); // calculate PAB - const calcButtonPAB = calcPage.getCalculateButton(); + const calcButtonPAB = await calcPage.getCalculateButton(); await calcButtonPAB.click(); + await browser.pause(200); + // check that result is not empty const hasResults = await calcPage.hasResults(); expect(hasResults).toBe(true); @@ -157,71 +164,78 @@ describe("ngHyd − Passe à Bassins", () => { }); it("from a Cloisons among many", async () => { + await newSession(navBar, sideNav); + // create many Cloisons - await navbar.clickNewCalculatorButton(); + // await navBar.clickNewCalculatorButton(); await listPage.clickMenuEntryForCalcType(10); - await navbar.clickNewCalculatorButton(); + await navBar.clickNewCalculatorButton(); await listPage.clickMenuEntryForCalcType(10); - await navbar.clickNewCalculatorButton(); + await navBar.clickNewCalculatorButton(); await listPage.clickMenuEntryForCalcType(10); // choose one of them and change its parameters - await navbar.clickCalculatorTab(1); - const Z1 = calcPage.getInputById("Z1"); - await Z1.clearValue(); + await navBar.clickCalculatorTab(1); + const Z1 = await calcPage.getInputById("Z1"); + // await Z1.clearValue(); await Z1.setValue("114"); - const LB = calcPage.getInputById("LB"); - await LB.clearValue(); + const LB = await calcPage.getInputById("LB"); + // await LB.clearValue(); await LB.setValue("11.5"); - const DH = calcPage.getInputById("DH"); - await DH.clearValue(); + const DH = await calcPage.getInputById("DH"); + // await DH.clearValue(); await DH.setValue("0.72"); // calculate Cloisons - const calcButtonCl = calcPage.getCalculateButton(); + const calcButtonCl = await calcPage.getCalculateButton(); await calcButtonCl.click(); + await browser.pause(200); // make sure "Generate PAB" button is visible (it might be hidden behind navbar) await scrollPageToTop(); // create PAB from it, changing modal parameters - const genButton = calcPage.getGeneratePabButton(); + const genButton = await calcPage.getGeneratePabButton(); await genButton.click(); - const debit = calcPage.getInputById("generatePabDebit"); - expect(await debit.getAttribute("value")).toBe("0.564"); - await debit.clearValue(); - await browser.pause(300); + await browser.pause(1000); + const debit = await calcPage.getInputById("generatePabDebit"); + expect(await debit.getValue()).toBe("0.564"); + // await debit.clearValue(); + // await browser.pause(300); // send "1.6" in 3 movements, because "." triggers an error and Angular can't cope with the subsequent keys await debit.setValue("1"); - await browser.pause(300); - await debit.setValue("."); - await browser.pause(300); - await debit.setValue("6"); - await browser.pause(300); - const coteAmont = calcPage.getInputById("generatePabCoteAmont"); - expect(await coteAmont.getAttribute("value")).toBe("114"); - await coteAmont.clearValue(); + // await browser.pause(50); + await debit.addValue("."); + // await browser.pause(50); + await debit.addValue("6"); + // await browser.pause(50); + const coteAmont = await calcPage.getInputById("generatePabCoteAmont"); + expect(await coteAmont.getValue()).toBe("114"); + // await coteAmont.clearValue(); await coteAmont.setValue("115"); - const nbBassins = calcPage.getInputById("generatePabNbBassins"); - expect(await nbBassins.getAttribute("value")).toBe("6"); - await nbBassins.clearValue(); + const nbBassins = await calcPage.getInputById("generatePabNbBassins"); + expect(await nbBassins.getValue()).toBe("6"); + // await nbBassins.clearValue(); await nbBassins.setValue("5"); // click "Generate" - await $("dialog-generate-pab button#do-generate").click(); + const btnGenerate = await $("dialog-generate-pab button#do-generate"); + await btnGenerate.click(); await browser.pause(1000); // check parameters values - const P_Q = calcPage.getInputById("Q"); - expect(await P_Q.getAttribute("value")).toBe("1.6"); - const P_Z2 = calcPage.getInputById("Z2"); - expect(await P_Z2.getAttribute("value")).toBe("111.4"); + 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"); // check number of basins - const innerFieldsets = $$("td.basin_number"); - expect(await innerFieldsets.length).toBe(5); + const innerFieldsets = await $$("td.basin_number"); + expect(innerFieldsets.length).toBe(5); // calculate PAB - 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(); expect(hasResults).toBe(true); @@ -232,29 +246,31 @@ describe("ngHyd − Passe à Bassins", () => { it("complete example of all PAB modules", async () => { await startPage.navigateTo(); // load - await navbar.clickMenuButton(); + await navBar.clickMenuButton(); await browser.pause(200); - await sidenav.clickLoadSessionButton(); + await sideNav.clickLoadSessionButton(); await browser.pause(200); - await sidenav.loadSessionFile("./session/session-pab-complete.json"); + await sideNav.loadSessionFile("./session/session-pab-complete.json"); await browser.pause(500); // check existence of the loaded modules - expect(await navbar.getAllCalculatorTabs().length).toBe(6); + expect(await navBar.getAllCalculatorTabs().length).toBe(6); // check parameters values - await navbar.clickCalculatorTab(5); + await navBar.clickCalculatorTab(5); await browser.pause(700); - const P_Q = calcPage.getInputById("Q"); - expect(await P_Q.getAttribute("value")).toBe("0.275"); - const P_Z2 = calcPage.getInputById("Z2"); - expect(await P_Z2.getAttribute("value")).toBe("74.865"); + 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"); // check number of basins - const innerFieldsets = $$("td.basin_number"); + const innerFieldsets = await $$("td.basin_number"); expect(await innerFieldsets.length).toBe(15); // calculate PAB - 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(); expect(hasResults).toBe(true); @@ -268,19 +284,21 @@ describe("ngHyd − Passe à Bassins", () => { it("should display logs", async () => { await startPage.navigateTo(); // load - await navbar.clickMenuButton(); + await navBar.clickMenuButton(); await browser.pause(200); - await sidenav.clickLoadSessionButton(); + await sideNav.clickLoadSessionButton(); await browser.pause(200); - await sidenav.loadSessionFile("./session/session-pab-regulee-variee.json"); + await sideNav.loadSessionFile("./session/session-pab-regulee-variee.json"); await browser.pause(500); // check existence of the loaded module - expect(await navbar.getAllCalculatorTabs().length).toBe(1); - await navbar.clickCalculatorTab(0); + expect(await navBar.getAllCalculatorTabs().length).toBe(1); + await navBar.clickCalculatorTab(0); // calculate - 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(); expect(hasResults).toBe(true); @@ -290,7 +308,7 @@ describe("ngHyd − Passe à Bassins", () => { expect(await calcPage.nbLogEntries()).toBe(2); // change iteration - const pve = calcPage.getSelectById("pab-variating-element"); + const pve = await calcPage.getSelectById("pab-variating-element"); await changeSelectValue(pve, 3); await browser.pause(300); // check absence of logs diff --git a/e2e/parallel-structures.e2e-spec.ts b/e2e/parallel-structures.e2e-spec.ts index 4d257594b4c4f850ee7983c0e0453a45352fec5a..f1dff37847f672118a377df88450c940eca0291c 100644 --- a/e2e/parallel-structures.e2e-spec.ts +++ b/e2e/parallel-structures.e2e-spec.ts @@ -2,6 +2,7 @@ import { ListPage } from "./list.po"; import { Navbar } from "./navbar.po"; import { CalculatorPage } from "./calculator.po"; import { PreferencesPage } from "./preferences.po"; +import { browser, $, $$, expect } from '@wdio/globals' describe("Check calculated parameter remains the same when copying a structure", () => { let listPage: ListPage; @@ -26,29 +27,37 @@ describe("Check calculated parameter remains the same when copying a structure", it("", async () => { // open "fish ladder: cross walls" calculator await navBar.clickNewCalculatorButton(); + await browser.pause(200); await listPage.clickMenuEntryForCalcType(10); await browser.pause(200); // check L in first structure calc toggle is not checked - const L1 = calcPage.getInputById("0_L"); + const L1 = await calcPage.getInputById("0_L"); // const h11 = calcPage.getInputById("0_h1"); // set L to calculated in first structure await calcPage.setParamMode(L1, "cal"); + await browser.pause(500); // check L calc toggle is checked expect(await calcPage.inputIsInCalculatedMode(L1)).toBe(true); // copy 1st structure - const copyStruct = calcPage.getCopyStructureButton(); - await copyStruct.click(); + const copyStruct = await calcPage.getCopyStructureButton(); + + // await copyStruct.click(); + await browser.execute(e => { e.click() }, copyStruct); // await copyStruct.click() fails with "element not interactable" error + await browser.pause(200); + + await calcPage.closeSnackBar(); + await browser.pause(200); // check L in first structure is still in "calc" state expect(await calcPage.inputIsInCalculatedMode(L1)).toBe(true); // // check L in second structure is still in "fix" state - const L2 = calcPage.getInputById("1_L"); + const L2 = await calcPage.getInputById("1_L"); expect(await calcPage.inputIsInFixedMode(L2)).toBe(true); }); }); diff --git a/e2e/predam-empty-fields.e2e-spec.ts b/e2e/predam-empty-fields.e2e-spec.ts index 8c4182b1afd6da6b3764301f366686bda03372db..0915297ae979badbb20dd13e5afd2035a8e6e3bb 100644 --- a/e2e/predam-empty-fields.e2e-spec.ts +++ b/e2e/predam-empty-fields.e2e-spec.ts @@ -2,6 +2,7 @@ import { CalculatorPage } from "./calculator.po"; import { ListPage } from "./list.po"; import { Navbar } from "./navbar.po"; import { PreferencesPage } from "./preferences.po" +import { browser, $, $$, expect } from '@wdio/globals' /** * check that fields are empty on creation @@ -40,29 +41,30 @@ describe("ngHyd − check that predam fields are empty", () => { await calcPage.checkEmptyInput("Z2"); // check basin 1 inputs - let node = $("g.node.basin"); + let node = await $("g.node.basin"); await node.click(); await browser.pause(200); await calcPage.checkEmptyInput("0_S"); await calcPage.checkEmptyInput("0_ZF"); // check walls inputs - const walls = $$("g.node.wall"); + const walls = await $$("g.node.wall"); expect(walls.length).toEqual(2); - await walls.each(async (w) => { + // await walls.each(async (w) => { + for (const w of walls) { await w.click(); await browser.pause(200); await calcPage.checkEmptyInput("0_ZDV"); await calcPage.checkEmptyInput("0_L"); - }); + }; // check downstream basin inputs - node = $("g[id^='flowchart-aval-']"); // Mermaid generated id + node = await $("g[id^='flowchart-aval-']"); // Mermaid generated id await node.click(); await browser.pause(200); - calcPage.checkEmptyInput("Q"); + await calcPage.checkEmptyInput("Q"); // Z1 is calculated - calcPage.checkEmptyInput("Z2"); + await calcPage.checkEmptyInput("Z2"); }); it("when a basin is added", async () => { @@ -72,18 +74,20 @@ describe("ngHyd − check that predam fields are empty", () => { await browser.pause(200); // add basin - const addBasinBtn = $("#add-basin"); + const addBasinBtn = await $("#add-basin"); await addBasinBtn.click(); await browser.pause(200); // check "surface" input is empty - let inp = calcPage.getInputById("3_S"); - let txt = await inp.getAttribute("value"); + let inp = await calcPage.getInputById("3_S"); + // let txt = await inp.getAttribute("value"); + let txt = await inp.getValue(); expect(txt).toEqual(""); // check "cote de fond" input is empty - inp = calcPage.getInputById("3_ZF"); - txt = await inp.getAttribute("value"); + inp = await calcPage.getInputById("3_ZF"); + // txt = await inp.getAttribute("value"); + txt = await inp.getValue(); expect(txt).toEqual(""); }); @@ -94,27 +98,29 @@ describe("ngHyd − check that predam fields are empty", () => { await browser.pause(200); // add wall - const addWallBtn = $("#add-wall"); + const addWallBtn = await $("#add-wall"); await addWallBtn.click(); // connect basins - const connectBasinsBtn = $("#validate-connect-basins"); + const connectBasinsBtn = await $("#validate-connect-basins"); await connectBasinsBtn.click(); // check ZDV input is empty - let inp = calcPage.getInputById("0_ZDV"); - let txt = await inp.getAttribute("value"); + let inp = await calcPage.getInputById("0_ZDV"); + let txt = await inp.getValue(); expect(txt).toEqual(""); // check L input is empty - inp = calcPage.getInputById("0_L"); - txt = await inp.getAttribute("value"); + inp = await calcPage.getInputById("0_L"); + // txt = await inp.getAttribute("value"); + txt = await inp.getValue(); expect(txt).toEqual(""); // check CdWSL input is empty (in this case, the structure happens to be a Larinier weir // which discharge coefficient must be empty) - inp = calcPage.getInputById("0_CdWSL"); - txt = await inp.getAttribute("value"); + inp = await calcPage.getInputById("0_CdWSL"); + // txt = await inp.getAttribute("value"); + txt = await inp.getValue(); expect(txt).toEqual(""); }); }); diff --git a/e2e/predam-log.e2e-spec.ts b/e2e/predam-log.e2e-spec.ts index 102fb8194814be544000ff758101f631b28ad284..85b7b59513d23f8c5d200b554ac781cf838252f8 100644 --- a/e2e/predam-log.e2e-spec.ts +++ b/e2e/predam-log.e2e-spec.ts @@ -2,6 +2,7 @@ import { CalculatorPage } from "./calculator.po"; import { ListPage } from "./list.po"; import { Navbar } from "./navbar.po"; import { PreferencesPage } from "./preferences.po" +import { browser, $, $$, expect } from '@wdio/globals' describe("check that low iteration count leads to log messages", () => { let listPage: ListPage; @@ -25,7 +26,7 @@ describe("check that low iteration count leads to log messages", () => { }); it("", async () => { - browser.manage().window().setPosition(2000, 30); + // browser.manage().window().setPosition(2000, 30); // set low iteration count await prefPage.setIterationCount(5); @@ -34,12 +35,13 @@ describe("check that low iteration count leads to log messages", () => { await navBar.clickNewCalculatorButton(); await listPage.clickMenuEntryForCalcType(30); await browser.pause(200); - + // run calculation - const calcButton = calcPage.getCalculateButton(); + const calcButton = await calcPage.getCalculateButton(); await calcButton.click(); + await browser.pause(200); // check log messages presence - expect(calcPage.hasLog()).toBe(true); + expect(await calcPage.hasLog()).toBe(true); }); }); diff --git a/e2e/preferences.e2e-spec.ts b/e2e/preferences.e2e-spec.ts index 6b00a4d81cbc94db8c66e7ea7ac9039212fadace..0e09c1128b48f0884c58d060bcd518d74c862db8 100644 --- a/e2e/preferences.e2e-spec.ts +++ b/e2e/preferences.e2e-spec.ts @@ -1,4 +1,5 @@ import { PreferencesPage } from "./preferences.po"; +import { browser, $, $$, expect } from '@wdio/globals' /** * Open app preferences, check the default values, the validators, the language change @@ -10,52 +11,74 @@ describe("ngHyd − preferences page", () => { page = new PreferencesPage(); }); - it("when preferences are open, user should see a heading title", async () => { + beforeEach(async () => { await page.navigateTo(); + browser.pause(200); + }); + + it("when preferences are open, user should see a heading title", async () => { const text = await page.getHeader1().getText(); expect(text.length).toBeGreaterThan(0); }); it("when preferences are open, no label should be empty", async () => { - const labels = page.getInputLabels(); - await labels.each(async (l) => { + const labels = await page.getInputLabels(); + // await labels.each(async (l) => { + for (const l of labels) { const label = await l.getText(); expect(label.length).toBeGreaterThan(0); - }); + }; }); it("when preferences are open, no input field should be empty", async () => { - const numericFields = page.getNumericFormFields(); - await numericFields.each(async (nf) => { - const input = page.getInputForField(nf); - const val = await input.getAttribute("value"); + const numericFields = await page.getNumericFormFields(); + // await numericFields.each(async (nf) => { + for (const nf of numericFields) { + const input = await page.getInputForField(nf); + // const val = await input.getAttribute("value"); + const val = await input.getValue(); expect(val).toBeTruthy(); - }); + }; }); it("when erroneous values are input, errors should appear", async () => { - const numericFields = page.getNumericFormFields(); - await numericFields.each(async (nf) => { + const numericFields = await page.getNumericFormFields(); + // await numericFields.each(async (nf) => { + for (const nf of numericFields) { + const inp = await page.getInputForField(nf); // add a letter after the numerical value - await page.getInputForField(nf).setValue("d"); - expect(page.getErrorsForField(nf).isExisting()).toBe(true); + // await page.getInputForField(nf).addValue("d"); + await inp.addValue("d"); + let errorField = await page.getErrorsForField(nf); + expect(await errorField.isExisting()).toBe(true); // empty input - await page.getInputForField(nf).clearValue(); - expect(page.getErrorsForField(nf).isExisting()).toBe(true); + // await page.getInputForField(nf).clearValue(); + await inp.clearValue(); + // expect(page.getErrorsForField(nf).isExisting()).toBe(true); + errorField = await page.getErrorsForField(nf); + expect(await errorField.isExisting()).toBe(true); // send bad value - await page.getInputForField(nf).setValue("50000"); - expect(page.getErrorsForField(nf).isExisting()).toBe(true); - }); + // await page.getInputForField(nf).setValue("50000"); + await inp.setValue("50000"); + // expect(page.getErrorsForField(nf).isExisting()).toBe(true); + errorField = await page.getErrorsForField(nf); + expect(await errorField.isExisting()).toBe(true); + }; }); it("when correct values are input, errors should disappear", async () => { - const numericFields = page.getNumericFormFields(); - await numericFields.each(async (nf) => { + const numericFields = await page.getNumericFormFields(); + // await numericFields.each(async (nf) => { + for (const nf of numericFields) { // send correct value - await page.getInputForField(nf).clearValue(); - await page.getInputForField(nf).setValue("1"); - expect(page.getErrorsForField(nf).isExisting()).toBe(false); - }); + const inp = await page.getInputForField(nf); + // await page.getInputForField(nf).clearValue(); + // await page.getInputForField(nf).setValue("1"); + await inp.setValue("1"); + const errorField = await page.getErrorsForField(nf); + // expect(page.getErrorsForField(nf).isExisting()).toBe(false); + expect(await errorField.isExisting()).toBe(false); + }; }); it("when language is changed, language should change", async () => { diff --git a/e2e/preferences.po.ts b/e2e/preferences.po.ts index eddb67807215dce9d9554d55d9a03100c3d54756..ea44297946408147c1f10c11b42661859926a1e7 100644 --- a/e2e/preferences.po.ts +++ b/e2e/preferences.po.ts @@ -43,22 +43,22 @@ export class PreferencesPage { } async changeLanguage(index: number) { - const select = this.getLanguageSelect(); + const select = await this.getLanguageSelect(); await changeSelectValue(select, index); } async enableEvilEmptyFields() { - const cb = this.getEmptyFieldsCheckbox(); - const underlyingCB = cb.$(`input.mat-checkbox-input`); - if (!underlyingCB.isSelected()) { + const cb = await this.getEmptyFieldsCheckbox(); + const underlyingCB = await cb.$(`input.mat-checkbox-input`); + if (!await underlyingCB.isSelected()) { await cb.click(); } } async disableEvilEmptyFields() { - const cb = this.getEmptyFieldsCheckbox(); - const underlyingCB = cb.$(`input.mat-checkbox-input`); - if (underlyingCB.isSelected()) { + const cb = await this.getEmptyFieldsCheckbox(); + const underlyingCB = await cb.$(`input.mat-checkbox-input`); + if (await underlyingCB.isSelected()) { await cb.click(); } } @@ -81,8 +81,8 @@ export class PreferencesPage { } async setIterationCount(n: number) { - const input = this.getInputFromName("nmi"); - input.clearValue(); + const input = await this.getInputFromName("nmi"); + // input.clearValue(); await input.setValue(n.toString()); } } diff --git a/e2e/pressure-loss-empty-fields.e2e-spec.ts b/e2e/pressure-loss-empty-fields.e2e-spec.ts index b040c04ccedff4f15442a7f0fec9dcc249c8f763..53b14e380df59c89b104452c73f91959f2f5d36b 100644 --- a/e2e/pressure-loss-empty-fields.e2e-spec.ts +++ b/e2e/pressure-loss-empty-fields.e2e-spec.ts @@ -3,6 +3,7 @@ import { Navbar } from "./navbar.po"; import { CalculatorPage } from "./calculator.po"; import { PreferencesPage } from "./preferences.po"; import { changeSelectValue } from "./util.po"; +import { browser, $, $$, expect } from '@wdio/globals' describe("Check fields are empty in 'pressure loss' calculator when created with 'empty fields' option -", () => { let listPage: ListPage; @@ -31,10 +32,10 @@ describe("Check fields are empty in 'pressure loss' calculator when created with await browser.pause(200); // select Lechapt-Calmon pressure loss law - const materialSelect = calcPage.getSelectById("select_pressurelosstype"); + const materialSelect = await calcPage.getSelectById("select_pressurelosstype"); await changeSelectValue(materialSelect, 0); await browser.pause(200); - expect(calcPage.checkEmptyOrFilledFields(["Q", "D", "Lg", "Kloc"], [true, true, true, true])); + expect(await calcPage.checkEmptyOrFilledFields(["Q", "D", "Lg", "Kloc"], [true, true, true, true])); }); }); diff --git a/e2e/pressure-loss.e2e-spec.ts b/e2e/pressure-loss.e2e-spec.ts index 38b8e993a495e5733a8917a7ad67efbe0c31d259..e4d6e530c70adef28e6bcb55704448c84c04ac84 100644 --- a/e2e/pressure-loss.e2e-spec.ts +++ b/e2e/pressure-loss.e2e-spec.ts @@ -3,6 +3,7 @@ import { Navbar } from "./navbar.po"; import { CalculatorPage } from "./calculator.po"; import { PreferencesPage } from "./preferences.po"; import { changeSelectValue } from "./util.po"; +import { browser, $, $$, expect } from '@wdio/globals' describe("Pressure loss - ", () => { let listPage: ListPage; @@ -32,7 +33,7 @@ describe("Pressure loss - ", () => { await browser.pause(200); // select Lechapt-Calmon pressure loss law - const materialSelect = calcPage.getSelectById("select_pressurelosstype"); + const materialSelect = await calcPage.getSelectById("select_pressurelosstype"); await changeSelectValue(materialSelect, 0); await browser.pause(200); @@ -48,7 +49,7 @@ describe("Pressure loss - ", () => { }); it("Strickler", async () => { - browser.manage().window().setPosition(2000, 30); + // browser.manage().window().setPosition(2000, 30); // open "pressure loss" calculator await navBar.clickNewCalculatorButton(); @@ -56,16 +57,13 @@ describe("Pressure loss - ", () => { await browser.pause(200); // select Strickler pressure loss law - const materialSelect = calcPage.getSelectById("select_pressurelosstype"); + const materialSelect = await calcPage.getSelectById("select_pressurelosstype"); await changeSelectValue(materialSelect, 1); await browser.pause(200); - debugger // check inputs presence - const ks = $("#0_Ks"); - expect(await ks.isExisting()).toBe(true); // isNgParamPresent does not work on "0_Ks". Why ? Mystery... - + expect(await calcPage.isNgParamPresent("0_Ks")).toBe(true); expect(await calcPage.isNgParamPresent("Q")).toBe(true); expect(await calcPage.isNgParamPresent("D")).toBe(true); expect(await calcPage.isNgParamPresent("J")).toBe(true); diff --git a/e2e/regime-uniforme-empty-fields.e2e-spec.ts b/e2e/regime-uniforme-empty-fields.e2e-spec.ts index 636ba633676fda81ed723a8973aed4cab189b98e..f9178310462e7c65f697d186e21a2ba7c37d08a1 100644 --- a/e2e/regime-uniforme-empty-fields.e2e-spec.ts +++ b/e2e/regime-uniforme-empty-fields.e2e-spec.ts @@ -2,6 +2,7 @@ import { ListPage } from "./list.po"; import { Navbar } from "./navbar.po"; import { CalculatorPage } from "./calculator.po"; import { PreferencesPage } from "./preferences.po"; +import { browser, $, $$, expect } from '@wdio/globals' describe("Check fields are empty in 'uniform flow' calculator when created with 'empty fields' option", () => { let listPage: ListPage; @@ -29,6 +30,6 @@ describe("Check fields are empty in 'uniform flow' calculator when created with await listPage.clickMenuEntryForCalcType(3); await browser.pause(200); - expect(calcPage.checkEmptyOrFilledFields(["LargeurBerge", "Ks", "If", "YB", "Q", "Y"], [true, true, true, true, true, true])) + expect(await calcPage.checkEmptyOrFilledFields(["LargeurBerge", "Ks", "If", "YB", "Q", "Y"], [true, true, true, true, true, true])) }); }); diff --git a/e2e/remous.e2e-spec.ts b/e2e/remous.e2e-spec.ts index 80fb6cd12122216b36f24efe2da8931069e5e6ab..fb2b14b63c38f8e5d7c3853be36ed1fff3ec7b61 100644 --- a/e2e/remous.e2e-spec.ts +++ b/e2e/remous.e2e-spec.ts @@ -4,6 +4,7 @@ import { Navbar } from "./navbar.po"; import { PreferencesPage } from "./preferences.po"; import { SideNav } from "./sidenav.po"; import { changeSelectValue } from "./util.po"; +import { browser, $, $$, expect } from '@wdio/globals' /** * Remous @@ -38,7 +39,10 @@ describe("ngHyd − remous", () => { await browser.pause(300); // 2. calculate it, there should be 6 messages in the log - await calcPage.getCalculateButton().click(); + const calcBtn = await calcPage.getCalculateButton() + await calcBtn.click(); + await browser.pause(200); + expect(await calcPage.nbLogEntries()).toBe(6); await browser.pause(300); @@ -62,7 +66,7 @@ describe("ngHyd − remous", () => { await browser.pause(300); // 2. Set to trapezoidal section with bank slope of 2m/m and 20 meter width bed - await changeSelectValue(calcPage.getSelectById("select_section"), 2); + await changeSelectValue(await calcPage.getSelectById("select_section"), 2); await browser.pause(300); await calcPage.getInputById("LargeurFond").clearValue(); await browser.pause(300); @@ -72,7 +76,10 @@ describe("ngHyd − remous", () => { await calcPage.getInputById("Fruit").setValue("2"); // 3. Calculate, the calculation should succeed - await calcPage.getCalculateButton().click(); + const calcBtn = await calcPage.getCalculateButton() + await calcBtn.click(); + await browser.pause(200); + const hasResults = await calcPage.hasResults(); expect(hasResults).toBe(true); }); @@ -80,15 +87,16 @@ describe("ngHyd − remous", () => { it("Check that calculation with dx >= reach length fails", async () => { // load backwater curve session file with Dx>=Long await navBar.clickMenuButton(); - await browser.pause(500); + await browser.pause(200); await sidenav.clickLoadSessionButton(); - await browser.pause(500); + await browser.pause(200); await sidenav.loadSessionFile("./session/session-remous-dx-bief.json"); - await browser.pause(1000); + await browser.pause(300); // Calculate, the calculation should fail - await calcPage.getCalculateButton().click(); - await browser.pause(1000); + const calcBtn = await calcPage.getCalculateButton() + await calcBtn.click(); + await browser.pause(200); // check error message in log expect(await calcPage.nbLogEntries()).toBe(1); diff --git a/e2e/reset-param-mode.e2e-spec.ts b/e2e/reset-param-mode.e2e-spec.ts index f8a061df1f74bba5ee3b7e72260e8d44986d040a..d5e85ef809844e9356429aded6f990d0ee8c7ca1 100644 --- a/e2e/reset-param-mode.e2e-spec.ts +++ b/e2e/reset-param-mode.e2e-spec.ts @@ -1,4 +1,9 @@ import { ListPage } from "./list.po"; +import { browser, $, $$, expect } from '@wdio/globals' +import { newSession } from "./util.po"; +import { Navbar } from "./navbar.po"; +import { SideNav } from "./sidenav.po"; +import { CalculatorPage } from "./calculator.po"; /** * Parameter mode should be set to its previous mode (fixed/var/...) when cancel is pressed @@ -6,76 +11,92 @@ import { ListPage } from "./list.po"; */ describe("ngHyd - check parameter mode is set to its previous value - ", () => { let listPage: ListPage; + let navBar: Navbar; + let sideNav: SideNav; + let calcPage: CalculatorPage; beforeAll(() => { listPage = new ListPage(); + // navBar = new Navbar(); + // sideNav = new SideNav(); + calcPage = new CalculatorPage(); }); it("when min/max/list values dialog is cancelled on 'fish ladder: fall' calculator", async () => { // start page await listPage.navigateTo(); - await browser.pause(500); + await browser.pause(300); // open 'PAB fall' calculator await listPage.clickMenuEntryForCalcType(12); - await browser.pause(500); + await browser.pause(200); // click "calc" radio on Z1 parameter - const z1calcbtn = $("#mat-button-toggle-3"); + // const z1calcbtn = await $("#mat-button-toggle-3"); + const z1calcbtn = await calcPage.getInputRadioButtonFromId("Z1", "cal"); await z1calcbtn.click(); await browser.pause(200); // click "var" radio on Z1 parameter - const z1varbtn = $("#mat-button-toggle-2"); + // const z1varbtn = await $("#mat-button-toggle-2"); + const z1varbtn = await calcPage.getInputRadioButtonFromId("Z1", "var"); await z1varbtn.click(); await browser.pause(200); // click cancel button - const cancelbtn = $("#btn-cancel"); + const cancelbtn = await $("#btn-cancel"); await cancelbtn.click(); - await browser.pause(200); + await browser.pause(500); // check Z1 var toggle is not checked - expect(await z1varbtn.getAttribute("ng-reflect-checked")).toBe("false"); + // expect(await z1varbtn.getASttribute("ng-reflect-checked")).toBe("false"); + expect(await calcPage.isRadioButtonChecked(z1varbtn)).toEqual(false); // check Z1 calc toggle is checked - expect(await z1calcbtn.getAttribute("ng-reflect-checked")).toBe("true"); + // expect(await z1calcbtn.getAttribute("ng-reflect-checked")).toBe("true"); + expect(await calcPage.isRadioButtonChecked(z1calcbtn)).toEqual(true); }); it("when min/max/list values dialog is cancelled on 'fish ladder' calculator", async () => { // start page await listPage.navigateTo(); - await browser.pause(500); + await browser.pause(300); + // await newSession(navBar, sideNav); // open PAB calculator await listPage.clickMenuEntryForCalcType(15); await browser.pause(500); // "fixed" radio on Q parameter - const qfixbtn = $("#mat-button-toggle-1"); - await browser.pause(50); + // const qfixbtn = await $("#mat-button-toggle-1"); + const qfixbtn = await calcPage.getInputRadioButtonFromId("Q", "fix"); + // await browser.pause(50); // "var" radio on Z1 parameter - const z1varbtn = $("#mat-button-toggle-6"); - await browser.pause(50); + // const z1varbtn = await $("#mat-button-toggle-6"); + const z1varbtn = await calcPage.getInputRadioButtonFromId("Z1", "var"); + // await browser.pause(50); // "calc" radio on Z1 parameter - const z1calcbtn = $("#mat-button-toggle-7"); - await browser.pause(50); + // const z1calcbtn = await $("#mat-button-toggle-7"); + const z1calcbtn = await calcPage.getInputRadioButtonFromId("Z1", "cal"); + // await browser.pause(50); // click "var" radio on Z1 parameter await z1varbtn.click(); await browser.pause(200); // click cancel button - const cancelbtn = $("#btn-cancel"); + const cancelbtn = await $("#btn-cancel"); await cancelbtn.click(); - await browser.pause(200); + await browser.pause(500); // check Q fix toggle is checked - expect(await qfixbtn.getAttribute("ng-reflect-checked")).toBe("true"); + // expect(await qfixbtn.getAttribute("ng-reflect-checked")).toBe("true"); + expect(await calcPage.isRadioButtonChecked(qfixbtn)).toEqual(true); // check Z1 calc toggle is checked - expect(await z1calcbtn.getAttribute("ng-reflect-checked")).toBe("true"); + // expect(await z1calcbtn.getAttribute("ng-reflect-checked")).toBe("true"); + expect(await calcPage.isRadioButtonChecked(z1calcbtn)).toEqual(true); }); }); diff --git a/e2e/reset-results.e2e-spec.ts b/e2e/reset-results.e2e-spec.ts index 9d1e3dba698b18a34956013aad141b755328baa0..5811449db5655390cbc4ceb8ac56c0ef37e5735c 100644 --- a/e2e/reset-results.e2e-spec.ts +++ b/e2e/reset-results.e2e-spec.ts @@ -3,6 +3,7 @@ import { Navbar } from "./navbar.po"; import { CalculatorPage } from "./calculator.po"; import { PreferencesPage } from "./preferences.po"; import { SideNav } from "./sidenav.po"; +import { browser, $, $$, expect } from '@wdio/globals' describe("Check results are reset after application settings modification - ", () => { let listPage: ListPage; @@ -28,13 +29,13 @@ describe("Check results are reset after application settings modification - ", ( await browser.pause(200); }); - async function runTestWithParamater(param: string, val1: number, val2: number) { + async function runTestWithParameter(param: string, val1: number, val2: number) { // set starting compute precision - const input = prefPage.getInputFromName(param); - await input.clearValue(); - await browser.pause(20); + const input = await prefPage.getInputFromName(param); + // await input.clearValue(); + // await browser.pause(20); await input.setValue(val1.toString()); - await browser.pause(200); + // await browser.pause(200); // open "fish ladder: fall" calculator await navBar.clickNewCalculatorButton(); @@ -42,7 +43,7 @@ describe("Check results are reset after application settings modification - ", ( await browser.pause(200); // click "compute" button - const calcButton = calcPage.getCalculateButton(); + const calcButton = await calcPage.getCalculateButton(); await calcButton.click(); await browser.pause(200); @@ -58,10 +59,10 @@ describe("Check results are reset after application settings modification - ", ( await browser.pause(200); // modify compute precision - await input.clearValue(); - await browser.pause(20); + // await input.clearValue(); + // await browser.pause(20); await input.setValue(val2.toString()); - await browser.pause(200); + await browser.pause(500); // back to calculator await navBar.openNthCalculator(0); @@ -69,14 +70,13 @@ describe("Check results are reset after application settings modification - ", ( // results should not be here hasResults = await calcPage.hasResults(); expect(hasResults).toBe(false); - } it("compute precision", async () => { - await runTestWithParamater("cp", 0.001, 0.0001); + await runTestWithParameter("cp", 0.001, 0.0001); }); it("max iterations", async () => { - await runTestWithParamater("nmi", 10, 100); + await runTestWithParameter("nmi", 10, 100); }); }); diff --git a/e2e/section-empty-fields.e2e-spec.ts b/e2e/section-empty-fields.e2e-spec.ts index 94793035424b646415eee3e47c60a2de0b1f26bb..5d867024c690a0aa19da2f2552c95cf0d2b63735 100644 --- a/e2e/section-empty-fields.e2e-spec.ts +++ b/e2e/section-empty-fields.e2e-spec.ts @@ -2,6 +2,7 @@ import { ListPage } from "./list.po"; import { Navbar } from "./navbar.po"; import { CalculatorPage } from "./calculator.po"; import { PreferencesPage } from "./preferences.po"; +import { browser, $, $$, expect } from '@wdio/globals' describe("Check fields are empty in 'parametric section' calculator when created with 'empty fields' option", () => { let listPage: ListPage; @@ -29,6 +30,6 @@ describe("Check fields are empty in 'parametric section' calculator when created await listPage.clickMenuEntryForCalcType(2); await browser.pause(200); - expect(calcPage.checkEmptyOrFilledFields(["LargeurBerge", "Ks", "If", "YB", "Q", "Y"], [true, true, true, true, true, true])); + expect(await calcPage.checkEmptyOrFilledFields(["LargeurBerge", "Ks", "If", "YB", "Q", "Y"], [true, true, true, true, true, true])); }); }); diff --git a/e2e/select-default-value.e2e-spec.ts b/e2e/select-default-value.e2e-spec.ts index a1323b09206a4f9f686f91a9e6b3202f6ac81563..058408310ab9cfd9a9a115c23a6d24eb75e1d10e 100644 --- a/e2e/select-default-value.e2e-spec.ts +++ b/e2e/select-default-value.e2e-spec.ts @@ -2,6 +2,7 @@ import { CalculatorPage } from "./calculator.po"; import { ListPage } from "./list.po"; import { Navbar } from "./navbar.po"; import { PreferencesPage } from "./preferences.po"; +import { browser, $, $$, expect } from '@wdio/globals' describe("check the select default value - ", () => { let prefPage: PreferencesPage; @@ -34,7 +35,7 @@ describe("check the select default value - ", () => { // in the calculator configuration file, the default resolution method is 'Trapezes'. // let's check this... - const sel = calcPage.getSelectById("select_resolution"); + const sel = await calcPage.getSelectById("select_resolution"); const val = await calcPage.getSelectValueText(sel); expect(val).toBe("Intégration par trapèzes"); }); @@ -47,7 +48,7 @@ describe("check the select default value - ", () => { // in the calculator configuration file, the default section method is 'Rectangulaire'. // let's check this... - const sel = calcPage.getSelectById("select_section"); + const sel = await calcPage.getSelectById("select_section"); const val = await calcPage.getSelectValueText(sel); expect(val).toBe("Rectangulaire"); }); diff --git a/e2e/sidenav.po.ts b/e2e/sidenav.po.ts index 94ba72779d39000497b77e37046a6ba6219ba10f..e7e79bbe231db92db744b13c8498e2694fee3b1f 100644 --- a/e2e/sidenav.po.ts +++ b/e2e/sidenav.po.ts @@ -1,4 +1,7 @@ import * as path from "path"; +import { browser, $, $$, expect } from '@wdio/globals' +import { CalculatorPage } from "./calculator.po"; +import { scrollToElement } from "./util.po"; export class SideNav { @@ -20,6 +23,7 @@ export class SideNav { getFileInput() { return $(`dialog-load-session input[type="file"]`); + // return $(`dialog-load-session ngx-mat-file-input`); } getFileLoadButton() { @@ -35,7 +39,7 @@ export class SideNav { } async clickLoadSessionButton() { - const ncb = this.getLoadSessionButton(); + const ncb = await this.getLoadSessionButton(); await browser.pause(500); await ncb.click(); } @@ -47,20 +51,25 @@ export class SideNav { } async clickNewSessionButton() { - const ncb = this.getNewSessionButton(); - await browser.pause(200); + const ncb = await this.getNewSessionButton(); + // await browser.pause(200); await ncb.click(); await browser.pause(200); - await this.getConfirmNewSessionButton().click(); + const cb = await this.getConfirmNewSessionButton(); + await cb.click(); } async loadSessionFile(file: string, click: boolean = true) { const absolutePath = path.resolve(__dirname, file); - const input = this.getFileInput(); - await input.setValue(absolutePath); - await browser.pause(500); + const input = await this.getFileInput(); + // await input.click(); + // await scrollToElement(input) + // await input.setValue(absolutePath); + await input.addValue(absolutePath); + // await browser.pause(500); if (click) { - await this.getFileLoadButton().click(); + const btn = await this.getFileLoadButton(); + await btn.click(); } } diff --git a/e2e/solveur.e2e-spec.ts b/e2e/solveur.e2e-spec.ts index 2b09a33874dfbb6c561092fb7c0421f81470f2cf..1aa86e1ddace61d2ed360e254697953115bdc926 100644 --- a/e2e/solveur.e2e-spec.ts +++ b/e2e/solveur.e2e-spec.ts @@ -3,7 +3,8 @@ import { CalculatorPage } from "./calculator.po"; import { Navbar } from "./navbar.po"; import { SideNav } from "./sidenav.po"; import { PreferencesPage } from "./preferences.po"; -import { changeSelectValue, scrollPageToTop } from "./util.po"; +import { changeSelectValue, newSession, openCalculator, scrollPageToTop } from "./util.po"; +import { browser, $, $$, expect } from '@wdio/globals' /** * Clone calculators @@ -11,16 +12,16 @@ import { changeSelectValue, scrollPageToTop } from "./util.po"; describe("Solveur - ", () => { let listPage: ListPage; let calcPage: CalculatorPage; - let navbar: Navbar; - let sidenav: SideNav; + let navBar: Navbar; + let sideNav: SideNav; let prefPage: PreferencesPage; beforeAll(() => { prefPage = new PreferencesPage(); listPage = new ListPage(); calcPage = new CalculatorPage(); - navbar = new Navbar(); - sidenav = new SideNav(); + navBar = new Navbar(); + sideNav = new SideNav(); }); beforeEach(async () => { @@ -29,35 +30,39 @@ describe("Solveur - ", () => { // force language to prevent issues due to default browser language await prefPage.changeLanguage(1); // fr await browser.pause(200); - await navbar.clickNewCalculatorButton(); + await navBar.clickNewCalculatorButton(); }); it("load > calculate", async () => { - await navbar.clickMenuButton(); + await navBar.clickMenuButton(); await browser.pause(200); - await sidenav.clickLoadSessionButton(); + await sideNav.clickLoadSessionButton(); await browser.pause(200); - await sidenav.loadSessionFile("./session/session-solveur-chutes.json"); + await sideNav.loadSessionFile("./session/session-solveur-chutes.json"); await browser.pause(200); - expect(await navbar.getAllCalculatorTabs().length).toBe(4); - await navbar.clickCalculatorTab(3); // n°3 should be the latest + expect(await navBar.getAllCalculatorTabs().length).toBe(4); + await navBar.clickCalculatorTab(3); // n°3 should be the latest // check input values - expect(await calcPage.getInputById("Xinit").getAttribute("value")).toBe("0.5"); - expect(await calcPage.getInputById("Ytarget").getAttribute("value")).toBe("252"); + // expect(await calcPage.getInputById("Xinit").getAttribute("value")).toBe("0.5"); + const inpXinit = await calcPage.getInputById("Xinit"); + expect(await inpXinit.getValue()).toBe("0.5"); + // expect(await calcPage.getInputById("Ytarget").getAttribute("value")).toBe("252"); + const inpYtarget = await calcPage.getInputById("Ytarget"); + expect(await inpYtarget.getValue()).toBe("252"); // check Nub to calculate - const ntc = calcPage.getSelectById("select_target_nub"); + const ntc = await calcPage.getSelectById("select_target_nub"); const ntcV = await calcPage.getSelectValueText(ntc); expect(ntcV).toContain("PAB : puissance / Puissance dissipée (PV)"); // check targetted result - const ntt = calcPage.getSelectById("select_target_result"); + const ntt = await calcPage.getSelectById("select_target_result"); const nttV = await calcPage.getSelectValueText(ntt); expect(nttV).toContain("Puissance dissipée (PV)"); // check searched Parameter - const sp = calcPage.getSelectById("select_searched_param"); + const sp = await calcPage.getSelectById("select_searched_param"); const spV = await calcPage.getSelectValueText(sp); expect(spV).toContain("Z2 - Cote aval (PAB : chute)"); @@ -65,6 +70,8 @@ describe("Solveur - ", () => { 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); @@ -76,45 +83,52 @@ describe("Solveur - ", () => { }); it("create > feed > calculate > clone > calculate clone", async () => { + await newSession(navBar, sideNav); + // 1. create empty Solveur - await listPage.clickMenuEntryForCalcType(22); // Solveur - await browser.pause(500); + // await listPage.clickMenuEntryForCalcType(22); // Solveur + // await browser.pause(500); + openCalculator(22, navBar, listPage); // 2. create PAB:Chute, PAB:Nombre and PAB:Puissance linked to one another - await navbar.clickNewCalculatorButton(); + await navBar.clickNewCalculatorButton(); await listPage.clickMenuEntryForCalcType(12); // PAB:Chute await browser.pause(500); - await navbar.clickNewCalculatorButton(); + await navBar.clickNewCalculatorButton(); await listPage.clickMenuEntryForCalcType(13); // PAB:Nombre await browser.pause(500); // link DHT to PAB:Chute.DH - const dht = calcPage.getInputById("DHT"); + const dht = await calcPage.getInputById("DHT"); await calcPage.setParamMode(dht, "link"); // Calculate DH - const dh_nombre = calcPage.getInputById("DH"); + const dh_nombre = await calcPage.getInputById("DH"); await calcPage.setParamMode(dh_nombre, "cal"); - await navbar.clickNewCalculatorButton(); + await navBar.clickNewCalculatorButton(); await listPage.clickMenuEntryForCalcType(6); // PAB:Puissance await browser.pause(500); // link DH to PAB:Nombre.DH - const dh_puiss = calcPage.getInputById("DH"); + const dh_puiss = await calcPage.getInputById("DH"); await calcPage.setParamMode(dh_puiss, "link"); // Go back to Solveur - await navbar.clickCalculatorTab(0); + await navBar.clickCalculatorTab(0); - await changeSelectValue(calcPage.getSelectById("select_target_nub"), 1); // "Puissance / PV" + await changeSelectValue(await calcPage.getSelectById("select_target_nub"), 1); // "Puissance / PV" await browser.pause(500); - await changeSelectValue(calcPage.getSelectById("select_searched_param"), 2); // "Chute / Z2" + await changeSelectValue(await calcPage.getSelectById("select_searched_param"), 2); // "Chute / Z2" await browser.pause(500); await calcPage.getInputById("Ytarget").setValue("318"); // check that "compute" button is active const calcButton = await calcPage.checkCalcButtonEnabled(true); + await browser.pause(200); + // 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); @@ -125,8 +139,8 @@ describe("Solveur - ", () => { await browser.pause(500); // 4. check existence of the cloned module - expect(await navbar.getAllCalculatorTabs().length).toBe(5); - await navbar.clickCalculatorTab(4); // n°4 should be the latest + expect(await navBar.getAllCalculatorTabs().length).toBe(5); + await navBar.clickCalculatorTab(4); // n°4 should be the latest // check that result is empty const hasResultsClone1 = await calcPage.hasResults(); @@ -134,31 +148,37 @@ describe("Solveur - ", () => { // check that "compute" button is active const calcButtonClone = await calcPage.checkCalcButtonEnabled(true); + await browser.pause(200); + // click "compute" button await calcButtonClone.click(); + await browser.pause(200); + // check that result is not empty const hasResultsClone2 = await calcPage.hasResults(); expect(hasResultsClone2).toBe(true); }); it("channel flow example > solver > change searched parameter > run calculation", async () => { + await newSession(navBar, sideNav); + // open "channel flow with hydraulic structures" example const examples = await $$("#examples-list .load-example"); - await (await examples)[1].click(); + await examples[1].click(); await browser.pause(500); // select solver tab - await navbar.clickCalculatorTab(3); + await navBar.clickCalculatorTab(3); await browser.pause(500); // modify searched parameter - const sel = calcPage.getSelectById("select_searched_param"); + const sel = await calcPage.getSelectById("select_searched_param"); await changeSelectValue(sel, 11); await browser.pause(300); const selText = await calcPage.getSelectValueText(sel); // run calculation - const calcButton = calcPage.getCalculateButton(); + const calcButton = await calcPage.getCalculateButton(); await calcButton.click(); await browser.pause(500); @@ -167,17 +187,19 @@ describe("Solveur - ", () => { }); it("check solver searched parameter is set to 'bottom slope'", async () => { + await newSession(navBar, sideNav); + // open "canal critical slope" example const examples = await $$("#examples-list .load-example"); - await (await examples)[3].click(); + await examples[3].click(); await browser.pause(500); // select solver tab - await navbar.clickCalculatorTab(2); + await navBar.clickCalculatorTab(2); await browser.pause(500); // check selected searched parameter text - const sel = calcPage.getSelectById("select_searched_param"); + const sel = await calcPage.getSelectById("select_searched_param"); const selText = await calcPage.getSelectValueText(sel); expect(selText).toEqual("If - Pente du fond (Sec. param.)"); }); @@ -191,24 +213,19 @@ describe("Solveur - nghyd#601 with empty fields option", () => { let navBar: Navbar; let listPage: ListPage; let calcPage: CalculatorPage; + let sideNav: SideNav; beforeAll(() => { prefPage = new PreferencesPage(); navBar = new Navbar(); listPage = new ListPage(); calcPage = new CalculatorPage(); + sideNav = new SideNav(); }); - async function openCalculator(id: number) { - await navBar.clickNewCalculatorButton(); - await browser.pause(200); - - await listPage.clickMenuEntryForCalcType(id); - await browser.pause(200); - } async function openSolver() { - await openCalculator(22); + await openCalculator(22, navBar, listPage); } beforeEach(async () => { @@ -217,6 +234,8 @@ describe("Solveur - nghyd#601 with empty fields option", () => { }); it("check solver with empty fields option does not fill inputs - solver alone", async () => { + await newSession(navBar, sideNav); + // open new solver calculator await openSolver(); @@ -230,13 +249,13 @@ describe("Solveur - nghyd#601 with empty fields option", () => { it("check solver with empty fields option does not fill target parameter input", async () => { // open "parallel structures" calculator - await openCalculator(8); + await openCalculator(8, navBar, listPage); // open second "parallel structures" calculator - await openCalculator(8); + await openCalculator(8, navBar, listPage); // link Q to first calculator's - const inpQ = calcPage.getInputById("Q"); + const inpQ = await calcPage.getInputById("Q"); await calcPage.setParamMode(inpQ, "link"); await browser.pause(200); @@ -245,20 +264,22 @@ describe("Solveur - nghyd#601 with empty fields option", () => { // check target parameter input is empty await calcPage.checkEmptyInput("Ytarget"); - await browser.pause(200); + await browser.pause(100); // check initial value input is not empty await calcPage.checkEmptyInput("Xinit"); - await browser.pause(200); + await browser.pause(100); }); it("check removing and recreating solver with empty fields option does not fill target parameter input", async () => { - await navBar.clickNewCalculatorButton(); - await browser.pause(200); + await newSession(navBar, sideNav); + + // await navBar.clickNewCalculatorButton(); + // await browser.pause(200); // open "channel flow with hydraulic structures" example const examples = await $$("#examples-list .load-example"); - await (await examples)[1].click(); + await examples[1].click(); await browser.pause(500); // close existing "solver" calculator @@ -286,24 +307,26 @@ describe("Solveur - nghyd#601 without empty fields option", () => { let navBar: Navbar; let listPage: ListPage; let calcPage: CalculatorPage; + let sideNav: SideNav; beforeAll(() => { prefPage = new PreferencesPage(); navBar = new Navbar(); listPage = new ListPage(); calcPage = new CalculatorPage(); + sideNav = new SideNav(); }); - async function openCalculator(id: number) { - await navBar.clickNewCalculatorButton(); - await browser.pause(200); + // async function openCalculator(id: number) { + // await navBar.clickNewCalculatorButton(); + // await browser.pause(200); - await listPage.clickMenuEntryForCalcType(id); - await browser.pause(200); - } + // await listPage.clickMenuEntryForCalcType(id); + // await browser.pause(200); + // } async function openSolver() { - await openCalculator(22); + await openCalculator(22, navBar, listPage); } beforeEach(async () => { @@ -314,6 +337,8 @@ describe("Solveur - nghyd#601 without empty fields option", () => { }); it("check solver without empty fields option does not fill inputs - solver alone", async () => { + await newSession(navBar, sideNav); + // open new solver calculator await openSolver(); @@ -327,13 +352,13 @@ describe("Solveur - nghyd#601 without empty fields option", () => { it("check solver without empty fields option fills inputs", async () => { // open "parallel structures" calculator - await openCalculator(8); + await openCalculator(8, navBar, listPage); // open second "parallel structures" calculator - await openCalculator(8); + await openCalculator(8, navBar, listPage); // link Q to first calculator's - const inpQ = calcPage.getInputById("Q"); + const inpQ = await calcPage.getInputById("Q"); await calcPage.setParamMode(inpQ, "link"); await browser.pause(200); @@ -350,12 +375,14 @@ describe("Solveur - nghyd#601 without empty fields option", () => { }); it("check removing and recreating solver without empty fields option fills inputs", async () => { - await navBar.clickNewCalculatorButton(); - await browser.pause(200); + await newSession(navBar, sideNav); + + // await navBar.clickNewCalculatorButton(); + // await browser.pause(200); // open "channel flow with hydraulic structures" example const examples = await $$("#examples-list .load-example"); - await (await examples)[1].click(); + await examples[1].click(); await browser.pause(500); // close existing "solver" calculator @@ -384,7 +411,7 @@ describe("Solveur - nghyd#601 without empty fields option", () => { // open "channel flow with hydraulic structures" example const examples = await $$("#examples-list .load-example"); - await (await examples)[1].click(); + await examples[1].click(); await browser.pause(500); // close existing "solver" calculator @@ -396,7 +423,7 @@ describe("Solveur - nghyd#601 without empty fields option", () => { await browser.pause(500); // select other target module - const ntc = calcPage.getSelectById("select_target_nub"); + const ntc = await calcPage.getSelectById("select_target_nub"); await changeSelectValue(ntc, 1); // check target value input is empty @@ -410,24 +437,26 @@ describe("Solveur - nghyd#606 - a single module cannot be used with solver", () let navBar: Navbar; let listPage: ListPage; let calcPage: CalculatorPage; + let sideNav: SideNav; beforeAll(() => { prefPage = new PreferencesPage(); navBar = new Navbar(); listPage = new ListPage(); calcPage = new CalculatorPage(); + sideNav = new SideNav(); }); - async function openCalculator(id: number) { - await navBar.clickNewCalculatorButton(); - await browser.pause(200); + // async function openCalculator(id: number) { + // await navBar.clickNewCalculatorButton(); + // await browser.pause(200); - await listPage.clickMenuEntryForCalcType(id); - await browser.pause(200); - } + // await listPage.clickMenuEntryForCalcType(id); + // await browser.pause(200); + // } async function openSolver() { - await openCalculator(22); + await openCalculator(22, navBar, listPage); } beforeEach(async () => { @@ -438,19 +467,21 @@ describe("Solveur - nghyd#606 - a single module cannot be used with solver", () }); it("", async () => { + await newSession(navBar, sideNav); + // open uniform flow calculator - await openCalculator(3); + await openCalculator(3, navBar, listPage); // open a solver module await openSolver(); // set speed as target parameter - const trs = calcPage.getSelectById("select_target_result"); + const trs = await calcPage.getSelectById("select_target_result"); await changeSelectValue(trs, 1); await browser.pause(200); // check searched parameter has options - const sps = calcPage.getSelectById("select_searched_param"); + const sps = await calcPage.getSelectById("select_searched_param"); expect(await calcPage.isSelectEmpty(sps)).toBe(false); }); }); diff --git a/e2e/translation.e2e-spec.ts b/e2e/translation.e2e-spec.ts index 00f0e3316fefa0bfc4943b90fe6d976ab3c5e034..93bcb3f483969cff26b4dd425251737b4fe41133 100644 --- a/e2e/translation.e2e-spec.ts +++ b/e2e/translation.e2e-spec.ts @@ -3,6 +3,7 @@ import { Navbar } from "./navbar.po"; import { CalculatorPage } from "./calculator.po"; import { PreferencesPage } from "./preferences.po"; import { SideNav } from "./sidenav.po"; +import { browser, $, $$, expect } from '@wdio/globals' describe("Check translation", () => { let listPage: ListPage; @@ -26,8 +27,9 @@ describe("Check translation", () => { it("variables in results", async () => { // *** results in french *** - prefPage.changeLanguage(1); // fr - await browser.pause(200); + await prefPage.navigateTo(); + await prefPage.changeLanguage(1); // fr + // await browser.pause(200); // open "fish ladder: fall" calculator await navBar.clickNewCalculatorButton(); @@ -35,7 +37,7 @@ describe("Check translation", () => { await browser.pause(200); // set Z2 to variated mode - const inpZ2 = calcPage.getInputById("Z2"); + const inpZ2 = await calcPage.getInputById("Z2"); await calcPage.setParamMode(inpZ2, "var"); // run calculation @@ -43,20 +45,22 @@ describe("Check translation", () => { await browser.pause(500); // "variable for X axis" select label - const selXaxis = calcPage.getSelectById("selectX"); + const selXaxis = await calcPage.getSelectById("selectX"); expect(await calcPage.getMatselectCurrentOptionText(selXaxis)).toEqual("Cote aval"); // "variable for Y axis" select label - const selYaxis = calcPage.getSelectById("selectY"); + const selYaxis = await calcPage.getSelectById("selectY"); expect(await calcPage.getMatselectCurrentOptionText(selYaxis)).toEqual("DH : Chute (m)"); // fixed results variables - const frr = calcPage.getAllFixedResultsRows(); - let lbl1 = await frr.$$("td")[0].getText(); + const frr = await calcPage.getAllFixedResultsRows(); + let row0 = frr[0]; + // let lbl1 = await frr.$$("td")[0].getText(); + let lbl1 = await row0.$("td").getText(); expect(lbl1).toEqual("Cote amont (m)"); // variated results headers - const vrh = calcPage.getAllVariatedResultsTableHeaders(); + const vrh = await calcPage.getAllVariatedResultsTableHeaders(); let lbl2 = await vrh[0].getText(); expect(lbl2).toEqual("Cote aval"); let lbl3 = await vrh[1].getText(); @@ -65,11 +69,12 @@ describe("Check translation", () => { // *** results in english *** // setup -> english - await navBar.clickMenuButton(); - await browser.pause(200); - const setupBtn = sideNav.getSetupButton(); - await setupBtn.click(); - await browser.pause(200); + // await navBar.clickMenuButton(); + // await browser.pause(200); + // const setupBtn = await sideNav.getSetupButton(); + // await setupBtn.click(); + // await browser.pause(200); + await prefPage.navigateTo(); await prefPage.changeLanguage(0); // en await browser.pause(200); @@ -84,7 +89,9 @@ describe("Check translation", () => { expect(await calcPage.getMatselectCurrentOptionText(selYaxis)).toEqual("DH : Fall (m)"); // fixed results variables - lbl1 = await frr.$$("td")[0].getText(); + row0 = frr[0]; + // lbl1 = await frr.$$("td")[0].getText(); + lbl1 = await row0.$("td").getText(); expect(lbl1).toEqual("Upstream elevation (m)"); // variated results headers diff --git a/e2e/util.po.ts b/e2e/util.po.ts index c7717900fea62034fa35301303da9e31de0a3f63..6e3d63c2eeefa49b0c4f084fa39072819273c022 100644 --- a/e2e/util.po.ts +++ b/e2e/util.po.ts @@ -1,11 +1,16 @@ import { browser, $, $$, expect } from '@wdio/globals' +import { Navbar } from './navbar.po'; +import { SideNav } from './sidenav.po'; +import { ListPage } from './list.po'; /** * scroll page to make element visible */ export async function scrollToElement(elem) { - await browser.execute("arguments[0].scrollIntoView({ block: 'center' });", elem); - await browser.pause(50); + // await browser.execute("arguments[0].scrollIntoView({ block: 'center' });", elem); + // await browser.pause(50); + await browser.execute(e => { e.scrollIntoView({ block: 'center' }) }, elem); + await browser.pause(100); } /** @@ -13,6 +18,7 @@ export async function scrollToElement(elem) { */ export async function scrollPageToTop() { await browser.execute("window.scrollTo(0, 0);"); + // await browser.scroll(0, 0); } /** @@ -29,9 +35,42 @@ export function expectNumber(msg: string, val: number, expected: number) { } export async function changeSelectValue(elt, index: number) { + await scrollToElement(elt); + await browser.pause(100); await elt.click(); + await browser.pause(100); const optionId = ".cdk-overlay-container mat-option:nth-of-type(" + (index + 1) + ")"; - const option = $(optionId); + const option = await $(optionId); await option.click(); await browser.pause(200); } + +// Remove all calculators from current session. +// Often used since WebDriverIO migration since it()s in a single e2e-spec file +// reuse the same browser window, hence calculators from previous it()s remain +// and may disturb subsequent tests. +// Avoids splitting it()s into multiple e2e-spec files... +export async function newSession(navBar: Navbar, sideNav: SideNav) { + const tabs = await navBar.getAllCalculatorTabs(); + if (tabs.length > 0) { + await navBar.clickMenuButton(); + await browser.pause(200); + await sideNav.clickNewSessionButton(); + await browser.pause(200); + // après ça, le bouton "#new-calculator" est absent + } +} + +export async function openCalculator(id: number, navBar: Navbar, listPage: ListPage) { + const ncButton = await navBar.getNewCalculatorButton(); + if (await ncButton.isExisting()) { + await scrollToElement(ncButton); + if (await ncButton.isDisplayed()) { + await ncButton.click() + await browser.pause(200); + } + } + + await listPage.clickMenuEntryForCalcType(id); + await browser.pause(200); +} diff --git a/e2e/valeurs-erronees.e2e-spec.ts b/e2e/valeurs-erronees.e2e-spec.ts index 716ce4060e56341b67042a6c470b0217d5ec23e7..5f2ca99b49e8ec68165e6957a0bf2ef033ad0470 100644 --- a/e2e/valeurs-erronees.e2e-spec.ts +++ b/e2e/valeurs-erronees.e2e-spec.ts @@ -2,6 +2,7 @@ import { CalculatorPage } from "./calculator.po"; import { ListPage } from "./list.po"; import { Navbar } from "./navbar.po"; import { PreferencesPage } from "./preferences.po"; +import { browser, $, $$, expect } from '@wdio/globals' describe("ngHyd - check invalid values are removed - ", () => { let listPage: ListPage; @@ -31,12 +32,12 @@ describe("ngHyd - check invalid values are removed - ", () => { await browser.pause(200); // modify W input with invalid value - const inputW = calcPage.getInputById("W"); - await browser.pause(200); - await inputW.clearValue(); - await browser.pause(200); + const inputW = await calcPage.getInputById("W"); + // await browser.pause(200); + // await inputW.clearValue(); + // await browser.pause(200); await inputW.setValue("-1"); - await browser.pause(200); + // await browser.pause(200); // open another calculator await navBar.clickNewCalculatorButton(); @@ -48,8 +49,9 @@ describe("ngHyd - check invalid values are removed - ", () => { await browser.pause(200); // check invalid value is removed - const w = await inputW.getAttribute("value"); - await browser.pause(200); + // const w = await inputW.getAttribute("value"); + const w = await inputW.getValue(); + // await browser.pause(200); expect(w).toEqual(""); // check that "compute" button is disabled diff --git a/e2e/variable-param-cancel.e2e-spec.ts b/e2e/variable-param-cancel.e2e-spec.ts index 46219fd4bad976b0fe8cfbb1c991bfadea4117d1..534e3cc9c4cebf25dd2de3c55bdf53b28a39a10e 100644 --- a/e2e/variable-param-cancel.e2e-spec.ts +++ b/e2e/variable-param-cancel.e2e-spec.ts @@ -1,4 +1,7 @@ +import { brotliCompress } from "zlib"; +import { CalculatorPage } from "./calculator.po"; import { ListPage } from "./list.po"; +import { browser, $, $$, expect } from '@wdio/globals' /** * Check that a cancel button is present in min/max/list edition dialog @@ -6,24 +9,31 @@ import { ListPage } from "./list.po"; */ describe("ngHyd - check cancel button for variable parameters - ", () => { let listPage: ListPage; + let calcPage: CalculatorPage; beforeAll(() => { listPage = new ListPage(); + calcPage = new CalculatorPage(); }); it("when min/max/list values dialog opens, a cancel button should be present", async () => { + debugger // start page await listPage.navigateTo(); + await browser.pause(200); // open PAB chute await listPage.clickMenuEntryForCalcType(12); + await browser.pause(200); // click "var" radio on Z1 parameter - const z1btn = $("#mat-button-toggle-2-button"); + // const z1btn = $("#mat-button-toggle-2-button"); + const z1btn = await calcPage.getInputRadioButtonFromId("Z1", "var"); await z1btn.click(); + await browser.pause(300); // cancel button presence - const cancelbtn = $("#btn-cancel"); - expect((await cancelbtn.isExisting()) && (await cancelbtn.isDisplayed())).toBeTruthy(); + const cancelbtn = await $("#btn-cancel"); + expect((await cancelbtn.isExisting()) && (await cancelbtn.isDisplayed())).toEqual(true); }); }); diff --git a/wdio.conf.ts b/wdio.conf.ts index 8f5d4c440cbca6811a80d8727b166f96ddd11d26..6ce74ab63652f6863ae9211b09b6c808d7b0433d 100644 --- a/wdio.conf.ts +++ b/wdio.conf.ts @@ -62,14 +62,12 @@ export const config: Options.Testrunner = { // https://saucelabs.com/platform/platform-configurator // capabilities: [{ - 'goog:chromeOptions': { - args: ['--headless'], - }, + 'goog:chromeOptions': { args: ['--headless'], }, // maxInstances can get overwritten per capability. So if you have an in-house Selenium // grid with only 5 firefox instances available you can make sure that not more than // 5 instances get started at a time. - maxInstances: 5, + maxInstances: 1, // browserName: 'chrome', acceptInsecureCerts: true @@ -85,7 +83,9 @@ export const config: Options.Testrunner = { // Define all options that are relevant for the WebdriverIO instance here // // Level of logging verbosity: trace | debug | info | warn | error | silent - logLevel: 'info', + // logLevel: 'info', + logLevel: 'warn', + // logLevel: 'error', // // Set specific log levels per logger // loggers: