mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-05-12 17:04:46 +00:00
Merge pull request #48 from Alfresco/adina-add-wait
[ACA-964] Add proper wait methods to fix the intermittently failing tests
This commit is contained in:
commit
44bb71aa53
@ -49,10 +49,21 @@ export class LoginPage extends Page {
|
|||||||
|
|
||||||
loginWith(username: string, password?: string): promise.Promise<void> {
|
loginWith(username: string, password?: string): promise.Promise<void> {
|
||||||
const pass = password || username;
|
const pass = password || username;
|
||||||
return this.login.enterCredentials(username, pass).submit();
|
return this.login.enterCredentials(username, pass).submit()
|
||||||
|
.then(() => {
|
||||||
|
super.waitForApp();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
loginWithAdmin(): promise.Promise<any> {
|
loginWithAdmin(): promise.Promise<any> {
|
||||||
return this.loginWith(ADMIN_USERNAME, ADMIN_PASSWORD);
|
return this.loginWith(ADMIN_USERNAME, ADMIN_PASSWORD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tryLoginWith(username: string, password?: string): promise.Promise<void> {
|
||||||
|
const pass = password || username;
|
||||||
|
return this.login.enterCredentials(username, pass).submit()
|
||||||
|
.then(() => {
|
||||||
|
browser.wait(EC.presenceOf(this.login.errorMessage), BROWSER_WAIT_TIMEOUT);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,18 +15,21 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { browser, element, by, ElementFinder, promise } from 'protractor';
|
import { browser, element, by, ElementFinder, promise, ExpectedConditions as EC } from 'protractor';
|
||||||
|
import { BROWSER_WAIT_TIMEOUT } from './../configs';
|
||||||
|
|
||||||
export abstract class Page {
|
export abstract class Page {
|
||||||
private static USE_HASH_STRATEGY = false;
|
private static USE_HASH_STRATEGY = false;
|
||||||
|
|
||||||
private locators = {
|
private locators = {
|
||||||
app: by.css('app-root'),
|
app: by.css('app-root'),
|
||||||
|
layout: by.css('app-layout'),
|
||||||
overlay: by.css('.cdk-overlay-container'),
|
overlay: by.css('.cdk-overlay-container'),
|
||||||
snackBar: by.css('simple-snack-bar')
|
snackBar: by.css('simple-snack-bar')
|
||||||
};
|
};
|
||||||
|
|
||||||
public app: ElementFinder = element(this.locators.app);
|
public app: ElementFinder = element(this.locators.app);
|
||||||
|
public layout: ElementFinder = element(this.locators.layout);
|
||||||
public overlay: ElementFinder = element(this.locators.overlay);
|
public overlay: ElementFinder = element(this.locators.overlay);
|
||||||
public snackBar: ElementFinder = element(this.locators.snackBar);
|
public snackBar: ElementFinder = element(this.locators.snackBar);
|
||||||
|
|
||||||
@ -43,6 +46,10 @@ export abstract class Page {
|
|||||||
return browser.get(path);
|
return browser.get(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
waitForApp() {
|
||||||
|
return browser.wait(EC.presenceOf(this.layout), BROWSER_WAIT_TIMEOUT);
|
||||||
|
}
|
||||||
|
|
||||||
refresh(): promise.Promise<void> {
|
refresh(): promise.Promise<void> {
|
||||||
return browser.refresh();
|
return browser.refresh();
|
||||||
}
|
}
|
||||||
|
@ -150,7 +150,7 @@ describe('Login', () => {
|
|||||||
|
|
||||||
it('shows error when entering nonexistent user', () => {
|
it('shows error when entering nonexistent user', () => {
|
||||||
loginPage
|
loginPage
|
||||||
.loginWith('nonexistent-user', 'any-password')
|
.tryLoginWith('nonexistent-user', 'any-password')
|
||||||
.then(() => {
|
.then(() => {
|
||||||
expect(browser.getCurrentUrl()).toContain(APP_ROUTES.LOGIN);
|
expect(browser.getCurrentUrl()).toContain(APP_ROUTES.LOGIN);
|
||||||
expect(errorMessage.isDisplayed()).toBe(true);
|
expect(errorMessage.isDisplayed()).toBe(true);
|
||||||
@ -161,7 +161,7 @@ describe('Login', () => {
|
|||||||
const { username } = johnDoe;
|
const { username } = johnDoe;
|
||||||
|
|
||||||
loginPage
|
loginPage
|
||||||
.loginWith(username, 'incorrect-password')
|
.tryLoginWith(username, 'incorrect-password')
|
||||||
.then(() => {
|
.then(() => {
|
||||||
expect(browser.getCurrentUrl()).toContain(APP_ROUTES.LOGIN);
|
expect(browser.getCurrentUrl()).toContain(APP_ROUTES.LOGIN);
|
||||||
expect(errorMessage.isDisplayed()).toBe(true);
|
expect(errorMessage.isDisplayed()).toBe(true);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user