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> {
|
||||
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> {
|
||||
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.
|
||||
*/
|
||||
|
||||
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 {
|
||||
private static USE_HASH_STRATEGY = false;
|
||||
|
||||
private locators = {
|
||||
app: by.css('app-root'),
|
||||
layout: by.css('app-layout'),
|
||||
overlay: by.css('.cdk-overlay-container'),
|
||||
snackBar: by.css('simple-snack-bar')
|
||||
};
|
||||
|
||||
public app: ElementFinder = element(this.locators.app);
|
||||
public layout: ElementFinder = element(this.locators.layout);
|
||||
public overlay: ElementFinder = element(this.locators.overlay);
|
||||
public snackBar: ElementFinder = element(this.locators.snackBar);
|
||||
|
||||
@ -43,6 +46,10 @@ export abstract class Page {
|
||||
return browser.get(path);
|
||||
}
|
||||
|
||||
waitForApp() {
|
||||
return browser.wait(EC.presenceOf(this.layout), BROWSER_WAIT_TIMEOUT);
|
||||
}
|
||||
|
||||
refresh(): promise.Promise<void> {
|
||||
return browser.refresh();
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ describe('Login', () => {
|
||||
|
||||
it('shows error when entering nonexistent user', () => {
|
||||
loginPage
|
||||
.loginWith('nonexistent-user', 'any-password')
|
||||
.tryLoginWith('nonexistent-user', 'any-password')
|
||||
.then(() => {
|
||||
expect(browser.getCurrentUrl()).toContain(APP_ROUTES.LOGIN);
|
||||
expect(errorMessage.isDisplayed()).toBe(true);
|
||||
@ -161,7 +161,7 @@ describe('Login', () => {
|
||||
const { username } = johnDoe;
|
||||
|
||||
loginPage
|
||||
.loginWith(username, 'incorrect-password')
|
||||
.tryLoginWith(username, 'incorrect-password')
|
||||
.then(() => {
|
||||
expect(browser.getCurrentUrl()).toContain(APP_ROUTES.LOGIN);
|
||||
expect(errorMessage.isDisplayed()).toBe(true);
|
||||
|
Loading…
x
Reference in New Issue
Block a user