From 4c240b2cb3ee1b074cd513333d0707f907942f4b Mon Sep 17 00:00:00 2001
From: "mathias.chouet" <mathias.chouet@irstea.fr>
Date: Tue, 24 Sep 2019 17:35:48 +0200
Subject: [PATCH] Update translation checking e2e test

---
 e2e/check-translations.e2e-spec.ts | 32 ++++++++++++++++++++++--------
 1 file changed, 24 insertions(+), 8 deletions(-)

diff --git a/e2e/check-translations.e2e-spec.ts b/e2e/check-translations.e2e-spec.ts
index af7abc200..bfdaf3f88 100644
--- a/e2e/check-translations.e2e-spec.ts
+++ b/e2e/check-translations.e2e-spec.ts
@@ -9,7 +9,7 @@ import { SideNav } from "./sidenav.po";
  * For all calculators, try to calculate every parameter: check that only one parameter
  * is set to CAL mode, trigger the calculation, check that result is not empty
  */
-fdescribe("ngHyd − check translation of all calculators", () => {
+describe("ngHyd − check translation of all calculators", () => {
   let listPage: ListPage;
   let calcPage: CalculatorPage;
   let navBar: Navbar;
@@ -37,15 +37,29 @@ fdescribe("ngHyd − check translation of all calculators", () => {
       beforeAll(async () => {
         await prefPage.navigateTo();
         await prefPage.changeLanguage(i);
-        await browser.sleep(2000);
+        await browser.sleep(200);
+        await navBar.clickNewCalculatorButton();
+      });
+
+      beforeEach(function () {
+        jasmine.addMatchers({
+          toContain: function () {
+              return {
+                compare: function (actual, expected) {
+                  const result = {
+                    pass: actual.includes(expected),
+                    message: "error" // short message to avoid whole page source being dumped on expect() failure
+                  };
+                  return result;
+                }
+              };
+          }
+        });
       });
 
       // for each calculator
       for (const ct of calcTypes) {
         it(" − check translations of calculator type [" + ct + "]", async () => {
-          // go to list page
-          await navBar.clickNewCalculatorButton();
-
           // click calculator button (instanciate)
           await listPage.clickMenuEntryForCalcType(ct);
 
@@ -60,10 +74,12 @@ fdescribe("ngHyd − check translation of all calculators", () => {
           const hasResults = await calcPage.hasResults();
           expect(hasResults).toBe(true);
 
-          // @TODO check absence of "*** message not found" in whole DOM
-          expect(" SOURCE CODE ").not.toContain("*** message not found");
+          // check absence of "*** message not found" in whole DOM
+          expect(await browser.getPageSource()).not.toContain("*** message not found");
 
-          // close calc
+          // empty session
+          await navBar.clickMenuButton();
+          await browser.sleep(200);
           await sideNav.clickNewSessionButton();
           browser.sleep(200);
         });
-- 
GitLab