mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-18 15:33: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 { ProtractorPage } from './app.po';
|
||||||
import { by, element } from 'protractor';
|
import { browser, by, element, protractor } from 'protractor';
|
||||||
|
|
||||||
describe('protractor App', () => {
|
describe('protractor App', () => {
|
||||||
let page: ProtractorPage;
|
let page: ProtractorPage;
|
||||||
@@ -10,16 +10,18 @@ describe('protractor App', () => {
|
|||||||
|
|
||||||
it('should display translated title "DSpace Angular :: Home"', () => {
|
it('should display translated title "DSpace Angular :: Home"', () => {
|
||||||
page.navigateTo()
|
page.navigateTo()
|
||||||
|
.then(() => page.waitUntilNotLoading())
|
||||||
.then(() => {
|
.then(() => {
|
||||||
element(by.css('.main-content')).getAttribute('innerHTML').then((v) => process.stdout.write(v));
|
|
||||||
expect<any>(page.getPageTitleText()).toEqual('DSpace Angular :: Home');
|
expect<any>(page.getPageTitleText()).toEqual('DSpace Angular :: Home');
|
||||||
}
|
}
|
||||||
);
|
)
|
||||||
|
;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should contain a news section', () => {
|
it('should contain a news section', () => {
|
||||||
page.navigateTo()
|
page.navigateTo()
|
||||||
.then(() =>
|
.then(() => page.waitUntilNotLoading())
|
||||||
page.getHomePageNewsText().then((text) => expect<any>(text).toBeDefined()));
|
.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 {
|
export class ProtractorPage {
|
||||||
navigateTo() {
|
navigateTo() {
|
||||||
@@ -13,4 +13,11 @@ export class ProtractorPage {
|
|||||||
getHomePageNewsText() {
|
getHomePageNewsText() {
|
||||||
return element(by.css('ds-home-news')).getText();
|
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(() => page.getRandomScopeOption())
|
||||||
.then((scopeString: string) => {
|
.then((scopeString: string) => {
|
||||||
page.navigateToSearchWithScopeParameter(scopeString)
|
page.navigateToSearchWithScopeParameter(scopeString)
|
||||||
|
.then(() => page.waitUntilNotLoading())
|
||||||
.then(() => page.getCurrentScope())
|
.then(() => page.getCurrentScope())
|
||||||
.then((s: string) => {
|
.then((s: string) => {
|
||||||
expect<string>(s).toEqual(scopeString);
|
expect<string>(s).toEqual(scopeString);
|
||||||
@@ -36,6 +37,7 @@ describe('protractor SearchPage', () => {
|
|||||||
.then((scopeString: string) => {
|
.then((scopeString: string) => {
|
||||||
page.setCurrentScope(scopeString)
|
page.setCurrentScope(scopeString)
|
||||||
.then(() => page.submitSearchForm())
|
.then(() => page.submitSearchForm())
|
||||||
|
.then(() => page.waitUntilNotLoading())
|
||||||
.then(() => () => {
|
.then(() => () => {
|
||||||
browser.wait(() => {
|
browser.wait(() => {
|
||||||
return browser.getCurrentUrl().then((url: string) => {
|
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