Added more thens to e2e tests

This commit is contained in:
lotte
2020-04-02 09:44:05 +02:00
parent 5bcc700cc9
commit 45beb3f93f
3 changed files with 21 additions and 16 deletions

View File

@@ -8,12 +8,14 @@ describe('protractor App', () => {
});
it('should display translated title "DSpace Angular :: Home"', () => {
page.navigateTo();
expect<any>(page.getPageTitleText()).toEqual('DSpace Angular :: Home');
page.navigateTo()
.then(() =>
expect<any>(page.getPageTitleText()).toEqual('DSpace Angular :: Home'));
});
it('should contain a news section', () => {
page.navigateTo()
.then(() => expect<any>(page.getHomePageNewsText()).toBeDefined());
.then(() =>
page.getHomePageNewsText().then((text) => expect<any>(text).toBeDefined()));
});
});

View File

@@ -22,10 +22,11 @@ describe('protractor SearchPage', () => {
page.navigateToSearch()
.then(() => page.getRandomScopeOption())
.then((scopeString: string) => {
page.navigateToSearchWithScopeParameter(scopeString);
page.getCurrentScope().then((s: string) => {
expect<string>(s).toEqual(scopeString);
});
page.navigateToSearchWithScopeParameter(scopeString)
.then(() => page.getCurrentScope())
.then((s: string) => {
expect<string>(s).toEqual(scopeString);
})
});
});
@@ -33,13 +34,15 @@ describe('protractor SearchPage', () => {
page.navigateToSearch()
.then(() => page.getRandomScopeOption())
.then((scopeString: string) => {
page.setCurrentScope(scopeString);
page.submitSearchForm();
browser.wait(() => {
return browser.getCurrentUrl().then((url: string) => {
return url.indexOf('scope=' + encodeURI(scopeString)) !== -1;
});
});
page.setCurrentScope(scopeString)
.then(() => page.submitSearchForm())
.then(() => () => {
browser.wait(() => {
return browser.getCurrentUrl().then((url: string) => {
return url.indexOf('scope=' + encodeURI(scopeString)) !== -1;
})
})
})
});
});

View File

@@ -27,7 +27,7 @@ export class ProtractorPage {
}
setCurrentScope(scope: string) {
element(by.css('#search-form option[value="' + scope + '"]')).click();
return element(by.css('#search-form option[value="' + scope + '"]')).click();
}
setCurrentQuery(query: string) {
@@ -35,7 +35,7 @@ export class ProtractorPage {
}
submitSearchForm() {
element(by.css('#search-form button.search-button')).click();
return element(by.css('#search-form button.search-button')).click();
}
getRandomScopeOption(): promise.Promise<string> {