From 8949e7cc270f499c446c65550bc1243c2f0ce4f3 Mon Sep 17 00:00:00 2001 From: Adan Roman Date: Tue, 20 Dec 2022 15:42:56 +0100 Subject: [PATCH 01/23] DS-8408 - In Advanced Search, list collections alphabetically --- .../dso-selector/dso-selector/dso-selector.component.ts | 9 ++++++++- .../create-community-parent-selector.component.html | 2 +- .../create-community-parent-selector.component.ts | 6 ++++++ .../dso-selector-modal-wrapper.component.html | 2 +- .../dso-selector-modal-wrapper.component.ts | 6 ++++++ .../scope-selector-modal.component.html | 2 +- .../scope-selector-modal.component.ts | 7 ++++++- .../create-collection-parent-selector.component.html | 2 +- .../create-community-parent-selector.component.html | 2 +- .../edit-collection-selector.component.html | 2 +- .../edit-community-selector.component.html | 2 +- .../edit-item-selector/edit-item-selector.component.html | 2 +- 12 files changed, 34 insertions(+), 10 deletions(-) diff --git a/src/app/shared/dso-selector/dso-selector/dso-selector.component.ts b/src/app/shared/dso-selector/dso-selector/dso-selector.component.ts index 0c799369ef..087ef3216d 100644 --- a/src/app/shared/dso-selector/dso-selector/dso-selector.component.ts +++ b/src/app/shared/dso-selector/dso-selector/dso-selector.component.ts @@ -31,6 +31,7 @@ import { getFirstCompletedRemoteData, getFirstSucceededRemoteDataPayload } from import { hasNoValue, hasValue, isEmpty, isNotEmpty } from '../../empty.util'; import { buildPaginatedList, PaginatedList } from '../../../core/data/paginated-list.model'; import { SearchResult } from '../../search/models/search-result.model'; +import {SortDirection, SortOptions} from '../../../core/cache/models/sort-options.model'; import { RemoteData } from '../../../core/data/remote-data'; import { NotificationsService } from '../../notifications/notifications.service'; import { TranslateService } from '@ngx-translate/core'; @@ -61,6 +62,11 @@ export class DSOSelectorComponent implements OnInit, OnDestroy { */ @Input() types: DSpaceObjectType[]; + /** + * The sorting options + */ + @Input() sort: SortOptions; + // list of allowed selectable dsoTypes typesString: string; @@ -219,7 +225,8 @@ export class DSOSelectorComponent implements OnInit, OnDestroy { dsoTypes: this.types, pagination: Object.assign({}, this.defaultPagination, { currentPage: page - }) + }), + sort: this.sort }) ).pipe( getFirstCompletedRemoteData() diff --git a/src/app/shared/dso-selector/modal-wrappers/create-community-parent-selector/create-community-parent-selector.component.html b/src/app/shared/dso-selector/modal-wrappers/create-community-parent-selector/create-community-parent-selector.component.html index 84fdd34c01..2ec9a4f5ab 100644 --- a/src/app/shared/dso-selector/modal-wrappers/create-community-parent-selector/create-community-parent-selector.component.html +++ b/src/app/shared/dso-selector/modal-wrappers/create-community-parent-selector/create-community-parent-selector.component.html @@ -14,6 +14,6 @@
{{'dso-selector.create.community.sub-level' | translate}}
- + diff --git a/src/app/shared/dso-selector/modal-wrappers/create-community-parent-selector/create-community-parent-selector.component.ts b/src/app/shared/dso-selector/modal-wrappers/create-community-parent-selector/create-community-parent-selector.component.ts index a7f583df50..f344c1c3f3 100644 --- a/src/app/shared/dso-selector/modal-wrappers/create-community-parent-selector/create-community-parent-selector.component.ts +++ b/src/app/shared/dso-selector/modal-wrappers/create-community-parent-selector/create-community-parent-selector.component.ts @@ -12,6 +12,7 @@ import { getCommunityCreateRoute, COMMUNITY_PARENT_PARAMETER } from '../../../../community-page/community-page-routing-paths'; +import {SortDirection, SortOptions} from '../../../../core/cache/models/sort-options.model'; /** * Component to wrap a button - for top communities - @@ -30,6 +31,11 @@ export class CreateCommunityParentSelectorComponent extends DSOSelectorModalWrap selectorTypes = [DSpaceObjectType.COMMUNITY]; action = SelectorActionType.CREATE; + /** + * Default DSO ordering + */ + defaultSort = new SortOptions('dc.title', SortDirection.ASC); + constructor(protected activeModal: NgbActiveModal, protected route: ActivatedRoute, private router: Router) { super(activeModal, route); } diff --git a/src/app/shared/dso-selector/modal-wrappers/dso-selector-modal-wrapper.component.html b/src/app/shared/dso-selector/modal-wrappers/dso-selector-modal-wrapper.component.html index 85d8797e66..54044f5d79 100644 --- a/src/app/shared/dso-selector/modal-wrappers/dso-selector-modal-wrapper.component.html +++ b/src/app/shared/dso-selector/modal-wrappers/dso-selector-modal-wrapper.component.html @@ -6,6 +6,6 @@ diff --git a/src/app/shared/dso-selector/modal-wrappers/dso-selector-modal-wrapper.component.ts b/src/app/shared/dso-selector/modal-wrappers/dso-selector-modal-wrapper.component.ts index 113ca518fd..2a25da2f72 100644 --- a/src/app/shared/dso-selector/modal-wrappers/dso-selector-modal-wrapper.component.ts +++ b/src/app/shared/dso-selector/modal-wrappers/dso-selector-modal-wrapper.component.ts @@ -5,6 +5,7 @@ import { RemoteData } from '../../../core/data/remote-data'; import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; import { DSpaceObjectType } from '../../../core/shared/dspace-object-type.model'; import { hasValue, isNotEmpty } from '../../empty.util'; +import {SortDirection, SortOptions} from '../../../core/cache/models/sort-options.model'; export enum SelectorActionType { CREATE = 'create', @@ -49,6 +50,11 @@ export abstract class DSOSelectorModalWrapperComponent implements OnInit { */ action: SelectorActionType; + /** + * Default DSO ordering + */ + defaultSort = new SortOptions('dc.title', SortDirection.ASC); + constructor(protected activeModal: NgbActiveModal, protected route: ActivatedRoute) { } diff --git a/src/app/shared/search-form/scope-selector-modal/scope-selector-modal.component.html b/src/app/shared/search-form/scope-selector-modal/scope-selector-modal.component.html index bf5c15e963..ad360be677 100644 --- a/src/app/shared/search-form/scope-selector-modal/scope-selector-modal.component.html +++ b/src/app/shared/search-form/scope-selector-modal/scope-selector-modal.component.html @@ -14,6 +14,6 @@
{{'dso-selector.' + action + '.' + objectType.toString().toLowerCase() + '.input-header' | translate}}
- + diff --git a/src/app/shared/search-form/scope-selector-modal/scope-selector-modal.component.ts b/src/app/shared/search-form/scope-selector-modal/scope-selector-modal.component.ts index 86c3010287..416242520c 100644 --- a/src/app/shared/search-form/scope-selector-modal/scope-selector-modal.component.ts +++ b/src/app/shared/search-form/scope-selector-modal/scope-selector-modal.component.ts @@ -4,7 +4,7 @@ import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; import { DSpaceObjectType } from '../../../core/shared/dspace-object-type.model'; import { DSOSelectorModalWrapperComponent, SelectorActionType } from '../../dso-selector/modal-wrappers/dso-selector-modal-wrapper.component'; import { DSpaceObject } from '../../../core/shared/dspace-object.model'; - +import {SortDirection, SortOptions} from '../../../core/cache/models/sort-options.model'; /** * Component to wrap a button - to select the entire repository - * and a list of parent communities - for scope selection @@ -33,6 +33,11 @@ export class ScopeSelectorModalComponent extends DSOSelectorModalWrapperComponen */ scopeChange = new EventEmitter(); + /** + * Default DSO ordering + */ + defaultSort = new SortOptions('dc.title', SortDirection.ASC); + constructor(protected activeModal: NgbActiveModal, protected route: ActivatedRoute) { super(activeModal, route); } diff --git a/src/themes/custom/app/shared/dso-selector/modal-wrappers/create-collection-parent-selector/create-collection-parent-selector.component.html b/src/themes/custom/app/shared/dso-selector/modal-wrappers/create-collection-parent-selector/create-collection-parent-selector.component.html index 85d8797e66..54044f5d79 100644 --- a/src/themes/custom/app/shared/dso-selector/modal-wrappers/create-collection-parent-selector/create-collection-parent-selector.component.html +++ b/src/themes/custom/app/shared/dso-selector/modal-wrappers/create-collection-parent-selector/create-collection-parent-selector.component.html @@ -6,6 +6,6 @@ diff --git a/src/themes/custom/app/shared/dso-selector/modal-wrappers/create-community-parent-selector/create-community-parent-selector.component.html b/src/themes/custom/app/shared/dso-selector/modal-wrappers/create-community-parent-selector/create-community-parent-selector.component.html index 84fdd34c01..2ec9a4f5ab 100644 --- a/src/themes/custom/app/shared/dso-selector/modal-wrappers/create-community-parent-selector/create-community-parent-selector.component.html +++ b/src/themes/custom/app/shared/dso-selector/modal-wrappers/create-community-parent-selector/create-community-parent-selector.component.html @@ -14,6 +14,6 @@
{{'dso-selector.create.community.sub-level' | translate}}
- + diff --git a/src/themes/custom/app/shared/dso-selector/modal-wrappers/edit-collection-selector/edit-collection-selector.component.html b/src/themes/custom/app/shared/dso-selector/modal-wrappers/edit-collection-selector/edit-collection-selector.component.html index 85d8797e66..54044f5d79 100644 --- a/src/themes/custom/app/shared/dso-selector/modal-wrappers/edit-collection-selector/edit-collection-selector.component.html +++ b/src/themes/custom/app/shared/dso-selector/modal-wrappers/edit-collection-selector/edit-collection-selector.component.html @@ -6,6 +6,6 @@ diff --git a/src/themes/custom/app/shared/dso-selector/modal-wrappers/edit-community-selector/edit-community-selector.component.html b/src/themes/custom/app/shared/dso-selector/modal-wrappers/edit-community-selector/edit-community-selector.component.html index 85d8797e66..54044f5d79 100644 --- a/src/themes/custom/app/shared/dso-selector/modal-wrappers/edit-community-selector/edit-community-selector.component.html +++ b/src/themes/custom/app/shared/dso-selector/modal-wrappers/edit-community-selector/edit-community-selector.component.html @@ -6,6 +6,6 @@ diff --git a/src/themes/custom/app/shared/dso-selector/modal-wrappers/edit-item-selector/edit-item-selector.component.html b/src/themes/custom/app/shared/dso-selector/modal-wrappers/edit-item-selector/edit-item-selector.component.html index 85d8797e66..54044f5d79 100644 --- a/src/themes/custom/app/shared/dso-selector/modal-wrappers/edit-item-selector/edit-item-selector.component.html +++ b/src/themes/custom/app/shared/dso-selector/modal-wrappers/edit-item-selector/edit-item-selector.component.html @@ -6,6 +6,6 @@ From d6402fbaf80e309de6e600caf9cfc8714f7db2e3 Mon Sep 17 00:00:00 2001 From: Adan Roman Date: Wed, 21 Dec 2022 08:31:42 +0100 Subject: [PATCH 02/23] DS-8408 - Unused dependency --- .../shared/dso-selector/dso-selector/dso-selector.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/shared/dso-selector/dso-selector/dso-selector.component.ts b/src/app/shared/dso-selector/dso-selector/dso-selector.component.ts index 3900de8571..4b5d8c7614 100644 --- a/src/app/shared/dso-selector/dso-selector/dso-selector.component.ts +++ b/src/app/shared/dso-selector/dso-selector/dso-selector.component.ts @@ -31,7 +31,7 @@ import { getFirstCompletedRemoteData, getFirstSucceededRemoteDataPayload } from import { hasNoValue, hasValue, isEmpty, isNotEmpty } from '../../empty.util'; import { buildPaginatedList, PaginatedList } from '../../../core/data/paginated-list.model'; import { SearchResult } from '../../search/models/search-result.model'; -import {SortDirection, SortOptions} from '../../../core/cache/models/sort-options.model'; +import { SortOptions } from '../../../core/cache/models/sort-options.model'; import { RemoteData } from '../../../core/data/remote-data'; import { NotificationsService } from '../../notifications/notifications.service'; import { TranslateService } from '@ngx-translate/core'; From 6523b029134db91a449d17085dcb58b79e335f21 Mon Sep 17 00:00:00 2001 From: aroman-arvo Date: Mon, 16 Jan 2023 13:07:19 +0100 Subject: [PATCH 03/23] DS-8408: Edit item is ordered by relevance --- .../edit-item-selector.component.html | 11 +++++++++++ .../edit-item-selector.component.ts | 2 +- .../edit-item-selector.component.html | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 src/app/shared/dso-selector/modal-wrappers/edit-item-selector/edit-item-selector.component.html diff --git a/src/app/shared/dso-selector/modal-wrappers/edit-item-selector/edit-item-selector.component.html b/src/app/shared/dso-selector/modal-wrappers/edit-item-selector/edit-item-selector.component.html new file mode 100644 index 0000000000..85d8797e66 --- /dev/null +++ b/src/app/shared/dso-selector/modal-wrappers/edit-item-selector/edit-item-selector.component.html @@ -0,0 +1,11 @@ +
+ + +
diff --git a/src/app/shared/dso-selector/modal-wrappers/edit-item-selector/edit-item-selector.component.ts b/src/app/shared/dso-selector/modal-wrappers/edit-item-selector/edit-item-selector.component.ts index 4822849e4c..c1ae583908 100644 --- a/src/app/shared/dso-selector/modal-wrappers/edit-item-selector/edit-item-selector.component.ts +++ b/src/app/shared/dso-selector/modal-wrappers/edit-item-selector/edit-item-selector.component.ts @@ -14,7 +14,7 @@ import { Item } from '../../../../core/shared/item.model'; @Component({ selector: 'ds-edit-item-selector', - templateUrl: '../dso-selector-modal-wrapper.component.html', + templateUrl: 'edit-item-selector.component.html', }) export class EditItemSelectorComponent extends DSOSelectorModalWrapperComponent implements OnInit { objectType = DSpaceObjectType.ITEM; diff --git a/src/themes/custom/app/shared/dso-selector/modal-wrappers/edit-item-selector/edit-item-selector.component.html b/src/themes/custom/app/shared/dso-selector/modal-wrappers/edit-item-selector/edit-item-selector.component.html index 54044f5d79..85d8797e66 100644 --- a/src/themes/custom/app/shared/dso-selector/modal-wrappers/edit-item-selector/edit-item-selector.component.html +++ b/src/themes/custom/app/shared/dso-selector/modal-wrappers/edit-item-selector/edit-item-selector.component.html @@ -6,6 +6,6 @@ From e4e973bbefc6222818eb1b97702e04dfbdd033a4 Mon Sep 17 00:00:00 2001 From: cris Date: Thu, 9 Feb 2023 20:53:28 +0000 Subject: [PATCH 04/23] ul and li replaced to role list and listitem --- src/app/shared/form/chips/chips.component.html | 8 ++++---- src/app/shared/form/chips/chips.component.spec.ts | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/app/shared/form/chips/chips.component.html b/src/app/shared/form/chips/chips.component.html index 2233c1bd16..a6b90b23aa 100644 --- a/src/app/shared/form/chips/chips.component.html +++ b/src/app/shared/form/chips/chips.component.html @@ -1,5 +1,5 @@
- +
diff --git a/src/app/shared/form/chips/chips.component.spec.ts b/src/app/shared/form/chips/chips.component.spec.ts index 2b8a469bd1..050950ed4d 100644 --- a/src/app/shared/form/chips/chips.component.spec.ts +++ b/src/app/shared/form/chips/chips.component.spec.ts @@ -122,7 +122,7 @@ describe('ChipsComponent test suite', () => { })); it('should save chips item index when drag and drop start', fakeAsync(() => { - const de = chipsFixture.debugElement.query(By.css('li.nav-item')); + const de = chipsFixture.debugElement.query(By.css('div.nav-item')); de.triggerEventHandler('dragstart', null); @@ -131,7 +131,7 @@ describe('ChipsComponent test suite', () => { it('should update chips item order when drag and drop end', fakeAsync(() => { spyOn(chipsComp.chips, 'updateOrder'); - const de = chipsFixture.debugElement.query(By.css('li.nav-item')); + const de = chipsFixture.debugElement.query(By.css('div.nav-item')); de.triggerEventHandler('dragend', null); @@ -158,7 +158,7 @@ describe('ChipsComponent test suite', () => { }); it('should show icon for every field that has a configured icon', () => { - const de = chipsFixture.debugElement.query(By.css('li.nav-item')); + const de = chipsFixture.debugElement.query(By.css('div.nav-item')); const icons = de.queryAll(By.css('i.fas')); expect(icons.length).toBe(4); @@ -166,7 +166,7 @@ describe('ChipsComponent test suite', () => { }); it('should show tooltip on mouse over an icon', () => { - const de = chipsFixture.debugElement.query(By.css('li.nav-item')); + const de = chipsFixture.debugElement.query(By.css('div.nav-item')); const icons = de.queryAll(By.css('i.fas')); icons[0].triggerEventHandler('mouseover', null); From e1beb615252973fceb8d48d12a77b83e94a2a057 Mon Sep 17 00:00:00 2001 From: cris Date: Thu, 9 Feb 2023 21:44:02 +0000 Subject: [PATCH 05/23] ul and li in dropdwon collection in submissions form --- .../collection-dropdown.component.html | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/app/shared/collection-dropdown/collection-dropdown.component.html b/src/app/shared/collection-dropdown/collection-dropdown.component.html index db6c1fb41d..470291373f 100644 --- a/src/app/shared/collection-dropdown/collection-dropdown.component.html +++ b/src/app/shared/collection-dropdown/collection-dropdown.component.html @@ -7,7 +7,7 @@ #searchFieldEl> -
- + - +
+
{{ listItem.collection.name}}
+ + - + From 1d69e1581adbffd53b01b1c7342669b383273242 Mon Sep 17 00:00:00 2001 From: Alexandre Vryghem Date: Fri, 10 Feb 2023 17:45:59 +0100 Subject: [PATCH 06/23] 97755: Call spy before component is created --- src/app/admin/admin-sidebar/admin-sidebar.component.spec.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/app/admin/admin-sidebar/admin-sidebar.component.spec.ts b/src/app/admin/admin-sidebar/admin-sidebar.component.spec.ts index 65026c1504..fe8e4187d3 100644 --- a/src/app/admin/admin-sidebar/admin-sidebar.component.spec.ts +++ b/src/app/admin/admin-sidebar/admin-sidebar.component.spec.ts @@ -55,6 +55,7 @@ describe('AdminSidebarComponent', () => { isAuthorized: observableOf(true) }); scriptService = jasmine.createSpyObj('scriptService', { scriptWithNameExistsAndCanExecute: observableOf(true) }); + spyOn(menuService, 'addSection').and.callThrough(); TestBed.configureTestingModule({ imports: [TranslateModule.forRoot(), NoopAnimationsModule, RouterTestingModule], declarations: [AdminSidebarComponent], @@ -184,10 +185,6 @@ describe('AdminSidebarComponent', () => { }); describe('menu', () => { - beforeEach(() => { - spyOn(menuService, 'addSection'); - }); - describe('for regular user', () => { beforeEach(() => { authorizationService.isAuthorized = createSpy('isAuthorized').and.callFake(() => { From eeda26e122859bfac8fcbc6ea806eae86c19431e Mon Sep 17 00:00:00 2001 From: aroman-arvo Date: Mon, 13 Feb 2023 10:42:56 +0100 Subject: [PATCH 07/23] 8408 - sort ordering is parametrized and used only when no text query is send. --- config/config.example.yml | 5 +++++ config/config.yml | 6 +++--- .../dso-selector/dso-selector.component.ts | 4 +++- .../create-community-parent-selector.component.ts | 6 ------ .../dso-selector-modal-wrapper.component.ts | 5 +++-- .../scope-selector-modal.component.ts | 7 +------ src/config/app-config.interface.ts | 2 ++ src/config/default-app-config.ts | 7 +++++++ src/config/discovery-sort.config.ts | 14 ++++++++++++++ src/environments/environment.test.ts | 4 ++++ 10 files changed, 42 insertions(+), 18 deletions(-) create mode 100644 src/config/discovery-sort.config.ts diff --git a/config/config.example.yml b/config/config.example.yml index 9abf167b90..c5a9ea6f85 100644 --- a/config/config.example.yml +++ b/config/config.example.yml @@ -310,3 +310,8 @@ info: markdown: enabled: false mathjax: false + +# Default collection/community sorting order at Advanced search, Create/update community and collection when there are not a query. +collectionSelectionSort: + sortMetadata: "dc.title" + sortDirection: "ASC" \ No newline at end of file diff --git a/config/config.yml b/config/config.yml index b5eecd112f..38ac562b15 100644 --- a/config/config.yml +++ b/config/config.yml @@ -1,5 +1,5 @@ rest: - ssl: true - host: api7.dspace.org - port: 443 + ssl: false + host: localhost + port: 9090 nameSpace: /server diff --git a/src/app/shared/dso-selector/dso-selector/dso-selector.component.ts b/src/app/shared/dso-selector/dso-selector/dso-selector.component.ts index 4b5d8c7614..52ca9224b1 100644 --- a/src/app/shared/dso-selector/dso-selector/dso-selector.component.ts +++ b/src/app/shared/dso-selector/dso-selector/dso-selector.component.ts @@ -227,6 +227,8 @@ export class DSOSelectorComponent implements OnInit, OnDestroy { * @param useCache Whether or not to use the cache */ search(query: string, page: number, useCache: boolean = true): Observable>>> { + // default sort is only used when there is not query + var efectiveSort=query?null:this.sort; return this.searchService.search( new PaginatedSearchOptions({ query: query, @@ -234,7 +236,7 @@ export class DSOSelectorComponent implements OnInit, OnDestroy { pagination: Object.assign({}, this.defaultPagination, { currentPage: page }), - sort: this.sort + sort: efectiveSort }), null, useCache, diff --git a/src/app/shared/dso-selector/modal-wrappers/create-community-parent-selector/create-community-parent-selector.component.ts b/src/app/shared/dso-selector/modal-wrappers/create-community-parent-selector/create-community-parent-selector.component.ts index f344c1c3f3..a7f583df50 100644 --- a/src/app/shared/dso-selector/modal-wrappers/create-community-parent-selector/create-community-parent-selector.component.ts +++ b/src/app/shared/dso-selector/modal-wrappers/create-community-parent-selector/create-community-parent-selector.component.ts @@ -12,7 +12,6 @@ import { getCommunityCreateRoute, COMMUNITY_PARENT_PARAMETER } from '../../../../community-page/community-page-routing-paths'; -import {SortDirection, SortOptions} from '../../../../core/cache/models/sort-options.model'; /** * Component to wrap a button - for top communities - @@ -31,11 +30,6 @@ export class CreateCommunityParentSelectorComponent extends DSOSelectorModalWrap selectorTypes = [DSpaceObjectType.COMMUNITY]; action = SelectorActionType.CREATE; - /** - * Default DSO ordering - */ - defaultSort = new SortOptions('dc.title', SortDirection.ASC); - constructor(protected activeModal: NgbActiveModal, protected route: ActivatedRoute, private router: Router) { super(activeModal, route); } diff --git a/src/app/shared/dso-selector/modal-wrappers/dso-selector-modal-wrapper.component.ts b/src/app/shared/dso-selector/modal-wrappers/dso-selector-modal-wrapper.component.ts index 2a25da2f72..fcb8aea9d2 100644 --- a/src/app/shared/dso-selector/modal-wrappers/dso-selector-modal-wrapper.component.ts +++ b/src/app/shared/dso-selector/modal-wrappers/dso-selector-modal-wrapper.component.ts @@ -5,7 +5,8 @@ import { RemoteData } from '../../../core/data/remote-data'; import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; import { DSpaceObjectType } from '../../../core/shared/dspace-object-type.model'; import { hasValue, isNotEmpty } from '../../empty.util'; -import {SortDirection, SortOptions} from '../../../core/cache/models/sort-options.model'; +import { SortDirection, SortOptions } from '../../../core/cache/models/sort-options.model'; +import { environment } from '../../../../environments/environment'; export enum SelectorActionType { CREATE = 'create', @@ -53,7 +54,7 @@ export abstract class DSOSelectorModalWrapperComponent implements OnInit { /** * Default DSO ordering */ - defaultSort = new SortOptions('dc.title', SortDirection.ASC); + defaultSort = new SortOptions(environment.collectionSelectionSort.sortMetadata, environment.collectionSelectionSort.sortDirection as SortDirection); constructor(protected activeModal: NgbActiveModal, protected route: ActivatedRoute) { } diff --git a/src/app/shared/search-form/scope-selector-modal/scope-selector-modal.component.ts b/src/app/shared/search-form/scope-selector-modal/scope-selector-modal.component.ts index 416242520c..86c3010287 100644 --- a/src/app/shared/search-form/scope-selector-modal/scope-selector-modal.component.ts +++ b/src/app/shared/search-form/scope-selector-modal/scope-selector-modal.component.ts @@ -4,7 +4,7 @@ import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; import { DSpaceObjectType } from '../../../core/shared/dspace-object-type.model'; import { DSOSelectorModalWrapperComponent, SelectorActionType } from '../../dso-selector/modal-wrappers/dso-selector-modal-wrapper.component'; import { DSpaceObject } from '../../../core/shared/dspace-object.model'; -import {SortDirection, SortOptions} from '../../../core/cache/models/sort-options.model'; + /** * Component to wrap a button - to select the entire repository - * and a list of parent communities - for scope selection @@ -33,11 +33,6 @@ export class ScopeSelectorModalComponent extends DSOSelectorModalWrapperComponen */ scopeChange = new EventEmitter(); - /** - * Default DSO ordering - */ - defaultSort = new SortOptions('dc.title', SortDirection.ASC); - constructor(protected activeModal: NgbActiveModal, protected route: ActivatedRoute) { super(activeModal, route); } diff --git a/src/config/app-config.interface.ts b/src/config/app-config.interface.ts index ce9c8b3bf7..cc7227d11e 100644 --- a/src/config/app-config.interface.ts +++ b/src/config/app-config.interface.ts @@ -20,6 +20,7 @@ import { InfoConfig } from './info-config.interface'; import { CommunityListConfig } from './community-list-config.interface'; import { HomeConfig } from './homepage-config.interface'; import { MarkdownConfig } from './markdown-config.interface'; +import { DiscoverySortConfig } from './discovery-sort.config'; interface AppConfig extends Config { ui: UIServerConfig; @@ -44,6 +45,7 @@ interface AppConfig extends Config { actuators: ActuatorsConfig info: InfoConfig; markdown: MarkdownConfig; + collectionSelectionSort: DiscoverySortConfig; } /** diff --git a/src/config/default-app-config.ts b/src/config/default-app-config.ts index 276d2d7150..572f757f86 100644 --- a/src/config/default-app-config.ts +++ b/src/config/default-app-config.ts @@ -20,6 +20,7 @@ import { InfoConfig } from './info-config.interface'; import { CommunityListConfig } from './community-list-config.interface'; import { HomeConfig } from './homepage-config.interface'; import { MarkdownConfig } from './markdown-config.interface'; +import { DiscoverySortConfig } from './discovery-sort.config'; export class DefaultAppConfig implements AppConfig { production = false; @@ -385,4 +386,10 @@ export class DefaultAppConfig implements AppConfig { enabled: false, mathjax: false, }; + + // Configuration that determines the metadata sorting of community and collection edition and creation when there are not a search query. + collectionSelectionSort: DiscoverySortConfig = { + sortMetadata:"dc.title", + sortDirection:"ASC", + }; } diff --git a/src/config/discovery-sort.config.ts b/src/config/discovery-sort.config.ts new file mode 100644 index 0000000000..02428f70a8 --- /dev/null +++ b/src/config/discovery-sort.config.ts @@ -0,0 +1,14 @@ +import { Config } from './config.interface'; + +/** + * Config that determines a metadata sorting config. + * It's created mainly to sort by metadata community and collection edition and creation + */ +export class DiscoverySortConfig implements Config { + + public sortMetadata: string; + /** + * ASC / DESC values expected + */ + public sortDirection: string; +} diff --git a/src/environments/environment.test.ts b/src/environments/environment.test.ts index 19eec26a14..2cdbee9c29 100644 --- a/src/environments/environment.test.ts +++ b/src/environments/environment.test.ts @@ -283,4 +283,8 @@ export const environment: BuildConfig = { enabled: false, mathjax: false, }, + collectionSelectionSort: { + sortMetadata:"dc.title", + sortDirection:"ASC", + }, }; From e2668cdf972e22ee5142427d551e48956848e342 Mon Sep 17 00:00:00 2001 From: aroman-arvo Date: Mon, 13 Feb 2023 12:22:07 +0100 Subject: [PATCH 08/23] DS-8408 - lint errors --- .../dso-selector/dso-selector/dso-selector.component.ts | 2 +- src/config/default-app-config.ts | 4 ++-- src/config/discovery-sort.config.ts | 2 +- src/environments/environment.test.ts | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/app/shared/dso-selector/dso-selector/dso-selector.component.ts b/src/app/shared/dso-selector/dso-selector/dso-selector.component.ts index 52ca9224b1..05fb512c9a 100644 --- a/src/app/shared/dso-selector/dso-selector/dso-selector.component.ts +++ b/src/app/shared/dso-selector/dso-selector/dso-selector.component.ts @@ -228,7 +228,7 @@ export class DSOSelectorComponent implements OnInit, OnDestroy { */ search(query: string, page: number, useCache: boolean = true): Observable>>> { // default sort is only used when there is not query - var efectiveSort=query?null:this.sort; + var efectiveSort=query ? null : this.sort; return this.searchService.search( new PaginatedSearchOptions({ query: query, diff --git a/src/config/default-app-config.ts b/src/config/default-app-config.ts index 095a20a4e5..89a627f459 100644 --- a/src/config/default-app-config.ts +++ b/src/config/default-app-config.ts @@ -425,7 +425,7 @@ export class DefaultAppConfig implements AppConfig { // Configuration that determines the metadata sorting of community and collection edition and creation when there are not a search query. collectionSelectionSort: DiscoverySortConfig = { - sortMetadata:"dc.title", - sortDirection:"ASC", + sortMetadata:'dc.title', + sortDirection:'ASC', }; } diff --git a/src/config/discovery-sort.config.ts b/src/config/discovery-sort.config.ts index 02428f70a8..3f08b3fb17 100644 --- a/src/config/discovery-sort.config.ts +++ b/src/config/discovery-sort.config.ts @@ -1,7 +1,7 @@ import { Config } from './config.interface'; /** - * Config that determines a metadata sorting config. + * Config that determines a metadata sorting config. * It's created mainly to sort by metadata community and collection edition and creation */ export class DiscoverySortConfig implements Config { diff --git a/src/environments/environment.test.ts b/src/environments/environment.test.ts index c352cdca92..8b132dab60 100644 --- a/src/environments/environment.test.ts +++ b/src/environments/environment.test.ts @@ -298,8 +298,8 @@ export const environment: BuildConfig = { mathjax: false, }, collectionSelectionSort: { - sortMetadata:"dc.title", - sortDirection:"ASC", + sortMetadata:'dc.title', + sortDirection:'ASC', }, vocabularies: [ From 0121e6d895de30c6c1054b8087fa6ecb1b7dd0bd Mon Sep 17 00:00:00 2001 From: aroman-arvo Date: Mon, 13 Feb 2023 12:34:13 +0100 Subject: [PATCH 09/23] DS-8408 - more lint problems --- .../shared/dso-selector/dso-selector/dso-selector.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/shared/dso-selector/dso-selector/dso-selector.component.ts b/src/app/shared/dso-selector/dso-selector/dso-selector.component.ts index 05fb512c9a..fe64c0a41e 100644 --- a/src/app/shared/dso-selector/dso-selector/dso-selector.component.ts +++ b/src/app/shared/dso-selector/dso-selector/dso-selector.component.ts @@ -228,7 +228,7 @@ export class DSOSelectorComponent implements OnInit, OnDestroy { */ search(query: string, page: number, useCache: boolean = true): Observable>>> { // default sort is only used when there is not query - var efectiveSort=query ? null : this.sort; + let efectiveSort = query ? null : this.sort; return this.searchService.search( new PaginatedSearchOptions({ query: query, From 742922dba04f3a189bdfab80bd2a57093adcb142 Mon Sep 17 00:00:00 2001 From: aroman-arvo Date: Mon, 13 Feb 2023 19:32:47 +0100 Subject: [PATCH 10/23] DS-8408: Test cases and some fixes or comcol ordering --- config/config.example.yml | 6 +-- .../dso-selector.component.spec.ts | 40 ++++++++++++++++++- ...te-collection-parent-selector.component.ts | 4 +- ...ate-community-parent-selector.component.ts | 5 ++- .../create-item-parent-selector.component.ts | 3 ++ .../dso-selector-modal-wrapper.component.ts | 5 +-- .../edit-collection-selector.component.ts | 5 ++- .../edit-community-selector.component.ts | 5 ++- .../scope-selector-modal.component.ts | 7 ++++ src/config/app-config.interface.ts | 2 +- src/config/default-app-config.ts | 4 +- src/config/discovery-sort.config.ts | 2 +- src/environments/environment.test.ts | 4 +- 13 files changed, 75 insertions(+), 17 deletions(-) diff --git a/config/config.example.yml b/config/config.example.yml index 5fad57c654..7c784b4a8e 100644 --- a/config/config.example.yml +++ b/config/config.example.yml @@ -371,6 +371,6 @@ vocabularies: enabled: true # Default collection/community sorting order at Advanced search, Create/update community and collection when there are not a query. -collectionSelectionSort: - sortMetadata: "dc.title" - sortDirection: "ASC" \ No newline at end of file +comcolSelectionSort: + sortMetadata: 'dc.title' + sortDirection: 'ASC' \ No newline at end of file diff --git a/src/app/shared/dso-selector/dso-selector/dso-selector.component.spec.ts b/src/app/shared/dso-selector/dso-selector/dso-selector.component.spec.ts index 7c28859388..e2acd17bc0 100644 --- a/src/app/shared/dso-selector/dso-selector/dso-selector.component.spec.ts +++ b/src/app/shared/dso-selector/dso-selector/dso-selector.component.spec.ts @@ -11,6 +11,7 @@ import { PaginatedSearchOptions } from '../../search/models/paginated-search-opt import { hasValue } from '../../empty.util'; import { createPaginatedList } from '../../testing/utils.test'; import { NotificationsService } from '../../notifications/notifications.service'; +import { SortDirection, SortOptions } from '../../../core/cache/models/sort-options.model'; describe('DSOSelectorComponent', () => { let component: DSOSelectorComponent; @@ -34,7 +35,7 @@ describe('DSOSelectorComponent', () => { ]; const searchService = { - search: (options: PaginatedSearchOptions) => { + search: (options: PaginatedSearchOptions, responseMsToLive?: number, useCachedVersionIfAvailable = true) => { if (hasValue(options.query) && options.query.startsWith('search.resourceid')) { return createSuccessfulRemoteDataObject$(createPaginatedList([searchResult])); } else if (options.pagination.currentPage === 1) { @@ -120,6 +121,43 @@ describe('DSOSelectorComponent', () => { }); }); + describe('search', () => { + beforeEach(() => { + spyOn(searchService, 'search').and.callThrough(); + }); + + it('should specify how to sort if no query is given', () => { + component.sort = new SortOptions('dc.title', SortDirection.ASC); + component.search(undefined, 0); + + expect(searchService.search).toHaveBeenCalledWith( + jasmine.objectContaining({ + query: undefined, + sort: jasmine.objectContaining({ + field: 'dc.title', + direction: SortDirection.ASC, + }), + }), + null, + true + ); + }); + + it('should not specify how to sort if a query is given', () => { + component.sort = new SortOptions('dc.title', SortDirection.ASC); + component.search('testQuery', 0); + + expect(searchService.search).toHaveBeenCalledWith( + jasmine.objectContaining({ + query: 'testQuery', + sort: null, + }), + null, + true + ); + }); + }); + describe('when search returns an error', () => { beforeEach(() => { spyOn(searchService, 'search').and.returnValue(createFailedRemoteDataObject$()); diff --git a/src/app/shared/dso-selector/modal-wrappers/create-collection-parent-selector/create-collection-parent-selector.component.ts b/src/app/shared/dso-selector/modal-wrappers/create-collection-parent-selector/create-collection-parent-selector.component.ts index 8b38b62378..e0b7c1675b 100644 --- a/src/app/shared/dso-selector/modal-wrappers/create-collection-parent-selector/create-collection-parent-selector.component.ts +++ b/src/app/shared/dso-selector/modal-wrappers/create-collection-parent-selector/create-collection-parent-selector.component.ts @@ -8,7 +8,8 @@ import { getCollectionCreateRoute, COLLECTION_PARENT_PARAMETER } from '../../../../collection-page/collection-page-routing-paths'; - +import { SortDirection, SortOptions } from '../../../../core/cache/models/sort-options.model'; +import { environment } from '../../../../../environments/environment'; /** * Component to wrap a list of existing communities inside a modal * Used to choose a community from to create a new collection in @@ -23,6 +24,7 @@ export class CreateCollectionParentSelectorComponent extends DSOSelectorModalWra selectorTypes = [DSpaceObjectType.COMMUNITY]; action = SelectorActionType.CREATE; header = 'dso-selector.create.collection.sub-level'; + defaultSort = new SortOptions(environment.comcolSelectionSort.sortField, environment.comcolSelectionSort.sortDirection as SortDirection); constructor(protected activeModal: NgbActiveModal, protected route: ActivatedRoute, private router: Router) { super(activeModal, route); diff --git a/src/app/shared/dso-selector/modal-wrappers/create-community-parent-selector/create-community-parent-selector.component.ts b/src/app/shared/dso-selector/modal-wrappers/create-community-parent-selector/create-community-parent-selector.component.ts index a7f583df50..005c0e5f23 100644 --- a/src/app/shared/dso-selector/modal-wrappers/create-community-parent-selector/create-community-parent-selector.component.ts +++ b/src/app/shared/dso-selector/modal-wrappers/create-community-parent-selector/create-community-parent-selector.component.ts @@ -12,6 +12,8 @@ import { getCommunityCreateRoute, COMMUNITY_PARENT_PARAMETER } from '../../../../community-page/community-page-routing-paths'; +import { SortDirection, SortOptions } from '../../../../core/cache/models/sort-options.model'; +import { environment } from '../../../../../environments/environment'; /** * Component to wrap a button - for top communities - @@ -29,7 +31,8 @@ export class CreateCommunityParentSelectorComponent extends DSOSelectorModalWrap objectType = DSpaceObjectType.COMMUNITY; selectorTypes = [DSpaceObjectType.COMMUNITY]; action = SelectorActionType.CREATE; - + defaultSort = new SortOptions(environment.comcolSelectionSort.sortField, environment.comcolSelectionSort.sortDirection as SortDirection); + constructor(protected activeModal: NgbActiveModal, protected route: ActivatedRoute, private router: Router) { super(activeModal, route); } diff --git a/src/app/shared/dso-selector/modal-wrappers/create-item-parent-selector/create-item-parent-selector.component.ts b/src/app/shared/dso-selector/modal-wrappers/create-item-parent-selector/create-item-parent-selector.component.ts index b109be0af2..ed8a7b0780 100644 --- a/src/app/shared/dso-selector/modal-wrappers/create-item-parent-selector/create-item-parent-selector.component.ts +++ b/src/app/shared/dso-selector/modal-wrappers/create-item-parent-selector/create-item-parent-selector.component.ts @@ -4,6 +4,8 @@ import { DSpaceObjectType } from '../../../../core/shared/dspace-object-type.mod import { DSpaceObject } from '../../../../core/shared/dspace-object.model'; import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; import { DSOSelectorModalWrapperComponent, SelectorActionType } from '../dso-selector-modal-wrapper.component'; +import { SortDirection, SortOptions } from '../../../../core/cache/models/sort-options.model'; +import { environment } from '../../../../../environments/environment'; /** * Component to wrap a list of existing collections inside a modal @@ -21,6 +23,7 @@ export class CreateItemParentSelectorComponent extends DSOSelectorModalWrapperCo selectorTypes = [DSpaceObjectType.COLLECTION]; action = SelectorActionType.CREATE; header = 'dso-selector.create.item.sub-level'; + defaultSort = new SortOptions(environment.comcolSelectionSort.sortField, environment.comcolSelectionSort.sortDirection as SortDirection); /** * If present this value is used to filter collection list by entity type diff --git a/src/app/shared/dso-selector/modal-wrappers/dso-selector-modal-wrapper.component.ts b/src/app/shared/dso-selector/modal-wrappers/dso-selector-modal-wrapper.component.ts index fcb8aea9d2..3f81687c9f 100644 --- a/src/app/shared/dso-selector/modal-wrappers/dso-selector-modal-wrapper.component.ts +++ b/src/app/shared/dso-selector/modal-wrappers/dso-selector-modal-wrapper.component.ts @@ -5,8 +5,7 @@ import { RemoteData } from '../../../core/data/remote-data'; import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; import { DSpaceObjectType } from '../../../core/shared/dspace-object-type.model'; import { hasValue, isNotEmpty } from '../../empty.util'; -import { SortDirection, SortOptions } from '../../../core/cache/models/sort-options.model'; -import { environment } from '../../../../environments/environment'; +import { SortOptions } from '../../../core/cache/models/sort-options.model'; export enum SelectorActionType { CREATE = 'create', @@ -54,7 +53,7 @@ export abstract class DSOSelectorModalWrapperComponent implements OnInit { /** * Default DSO ordering */ - defaultSort = new SortOptions(environment.collectionSelectionSort.sortMetadata, environment.collectionSelectionSort.sortDirection as SortDirection); + defaultSort: SortOptions; constructor(protected activeModal: NgbActiveModal, protected route: ActivatedRoute) { } diff --git a/src/app/shared/dso-selector/modal-wrappers/edit-collection-selector/edit-collection-selector.component.ts b/src/app/shared/dso-selector/modal-wrappers/edit-collection-selector/edit-collection-selector.component.ts index cfc2ea282d..ed117995b8 100644 --- a/src/app/shared/dso-selector/modal-wrappers/edit-collection-selector/edit-collection-selector.component.ts +++ b/src/app/shared/dso-selector/modal-wrappers/edit-collection-selector/edit-collection-selector.component.ts @@ -8,6 +8,8 @@ import { SelectorActionType } from '../dso-selector-modal-wrapper.component'; import { getCollectionEditRoute } from '../../../../collection-page/collection-page-routing-paths'; +import { SortDirection, SortOptions } from '../../../../core/cache/models/sort-options.model'; +import { environment } from '../../../../../environments/environment'; /** * Component to wrap a list of existing collections inside a modal @@ -22,7 +24,8 @@ export class EditCollectionSelectorComponent extends DSOSelectorModalWrapperComp objectType = DSpaceObjectType.COLLECTION; selectorTypes = [DSpaceObjectType.COLLECTION]; action = SelectorActionType.EDIT; - + defaultSort = new SortOptions(environment.comcolSelectionSort.sortField, environment.comcolSelectionSort.sortDirection as SortDirection); + constructor(protected activeModal: NgbActiveModal, protected route: ActivatedRoute, private router: Router) { super(activeModal, route); } diff --git a/src/app/shared/dso-selector/modal-wrappers/edit-community-selector/edit-community-selector.component.ts b/src/app/shared/dso-selector/modal-wrappers/edit-community-selector/edit-community-selector.component.ts index d73a7b48c5..ce09cd498e 100644 --- a/src/app/shared/dso-selector/modal-wrappers/edit-community-selector/edit-community-selector.component.ts +++ b/src/app/shared/dso-selector/modal-wrappers/edit-community-selector/edit-community-selector.component.ts @@ -8,6 +8,8 @@ import { SelectorActionType } from '../dso-selector-modal-wrapper.component'; import { getCommunityEditRoute } from '../../../../community-page/community-page-routing-paths'; +import { SortDirection, SortOptions } from '../../../../core/cache/models/sort-options.model'; +import { environment } from '../../../../../environments/environment'; /** * Component to wrap a list of existing communities inside a modal @@ -23,7 +25,8 @@ export class EditCommunitySelectorComponent extends DSOSelectorModalWrapperCompo objectType = DSpaceObjectType.COMMUNITY; selectorTypes = [DSpaceObjectType.COMMUNITY]; action = SelectorActionType.EDIT; - + defaultSort = new SortOptions(environment.comcolSelectionSort.sortField, environment.comcolSelectionSort.sortDirection as SortDirection); + constructor(protected activeModal: NgbActiveModal, protected route: ActivatedRoute, private router: Router) { super(activeModal, route); } diff --git a/src/app/shared/search-form/scope-selector-modal/scope-selector-modal.component.ts b/src/app/shared/search-form/scope-selector-modal/scope-selector-modal.component.ts index 86c3010287..3301435956 100644 --- a/src/app/shared/search-form/scope-selector-modal/scope-selector-modal.component.ts +++ b/src/app/shared/search-form/scope-selector-modal/scope-selector-modal.component.ts @@ -4,6 +4,8 @@ import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; import { DSpaceObjectType } from '../../../core/shared/dspace-object-type.model'; import { DSOSelectorModalWrapperComponent, SelectorActionType } from '../../dso-selector/modal-wrappers/dso-selector-modal-wrapper.component'; import { DSpaceObject } from '../../../core/shared/dspace-object.model'; +import { SortDirection, SortOptions } from '../../../core/cache/models/sort-options.model'; +import { environment } from '../../../../environments/environment'; /** * Component to wrap a button - to select the entire repository - @@ -33,6 +35,11 @@ export class ScopeSelectorModalComponent extends DSOSelectorModalWrapperComponen */ scopeChange = new EventEmitter(); + /** + * Default DSO ordering + */ + defaultSort = new SortOptions(environment.comcolSelectionSort.sortField, environment.comcolSelectionSort.sortDirection as SortDirection); + constructor(protected activeModal: NgbActiveModal, protected route: ActivatedRoute) { super(activeModal, route); } diff --git a/src/config/app-config.interface.ts b/src/config/app-config.interface.ts index 1bc3e33b8a..e3f8988744 100644 --- a/src/config/app-config.interface.ts +++ b/src/config/app-config.interface.ts @@ -47,7 +47,7 @@ interface AppConfig extends Config { info: InfoConfig; markdown: MarkdownConfig; vocabularies: FilterVocabularyConfig[]; - collectionSelectionSort: DiscoverySortConfig; + comcolSelectionSort: DiscoverySortConfig; } /** diff --git a/src/config/default-app-config.ts b/src/config/default-app-config.ts index 89a627f459..67c2feada8 100644 --- a/src/config/default-app-config.ts +++ b/src/config/default-app-config.ts @@ -424,8 +424,8 @@ export class DefaultAppConfig implements AppConfig { ]; // Configuration that determines the metadata sorting of community and collection edition and creation when there are not a search query. - collectionSelectionSort: DiscoverySortConfig = { - sortMetadata:'dc.title', + comcolSelectionSort: DiscoverySortConfig = { + sortField:'dc.title', sortDirection:'ASC', }; } diff --git a/src/config/discovery-sort.config.ts b/src/config/discovery-sort.config.ts index 3f08b3fb17..c0d5e5e391 100644 --- a/src/config/discovery-sort.config.ts +++ b/src/config/discovery-sort.config.ts @@ -6,7 +6,7 @@ import { Config } from './config.interface'; */ export class DiscoverySortConfig implements Config { - public sortMetadata: string; + public sortField: string; /** * ASC / DESC values expected */ diff --git a/src/environments/environment.test.ts b/src/environments/environment.test.ts index 8b132dab60..08d7739f7d 100644 --- a/src/environments/environment.test.ts +++ b/src/environments/environment.test.ts @@ -297,8 +297,8 @@ export const environment: BuildConfig = { enabled: false, mathjax: false, }, - collectionSelectionSort: { - sortMetadata:'dc.title', + comcolSelectionSort: { + sortField:'dc.title', sortDirection:'ASC', }, From 9a2b885501dddda76ead69184ce48680cd791e28 Mon Sep 17 00:00:00 2001 From: aroman-arvo Date: Mon, 13 Feb 2023 19:38:32 +0100 Subject: [PATCH 11/23] DS-8498: ling fixes --- .../create-community-parent-selector.component.ts | 2 +- .../edit-collection-selector.component.ts | 2 +- .../edit-community-selector.component.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/shared/dso-selector/modal-wrappers/create-community-parent-selector/create-community-parent-selector.component.ts b/src/app/shared/dso-selector/modal-wrappers/create-community-parent-selector/create-community-parent-selector.component.ts index 005c0e5f23..77458d9802 100644 --- a/src/app/shared/dso-selector/modal-wrappers/create-community-parent-selector/create-community-parent-selector.component.ts +++ b/src/app/shared/dso-selector/modal-wrappers/create-community-parent-selector/create-community-parent-selector.component.ts @@ -32,7 +32,7 @@ export class CreateCommunityParentSelectorComponent extends DSOSelectorModalWrap selectorTypes = [DSpaceObjectType.COMMUNITY]; action = SelectorActionType.CREATE; defaultSort = new SortOptions(environment.comcolSelectionSort.sortField, environment.comcolSelectionSort.sortDirection as SortDirection); - + constructor(protected activeModal: NgbActiveModal, protected route: ActivatedRoute, private router: Router) { super(activeModal, route); } diff --git a/src/app/shared/dso-selector/modal-wrappers/edit-collection-selector/edit-collection-selector.component.ts b/src/app/shared/dso-selector/modal-wrappers/edit-collection-selector/edit-collection-selector.component.ts index ed117995b8..fd54cd44ed 100644 --- a/src/app/shared/dso-selector/modal-wrappers/edit-collection-selector/edit-collection-selector.component.ts +++ b/src/app/shared/dso-selector/modal-wrappers/edit-collection-selector/edit-collection-selector.component.ts @@ -25,7 +25,7 @@ export class EditCollectionSelectorComponent extends DSOSelectorModalWrapperComp selectorTypes = [DSpaceObjectType.COLLECTION]; action = SelectorActionType.EDIT; defaultSort = new SortOptions(environment.comcolSelectionSort.sortField, environment.comcolSelectionSort.sortDirection as SortDirection); - + constructor(protected activeModal: NgbActiveModal, protected route: ActivatedRoute, private router: Router) { super(activeModal, route); } diff --git a/src/app/shared/dso-selector/modal-wrappers/edit-community-selector/edit-community-selector.component.ts b/src/app/shared/dso-selector/modal-wrappers/edit-community-selector/edit-community-selector.component.ts index ce09cd498e..cf2f97c6d3 100644 --- a/src/app/shared/dso-selector/modal-wrappers/edit-community-selector/edit-community-selector.component.ts +++ b/src/app/shared/dso-selector/modal-wrappers/edit-community-selector/edit-community-selector.component.ts @@ -26,7 +26,7 @@ export class EditCommunitySelectorComponent extends DSOSelectorModalWrapperCompo selectorTypes = [DSpaceObjectType.COMMUNITY]; action = SelectorActionType.EDIT; defaultSort = new SortOptions(environment.comcolSelectionSort.sortField, environment.comcolSelectionSort.sortDirection as SortDirection); - + constructor(protected activeModal: NgbActiveModal, protected route: ActivatedRoute, private router: Router) { super(activeModal, route); } From 1d00b431acd74895064fc56ab57b842e0f8e5106 Mon Sep 17 00:00:00 2001 From: cris Date: Tue, 14 Feb 2023 03:18:28 +0000 Subject: [PATCH 12/23] aria-label added to edit, view and delete button --- .../workspaceitem/workspaceitem-actions.component.html | 5 ++++- src/assets/i18n/en.json5 | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/app/shared/mydspace-actions/workspaceitem/workspaceitem-actions.component.html b/src/app/shared/mydspace-actions/workspaceitem/workspaceitem-actions.component.html index c658651790..f789f4df47 100644 --- a/src/app/shared/mydspace-actions/workspaceitem/workspaceitem-actions.component.html +++ b/src/app/shared/mydspace-actions/workspaceitem/workspaceitem-actions.component.html @@ -2,18 +2,21 @@ {{'submission.workflow.generic.edit' | translate}} - + \ No newline at end of file diff --git a/src/assets/i18n/en.json5 b/src/assets/i18n/en.json5 index fa6f2694fa..3491c066a1 100644 --- a/src/assets/i18n/en.json5 +++ b/src/assets/i18n/en.json5 @@ -4635,7 +4635,7 @@ "submission.workflow.generic.delete": "Delete", - "submission.workflow.generic.delete-help": "If you would to discard this item, select \"Delete\". You will then be asked to confirm it.", + "submission.workflow.generic.delete-help": "Select this option if you would to discard this item, select \"Delete\". You will then be asked to confirm it.", "submission.workflow.generic.edit": "Edit", From 938bf33ad24bc8d0545c8fc936bfc6bcaadf93d0 Mon Sep 17 00:00:00 2001 From: aroman-arvo Date: Wed, 15 Feb 2023 19:20:20 +0100 Subject: [PATCH 13/23] DS-8404 - fix config param name --- config/config.example.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.example.yml b/config/config.example.yml index 7c784b4a8e..f1e6be76aa 100644 --- a/config/config.example.yml +++ b/config/config.example.yml @@ -372,5 +372,5 @@ vocabularies: # Default collection/community sorting order at Advanced search, Create/update community and collection when there are not a query. comcolSelectionSort: - sortMetadata: 'dc.title' + sortField: 'dc.title' sortDirection: 'ASC' \ No newline at end of file From 718db3466deefcd733b39e069559e61bc07d9a60 Mon Sep 17 00:00:00 2001 From: Alexandre Vryghem Date: Thu, 19 Jan 2023 00:07:57 +0100 Subject: [PATCH 14/23] Fixed false positive tests caused by fixture.debugElement.query().toBeDefined() --- .../members-list.component.spec.ts | 84 ++++++++++--------- .../members-list/members-list.component.ts | 1 + .../subgroups-list.component.spec.ts | 69 +++++++-------- .../core/locale/locale.interceptor.spec.ts | 2 +- src/app/core/xsrf/xsrf.interceptor.spec.ts | 8 +- .../full/full-item-page.component.spec.ts | 12 ++- .../mirador-viewer.component.spec.ts | 2 +- .../file-section.component.spec.ts | 2 +- ...item-page-abstract-field.component.spec.ts | 2 +- .../browse-by/browse-by.component.spec.ts | 37 +++++--- .../lang-switch/lang-switch.component.spec.ts | 2 +- ...med-task-actions-approve.component.spec.ts | 4 +- ...sk-actions-edit-metadata.component.spec.ts | 2 +- ...imed-task-actions-reject.component.spec.ts | 4 +- ...k-actions-return-to-pool.component.spec.ts | 4 +- .../pool-task-actions.component.spec.ts | 6 +- .../workflowitem-actions.component.spec.ts | 4 +- .../workspaceitem-actions.component.spec.ts | 8 +- .../object-collection.component.spec.ts | 23 +++-- .../my-dspace-item-status.component.spec.ts | 2 +- .../item-submitter.component.spec.ts | 2 +- .../page-size-selector.component.spec.ts | 11 +-- .../search-settings.component.spec.ts | 6 +- ...rch-switch-configuration.component.spec.ts | 2 +- ...mission-form-section-add.component.spec.ts | 3 +- .../section-container.component.spec.ts | 12 +-- 26 files changed, 168 insertions(+), 146 deletions(-) diff --git a/src/app/access-control/group-registry/group-form/members-list/members-list.component.spec.ts b/src/app/access-control/group-registry/group-form/members-list/members-list.component.spec.ts index 8d0ddf0a85..4cf018445c 100644 --- a/src/app/access-control/group-registry/group-form/members-list/members-list.component.spec.ts +++ b/src/app/access-control/group-registry/group-form/members-list/members-list.component.spec.ts @@ -1,5 +1,5 @@ import { CommonModule } from '@angular/common'; -import { NO_ERRORS_SCHEMA } from '@angular/core'; +import { DebugElement, NO_ERRORS_SCHEMA } from '@angular/core'; import { ComponentFixture, fakeAsync, flush, inject, TestBed, tick, waitForAsync } from '@angular/core/testing'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { BrowserModule, By } from '@angular/platform-browser'; @@ -37,10 +37,10 @@ describe('MembersListComponent', () => { let ePersonDataServiceStub: any; let groupsDataServiceStub: any; let activeGroup; - let allEPersons; - let allGroups; - let epersonMembers; - let subgroupMembers; + let allEPersons: EPerson[]; + let allGroups: Group[]; + let epersonMembers: EPerson[]; + let subgroupMembers: Group[]; let paginationService; beforeEach(waitForAsync(() => { @@ -53,7 +53,7 @@ describe('MembersListComponent', () => { activeGroup: activeGroup, epersonMembers: epersonMembers, subgroupMembers: subgroupMembers, - findListByHref(href: string): Observable>> { + findListByHref(_href: string): Observable>> { return createSuccessfulRemoteDataObject$(buildPaginatedList(new PageInfo(), groupsDataServiceStub.getEPersonMembers())); }, searchByScope(scope: string, query: string): Observable>> { @@ -147,6 +147,7 @@ describe('MembersListComponent', () => { }); afterEach(fakeAsync(() => { fixture.destroy(); + fixture.debugElement.nativeElement.remove(); flush(); component = null; })); @@ -167,12 +168,19 @@ describe('MembersListComponent', () => { describe('search', () => { describe('when searching without query', () => { - let epersonsFound; + let epersonsFound: DebugElement[]; beforeEach(fakeAsync(() => { + spyOn(component, 'isMemberOfGroup').and.callFake((ePerson: EPerson) => { + return observableOf(activeGroup.epersons.includes(ePerson)); + }); component.search({ scope: 'metadata', query: '' }); tick(); fixture.detectChanges(); epersonsFound = fixture.debugElement.queryAll(By.css('#epersonsSearch tbody tr')); + // Stop using the fake spy function (because otherwise the clicking on the buttons will not change anything + // because they don't change the value of activeGroup.epersons) + jasmine.getEnv().allowRespy(true); + spyOn(component, 'isMemberOfGroup').and.callThrough(); })); it('should display all epersons', () => { @@ -181,62 +189,56 @@ describe('MembersListComponent', () => { describe('if eperson is already a eperson', () => { it('should have delete button, else it should have add button', () => { - activeGroup.epersons.map((eperson: EPerson) => { - epersonsFound.map((foundEPersonRowElement) => { - if (foundEPersonRowElement.debugElement !== undefined) { - const epersonId = foundEPersonRowElement.debugElement.query(By.css('td:first-child')); - const addButton = foundEPersonRowElement.debugElement.query(By.css('td:last-child .fa-plus')); - const deleteButton = foundEPersonRowElement.debugElement.query(By.css('td:last-child .fa-trash-alt')); - if (epersonId.nativeElement.textContent === eperson.id) { - expect(addButton).toBeUndefined(); - expect(deleteButton).toBeDefined(); - } else { - expect(deleteButton).toBeUndefined(); - expect(addButton).toBeDefined(); - } - } - }); + const memberIds: string[] = activeGroup.epersons.map((ePerson: EPerson) => ePerson.id); + epersonsFound.map((foundEPersonRowElement: DebugElement) => { + const epersonId: DebugElement = foundEPersonRowElement.query(By.css('td:first-child')); + const addButton: DebugElement = foundEPersonRowElement.query(By.css('td:last-child .fa-plus')); + const deleteButton: DebugElement = foundEPersonRowElement.query(By.css('td:last-child .fa-trash-alt')); + if (memberIds.includes(epersonId.nativeElement.textContent)) { + expect(addButton).toBeNull(); + expect(deleteButton).not.toBeNull(); + } else { + expect(deleteButton).toBeNull(); + expect(addButton).not.toBeNull(); + } }); }); }); describe('if first add button is pressed', () => { beforeEach(fakeAsync(() => { - const addButton = fixture.debugElement.query(By.css('#epersonsSearch tbody .fa-plus')); + const addButton: DebugElement = fixture.debugElement.query(By.css('#epersonsSearch tbody .fa-plus')); addButton.nativeElement.click(); tick(); fixture.detectChanges(); })); - it('all groups in search member of selected group', () => { + it('then all the ePersons are member of the active group', () => { epersonsFound = fixture.debugElement.queryAll(By.css('#epersonsSearch tbody tr')); expect(epersonsFound.length).toEqual(2); - epersonsFound.map((foundEPersonRowElement) => { - if (foundEPersonRowElement.debugElement !== undefined) { - const addButton = foundEPersonRowElement.debugElement.query(By.css('td:last-child .fa-plus')); - const deleteButton = foundEPersonRowElement.debugElement.query(By.css('td:last-child .fa-trash-alt')); - expect(addButton).toBeUndefined(); - expect(deleteButton).toBeDefined(); - } + epersonsFound.map((foundEPersonRowElement: DebugElement) => { + const addButton: DebugElement = foundEPersonRowElement.query(By.css('td:last-child .fa-plus')); + const deleteButton: DebugElement = foundEPersonRowElement.query(By.css('td:last-child .fa-trash-alt')); + expect(addButton).toBeNull(); + expect(deleteButton).not.toBeNull(); }); }); }); describe('if first delete button is pressed', () => { beforeEach(fakeAsync(() => { - const addButton = fixture.debugElement.query(By.css('#epersonsSearch tbody .fa-trash-alt')); - addButton.nativeElement.click(); + const deleteButton: DebugElement = fixture.debugElement.query(By.css('#epersonsSearch tbody .fa-trash-alt')); + deleteButton.nativeElement.click(); tick(); fixture.detectChanges(); })); - it('first eperson in search delete button, because now member', () => { + it('then no ePerson is member of the active group', () => { epersonsFound = fixture.debugElement.queryAll(By.css('#epersonsSearch tbody tr')); - epersonsFound.map((foundEPersonRowElement) => { - if (foundEPersonRowElement.debugElement !== undefined) { - const addButton = foundEPersonRowElement.debugElement.query(By.css('td:last-child .fa-plus')); - const deleteButton = foundEPersonRowElement.debugElement.query(By.css('td:last-child .fa-trash-alt')); - expect(deleteButton).toBeUndefined(); - expect(addButton).toBeDefined(); - } + expect(epersonsFound.length).toEqual(2); + epersonsFound.map((foundEPersonRowElement: DebugElement) => { + const addButton: DebugElement = foundEPersonRowElement.query(By.css('td:last-child .fa-plus')); + const deleteButton: DebugElement = foundEPersonRowElement.query(By.css('td:last-child .fa-trash-alt')); + expect(deleteButton).toBeNull(); + expect(addButton).not.toBeNull(); }); }); }); diff --git a/src/app/access-control/group-registry/group-form/members-list/members-list.component.ts b/src/app/access-control/group-registry/group-form/members-list/members-list.component.ts index 169d009d63..c569522be4 100644 --- a/src/app/access-control/group-registry/group-form/members-list/members-list.component.ts +++ b/src/app/access-control/group-registry/group-form/members-list/members-list.component.ts @@ -205,6 +205,7 @@ export class MembersListComponent implements OnInit, OnDestroy { * @param ePerson EPerson we want to delete as member from group that is currently being edited */ deleteMemberFromGroup(ePerson: EpersonDtoModel) { + ePerson.memberOfGroup = false; this.groupDataService.getActiveGroup().pipe(take(1)).subscribe((activeGroup: Group) => { if (activeGroup != null) { const response = this.groupDataService.deleteMemberFromGroup(activeGroup, ePerson.eperson); diff --git a/src/app/access-control/group-registry/group-form/subgroup-list/subgroups-list.component.spec.ts b/src/app/access-control/group-registry/group-form/subgroup-list/subgroups-list.component.spec.ts index 1ca6c88c5f..ff0fd121af 100644 --- a/src/app/access-control/group-registry/group-form/subgroup-list/subgroups-list.component.spec.ts +++ b/src/app/access-control/group-registry/group-form/subgroup-list/subgroups-list.component.spec.ts @@ -1,14 +1,6 @@ import { CommonModule } from '@angular/common'; -import { NO_ERRORS_SCHEMA } from '@angular/core'; -import { - ComponentFixture, - fakeAsync, - flush, - inject, - TestBed, - tick, - waitForAsync -} from '@angular/core/testing'; +import { NO_ERRORS_SCHEMA, DebugElement } from '@angular/core'; +import { ComponentFixture, fakeAsync, flush, inject, TestBed, tick, waitForAsync } from '@angular/core/testing'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { BrowserModule, By } from '@angular/platform-browser'; import { Router } from '@angular/router'; @@ -46,8 +38,8 @@ describe('SubgroupsListComponent', () => { let ePersonDataServiceStub: any; let groupsDataServiceStub: any; let activeGroup; - let subgroups; - let allGroups; + let subgroups: Group[]; + let allGroups: Group[]; let routerStub; let paginationService; @@ -65,7 +57,7 @@ describe('SubgroupsListComponent', () => { getSubgroups(): Group { return this.activeGroup; }, - findListByHref(href: string): Observable>> { + findListByHref(_href: string): Observable>> { return this.subgroups$.pipe( map((currentGroups: Group[]) => { return createSuccessfulRemoteDataObject(buildPaginatedList(new PageInfo(), currentGroups)); @@ -133,6 +125,7 @@ describe('SubgroupsListComponent', () => { }); afterEach(fakeAsync(() => { fixture.destroy(); + fixture.debugElement.nativeElement.remove(); flush(); component = null; })); @@ -152,7 +145,7 @@ describe('SubgroupsListComponent', () => { }); describe('if first group delete button is pressed', () => { - let groupsFound; + let groupsFound: DebugElement[]; beforeEach(fakeAsync(() => { const addButton = fixture.debugElement.query(By.css('#subgroupsOfGroup tbody .deleteButton')); addButton.triggerEventHandler('click', { @@ -170,7 +163,7 @@ describe('SubgroupsListComponent', () => { describe('search', () => { describe('when searching with empty query', () => { - let groupsFound; + let groupsFound: DebugElement[]; beforeEach(fakeAsync(() => { component.search({ query: '' }); groupsFound = fixture.debugElement.queryAll(By.css('#groupsSearch tbody tr')); @@ -181,9 +174,9 @@ describe('SubgroupsListComponent', () => { groupsFound = fixture.debugElement.queryAll(By.css('#groupsSearch tbody tr')); expect(groupsFound.length).toEqual(2); groupsFound = fixture.debugElement.queryAll(By.css('#groupsSearch tbody tr')); - const groupIdsFound = fixture.debugElement.queryAll(By.css('#groupsSearch tbody tr td:first-child')); + const groupIdsFound: DebugElement[] = fixture.debugElement.queryAll(By.css('#groupsSearch tbody tr td:first-child')); allGroups.map((group: Group) => { - expect(groupIdsFound.find((foundEl) => { + expect(groupIdsFound.find((foundEl: DebugElement) => { return (foundEl.nativeElement.textContent.trim() === group.uuid); })).toBeTruthy(); }); @@ -195,30 +188,30 @@ describe('SubgroupsListComponent', () => { groupsFound = fixture.debugElement.queryAll(By.css('#groupsSearch tbody tr')); const getSubgroups = groupsDataServiceStub.getSubgroups().subgroups; if (getSubgroups !== undefined && getSubgroups.length > 0) { - groupsFound.map((foundGroupRowElement) => { - if (foundGroupRowElement.debugElement !== undefined) { - const addButton = foundGroupRowElement.debugElement.query(By.css('td:last-child .fa-plus')); - const deleteButton = foundGroupRowElement.debugElement.query(By.css('td:last-child .fa-trash-alt')); - expect(addButton).toBeUndefined(); - expect(deleteButton).toBeDefined(); + groupsFound.map((foundGroupRowElement: DebugElement) => { + const groupId: DebugElement = foundGroupRowElement.query(By.css('td:first-child')); + const addButton: DebugElement = foundGroupRowElement.query(By.css('td:last-child .fa-plus')); + const deleteButton: DebugElement = foundGroupRowElement.query(By.css('td:last-child .fa-trash-alt')); + expect(addButton).toBeNull(); + if (activeGroup.id === groupId.nativeElement.textContent) { + expect(deleteButton).toBeNull(); + } else { + expect(deleteButton).not.toBeNull(); } }); } else { - getSubgroups.map((group: Group) => { - groupsFound.map((foundGroupRowElement) => { - if (foundGroupRowElement.debugElement !== undefined) { - const groupId = foundGroupRowElement.debugElement.query(By.css('td:first-child')); - const addButton = foundGroupRowElement.debugElement.query(By.css('td:last-child .fa-plus')); - const deleteButton = foundGroupRowElement.debugElement.query(By.css('td:last-child .fa-trash-alt')); - if (groupId.nativeElement.textContent === group.id) { - expect(addButton).toBeUndefined(); - expect(deleteButton).toBeDefined(); - } else { - expect(deleteButton).toBeUndefined(); - expect(addButton).toBeDefined(); - } - } - }); + const subgroupIds: string[] = activeGroup.subgroups.map((group: Group) => group.id); + groupsFound.map((foundGroupRowElement: DebugElement) => { + const groupId: DebugElement = foundGroupRowElement.query(By.css('td:first-child')); + const addButton: DebugElement = foundGroupRowElement.query(By.css('td:last-child .fa-plus')); + const deleteButton: DebugElement = foundGroupRowElement.query(By.css('td:last-child .fa-trash-alt')); + if (subgroupIds.includes(groupId.nativeElement.textContent)) { + expect(addButton).toBeNull(); + expect(deleteButton).not.toBeNull(); + } else { + expect(deleteButton).toBeNull(); + expect(addButton).not.toBeNull(); + } }); } }); diff --git a/src/app/core/locale/locale.interceptor.spec.ts b/src/app/core/locale/locale.interceptor.spec.ts index 9e298fefcc..e96126d19c 100644 --- a/src/app/core/locale/locale.interceptor.spec.ts +++ b/src/app/core/locale/locale.interceptor.spec.ts @@ -52,7 +52,7 @@ describe(`LocaleInterceptor`, () => { expect(httpRequest.request.headers.has('Accept-Language')); const lang = httpRequest.request.headers.get('Accept-Language'); - expect(lang).toBeDefined(); + expect(lang).not.toBeNull(); expect(lang).toBe(languageList.toString()); }); diff --git a/src/app/core/xsrf/xsrf.interceptor.spec.ts b/src/app/core/xsrf/xsrf.interceptor.spec.ts index 742c4a4a45..4a78b60fc1 100644 --- a/src/app/core/xsrf/xsrf.interceptor.spec.ts +++ b/src/app/core/xsrf/xsrf.interceptor.spec.ts @@ -67,7 +67,7 @@ describe(`XsrfInterceptor`, () => { expect(httpRequest.request.headers.has('X-XSRF-TOKEN')).toBeTrue(); expect(httpRequest.request.withCredentials).toBeTrue(); const token = httpRequest.request.headers.get('X-XSRF-TOKEN'); - expect(token).toBeDefined(); + expect(token).not.toBeNull(); expect(token).toBe(testToken.toString()); httpRequest.flush(mockPayload, { status: mockStatusCode, statusText: mockStatusText }); @@ -116,11 +116,11 @@ describe(`XsrfInterceptor`, () => { // ensure mock XSRF token is in response expect(response.headers.has('DSPACE-XSRF-TOKEN')).toBeTrue(); const token = response.headers.get('DSPACE-XSRF-TOKEN'); - expect(token).toBeDefined(); + expect(token).not.toBeNull(); expect(token).toBe(mockNewXSRFToken.toString()); // ensure our XSRF-TOKEN cookie exists & has the same value as the new DSPACE-XSRF-TOKEN header - expect(cookieService.get('XSRF-TOKEN')).toBeDefined(); + expect(cookieService.get('XSRF-TOKEN')).not.toBeNull(); expect(cookieService.get('XSRF-TOKEN')).toBe(mockNewXSRFToken.toString()); done(); @@ -153,7 +153,7 @@ describe(`XsrfInterceptor`, () => { expect(error.statusText).toBe(mockErrorText); // ensure our XSRF-TOKEN cookie exists & has the same value as the new DSPACE-XSRF-TOKEN header - expect(cookieService.get('XSRF-TOKEN')).toBeDefined(); + expect(cookieService.get('XSRF-TOKEN')).not.toBeNull(); expect(cookieService.get('XSRF-TOKEN')).toBe(mockNewXSRFToken.toString()); done(); diff --git a/src/app/item-page/full/full-item-page.component.spec.ts b/src/app/item-page/full/full-item-page.component.spec.ts index 66c6488b8e..53e36be1d1 100644 --- a/src/app/item-page/full/full-item-page.component.spec.ts +++ b/src/app/item-page/full/full-item-page.component.spec.ts @@ -104,9 +104,13 @@ describe('FullItemPageComponent', () => { fixture.detectChanges(); })); + afterEach(() => { + fixture.debugElement.nativeElement.remove(); + }); + it('should display the item\'s metadata', () => { const table = fixture.debugElement.query(By.css('table')); - for (const metadatum of mockItem.allMetadata([])) { + for (const metadatum of mockItem.allMetadata(Object.keys(mockItem.metadata))) { expect(table.nativeElement.innerHTML).toContain(metadatum.value); } }); @@ -137,7 +141,7 @@ describe('FullItemPageComponent', () => { it('should display the item', () => { const objectLoader = fixture.debugElement.query(By.css('.full-item-info')); - expect(objectLoader.nativeElement).toBeDefined(); + expect(objectLoader.nativeElement).not.toBeNull(); }); }); describe('when the item is withdrawn and the user is not an admin', () => { @@ -161,7 +165,7 @@ describe('FullItemPageComponent', () => { it('should display the item', () => { const objectLoader = fixture.debugElement.query(By.css('.full-item-info')); - expect(objectLoader.nativeElement).toBeDefined(); + expect(objectLoader).not.toBeNull(); }); }); @@ -173,7 +177,7 @@ describe('FullItemPageComponent', () => { it('should display the item', () => { const objectLoader = fixture.debugElement.query(By.css('.full-item-info')); - expect(objectLoader.nativeElement).toBeDefined(); + expect(objectLoader).not.toBeNull(); }); }); }); diff --git a/src/app/item-page/mirador-viewer/mirador-viewer.component.spec.ts b/src/app/item-page/mirador-viewer/mirador-viewer.component.spec.ts index 40ad0fd5d0..2727391dff 100644 --- a/src/app/item-page/mirador-viewer/mirador-viewer.component.spec.ts +++ b/src/app/item-page/mirador-viewer/mirador-viewer.component.spec.ts @@ -253,7 +253,7 @@ describe('MiradorViewerComponent in development mode', () => { it('should show message', (() => { const value = fixture.debugElement .nativeElement.querySelector('#viewer-message'); - expect(value).toBeDefined(); + expect(value).not.toBeNull(); })); }); diff --git a/src/app/item-page/simple/field-components/file-section/file-section.component.spec.ts b/src/app/item-page/simple/field-components/file-section/file-section.component.spec.ts index 2d185aef9c..a90abe9c90 100644 --- a/src/app/item-page/simple/field-components/file-section/file-section.component.spec.ts +++ b/src/app/item-page/simple/field-components/file-section/file-section.component.spec.ts @@ -143,7 +143,7 @@ describe('FileSectionComponent', () => { it('should contain a view less link', () => { const viewLess = fixture.debugElement.query(By.css('.bitstream-collapse')); - expect(viewLess).toBeDefined(); + expect(viewLess).not.toBeNull(); }); it('clicking on the view less link should reset the pages and call getNextPage()', () => { diff --git a/src/app/item-page/simple/field-components/specific-field/abstract/item-page-abstract-field.component.spec.ts b/src/app/item-page/simple/field-components/specific-field/abstract/item-page-abstract-field.component.spec.ts index 53f0522f39..bf1815c6b6 100644 --- a/src/app/item-page/simple/field-components/specific-field/abstract/item-page-abstract-field.component.spec.ts +++ b/src/app/item-page/simple/field-components/specific-field/abstract/item-page-abstract-field.component.spec.ts @@ -41,6 +41,6 @@ describe('ItemPageAbstractFieldComponent', () => { })); it('should render a ds-metadata-values', () => { - expect(fixture.debugElement.query(By.css('ds-metadata-values'))).toBeDefined(); + expect(fixture.debugElement.query(By.css('ds-metadata-values'))).not.toBeNull(); }); }); diff --git a/src/app/shared/browse-by/browse-by.component.spec.ts b/src/app/shared/browse-by/browse-by.component.spec.ts index 43a3910216..83bbe15801 100644 --- a/src/app/shared/browse-by/browse-by.component.spec.ts +++ b/src/app/shared/browse-by/browse-by.component.spec.ts @@ -47,7 +47,7 @@ import { getMockThemeService } from '../mocks/theme-service.mock'; @listableObjectComponent(BrowseEntry, ViewMode.ListElement, DEFAULT_CONTEXT, 'custom') @Component({ - selector: 'ds-browse-entry-list-element', + selector: '', template: '' }) class MockThemedBrowseEntryListElementComponent { @@ -147,19 +147,21 @@ describe('BrowseByComponent', () => { it('should display a loading message when objects is empty', () => { (comp as any).objects = undefined; fixture.detectChanges(); - expect(fixture.debugElement.query(By.css('ds-themed-loading'))).toBeDefined(); + expect(fixture.debugElement.query(By.css('ds-themed-loading'))).not.toBeNull(); }); it('should display results when objects is not empty', () => { - (comp as any).objects = observableOf({ - payload: { - page: { - length: 1 - } - } - }); + comp.objects$ = createSuccessfulRemoteDataObject$(buildPaginatedList(new PageInfo(), [ + Object.assign(new BrowseEntry(), { + type: ITEM, + authority: 'authority key 1', + value: 'browse entry 1', + language: null, + count: 1, + }), + ])); fixture.detectChanges(); - expect(fixture.debugElement.query(By.css('ds-viewable-collection'))).toBeDefined(); + expect(fixture.debugElement.query(By.css('ds-viewable-collection'))).not.toBeNull(); }); describe('when showPaginator is true and browseEntries are provided', () => { @@ -231,15 +233,24 @@ describe('BrowseByComponent', () => { describe('reset filters button', () => { it('should not be present when no startsWith or value is present ', () => { - const button = fixture.debugElement.query(By.css('reset')); + const button = fixture.debugElement.query(By.css('.reset')); expect(button).toBeNull(); }); it('should be present when a startsWith or value is present ', () => { + comp.objects$ = createSuccessfulRemoteDataObject$(buildPaginatedList(new PageInfo(), [ + Object.assign(new BrowseEntry(), { + type: ITEM, + authority: 'authority key 1', + value: 'browse entry 1', + language: null, + count: 1, + }), + ])); comp.shouldDisplayResetButton$ = observableOf(true); fixture.detectChanges(); - const button = fixture.debugElement.query(By.css('reset')); - expect(button).toBeDefined(); + const button = fixture.debugElement.query(By.css('.reset')); + expect(button).not.toBeNull(); }); }); describe('back', () => { diff --git a/src/app/shared/lang-switch/lang-switch.component.spec.ts b/src/app/shared/lang-switch/lang-switch.component.spec.ts index 7757622f4c..6d3c847086 100644 --- a/src/app/shared/lang-switch/lang-switch.component.spec.ts +++ b/src/app/shared/lang-switch/lang-switch.component.spec.ts @@ -109,7 +109,7 @@ describe('LangSwitchComponent', () => { })); it('should define the main A HREF in the UI', (() => { - expect(langSwitchElement.querySelector('a')).toBeDefined(); + expect(langSwitchElement.querySelector('a')).not.toBeNull(); })); describe('when selecting a language', () => { diff --git a/src/app/shared/mydspace-actions/claimed-task/approve/claimed-task-actions-approve.component.spec.ts b/src/app/shared/mydspace-actions/claimed-task/approve/claimed-task-actions-approve.component.spec.ts index ce67da1349..b15e246f53 100644 --- a/src/app/shared/mydspace-actions/claimed-task/approve/claimed-task-actions-approve.component.spec.ts +++ b/src/app/shared/mydspace-actions/claimed-task/approve/claimed-task-actions-approve.component.spec.ts @@ -72,7 +72,7 @@ describe('ClaimedTaskActionsApproveComponent', () => { it('should display approve button', () => { const btn = fixture.debugElement.query(By.css('.btn-success')); - expect(btn).toBeDefined(); + expect(btn).not.toBeNull(); }); it('should display spin icon when approve is pending', () => { @@ -81,7 +81,7 @@ describe('ClaimedTaskActionsApproveComponent', () => { const span = fixture.debugElement.query(By.css('.btn-success .fa-spin')); - expect(span).toBeDefined(); + expect(span).not.toBeNull(); }); describe('submitTask', () => { diff --git a/src/app/shared/mydspace-actions/claimed-task/edit-metadata/claimed-task-actions-edit-metadata.component.spec.ts b/src/app/shared/mydspace-actions/claimed-task/edit-metadata/claimed-task-actions-edit-metadata.component.spec.ts index 5bcddc9b11..7bdf57561f 100644 --- a/src/app/shared/mydspace-actions/claimed-task/edit-metadata/claimed-task-actions-edit-metadata.component.spec.ts +++ b/src/app/shared/mydspace-actions/claimed-task/edit-metadata/claimed-task-actions-edit-metadata.component.spec.ts @@ -66,7 +66,7 @@ describe('ClaimedTaskActionsEditMetadataComponent', () => { it('should display edit button', () => { const btn = fixture.debugElement.query(By.css('.btn-primary')); - expect(btn).toBeDefined(); + expect(btn).not.toBeNull(); }); }); diff --git a/src/app/shared/mydspace-actions/claimed-task/reject/claimed-task-actions-reject.component.spec.ts b/src/app/shared/mydspace-actions/claimed-task/reject/claimed-task-actions-reject.component.spec.ts index 2ccb671d83..b3ea5e1258 100644 --- a/src/app/shared/mydspace-actions/claimed-task/reject/claimed-task-actions-reject.component.spec.ts +++ b/src/app/shared/mydspace-actions/claimed-task/reject/claimed-task-actions-reject.component.spec.ts @@ -89,7 +89,7 @@ describe('ClaimedTaskActionsRejectComponent', () => { it('should display reject button', () => { const btn = fixture.debugElement.query(By.css('.btn-danger')); - expect(btn).toBeDefined(); + expect(btn).not.toBeNull(); }); it('should display spin icon when reject is pending', () => { @@ -98,7 +98,7 @@ describe('ClaimedTaskActionsRejectComponent', () => { const span = fixture.debugElement.query(By.css('.btn-danger .fa-spin')); - expect(span).toBeDefined(); + expect(span).not.toBeNull(); }); it('should call openRejectModal on reject button click', () => { diff --git a/src/app/shared/mydspace-actions/claimed-task/return-to-pool/claimed-task-actions-return-to-pool.component.spec.ts b/src/app/shared/mydspace-actions/claimed-task/return-to-pool/claimed-task-actions-return-to-pool.component.spec.ts index 46e89d9d3a..765849f0ae 100644 --- a/src/app/shared/mydspace-actions/claimed-task/return-to-pool/claimed-task-actions-return-to-pool.component.spec.ts +++ b/src/app/shared/mydspace-actions/claimed-task/return-to-pool/claimed-task-actions-return-to-pool.component.spec.ts @@ -72,7 +72,7 @@ describe('ClaimedTaskActionsReturnToPoolComponent', () => { it('should display return to pool button', () => { const btn = fixture.debugElement.query(By.css('.btn-secondary')); - expect(btn).toBeDefined(); + expect(btn).not.toBeNull(); }); it('should display spin icon when return to pool action is pending', () => { @@ -81,7 +81,7 @@ describe('ClaimedTaskActionsReturnToPoolComponent', () => { const span = fixture.debugElement.query(By.css('.btn-secondary .fa-spin')); - expect(span).toBeDefined(); + expect(span).not.toBeNull(); }); describe('actionExecution', () => { diff --git a/src/app/shared/mydspace-actions/pool-task/pool-task-actions.component.spec.ts b/src/app/shared/mydspace-actions/pool-task/pool-task-actions.component.spec.ts index 385dea73f3..cb0799caa6 100644 --- a/src/app/shared/mydspace-actions/pool-task/pool-task-actions.component.spec.ts +++ b/src/app/shared/mydspace-actions/pool-task/pool-task-actions.component.spec.ts @@ -131,13 +131,13 @@ describe('PoolTaskActionsComponent', () => { it('should display claim task button', () => { const btn = fixture.debugElement.query(By.css('.btn-info')); - expect(btn).toBeDefined(); + expect(btn).not.toBeNull(); }); it('should display view button', () => { - const btn = fixture.debugElement.query(By.css('button [data-test="view-btn"]')); + const btn = fixture.debugElement.query(By.css('button[data-test="view-btn"]')); - expect(btn).toBeDefined(); + expect(btn).not.toBeNull(); }); it('should call claim task with href of getPoolTaskEndpointById', ((done) => { diff --git a/src/app/shared/mydspace-actions/workflowitem/workflowitem-actions.component.spec.ts b/src/app/shared/mydspace-actions/workflowitem/workflowitem-actions.component.spec.ts index 79aece892e..9f266d054e 100644 --- a/src/app/shared/mydspace-actions/workflowitem/workflowitem-actions.component.spec.ts +++ b/src/app/shared/mydspace-actions/workflowitem/workflowitem-actions.component.spec.ts @@ -107,9 +107,9 @@ describe('WorkflowitemActionsComponent', () => { }); it('should display view button', () => { - const btn = fixture.debugElement.query(By.css('button [data-test="view-btn"]')); + const btn = fixture.debugElement.query(By.css('button[data-test="view-btn"]')); - expect(btn).toBeDefined(); + expect(btn).not.toBeNull(); }); }); diff --git a/src/app/shared/mydspace-actions/workspaceitem/workspaceitem-actions.component.spec.ts b/src/app/shared/mydspace-actions/workspaceitem/workspaceitem-actions.component.spec.ts index 7299c28df2..14d3c07650 100644 --- a/src/app/shared/mydspace-actions/workspaceitem/workspaceitem-actions.component.spec.ts +++ b/src/app/shared/mydspace-actions/workspaceitem/workspaceitem-actions.component.spec.ts @@ -123,19 +123,19 @@ describe('WorkspaceitemActionsComponent', () => { it('should display edit button', () => { const btn = fixture.debugElement.query(By.css('.btn-primary')); - expect(btn).toBeDefined(); + expect(btn).not.toBeNull(); }); it('should display delete button', () => { const btn = fixture.debugElement.query(By.css('.btn-danger')); - expect(btn).toBeDefined(); + expect(btn).not.toBeNull(); }); it('should display view button', () => { - const btn = fixture.debugElement.query(By.css('button [data-test="view-btn"]')); + const btn = fixture.debugElement.query(By.css('button[data-test="view-btn"]')); - expect(btn).toBeDefined(); + expect(btn).not.toBeNull(); }); describe('on discard confirmation', () => { diff --git a/src/app/shared/object-collection/object-collection.component.spec.ts b/src/app/shared/object-collection/object-collection.component.spec.ts index c28df74aa7..1619e56b0d 100644 --- a/src/app/shared/object-collection/object-collection.component.spec.ts +++ b/src/app/shared/object-collection/object-collection.component.spec.ts @@ -30,27 +30,34 @@ describe('ObjectCollectionComponent', () => { }).compileComponents(); // compile template and css })); - beforeEach(waitForAsync(() => { + beforeEach(() => { fixture = TestBed.createComponent(ObjectCollectionComponent); objectCollectionComponent = fixture.componentInstance; - })); + fixture.detectChanges(); + }); it('should only show the grid component when the viewmode is set to grid', () => { objectCollectionComponent.currentMode$ = observableOf(ViewMode.GridElement); + fixture.detectChanges(); - expect(fixture.debugElement.query(By.css('ds-object-grid'))).toBeDefined(); - expect(fixture.debugElement.query(By.css('ds-object-list'))).toBeNull(); + expect(fixture.debugElement.query(By.css('ds-object-grid'))).not.toBeNull(); + expect(fixture.debugElement.query(By.css('ds-themed-object-list'))).toBeNull(); }); it('should only show the list component when the viewmode is set to list', () => { objectCollectionComponent.currentMode$ = observableOf(ViewMode.ListElement); + fixture.detectChanges(); - expect(fixture.debugElement.query(By.css('ds-object-list'))).toBeDefined(); + expect(fixture.debugElement.query(By.css('ds-themed-object-list'))).not.toBeNull(); expect(fixture.debugElement.query(By.css('ds-object-grid'))).toBeNull(); }); - it('should set fallback placeholder font size during test', () => { - objectCollectionComponent.currentMode$ = observableOf(ViewMode.ListElement); - expect(fixture.debugElement.query(By.css('thumb-font-3'))).toBeDefined(); + it('should set fallback placeholder font size during test', async () => { + objectCollectionComponent.currentMode$ = observableOf(ViewMode.ListElement); + fixture.detectChanges(); + + const comp = fixture.debugElement.query(By.css('ds-themed-object-list')); + expect(comp).not.toBeNull(); + expect(comp.nativeElement.classList).not.toContain('hide-placeholder-text'); }); }); diff --git a/src/app/shared/object-collection/shared/mydspace-item-status/my-dspace-item-status.component.spec.ts b/src/app/shared/object-collection/shared/mydspace-item-status/my-dspace-item-status.component.spec.ts index 44e6a44b70..f3d1e868b7 100644 --- a/src/app/shared/object-collection/shared/mydspace-item-status/my-dspace-item-status.component.spec.ts +++ b/src/app/shared/object-collection/shared/mydspace-item-status/my-dspace-item-status.component.spec.ts @@ -48,7 +48,7 @@ describe('MyDSpaceItemStatusComponent', () => { it('should display badge', () => { const badge = fixture.debugElement.query(By.css('span')); - expect(badge).toBeDefined(); + expect(badge).not.toBeNull(); }); it('should init badge content and class', () => { diff --git a/src/app/shared/object-collection/shared/mydspace-item-submitter/item-submitter.component.spec.ts b/src/app/shared/object-collection/shared/mydspace-item-submitter/item-submitter.component.spec.ts index 227db9ec82..cf1de597f6 100644 --- a/src/app/shared/object-collection/shared/mydspace-item-submitter/item-submitter.component.spec.ts +++ b/src/app/shared/object-collection/shared/mydspace-item-submitter/item-submitter.component.spec.ts @@ -63,7 +63,7 @@ describe('ItemSubmitterComponent', () => { it('should show a badge with submitter name', () => { const badge = fixture.debugElement.query(By.css('.badge')); - expect(badge).toBeDefined(); + expect(badge).not.toBeNull(); expect(badge.nativeElement.innerHTML).toBe(EPersonMock.name); }); }); diff --git a/src/app/shared/page-size-selector/page-size-selector.component.spec.ts b/src/app/shared/page-size-selector/page-size-selector.component.spec.ts index 67947c3425..80956e7184 100644 --- a/src/app/shared/page-size-selector/page-size-selector.component.spec.ts +++ b/src/app/shared/page-size-selector/page-size-selector.component.spec.ts @@ -72,9 +72,9 @@ describe('PageSizeSelectorComponent', () => { }); it('it should show the size settings with the respective selectable options', (done) => { - (comp as any).paginationOptions$.pipe(first()).subscribe((options) => { + comp.paginationOptions$.pipe(first()).subscribe((options: PaginationComponentOptions) => { const pageSizeSetting = fixture.debugElement.query(By.css('div.page-size-settings')); - expect(pageSizeSetting).toBeDefined(); + expect(pageSizeSetting).not.toBeNull(); const childElements = pageSizeSetting.queryAll(By.css('option')); expect(childElements.length).toEqual(options.pageSizeOptions.length); done(); @@ -83,10 +83,11 @@ describe('PageSizeSelectorComponent', () => { }); it('should have the proper rpp value selected by default', (done) => { - (comp as any).paginationOptions$.pipe(take(1)).subscribe((options) => { + comp.paginationOptions$.pipe(take(1)).subscribe(() => { const pageSizeSetting = fixture.debugElement.query(By.css('div.page-size-settings')); - const childElementToBeSelected = pageSizeSetting.query(By.css('option[value="10"][selected="selected"]')); - expect(childElementToBeSelected).toBeDefined(); + const childElementToBeSelected = pageSizeSetting.query(By.css('option[value="10"]')); + expect(childElementToBeSelected).not.toBeNull(); + expect(childElementToBeSelected.nativeElement.selected).toBeTrue() done(); }); }); diff --git a/src/app/shared/search/search-settings/search-settings.component.spec.ts b/src/app/shared/search/search-settings/search-settings.component.spec.ts index 06e506ddb0..d0b51f04b1 100644 --- a/src/app/shared/search/search-settings/search-settings.component.spec.ts +++ b/src/app/shared/search/search-settings/search-settings.component.spec.ts @@ -107,6 +107,7 @@ describe('SearchSettingsComponent', () => { new SortOptions('dc.title', SortDirection.ASC), new SortOptions('dc.title', SortDirection.DESC) ]; + comp.currentSortOption = new SortOptions('score', SortDirection.DESC); // SearchPageComponent test instance fixture.detectChanges(); @@ -133,7 +134,8 @@ describe('SearchSettingsComponent', () => { it('should have the proper order value selected by default', () => { fixture.detectChanges(); const orderSetting = fixture.debugElement.query(By.css('div.result-order-settings')); - const childElementToBeSelected = orderSetting.query(By.css('option[value="score,DESC"][selected="selected"]')); - expect(childElementToBeSelected).toBeDefined(); + const childElementToBeSelected = orderSetting.query(By.css('option[value="score,DESC"]')); + expect(childElementToBeSelected).not.toBeNull(); + expect(childElementToBeSelected.nativeElement.selected).toBeTrue(); }); }); diff --git a/src/app/shared/search/search-switch-configuration/search-switch-configuration.component.spec.ts b/src/app/shared/search/search-switch-configuration/search-switch-configuration.component.spec.ts index fadde46e53..8fc178c67a 100644 --- a/src/app/shared/search/search-switch-configuration/search-switch-configuration.component.spec.ts +++ b/src/app/shared/search/search-switch-configuration/search-switch-configuration.component.spec.ts @@ -78,7 +78,7 @@ describe('SearchSwitchConfigurationComponent', () => { it('should display select field properly', () => { const selectField = fixture.debugElement.query(By.css('.form-control')); - expect(selectField).toBeDefined(); + expect(selectField).not.toBeNull(); const childElements = selectField.children; expect(childElements.length).toEqual(comp.configurationList.length); diff --git a/src/app/submission/form/section-add/submission-form-section-add.component.spec.ts b/src/app/submission/form/section-add/submission-form-section-add.component.spec.ts index 971b15d7b0..a8ad7fbe49 100644 --- a/src/app/submission/form/section-add/submission-form-section-add.component.spec.ts +++ b/src/app/submission/form/section-add/submission-form-section-add.component.spec.ts @@ -96,6 +96,7 @@ describe('SubmissionFormSectionAddComponent Component', () => { afterEach(() => { testFixture.destroy(); + testFixture.debugElement.nativeElement.remove(); }); it('should create SubmissionFormSectionAddComponent', inject([SubmissionFormSectionAddComponent], (app: SubmissionFormSectionAddComponent) => { @@ -163,7 +164,7 @@ describe('SubmissionFormSectionAddComponent Component', () => { it('should have dropdown menu closed', () => { - expect(dropdowBtn).not.toBeUndefined(); + expect(dropdowBtn).not.toBeNull(); expect(dropdownMenu.nativeElement.classList).not.toContain('show'); }); diff --git a/src/app/submission/sections/container/section-container.component.spec.ts b/src/app/submission/sections/container/section-container.component.spec.ts index 7568b17ea7..8a4b3ebc56 100644 --- a/src/app/submission/sections/container/section-container.component.spec.ts +++ b/src/app/submission/sections/container/section-container.component.spec.ts @@ -137,7 +137,7 @@ describe('SubmissionSectionContainerComponent test suite', () => { const section = fixture.debugElement.query(By.css('[id^=\'sectionContent_\']')); expect(comp.getSectionContent).toHaveBeenCalled(); - expect(section).toBeDefined(); + expect(section).not.toBeNull(); }); it('should call removeSection properly', () => { @@ -165,7 +165,7 @@ describe('SubmissionSectionContainerComponent test suite', () => { fixture.detectChanges(); sectionErrorsDiv = fixture.debugElement.query(By.css('[id^=\'sectionGenericError_\']')); - expect(sectionErrorsDiv).toBeDefined(); + expect(sectionErrorsDiv).not.toBeNull(); }); it('should display warning icon', () => { @@ -180,7 +180,7 @@ describe('SubmissionSectionContainerComponent test suite', () => { const iconWarn = fixture.debugElement.query(By.css('i.text-warning')); const iconErr = fixture.debugElement.query(By.css('i.text-danger')); const iconSuccess = fixture.debugElement.query(By.css('i.text-success')); - expect(iconWarn).toBeDefined(); + expect(iconWarn).not.toBeNull(); expect(iconErr).toBeNull(); expect(iconSuccess).toBeNull(); }); @@ -198,7 +198,7 @@ describe('SubmissionSectionContainerComponent test suite', () => { const iconErr = fixture.debugElement.query(By.css('i.text-danger')); const iconSuccess = fixture.debugElement.query(By.css('i.text-success')); expect(iconWarn).toBeNull(); - expect(iconErr).toBeDefined(); + expect(iconErr).not.toBeNull(); expect(iconSuccess).toBeNull(); }); @@ -216,7 +216,7 @@ describe('SubmissionSectionContainerComponent test suite', () => { const iconSuccess = fixture.debugElement.query(By.css('i.text-success')); expect(iconWarn).toBeNull(); expect(iconErr).toBeNull(); - expect(iconSuccess).toBeDefined(); + expect(iconSuccess).not.toBeNull(); }); }); @@ -224,7 +224,7 @@ describe('SubmissionSectionContainerComponent test suite', () => { // declare a test component @Component({ - selector: 'ds-test-cmp', + selector: '', template: `` }) class TestComponent { From 4f14d66400e069fe69797171f6e0469aa97e9591 Mon Sep 17 00:00:00 2001 From: Alexandre Vryghem Date: Sun, 19 Feb 2023 01:04:25 +0100 Subject: [PATCH 15/23] Fixed lint issues --- src/app/shared/browse-by/browse-by.component.spec.ts | 1 + .../page-size-selector/page-size-selector.component.spec.ts | 2 +- .../sections/container/section-container.component.spec.ts | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/app/shared/browse-by/browse-by.component.spec.ts b/src/app/shared/browse-by/browse-by.component.spec.ts index 83bbe15801..87bc2eb99e 100644 --- a/src/app/shared/browse-by/browse-by.component.spec.ts +++ b/src/app/shared/browse-by/browse-by.component.spec.ts @@ -47,6 +47,7 @@ import { getMockThemeService } from '../mocks/theme-service.mock'; @listableObjectComponent(BrowseEntry, ViewMode.ListElement, DEFAULT_CONTEXT, 'custom') @Component({ + // eslint-disable-next-line @angular-eslint/component-selector selector: '', template: '' }) diff --git a/src/app/shared/page-size-selector/page-size-selector.component.spec.ts b/src/app/shared/page-size-selector/page-size-selector.component.spec.ts index 80956e7184..6b0e9d265b 100644 --- a/src/app/shared/page-size-selector/page-size-selector.component.spec.ts +++ b/src/app/shared/page-size-selector/page-size-selector.component.spec.ts @@ -87,7 +87,7 @@ describe('PageSizeSelectorComponent', () => { const pageSizeSetting = fixture.debugElement.query(By.css('div.page-size-settings')); const childElementToBeSelected = pageSizeSetting.query(By.css('option[value="10"]')); expect(childElementToBeSelected).not.toBeNull(); - expect(childElementToBeSelected.nativeElement.selected).toBeTrue() + expect(childElementToBeSelected.nativeElement.selected).toBeTrue(); done(); }); }); diff --git a/src/app/submission/sections/container/section-container.component.spec.ts b/src/app/submission/sections/container/section-container.component.spec.ts index 8a4b3ebc56..d3f4a93762 100644 --- a/src/app/submission/sections/container/section-container.component.spec.ts +++ b/src/app/submission/sections/container/section-container.component.spec.ts @@ -224,6 +224,7 @@ describe('SubmissionSectionContainerComponent test suite', () => { // declare a test component @Component({ + // eslint-disable-next-line @angular-eslint/component-selector selector: '', template: `` }) From 17afdfa34b2786a7450012dcb74a17fa2f4c76e7 Mon Sep 17 00:00:00 2001 From: cris Date: Tue, 21 Feb 2023 22:44:45 +0000 Subject: [PATCH 16/23] avoiding error when user unselect a filter option --- .../search-labels/search-label/search-label.component.ts | 4 +++- .../shared/search/search-labels/search-labels.component.ts | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/app/shared/search/search-labels/search-label/search-label.component.ts b/src/app/shared/search/search-labels/search-label/search-label.component.ts index 74526ad2ad..ab4c57d9f5 100644 --- a/src/app/shared/search/search-labels/search-label/search-label.component.ts +++ b/src/app/shared/search/search-labels/search-label/search-label.component.ts @@ -7,6 +7,7 @@ import { SearchService } from '../../../../core/shared/search/search.service'; import { currentPath } from '../../../utils/route.utils'; import { PaginationService } from '../../../../core/pagination/pagination.service'; import { SearchConfigurationService } from '../../../../core/shared/search/search-configuration.service'; +import { stripOperatorFromFilterValue } from '../../search.utils'; @Component({ selector: 'ds-search-label', @@ -83,7 +84,8 @@ export class SearchLabelComponent implements OnInit { normalizeFilterValue(value: string) { // const pattern = /,[^,]*$/g; const pattern = /,authority*$/g; - return value.replace(pattern, ''); + value = value.replace(pattern, ''); + return stripOperatorFromFilterValue(value); } private getFilterName(): string { diff --git a/src/app/shared/search/search-labels/search-labels.component.ts b/src/app/shared/search/search-labels/search-labels.component.ts index 8f77d73b21..2cc1919f50 100644 --- a/src/app/shared/search/search-labels/search-labels.component.ts +++ b/src/app/shared/search/search-labels/search-labels.component.ts @@ -4,7 +4,6 @@ import { Observable } from 'rxjs'; import { Params, Router } from '@angular/router'; import { SearchConfigurationService } from '../../../core/shared/search/search-configuration.service'; import { map } from 'rxjs/operators'; -import { stripOperatorFromFilterValue } from '../search.utils'; @Component({ selector: 'ds-search-labels', @@ -37,7 +36,7 @@ export class SearchLabelsComponent { const labels = {}; Object.keys(params) .forEach((key) => { - labels[key] = [...params[key].map((value) => stripOperatorFromFilterValue(value))]; + labels[key] = [...params[key].map((value) => value)]; }); return labels; }) From 0a4f027129297994007e15ef7b5875aafa07dec5 Mon Sep 17 00:00:00 2001 From: lotte Date: Thu, 23 Feb 2023 15:44:06 +0100 Subject: [PATCH 17/23] 99615: Fixed #2087 and #2088 --- .../field-components/file-section/file-section.component.html | 2 +- .../file-download-link/file-download-link.component.html | 2 +- .../item/item-search-result-list-element.component.html | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/app/item-page/simple/field-components/file-section/file-section.component.html b/src/app/item-page/simple/field-components/file-section/file-section.component.html index 9d61b0a0e0..2f23f931bc 100644 --- a/src/app/item-page/simple/field-components/file-section/file-section.component.html +++ b/src/app/item-page/simple/field-components/file-section/file-section.component.html @@ -3,7 +3,7 @@
{{file?.name}} - ({{(file?.sizeBytes) | dsFileSize }}) + ({{(file?.sizeBytes) | dsFileSize }}) diff --git a/src/app/shared/file-download-link/file-download-link.component.html b/src/app/shared/file-download-link/file-download-link.component.html index ba81ee3d20..8ebe622a5b 100644 --- a/src/app/shared/file-download-link/file-download-link.component.html +++ b/src/app/shared/file-download-link/file-download-link.component.html @@ -1,5 +1,5 @@ - + diff --git a/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/item/item-search-result-list-element.component.html b/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/item/item-search-result-list-element.component.html index 6b2951495d..d7a462e62c 100644 --- a/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/item/item-search-result-list-element.component.html +++ b/src/app/shared/object-list/search-result-list-element/item-search-result/item-types/item/item-search-result-list-element.component.html @@ -25,7 +25,8 @@ - ( + ( + , ) From af23a3a8e3603f9c90dd8032ee993c53729b7540 Mon Sep 17 00:00:00 2001 From: Alexandre Vryghem Date: Thu, 23 Feb 2023 21:56:04 +0100 Subject: [PATCH 18/23] Fixed css issues of LogInComponent where text would overflow --- src/app/shared/log-in/log-in.component.html | 2 +- src/app/shared/log-in/log-in.component.scss | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/app/shared/log-in/log-in.component.html b/src/app/shared/log-in/log-in.component.html index 8fb5a33954..302ff1aca8 100644 --- a/src/app/shared/log-in/log-in.component.html +++ b/src/app/shared/log-in/log-in.component.html @@ -1,5 +1,5 @@ -