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

refactor(e2e): migrate commit 652f8631 (#614)

refs #618
parent 423362b2
No related branches found
No related tags found
2 merge requests!225Release v4.17.0,!221Resolve "Migration des tests e2e vers WebDriverIO"
......@@ -4,7 +4,7 @@ import { CalculatorPage } from "./calculator.po";
import { Navbar } from "./navbar.po";
import { SideNav } from "./sidenav.po";
import { PreferencesPage } from "./preferences.po";
import { changeSelectValue, expectNumber } from "./util.po";
import { changeSelectValue, expectNumber, loadSession } from "./util.po";
import { browser, $, $$, expect } from '@wdio/globals'
const fs = require("fs");
......@@ -54,16 +54,6 @@ async function saveSession(): Promise<string> {
return findDownloadedFile(sessionFile);
}
async function loadSession(path: string) {
await navbar.clickMenuButton();
await browser.pause(500);
await sidenav.clickLoadSessionButton();
await browser.pause(200);
await sidenav.loadSessionFile(path);
}
/**
* Save and load (serialise and unserialise) calculators to/from JSON files
*/
......@@ -84,7 +74,7 @@ describe("ngHyd − save and load sessions", () => {
it("when loading session-6-calc.test.json file from home page, 6 calculators should be loaded", async () => {
await startPage.navigateTo();
await loadSession("./session/session-6-calc.test.json");
await loadSession(navbar, sidenav, "./session/session-6-calc.test.json");
await browser.pause(1000);
expect(await navbar.getAllCalculatorTabs().length).toBe(6);
......@@ -93,7 +83,7 @@ describe("ngHyd − save and load sessions", () => {
it("when loading session-optional-params.test.json file from home page, the calculator should be loaded", async () => {
await startPage.navigateTo();
await loadSession("./session/session-optional-params.test.json");
await loadSession(navbar, sidenav, "./session/session-optional-params.test.json");
await browser.pause(200);
expect(await navbar.getAllCalculatorTabs().length).toBe(1);
......@@ -187,7 +177,7 @@ describe("ngHyd − save and load sessions", () => {
await browser.pause(500);
// load session
await loadSession(filename);
await loadSession(navbar, sidenav, filename);
await browser.pause(500);
// the displayed calculator is now the loaded one
......@@ -213,7 +203,7 @@ describe("ngHyd − save and load sessions", () => {
// get selects once again since page has been replaced (session load)
selects = await calcPage.getAllCalculatorSelects();
// restore select previous option, other selects presence may depend on it (eg. pressure loss calculator)
await changeSelectValue(selects[s], ind);
await browser.pause(200);
......
......@@ -71,3 +71,16 @@ export async function openCalculator(id: number, navBar: Navbar, listPage: ListP
await listPage.clickMenuEntryForCalcType(id);
await browser.pause(200);
}
/**
* load a session from JSON file
*/
export async function loadSession(navbar: Navbar, sideNav: SideNav, path: string) {
await navbar.clickMenuButton();
await browser.pause(200);
await sideNav.clickLoadSessionButton();
await browser.pause(200);
await sideNav.loadSessionFile(path);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment