Newer
Older
François Grand
committed
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'
François Grand
committed
import { changeSelectValue, loadSession, openCalculator, scrollToElement } from "./util.po";
import { AppPage } from "./app.po";
import { SideNav } from "./sidenav.po";
François Grand
committed
describe("predams - ", () => {
François Grand
committed
let listPage: ListPage;
let prefPage: PreferencesPage;
let navBar: Navbar;
let calcPage: CalculatorPage;
let startPage: AppPage;
let sideNav: SideNav;
François Grand
committed
François Grand
committed
prefPage = new PreferencesPage();
listPage = new ListPage();
navBar = new Navbar();
calcPage = new CalculatorPage();
startPage = new AppPage();
sideNav = new SideNav();
François Grand
committed
François Grand
committed
// disable evil option "empty fields on module creation"
await prefPage.navigateTo();
François Grand
committed
await prefPage.disableEvilEmptyFields();
François Grand
committed
});
it("check that low iteration count leads to log messages", async () => {
François Grand
committed
// set low iteration count
await prefPage.setIterationCount(5);
// open predam calculator
François Grand
committed
await openCalculator(30, navBar, listPage);
François Grand
committed
// run calculation
const calcButton = await calcPage.getCalculateButton();
François Grand
committed
await calcButton.click();
await browser.pause(200);
François Grand
committed
// check log messages presence
expect(await calcPage.hasLog()).toBe(true);
François Grand
committed
});
it("check log messages in predams example", async () => {
await startPage.navigateTo();
await browser.pause(200);
// open predams example
const examples = await $$("#examples-list .load-example");
await examples[6].click();
await browser.pause(500);
// click "Amont-B2"
const nodes = await $$("g.nodes > g");
const node = nodes[9];
await scrollToElement(node);
await browser.pause(100);
await node.click();
await browser.pause(200);
// change discharge law to Larinier
const sel = await calcPage.getSelectById("select_loidebit");
await changeSelectValue(sel, 3);
await browser.pause(100);
// calculate module
const calcBtn = await calcPage.getCalculateButton();
await calcBtn.click();
await browser.pause(300);
// check log messages presence
expect(await calcPage.hasLog()).toBe(true);
});
it("check submergence error does not trigger too soon", async () => {
await startPage.navigateTo();
await browser.pause(200);
await loadSession(navBar, sideNav, "./session/session-submergence-error-Larinier.json");
// calculate module
const calcBtn = await calcPage.getCalculateButton();
await calcBtn.click();
await browser.pause(300);
// check log messages absence
expect(await calcPage.hasLog()).toBe(false);
});
François Grand
committed
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
it("check submergence error and results if dichotomy did not converge", async () => {
await startPage.navigateTo();
await browser.pause(200);
// open predams example
const examples = await $$("#examples-list .load-example");
await examples[6].click();
await browser.pause(500);
// modify iteration count,precision
await prefPage.navigateTo();
await browser.pause(200);
await prefPage.setIterationCount(10);
await prefPage.setComputePrecision(1e-15);
// back to module
await navBar.openNthCalculator(0);
await browser.pause(500);
// calculate module
const calcBtn = await calcPage.getCalculateButton();
await calcBtn.click();
await browser.pause(300);
// check log messages presence
expect(await calcPage.hasLog()).toBe(true);
expect(await calcPage.nbLogEntries()).toBe(12);
// check that results are not empty (dichotomy did not convergence but results should be displayed anyway)
const hasResults = await calcPage.hasResults();
expect(hasResults).toBe(true);
});
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
it("check results (dichotomy did not converge + submergence error)", async () => {
await startPage.navigateTo();
await browser.pause(200);
// open predams example
const examples = await $$("#examples-list .load-example");
await examples[6].click();
await browser.pause(500);
// modify iteration count,precision (should trigger submergence+dichotomy non convergence errors)
await prefPage.navigateTo();
await browser.pause(200);
await prefPage.setIterationCount(20);
await prefPage.setComputePrecision(1e-15);
// back to module
await navBar.openNthCalculator(0);
await browser.pause(500);
// click "Amont-B2"
const nodes = await $$("g.nodes > g");
const node = nodes[9];
await scrollToElement(node);
await browser.pause(100);
await node.click();
await browser.pause(200);
// change discharge law to Larinier
const sel = await calcPage.getSelectById("select_loidebit");
await changeSelectValue(sel, 3);
await browser.pause(100);
// calculate module
const calcBtn = await calcPage.getCalculateButton();
await calcBtn.click();
await browser.pause(300);
// check that results are empty
const hasResults = await calcPage.hasResults();
expect(hasResults).toBe(false);
// check log messages
expect(await calcPage.hasLog()).toBe(true);
expect(await calcPage.nbLogEntries()).toBe(4);
expect(await calcPage.nthLogEntryIsWarning(0)).toBe(true);
expect(await calcPage.nthLogEntryIsError(1)).toBe(true);
expect(await calcPage.nthLogEntryIsWarning(2)).toBe(true);
expect(await calcPage.nthLogEntryIsError(3)).toBe(true);
});