diff --git a/e2e/src/item-statistics/item-statistics.e2e-spec.ts b/e2e/src/item-statistics/item-statistics.e2e-spec.ts new file mode 100644 index 0000000000..fe629804a3 --- /dev/null +++ b/e2e/src/item-statistics/item-statistics.e2e-spec.ts @@ -0,0 +1,31 @@ +import { ProtractorPage } from './item-statistics.po'; +import { browser } from 'protractor'; + +describe('protractor Item statics', () => { + let page: ProtractorPage; + + beforeEach(() => { + page = new ProtractorPage(); + }); + + it('should contain element ds-item-page when navigating when navigating to an item page', () => { + page.navigateToItemPage(); + expect(page.elementTagExists('ds-item-page')).toEqual(true); + expect(page.elementTagExists('ds-item-statistics-page')).toEqual(false); + }); + + it('should redirect to the entity page when navigating to an item page', () => { + page.navigateToItemPage(); + expect(browser.getCurrentUrl()).toEqual('http://localhost:4000' + page.ENTITYPAGE); + }); + + it('should contain element ds-item-statistics-page when navigating when navigating to an item statistics page', () => { + page.navigateToItemStatisticsPage(); + expect(page.elementTagExists('ds-item-statistics-page')).toEqual(true); + expect(page.elementTagExists('ds-item-page')).toEqual(false); + }); + it('should contain the item statistics page url when navigating to an item statistics page', () => { + page.navigateToItemStatisticsPage(); + expect(browser.getCurrentUrl()).toEqual('http://localhost:4000' + page.ITEMSTATISTICSPAGE); + }); +}); diff --git a/e2e/src/item-statistics/item-statistics.po.ts b/e2e/src/item-statistics/item-statistics.po.ts new file mode 100644 index 0000000000..618f65dc98 --- /dev/null +++ b/e2e/src/item-statistics/item-statistics.po.ts @@ -0,0 +1,23 @@ +import { browser, element, by } from 'protractor'; + +export class ProtractorPage { + ITEMPAGE = '/items/e98b0f27-5c19-49a0-960d-eb6ad5287067'; + ENTITYPAGE = '/entities/publication/e98b0f27-5c19-49a0-960d-eb6ad5287067'; + ITEMSTATISTICSPAGE = '/statistics/items/e98b0f27-5c19-49a0-960d-eb6ad5287067'; + + navigateToItemPage() { + return browser.get(this.ITEMPAGE); + } + navigateToItemStatisticsPage() { + return browser.get(this.ITEMSTATISTICSPAGE); + } + + elementTagExists(tag: string) { + return element(by.tagName(tag)).isPresent(); + } + + verifyCurrentUrl(url) { + browser.getCurrentUrl().then((currentUrl) => currentUrl === url ); + } + +} diff --git a/package.json b/package.json index 80af52e264..652ab409ac 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,8 @@ }, "private": true, "resolutions": { - "minimist": "^1.2.5" + "minimist": "^1.2.5", + "webdriver-manager": "^12.1.8" }, "dependencies": { "@angular/animations": "~10.2.3", diff --git a/src/app/+item-page/item-page.resolver.ts b/src/app/+item-page/item-page.resolver.ts index a12f961e57..7edffc5357 100644 --- a/src/app/+item-page/item-page.resolver.ts +++ b/src/app/+item-page/item-page.resolver.ts @@ -4,11 +4,7 @@ import { Observable } from 'rxjs'; import { RemoteData } from '../core/data/remote-data'; import { ItemDataService } from '../core/data/item-data.service'; import { Item } from '../core/shared/item.model'; -import { followLink, FollowLinkConfig } from '../shared/utils/follow-link-config.model'; -import { FindListOptions } from '../core/data/request.models'; -import { getFirstCompletedRemoteData } from '../core/shared/operators'; import { Store } from '@ngrx/store'; -import { ResolvedAction } from '../core/resolving/resolver.actions'; import { map } from 'rxjs/operators'; import { hasValue } from '../shared/empty.util'; import { getItemPageRoute } from './item-page-routing-paths'; diff --git a/src/app/+item-page/item.resolver.ts b/src/app/+item-page/item.resolver.ts index 7d020309dc..99b96511fe 100644 --- a/src/app/+item-page/item.resolver.ts +++ b/src/app/+item-page/item.resolver.ts @@ -9,9 +9,6 @@ import { FindListOptions } from '../core/data/request.models'; import { getFirstCompletedRemoteData } from '../core/shared/operators'; import { Store } from '@ngrx/store'; import { ResolvedAction } from '../core/resolving/resolver.actions'; -import { map } from 'rxjs/operators'; -import { hasValue } from '../shared/empty.util'; -import { getItemPageRoute } from './item-page-routing-paths'; /** * The self links defined in this list are expected to be requested somewhere in the near future diff --git a/src/app/statistics-page/statistics-page-routing.module.ts b/src/app/statistics-page/statistics-page-routing.module.ts index 0c63e35b34..5b96bcca6e 100644 --- a/src/app/statistics-page/statistics-page-routing.module.ts +++ b/src/app/statistics-page/statistics-page-routing.module.ts @@ -3,7 +3,6 @@ import { RouterModule } from '@angular/router'; import { I18nBreadcrumbResolver } from '../core/breadcrumbs/i18n-breadcrumb.resolver'; import { I18nBreadcrumbsService } from '../core/breadcrumbs/i18n-breadcrumbs.service'; import { StatisticsPageModule } from './statistics-page.module'; -import { ItemPageResolver } from '../+item-page/item-page.resolver'; import { CollectionPageResolver } from '../+collection-page/collection-page.resolver'; import { CommunityPageResolver } from '../+community-page/community-page.resolver'; import { ThemedCollectionStatisticsPageComponent } from './collection-statistics-page/themed-collection-statistics-page.component'; diff --git a/yarn.lock b/yarn.lock index 9b6e2d31d6..d6388ddb53 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11933,10 +11933,10 @@ webdriver-js-extender@2.1.0: "@types/selenium-webdriver" "^3.0.0" selenium-webdriver "^3.0.1" -webdriver-manager@^12.1.7: - version "12.1.7" - resolved "https://registry.yarnpkg.com/webdriver-manager/-/webdriver-manager-12.1.7.tgz#ed4eaee8f906b33c146e869b55e850553a1b1162" - integrity sha512-XINj6b8CYuUYC93SG3xPkxlyUc3IJbD6Vvo75CVGuG9uzsefDzWQrhz0Lq8vbPxtb4d63CZdYophF8k8Or/YiA== +webdriver-manager@^12.1.7, webdriver-manager@^12.1.8: + version "12.1.8" + resolved "https://registry.yarnpkg.com/webdriver-manager/-/webdriver-manager-12.1.8.tgz#5e70e73eaaf53a0767d5745270addafbc5905fd4" + integrity sha512-qJR36SXG2VwKugPcdwhaqcLQOD7r8P2Xiv9sfNbfZrKBnX243iAkOueX1yAmeNgIKhJ3YAT/F2gq6IiEZzahsg== dependencies: adm-zip "^0.4.9" chalk "^1.1.1"