mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-17 23:13:04 +00:00
added waiting until loading is done to e2e tests
This commit is contained in:
@@ -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());
|
||||
});
|
||||
});
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
@@ -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) => {
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user