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

refactor(e2e): move loadSession() function to util.po

refs #614
parent eae03513
No related branches found
No related tags found
No related merge requests found
......@@ -5,7 +5,7 @@ import { Navbar } from "./navbar.po";
import { SideNav } from "./sidenav.po";
import { browser, by, element } from "protractor";
import { PreferencesPage } from "./preferences.po";
import { changeSelectValue, expectNumber } from "./util.po";
import { changeSelectValue, expectNumber, loadSession } from "./util.po";
const fs = require("fs");
const path = require("path");
......@@ -86,16 +86,6 @@ async function saveSession(): Promise<string> {
return findDownloadedFile(sessionFile);
}
async function loadSession(path: string) {
await navbar.clickMenuButton();
await browser.sleep(200);
await sidenav.clickLoadSessionButton();
await browser.sleep(200);
await sidenav.loadSessionFile(path);
}
/**
* Save and load (serialise and unserialise) calculators to/from JSON files
*/
......@@ -117,7 +107,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.sleep(1000);
expect(await navbar.getAllCalculatorTabs().count()).toBe(6);
......@@ -126,7 +116,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.sleep(200);
expect(await navbar.getAllCalculatorTabs().count()).toBe(1);
......@@ -219,7 +209,7 @@ describe("ngHyd − save and load sessions", () => {
await browser.sleep(200);
// 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 loadSession(navbar, sidenav, filename); // bug here : the click on the menu button (top left) takes 40s to take effect and open the side nav!)
await browser.sleep(200);
// the displayed calculator is now the loaded one
......
import { ElementFinder, browser, by, element } from "protractor";
import { Navbar } from "./navbar.po";
import { SideNav } from "./sidenav.po";
/**
* scroll page to make element visible
......@@ -35,3 +37,16 @@ export async function changeSelectValue(elt: ElementFinder, index: number) {
await option.click();
await browser.sleep(200);
}
/**
* load a session from JSON file
*/
export async function loadSession(navbar: Navbar, sideNav: SideNav, path: string) {
await navbar.clickMenuButton();
await browser.sleep(200);
await sideNav.clickLoadSessionButton();
await browser.sleep(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