mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +00:00
[ACA] Dialogs - close on navigation by default (#634)
* close modals on navigation by default * lint * modals effect and action * add to store module * register in module * close modals if auth fails * rename action * change dialog selector
This commit is contained in:
committed by
Denys Vuika
parent
eb97b18f95
commit
2f4048a859
@@ -23,107 +23,125 @@
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { browser, element, by, ElementFinder, promise, ExpectedConditions as EC } from 'protractor';
|
||||
import {
|
||||
browser,
|
||||
element,
|
||||
by,
|
||||
ElementFinder,
|
||||
promise,
|
||||
ExpectedConditions as EC
|
||||
} from 'protractor';
|
||||
import { BROWSER_WAIT_TIMEOUT } from './../configs';
|
||||
|
||||
export abstract class Page {
|
||||
private static USE_HASH_STRATEGY = true;
|
||||
private static USE_HASH_STRATEGY = true;
|
||||
|
||||
private locators = {
|
||||
app: by.css('app-root'),
|
||||
layout: by.css('app-layout'),
|
||||
overlay: by.css('.cdk-overlay-container'),
|
||||
dialogContainer: by.css('.mat-dialog-container[role]'),
|
||||
snackBarContainer: '.cdk-overlay-pane .mat-snack-bar-container',
|
||||
snackBar: '.mat-simple-snackbar',
|
||||
snackBarAction: '.mat-simple-snackbar-action button',
|
||||
private locators = {
|
||||
app: by.css('app-root'),
|
||||
layout: by.css('app-layout'),
|
||||
overlay: by.css('.cdk-overlay-container'),
|
||||
dialogContainer: by.css('.mat-dialog-container'),
|
||||
snackBarContainer: '.cdk-overlay-pane .mat-snack-bar-container',
|
||||
snackBar: '.mat-simple-snackbar',
|
||||
snackBarAction: '.mat-simple-snackbar-action button',
|
||||
|
||||
genericError: 'aca-generic-error',
|
||||
genericErrorIcon: 'aca-generic-error .mat-icon',
|
||||
genericErrorTitle: '.generic-error__title'
|
||||
};
|
||||
genericError: 'aca-generic-error',
|
||||
genericErrorIcon: 'aca-generic-error .mat-icon',
|
||||
genericErrorTitle: '.generic-error__title'
|
||||
};
|
||||
|
||||
public app: ElementFinder = element(this.locators.app);
|
||||
public layout: ElementFinder = element(this.locators.layout);
|
||||
public overlay: ElementFinder = element(this.locators.overlay);
|
||||
snackBar: ElementFinder = browser.$(this.locators.snackBar);
|
||||
dialogContainer: ElementFinder = element(this.locators.dialogContainer);
|
||||
snackBarContainer: ElementFinder = browser.$(this.locators.snackBarContainer);
|
||||
snackBarAction: ElementFinder = browser.$(this.locators.snackBarAction);
|
||||
public app: ElementFinder = element(this.locators.app);
|
||||
public layout: ElementFinder = element(this.locators.layout);
|
||||
public overlay: ElementFinder = element(this.locators.overlay);
|
||||
snackBar: ElementFinder = browser.$(this.locators.snackBar);
|
||||
dialogContainer: ElementFinder = element(this.locators.dialogContainer);
|
||||
snackBarContainer: ElementFinder = browser.$(this.locators.snackBarContainer);
|
||||
snackBarAction: ElementFinder = browser.$(this.locators.snackBarAction);
|
||||
|
||||
genericError: ElementFinder = browser.$(this.locators.genericError);
|
||||
genericErrorIcon: ElementFinder = browser.$(this.locators.genericErrorIcon);
|
||||
genericErrorTitle: ElementFinder = browser.$(this.locators.genericErrorTitle);
|
||||
genericError: ElementFinder = browser.$(this.locators.genericError);
|
||||
genericErrorIcon: ElementFinder = browser.$(this.locators.genericErrorIcon);
|
||||
genericErrorTitle: ElementFinder = browser.$(this.locators.genericErrorTitle);
|
||||
|
||||
constructor(public url: string = '') {}
|
||||
constructor(public url: string = '') {}
|
||||
|
||||
get title(): promise.Promise<string> {
|
||||
return browser.getTitle();
|
||||
}
|
||||
get title(): promise.Promise<string> {
|
||||
return browser.getTitle();
|
||||
}
|
||||
|
||||
load(relativeUrl: string = ''): promise.Promise<void> {
|
||||
const hash = Page.USE_HASH_STRATEGY ? '/#' : '';
|
||||
const path = `${hash}${this.url}${relativeUrl}`;
|
||||
load(relativeUrl: string = ''): promise.Promise<void> {
|
||||
const hash = Page.USE_HASH_STRATEGY ? '/#' : '';
|
||||
const path = `${hash}${this.url}${relativeUrl}`;
|
||||
|
||||
return browser.get(path);
|
||||
}
|
||||
return browser.get(path);
|
||||
}
|
||||
|
||||
waitForApp() {
|
||||
return browser.wait(EC.presenceOf(this.layout), BROWSER_WAIT_TIMEOUT);
|
||||
}
|
||||
waitForApp() {
|
||||
return browser.wait(EC.presenceOf(this.layout), BROWSER_WAIT_TIMEOUT);
|
||||
}
|
||||
|
||||
waitForSnackBarToAppear() {
|
||||
return browser.wait(EC.visibilityOf(this.snackBarContainer), BROWSER_WAIT_TIMEOUT);
|
||||
}
|
||||
waitForSnackBarToAppear() {
|
||||
return browser.wait(
|
||||
EC.visibilityOf(this.snackBarContainer),
|
||||
BROWSER_WAIT_TIMEOUT
|
||||
);
|
||||
}
|
||||
|
||||
waitForSnackBarToClose() {
|
||||
return browser.wait(EC.not(EC.visibilityOf(this.snackBarContainer)), BROWSER_WAIT_TIMEOUT);
|
||||
}
|
||||
waitForSnackBarToClose() {
|
||||
return browser.wait(
|
||||
EC.not(EC.visibilityOf(this.snackBarContainer)),
|
||||
BROWSER_WAIT_TIMEOUT
|
||||
);
|
||||
}
|
||||
|
||||
waitForDialog() {
|
||||
return browser.wait(EC.visibilityOf(this.dialogContainer), BROWSER_WAIT_TIMEOUT);
|
||||
}
|
||||
waitForDialog() {
|
||||
return browser.wait(
|
||||
EC.visibilityOf(this.dialogContainer),
|
||||
BROWSER_WAIT_TIMEOUT
|
||||
);
|
||||
}
|
||||
|
||||
waitForDialogToClose() {
|
||||
return browser.wait(EC.not(EC.visibilityOf(this.dialogContainer)), BROWSER_WAIT_TIMEOUT);
|
||||
}
|
||||
waitForDialogToClose() {
|
||||
return browser.wait(
|
||||
EC.not(EC.visibilityOf(this.dialogContainer)),
|
||||
BROWSER_WAIT_TIMEOUT
|
||||
);
|
||||
}
|
||||
|
||||
refresh(): promise.Promise<void> {
|
||||
return browser.refresh();
|
||||
}
|
||||
refresh(): promise.Promise<void> {
|
||||
return browser.refresh();
|
||||
}
|
||||
|
||||
getDialogActionByLabel(label) {
|
||||
return element(by.cssContainingText('.mat-button-wrapper', label));
|
||||
}
|
||||
getDialogActionByLabel(label) {
|
||||
return element(by.cssContainingText('.mat-button-wrapper', label));
|
||||
}
|
||||
|
||||
isSnackBarDisplayed(): promise.Promise<boolean> {
|
||||
return this.snackBar.isDisplayed();
|
||||
}
|
||||
isSnackBarDisplayed(): promise.Promise<boolean> {
|
||||
return this.snackBar.isDisplayed();
|
||||
}
|
||||
|
||||
getSnackBarMessage(): promise.Promise<string> {
|
||||
return this.waitForSnackBarToAppear()
|
||||
.then(() => this.snackBar.getAttribute('innerText'));
|
||||
}
|
||||
getSnackBarMessage(): promise.Promise<string> {
|
||||
return this.waitForSnackBarToAppear().then(() =>
|
||||
this.snackBar.getAttribute('innerText')
|
||||
);
|
||||
}
|
||||
|
||||
getSnackBarAction() {
|
||||
return this.waitForSnackBarToAppear()
|
||||
.then(() => this.snackBarAction);
|
||||
}
|
||||
getSnackBarAction() {
|
||||
return this.waitForSnackBarToAppear().then(() => this.snackBarAction);
|
||||
}
|
||||
|
||||
clickSnackBarAction() {
|
||||
return this.waitForSnackBarToAppear()
|
||||
.then(() => {
|
||||
return browser.executeScript(function (elem) {
|
||||
elem.click();
|
||||
}, this.snackBarAction);
|
||||
});
|
||||
}
|
||||
clickSnackBarAction() {
|
||||
return this.waitForSnackBarToAppear().then(() => {
|
||||
return browser.executeScript(function(elem) {
|
||||
elem.click();
|
||||
}, this.snackBarAction);
|
||||
});
|
||||
}
|
||||
|
||||
isGenericErrorDisplayed() {
|
||||
return this.genericError.isDisplayed();
|
||||
}
|
||||
isGenericErrorDisplayed() {
|
||||
return this.genericError.isDisplayed();
|
||||
}
|
||||
|
||||
getGenericErrorTitle() {
|
||||
return this.genericErrorTitle.getText();
|
||||
}
|
||||
getGenericErrorTitle() {
|
||||
return this.genericErrorTitle.getText();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user