From 751997869619cbd1e8ddbc03410132ae34e75edd Mon Sep 17 00:00:00 2001 From: "mathias.chouet" <mathias.chouet@irstea.fr> Date: Tue, 24 Sep 2019 15:04:04 +0200 Subject: [PATCH] e2e test looking for missing translations --- e2e/calculate-all-params.e2e-spec.ts | 3 +- e2e/check-translations.e2e-spec.ts | 75 +++++++++++++++++++ e2e/clone-all-calc.e2e-spec.ts | 2 +- e2e/sidenav.po.ts | 17 +++++ ...ialog-confirm-empty-session.component.html | 4 +- 5 files changed, 96 insertions(+), 5 deletions(-) create mode 100644 e2e/check-translations.e2e-spec.ts diff --git a/e2e/calculate-all-params.e2e-spec.ts b/e2e/calculate-all-params.e2e-spec.ts index 28681832f..396fb44a6 100644 --- a/e2e/calculate-all-params.e2e-spec.ts +++ b/e2e/calculate-all-params.e2e-spec.ts @@ -1,7 +1,6 @@ import { ListPage } from "./list.po"; import { CalculatorPage } from "./calculator.po"; import { Navbar } from "./navbar.po"; -import { browser } from "protractor"; /** * For all calculators, try to calculate every parameter: check that only one parameter @@ -18,7 +17,7 @@ describe("ngHyd − calculate all parameters of all calculators", () => { navBar = new Navbar(); }); - // get calculators list (IDs) @TODO read it from config ! + // get calculators list (IDs) @TODO read it from config, but can't import jalhyd here :/ const calcTypes = [ 0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 15, 17, 18, 19 ]; // for each calculator diff --git a/e2e/check-translations.e2e-spec.ts b/e2e/check-translations.e2e-spec.ts new file mode 100644 index 000000000..af7abc200 --- /dev/null +++ b/e2e/check-translations.e2e-spec.ts @@ -0,0 +1,75 @@ +import { ListPage } from "./list.po"; +import { CalculatorPage } from "./calculator.po"; +import { Navbar } from "./navbar.po"; +import { PreferencesPage } from "./preferences.po"; +import { browser } from "protractor"; +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", () => { + let listPage: ListPage; + let calcPage: CalculatorPage; + let navBar: Navbar; + let prefPage: PreferencesPage; + let sideNav: SideNav; + + beforeAll(() => { + listPage = new ListPage(); + calcPage = new CalculatorPage(); + navBar = new Navbar(); + prefPage = new PreferencesPage(); + sideNav = new SideNav(); + }); + + // get calculators list (IDs) @TODO read it from config, but can't import jalhyd here :/ + const calcTypes = [ 0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 15, 17, 18, 19 ]; + + // options of "Language" selector on preferences page + const langs = [ "English", "Français" ]; + + // for each language + for (let i = 0; i < langs.length; i++) { + describe("language " + langs[i] + " − ", async () => { + + beforeAll(async () => { + await prefPage.navigateTo(); + await prefPage.changeLanguage(i); + await browser.sleep(2000); + }); + + // 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); + + // just click the "compute" button with default values + // check that "compute" button is active + const calcButton = calcPage.getCalculateButton(); + const disabledState = await calcButton.getAttribute("disabled"); + expect(disabledState).not.toBe("true"); + // click "compute" button + await calcButton.click(); + // check that result is not empty + 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"); + + // close calc + await sideNav.clickNewSessionButton(); + browser.sleep(200); + }); + } + + }); + } + +}); diff --git a/e2e/clone-all-calc.e2e-spec.ts b/e2e/clone-all-calc.e2e-spec.ts index 48d88675a..ab3b3c41c 100644 --- a/e2e/clone-all-calc.e2e-spec.ts +++ b/e2e/clone-all-calc.e2e-spec.ts @@ -17,7 +17,7 @@ describe("ngHyd − clone all calculators with all possible <select> values", () navbar = new Navbar(); }); - // get calculators list (IDs) @TODO read it from config ! + // get calculators list (IDs) @TODO read it from config, but can't import jalhyd here :/ const calcTypes = [ 0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 15, 17, 18, 19 ]; // for each calculator diff --git a/e2e/sidenav.po.ts b/e2e/sidenav.po.ts index 4edabdff9..8dc79467f 100644 --- a/e2e/sidenav.po.ts +++ b/e2e/sidenav.po.ts @@ -2,10 +2,15 @@ import { browser, by, element } from "protractor"; import * as path from "path"; export class SideNav { + getLoadSessionButton() { return element(by.css("#side-nav-load-session")); } + getNewSessionButton() { + return element(by.css("#side-nav-empty-session")); + } + getFileInput() { return element(by.css(`dialog-load-session input[type="file"]`)); } @@ -14,12 +19,24 @@ export class SideNav { return element(by.css(`dialog-load-session button[type="submit"]`)); } + getConfirmNewSessionButton() { + return element(by.css(`button#confirm-new-session`)); + } + async clickLoadSessionButton() { const ncb = this.getLoadSessionButton(); await browser.sleep(500); await ncb.click(); } + async clickNewSessionButton() { + const ncb = this.getNewSessionButton(); + await browser.sleep(200); + await ncb.click(); + await browser.sleep(200); + await this.getConfirmNewSessionButton().click(); + } + async loadSessionFile(file: string, click: boolean = true) { const absolutePath = path.resolve(__dirname, file); const input = this.getFileInput(); diff --git a/src/app/components/dialog-confirm-empty-session/dialog-confirm-empty-session.component.html b/src/app/components/dialog-confirm-empty-session/dialog-confirm-empty-session.component.html index 7d7d6cdc8..565d03593 100644 --- a/src/app/components/dialog-confirm-empty-session/dialog-confirm-empty-session.component.html +++ b/src/app/components/dialog-confirm-empty-session/dialog-confirm-empty-session.component.html @@ -3,10 +3,10 @@ <p [innerHTML]="uitextEmptySessionBody"></p> </div> <div mat-dialog-actions [attr.align]="'end'"> - <button mat-raised-button color="primary" [mat-dialog-close]="false" cdkFocusInitial> + <button id="cancel-new-session" mat-raised-button color="primary" [mat-dialog-close]="false" cdkFocusInitial> {{ uitextNo }} </button> - <button mat-raised-button color="warn" [mat-dialog-close]="true"> + <button id="confirm-new-session" mat-raised-button color="warn" [mat-dialog-close]="true"> {{ uitextYes }} </button> </div> -- GitLab