Newer
Older
import { ListPage } from "./list.po";
import { CalculatorPage } from "./calculator.po";
import { Navbar } from "./navbar.po";
import { browser, by, element } from "protractor";
import { AppPage } from "./app.po";
import { SideNav } from "./sidenav.po";
import { PreferencesPage } from "./preferences.po";
import { scrollPageToTop } from "./util.po";
/**
* Clone calculators
*/
describe("ngHyd − Passe à Bassins", () => {
let startPage: AppPage;
let listPage: ListPage;
let calcPage: CalculatorPage;
let navbar: Navbar;
let sidenav: SideNav;
let prefPage: PreferencesPage;
beforeEach(() => {
startPage = new AppPage();
listPage = new ListPage();
calcPage = new CalculatorPage();
navbar = new Navbar();
sidenav = new SideNav();
prefPage = new PreferencesPage();
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
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
describe("create PAB - ", async () => {
beforeEach(async () => {
// disable evil option "empty fields on module creation"
await prefPage.navigateTo();
await prefPage.disableEvilEmptyFields();
await browser.sleep(200);
});
it("when PAB is created from scratch", async () => {
// create PAB
await navbar.clickNewCalculatorButton();
await listPage.clickMenuEntryForCalcType(15);
// check that pab-table is present
const innerFieldsets = element.all(by.css(".pab-data-table"));
expect(await innerFieldsets.count()).toBe(1);
// calculate PAB
const calcButton = calcPage.getCalculateButton();
await calcButton.click();
// check that result is not empty
const hasResults = await calcPage.hasResults();
expect(hasResults).toBe(true);
// check absence of logs
expect(await calcPage.nbLogEntries()).toBe(0);
});
it("complete example of all PAB modules", async () => {
// PAB - chute
await navbar.clickNewCalculatorButton();
await listPage.clickMenuEntryForCalcType(12);
const c_Z1 = calcPage.getInputById("Z1");
await c_Z1.clear();
await c_Z1.sendKeys("78.27");
const c_Z2 = calcPage.getInputById("Z1");
await c_Z2.clear();
await c_Z2.sendKeys("74.86");
// PAB - nombre
await navbar.clickNewCalculatorButton();
await listPage.clickMenuEntryForCalcType(13);
const n_DHT = calcPage.getInputById("DHT");
await calcPage.setParamMode(n_DHT, "link");
const n_DH = calcPage.getInputById("DH");
await calcPage.setParamMode(n_DH, "cal");
const n_N = calcPage.getInputById("N");
await n_N.clear();
await n_N.sendKeys("15");
// PAB - dimensions
await navbar.clickNewCalculatorButton();
await listPage.clickMenuEntryForCalcType(5);
const d_V = calcPage.getInputById("V");
await calcPage.setParamMode(d_V, "cal");
const d_Y = calcPage.getInputById("Y");
await d_Y.clear();
await d_Y.sendKeys("1.5");
const d_L = calcPage.getInputById("L");
await d_L.clear();
await d_L.sendKeys("3.100");
const d_W = calcPage.getInputById("W");
await d_W.clear();
await d_W.sendKeys("2.5");
// PAB - puissance dissipée (volume)
await navbar.clickNewCalculatorButton();
await listPage.clickMenuEntryForCalcType(6);
const p_DH = calcPage.getInputById("DH");
await calcPage.setParamMode(p_DH, "link");
const p_Q = calcPage.getInputById("Q");
await calcPage.setParamMode(p_Q, "cal");
const p_V = calcPage.getInputById("V");
await calcPage.setParamMode(p_V, "link");
const p_PV = calcPage.getInputById("PV");
await p_PV.clear();
await p_PV.sendKeys("150");
// PAB - cloisons
await navbar.clickNewCalculatorButton();
await listPage.clickMenuEntryForCalcType(10);
const cl_LB = calcPage.getInputById("LB");
await calcPage.setParamMode(cl_LB, "link");
const cl_BB = calcPage.getInputById("BB");
await calcPage.setParamMode(cl_BB, "link");
const cl_DH = calcPage.getInputById("DH");
await calcPage.setParamMode(cl_DH, "link");
const cl_Z1 = calcPage.getInputById("Z1");
await calcPage.setParamMode(cl_Z1, "link");
const cl_PB = calcPage.getInputById("PB");
await cl_PB.clear();
await cl_PB.sendKeys("1.5");
// calculate Cloisons
const calcButtonCl = calcPage.getCalculateButton();
await calcButtonCl.click();
// make sure "Generate PAB" button is visible (it might be hidden behind navbar)
// generate PAB
const genButton = calcPage.getGeneratePabButton();
await genButton.isPresent();
await genButton.isDisplayed();
await genButton.click();
const nbBassins = calcPage.getInputById("generatePabNbBassins");
await nbBassins.clear();
await nbBassins.sendKeys("9");
// click "Generate"
await element(by.css("dialog-generate-pab button#do-generate")).click();
await browser.sleep(1000);
// calculate PAB
const calcButtonPAB = calcPage.getCalculateButton();
await calcButtonPAB.click();
// check that result is not empty
const hasResults = await calcPage.hasResults();
expect(hasResults).toBe(true);
});
mathias.chouet
committed
});
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
179
180
181
182
183
184
185
describe("generate PAB - ", async () => {
beforeEach(async () => {
// disable evil option "empty fields on module creation"
await prefPage.navigateTo();
await prefPage.disableEvilEmptyFields();
await browser.sleep(200);
});
it("from a Cloisons among many", async () => {
// create many Cloisons
await navbar.clickNewCalculatorButton();
await listPage.clickMenuEntryForCalcType(10);
await navbar.clickNewCalculatorButton();
await listPage.clickMenuEntryForCalcType(10);
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.clear();
await Z1.sendKeys("114");
const LB = calcPage.getInputById("LB");
await LB.clear();
await LB.sendKeys("11.5");
const DH = calcPage.getInputById("DH");
await DH.clear();
await DH.sendKeys("0.72");
// calculate Cloisons
const calcButtonCl = calcPage.getCalculateButton();
await calcButtonCl.click();
// make sure "Generate PAB" button is visible (it might be hidden behind navbar)
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
// create PAB from it, changing modal parameters
const genButton = calcPage.getGeneratePabButton();
await genButton.click();
const debit = calcPage.getInputById("generatePabDebit");
expect(await debit.getAttribute("value")).toBe("0.564");
await debit.clear();
await browser.sleep(300);
// send "1.6" in 3 movements, because "." triggers an error and Angular can't cope with the subsequent keys
await debit.sendKeys("1");
await browser.sleep(300);
await debit.sendKeys(".");
await browser.sleep(300);
await debit.sendKeys("6");
await browser.sleep(300);
const coteAmont = calcPage.getInputById("generatePabCoteAmont");
expect(await coteAmont.getAttribute("value")).toBe("114");
await coteAmont.clear();
await coteAmont.sendKeys("115");
const nbBassins = calcPage.getInputById("generatePabNbBassins");
expect(await nbBassins.getAttribute("value")).toBe("6");
await nbBassins.clear();
await nbBassins.sendKeys("5");
// click "Generate"
await element(by.css("dialog-generate-pab button#do-generate")).click();
await browser.sleep(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");
// check number of basins
const innerFieldsets = element.all(by.css("td.basin_number"));
expect(await innerFieldsets.count()).toBe(5);
// calculate PAB
const calcButton = calcPage.getCalculateButton();
await calcButton.click();
// check that result is not empty
const hasResults = await calcPage.hasResults();
expect(hasResults).toBe(true);
});
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
describe("load session files - ", async () => {
it("complete example of all PAB modules", async () => {
await startPage.navigateTo();
// load
await navbar.clickMenuButton();
await browser.sleep(200);
await sidenav.clickLoadSessionButton();
await browser.sleep(200);
await sidenav.loadSessionFile("./session/session-pab-complete.json");
await browser.sleep(500);
// check existence of the loaded modules
expect(await navbar.getAllCalculatorTabs().count()).toBe(6);
// check parameters values
await navbar.clickCalculatorTab(5);
await browser.sleep(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");
// check number of basins
const innerFieldsets = element.all(by.css("td.basin_number"));
expect(await innerFieldsets.count()).toBe(15);
// calculate PAB
const calcButton = calcPage.getCalculateButton();
await calcButton.click();
// check that result is not empty
const hasResults = await calcPage.hasResults();
expect(hasResults).toBe(true);
// check absence of logs
expect(await calcPage.nbLogEntries()).toBe(0);
});
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
describe("load regulated variated PAB with calc errors - ", async () => {
it("should display logs", async () => {
await startPage.navigateTo();
// load
await navbar.clickMenuButton();
await browser.sleep(200);
await sidenav.clickLoadSessionButton();
await browser.sleep(200);
await sidenav.loadSessionFile("./session/session-pab-regulee-variee.json");
await browser.sleep(500);
// check existence of the loaded module
expect(await navbar.getAllCalculatorTabs().count()).toBe(1);
await navbar.clickCalculatorTab(0);
// calculate
const calcButton = calcPage.getCalculateButton();
await calcButton.click();
// check that result is not empty
const hasResults = await calcPage.hasResults();
expect(hasResults).toBe(true);
// check presence of logs
await browser.sleep(300);
expect(await calcPage.nbLogEntries()).toBe(2);
// change iteration
const pve = calcPage.getSelectById("pab-variating-element");
calcPage.changeSelectValue(pve, 3);
await browser.sleep(300);
// check absence of logs
expect(await calcPage.nbLogEntries()).toBe(2);
});