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"', () => { it('should display translated title "DSpace Angular :: Home"', () => {
page.navigateTo(); page.navigateTo()
expect<any>(page.getPageTitleText()).toEqual('DSpace Angular :: Home'); .then(() =>
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(() => 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() page.navigateToSearch()
.then(() => page.getRandomScopeOption()) .then(() => page.getRandomScopeOption())
.then((scopeString: string) => { .then((scopeString: string) => {
page.navigateToSearchWithScopeParameter(scopeString); page.navigateToSearchWithScopeParameter(scopeString)
page.getCurrentScope().then((s: string) => { .then(() => page.getCurrentScope())
expect<string>(s).toEqual(scopeString); .then((s: string) => {
}); expect<string>(s).toEqual(scopeString);
})
}); });
}); });
@@ -33,13 +34,15 @@ describe('protractor SearchPage', () => {
page.navigateToSearch() page.navigateToSearch()
.then(() => page.getRandomScopeOption()) .then(() => page.getRandomScopeOption())
.then((scopeString: string) => { .then((scopeString: string) => {
page.setCurrentScope(scopeString); page.setCurrentScope(scopeString)
page.submitSearchForm(); .then(() => page.submitSearchForm())
browser.wait(() => { .then(() => () => {
return browser.getCurrentUrl().then((url: string) => { browser.wait(() => {
return url.indexOf('scope=' + encodeURI(scopeString)) !== -1; 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) { 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) { setCurrentQuery(query: string) {
@@ -35,7 +35,7 @@ export class ProtractorPage {
} }
submitSearchForm() { submitSearchForm() {
element(by.css('#search-form button.search-button')).click(); return element(by.css('#search-form button.search-button')).click();
} }
getRandomScopeOption(): promise.Promise<string> { getRandomScopeOption(): promise.Promise<string> {