Commit b6e9f72e authored by Mathias Chouet's avatar Mathias Chouet 🍝
Browse files

Update e2e

update protractor method for mat-select
parent 2ee0ac8c
Pipeline #15564 passed with stages
in 21 minutes and 11 seconds
......@@ -217,9 +217,8 @@ export class CalculatorPage {
async changeSelectValue(elt: ElementFinder, index: number) {
await elt.click();
const options = (await elt.getAttribute("aria-owns")).split(" ");
const optId = options[index];
const option = element(by.id(optId));
const optionId = ".cdk-overlay-container mat-option:nth-of-type(" + (index + 1) + ")";
const option = element(by.css(optionId));
await option.click();
}
......
......@@ -4,6 +4,7 @@ import { CalculatorPage } from "./calculator.po";
import { Navbar } from "./navbar.po";
import { SideNav } from "./sidenav.po";
import { browser } from "protractor";
import { PreferencesPage } from "./preferences.po";
/**
* Load a session containing 5 calculators, having multiple linked parameters
......@@ -14,21 +15,29 @@ describe("ngHyd − load session with multiple linked parameters − ", () => {
let startPage: AppPage;
let listPage: ListPage;
let calcPage: CalculatorPage;
let prefPage: PreferencesPage;
let navbar: Navbar;
let sidenav: SideNav;
function init() {
startPage = new AppPage();
calcPage = new CalculatorPage();
prefPage = new PreferencesPage();
navbar = new Navbar();
sidenav = new SideNav();
listPage = new ListPage();
}
beforeEach(init);
beforeAll(init);
it("when loading session-liens-spaghetti.json, all links should point to the right target", async () => {
await startPage.navigateTo();
beforeEach(async () => {
// force language to prevent issues due to default browser language
await prefPage.navigateTo();
await prefPage.changeLanguage(1); // fr
await browser.sleep(200);
await navbar.clickNewCalculatorButton();
});
it("when loading session-liens-spaghetti.json, all links should point to the right target", async () => {
await navbar.clickMenuButton();
await browser.sleep(200);
......
......@@ -2,6 +2,7 @@ import { AppPage } from "./app.po";
import { Navbar } from "./navbar.po";
import { SideNav } from "./sidenav.po";
import { browser, element, by } from "protractor";
import { PreferencesPage } from "./preferences.po";
/**
* Load 4 malformed session files :
......@@ -15,13 +16,23 @@ describe("ngHyd − load malformed session files − ", () => {
let startPage: AppPage;
let navbar: Navbar;
let sidenav: SideNav;
let prefPage: PreferencesPage;
function init() {
startPage = new AppPage();
navbar = new Navbar();
sidenav = new SideNav();
prefPage = new PreferencesPage();
}
beforeEach(init);
beforeAll(init);
beforeEach(async () => {
// force language to prevent issues due to default browser language
await prefPage.navigateTo();
await prefPage.changeLanguage(1); // fr
await browser.sleep(200);
await navbar.clickNewCalculatorButton();
});
it("when loading session-bad-syntax.json, displayed error should be relevant", async () => {
await startPage.navigateTo();
......
......@@ -14,9 +14,9 @@ export class Navbar {
const dropDown = element(by.css("mat-select#selectCalculator"));
if (await dropDown.isPresent() && await dropDown.isDisplayed()) {
await dropDown.click();
const options = (await dropDown.getAttribute("aria-owns")).split(" ");
const options = element.all(by.css(".cdk-overlay-container mat-option"));
await dropDown.sendKeys(protractor.Key.ESCAPE); // close dropdown
return options.length;
return await options.count();
} else {
return (await element.all(by.css("#tabs-container button.calculator-button"))).length;
}
......@@ -31,9 +31,8 @@ export class Navbar {
const dropDown = element(by.css("mat-select#selectCalculator"));
if (await dropDown.isPresent() && await dropDown.isDisplayed()) {
await dropDown.click();
const options = (await dropDown.getAttribute("aria-owns")).split(" ");
const optId = options[n];
const option = element(by.id(optId));
const optionId = ".cdk-overlay-container mat-option#mat-option-" + n;
const option = element(by.css(optionId));
await option.click();
} else {
const tabs = this.getAllCalculatorTabs();
......
......@@ -36,9 +36,8 @@ export class PreferencesPage {
async changeLanguage(index: number) {
const select = this.getLanguageSelect();
await select.click();
const options = (await select.getAttribute("aria-owns")).split(" ");
const optId = options[index];
const option = element(by.id(optId));
const optionId = ".cdk-overlay-container mat-option#mat-option-" + index;
const option = element(by.css(optionId));
await option.click();
}
......
......@@ -17,22 +17,27 @@ describe("Solveur - ", () => {
let sidenav: SideNav;
let prefPage: PreferencesPage;
beforeEach(async () => {
beforeAll(async () => {
startPage = new AppPage();
prefPage = new PreferencesPage();
listPage = new ListPage();
calcPage = new CalculatorPage();
navbar = new Navbar();
sidenav = new SideNav();
// disable evil option "empty fields on module creation"
});
beforeEach(async () => {
await prefPage.navigateTo();
// disable evil option "empty fields on module creation"
await prefPage.disableEvilEmptyFields();
await browser.sleep(200);
// force language to prevent issues due to default browser language
await prefPage.changeLanguage(1); // fr
await browser.sleep(200);
await navbar.clickNewCalculatorButton();
});
it("load > calculate", async () => {
await navbar.clickNewCalculatorButton();
await navbar.clickMenuButton();
await browser.sleep(200);
......@@ -78,8 +83,6 @@ describe("Solveur - ", () => {
});
it("create > feed > calculate > clone > calculate clone", async () => {
await navbar.clickNewCalculatorButton();
// 1. create empty Solveur
await listPage.clickMenuEntryForCalcType(22); // Solveur
await browser.sleep(500);
......
......@@ -37,8 +37,7 @@ exports.config = {
args: [
"--no-sandbox",
"--headless",
"--window-size=1024x768",
"lang=fr-FR"
"--window-size=1024x768"
],
prefs: {
download: {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment