added waiting until loading is done to e2e tests

This commit is contained in:
lotte
2020-04-02 11:22:48 +02:00
parent b3ba67e31d
commit 97953912c5
4 changed files with 23 additions and 6 deletions

View File

@@ -1,5 +1,5 @@
import { ProtractorPage } from './app.po';
import { by, element } from 'protractor';
import { browser, by, element, protractor } from 'protractor';
describe('protractor App', () => {
let page: ProtractorPage;
@@ -10,16 +10,18 @@ describe('protractor App', () => {
it('should display translated title "DSpace Angular :: Home"', () => {
page.navigateTo()
.then(() => page.waitUntilNotLoading())
.then(() => {
element(by.css('.main-content')).getAttribute('innerHTML').then((v) => process.stdout.write(v));
expect<any>(page.getPageTitleText()).toEqual('DSpace Angular :: Home');
}
);
)
;
});
it('should contain a news section', () => {
page.navigateTo()
.then(() =>
page.getHomePageNewsText().then((text) => expect<any>(text).toBeDefined()));
.then(() => page.waitUntilNotLoading())
.then(() => page.getHomePageNewsText())
.then((text) => expect<any>(text).toBeDefined());
});
});

View File

@@ -1,4 +1,4 @@
import { browser, element, by } from 'protractor';
import { browser, element, by, protractor, promise } from 'protractor';
export class ProtractorPage {
navigateTo() {
@@ -13,4 +13,11 @@ export class ProtractorPage {
getHomePageNewsText() {
return element(by.css('ds-home-news')).getText();
}
waitUntilNotLoading(): promise.Promise<unknown> {
const loading = element(by.css('.loader'))
const EC = protractor.ExpectedConditions;
const notLoading = EC.not(EC.presenceOf(loading));
return browser.wait(notLoading, 10000);
}
}

View File

@@ -23,6 +23,7 @@ describe('protractor SearchPage', () => {
.then(() => page.getRandomScopeOption())
.then((scopeString: string) => {
page.navigateToSearchWithScopeParameter(scopeString)
.then(() => page.waitUntilNotLoading())
.then(() => page.getCurrentScope())
.then((s: string) => {
expect<string>(s).toEqual(scopeString);
@@ -36,6 +37,7 @@ describe('protractor SearchPage', () => {
.then((scopeString: string) => {
page.setCurrentScope(scopeString)
.then(() => page.submitSearchForm())
.then(() => page.waitUntilNotLoading())
.then(() => () => {
browser.wait(() => {
return browser.getCurrentUrl().then((url: string) => {

View File

@@ -46,4 +46,10 @@ export class ProtractorPage {
});
}
waitUntilNotLoading(): promise.Promise<unknown> {
const loading = element(by.css('.loader'));
const EC = protractor.ExpectedConditions;
const notLoading = EC.not(EC.presenceOf(loading));
return browser.wait(notLoading, 10000);
}
}