mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
[CST-5339] Pass item as input - Tests
This commit is contained in:
@@ -10,4 +10,4 @@
|
||||
|
||||
<ds-orcid-auth *ngIf="(item | async)" [item]="(item | async)" (unlink)="updateItem()"></ds-orcid-auth>
|
||||
<ds-orcid-sync-setting *ngIf="(item | async) && isLinkedToOrcid()" [item]="(item | async)"></ds-orcid-sync-setting>
|
||||
<ds-orcid-queue *ngIf="isLinkedToOrcid()"></ds-orcid-queue>
|
||||
<ds-orcid-queue *ngIf="isLinkedToOrcid()" [item]="(item | async)"></ds-orcid-queue>
|
||||
|
@@ -1,60 +1,55 @@
|
||||
<div class="container custom-accordion mb-4">
|
||||
<ngb-accordion activeIds="queue">
|
||||
<ngb-panel title="{{'person.orcid.registry.queue' | translate}}" id="queue">
|
||||
<ng-template ngbPanelContent>
|
||||
<div class="container">
|
||||
<ds-loading *ngIf="(processing$ | async)"></ds-loading>
|
||||
<div>
|
||||
<ds-loading *ngIf="(processing$ | async)"></ds-loading>
|
||||
<div class="container">
|
||||
<h2>{{ 'person.orcid.registry.queue' | translate }}</h2>
|
||||
|
||||
<ds-alert *ngIf="!(processing$ | async) && (getList() | async)?.payload?.totalElements == 0"
|
||||
[type]="AlertTypeEnum.Info">
|
||||
{{ 'person.page.orcid.sync-queue.empty-message' | translate}}
|
||||
</ds-alert>
|
||||
<ds-pagination *ngIf="!(processing$ | async) && (getList() | async)?.payload?.totalElements > 0"
|
||||
[paginationOptions]="paginationOptions"
|
||||
[collectionSize]="(getList() | async)?.payload?.totalElements"
|
||||
[retainScrollPosition]="false" [hideGear]="true" (paginationChange)="updateList()">
|
||||
<ds-alert *ngIf="!(processing$ | async) && (getList() | async)?.payload?.totalElements == 0"
|
||||
[type]="AlertTypeEnum.Info">
|
||||
{{ 'person.page.orcid.sync-queue.empty-message' | translate}}
|
||||
</ds-alert>
|
||||
<ds-pagination *ngIf="!(processing$ | async) && (getList() | async)?.payload?.totalElements > 0"
|
||||
[paginationOptions]="paginationOptions"
|
||||
[collectionSize]="(getList() | async)?.payload?.totalElements"
|
||||
[retainScrollPosition]="false" [hideGear]="true" (paginationChange)="updateList()">
|
||||
|
||||
<div class="table-responsive">
|
||||
<table id="groups" class="table table-sm table-striped table-hover table-bordered">
|
||||
<thead>
|
||||
<tr class="text-center align-middle">
|
||||
<th>{{'person.page.orcid.sync-queue.table.header.type' | translate}}</th>
|
||||
<th>{{'person.page.orcid.sync-queue.table.header.description' | translate}}</th>
|
||||
<th>{{'person.page.orcid.sync-queue.table.header.action' | translate}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr *ngFor="let entry of (getList() | async)?.payload?.page">
|
||||
<td class="text-center align-middle">
|
||||
<i [ngClass]="getIconClass(entry)" [ngbTooltip]="getIconTooltip(entry) | translate"
|
||||
class="fa-2x" aria-hidden="true"></i>
|
||||
</td>
|
||||
<td class="text-center align-middle">
|
||||
{{ entry.description }}
|
||||
</td>
|
||||
<td style="width: 20%" class="text-center">
|
||||
<div class="btn-group edit-field">
|
||||
<!--<button [ngbTooltip]="getOperationTooltip(entry) | translate" container="body"
|
||||
class="btn btn-outline-success my-1 col-md">
|
||||
<i [ngClass]="getOperationClass(entry)"></i>
|
||||
</button>-->
|
||||
<button [ngbTooltip]="'person.page.orcid.sync-queue.send' | translate" container="body"
|
||||
class="btn btn-outline-success my-1 col-md" (click)="send(entry)">
|
||||
<i [ngClass]="getOperationClass(entry)"></i>
|
||||
</button>
|
||||
<button [ngbTooltip]="'person.page.orcid.sync-queue.discard' | translate" container="body"
|
||||
class="btn btn-outline-danger my-1 col-md" (click)="discardEntry(entry)">
|
||||
<i class="fas fa-unlink"></i>
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</ds-pagination>
|
||||
</div>
|
||||
</ng-template>
|
||||
</ngb-panel>
|
||||
</ngb-accordion>
|
||||
<div class="table-responsive">
|
||||
<table id="groups" class="table table-sm table-striped table-hover table-bordered">
|
||||
<thead>
|
||||
<tr class="text-center align-middle">
|
||||
<th>{{'person.page.orcid.sync-queue.table.header.type' | translate}}</th>
|
||||
<th>{{'person.page.orcid.sync-queue.table.header.description' | translate}}</th>
|
||||
<th>{{'person.page.orcid.sync-queue.table.header.action' | translate}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr *ngFor="let entry of (getList() | async)?.payload?.page" data-test="orcidQueueElementRow">
|
||||
<td class="text-center align-middle">
|
||||
<i [ngClass]="getIconClass(entry)" [ngbTooltip]="getIconTooltip(entry) | translate"
|
||||
class="fa-2x" aria-hidden="true"></i>
|
||||
</td>
|
||||
<td class="text-center align-middle">
|
||||
{{ entry.description }}
|
||||
</td>
|
||||
<td style="width: 20%" class="text-center">
|
||||
<div class="btn-group edit-field">
|
||||
<!--<button [ngbTooltip]="getOperationTooltip(entry) | translate" container="body"
|
||||
class="btn btn-outline-success my-1 col-md">
|
||||
<i [ngClass]="getOperationClass(entry)"></i>
|
||||
</button>-->
|
||||
<button [ngbTooltip]="'person.page.orcid.sync-queue.send' | translate" container="body"
|
||||
class="btn btn-outline-success my-1 col-md" (click)="send(entry)">
|
||||
<i [ngClass]="getOperationClass(entry)"></i>
|
||||
</button>
|
||||
<button [ngbTooltip]="'person.page.orcid.sync-queue.discard' | translate" container="body"
|
||||
class="btn btn-outline-danger my-1 col-md" (click)="discardEntry(entry)">
|
||||
<i class="fas fa-unlink"></i>
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</ds-pagination>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -10,13 +10,12 @@ import { PaginationServiceStub } from '../../../shared/testing/pagination-servic
|
||||
import { NotificationsService } from '../../../shared/notifications/notifications.service';
|
||||
import { NotificationsServiceStub } from '../../../shared/testing/notifications-service.stub';
|
||||
import { OrcidHistoryService } from '../../../core/orcid/orcid-history.service';
|
||||
import { ActivatedRoute, Params } from '@angular/router';
|
||||
import { ActivatedRouteStub } from '../../../shared/testing/active-router.stub';
|
||||
import { OrcidQueue } from '../../../core/orcid/model/orcid-queue.model';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../../shared/remote-data.utils';
|
||||
import { createPaginatedList } from '../../../shared/testing/utils.test';
|
||||
import { PaginatedList } from '../../../core/data/paginated-list.model';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { Item } from '../../../core/shared/item.model';
|
||||
|
||||
|
||||
fdescribe('OrcidQueueComponent test suite', () => {
|
||||
@@ -27,9 +26,63 @@ fdescribe('OrcidQueueComponent test suite', () => {
|
||||
|
||||
const testOwnerId = 'test-owner-id';
|
||||
|
||||
const routeParams: Params = {'id': testOwnerId};
|
||||
|
||||
const activatedRouteStub = new ActivatedRouteStub(routeParams);
|
||||
const mockItemLinkedToOrcid: Item = Object.assign(new Item(), {
|
||||
bundles: createSuccessfulRemoteDataObject$(createPaginatedList([])),
|
||||
metadata: {
|
||||
'dc.title': [{
|
||||
value: 'test person'
|
||||
}],
|
||||
'dspace.entity.type': [{
|
||||
'value': 'Person'
|
||||
}],
|
||||
'dspace.object.owner': [{
|
||||
'value': 'test person',
|
||||
'language': null,
|
||||
'authority': 'deced3e7-68e2-495d-bf98-7c44fc33b8ff',
|
||||
'confidence': 600,
|
||||
'place': 0
|
||||
}],
|
||||
'dspace.orcid.authenticated': [{
|
||||
'value': '2022-06-10T15:15:12.952872',
|
||||
'language': null,
|
||||
'authority': null,
|
||||
'confidence': -1,
|
||||
'place': 0
|
||||
}],
|
||||
'dspace.orcid.scope': [{
|
||||
'value': '/authenticate',
|
||||
'language': null,
|
||||
'authority': null,
|
||||
'confidence': -1,
|
||||
'place': 0
|
||||
}, {
|
||||
'value': '/read-limited',
|
||||
'language': null,
|
||||
'authority': null,
|
||||
'confidence': -1,
|
||||
'place': 1
|
||||
}, {
|
||||
'value': '/activities/update',
|
||||
'language': null,
|
||||
'authority': null,
|
||||
'confidence': -1,
|
||||
'place': 2
|
||||
}, {
|
||||
'value': '/person/update',
|
||||
'language': null,
|
||||
'authority': null,
|
||||
'confidence': -1,
|
||||
'place': 3
|
||||
}],
|
||||
'person.identifier.orcid': [{
|
||||
'value': 'orcid-id',
|
||||
'language': null,
|
||||
'authority': null,
|
||||
'confidence': -1,
|
||||
'place': 0
|
||||
}]
|
||||
}
|
||||
});
|
||||
|
||||
function orcidQueueElement(id: number) {
|
||||
return Object.assign(new OrcidQueue(), {
|
||||
@@ -45,14 +98,8 @@ fdescribe('OrcidQueueComponent test suite', () => {
|
||||
|
||||
const orcidQueueElements = [orcidQueueElement(1), orcidQueueElement(2)];
|
||||
|
||||
const orcidQueueServiceMock = {
|
||||
searchByOwnerId(id) {
|
||||
return createSuccessfulRemoteDataObject$<PaginatedList<OrcidQueue>>(createPaginatedList<OrcidQueue>(orcidQueueElements));
|
||||
},
|
||||
clearFindByOwnerRequests() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
const orcidQueueServiceSpy = jasmine.createSpyObj('orcidQueueService', ['searchByOwnerId', 'clearFindByOwnerRequests']);
|
||||
orcidQueueServiceSpy.searchByOwnerId.and.returnValue(createSuccessfulRemoteDataObject$<PaginatedList<OrcidQueue>>(createPaginatedList<OrcidQueue>(orcidQueueElements)));
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
void TestBed.configureTestingModule({
|
||||
@@ -67,11 +114,10 @@ fdescribe('OrcidQueueComponent test suite', () => {
|
||||
],
|
||||
declarations: [OrcidQueueComponent],
|
||||
providers: [
|
||||
{ provide: OrcidQueueService, useValue: orcidQueueServiceMock },
|
||||
{ provide: OrcidQueueService, useValue: orcidQueueServiceSpy },
|
||||
{ provide: OrcidHistoryService, useValue: {} },
|
||||
{ provide: PaginationService, useValue: new PaginationServiceStub() },
|
||||
{ provide: NotificationsService, useValue: new NotificationsServiceStub() },
|
||||
{ provide: ActivatedRoute, useValue: activatedRouteStub },
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).compileComponents();
|
||||
@@ -82,6 +128,7 @@ fdescribe('OrcidQueueComponent test suite', () => {
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(OrcidQueueComponent);
|
||||
component = fixture.componentInstance;
|
||||
component.item = mockItemLinkedToOrcid;
|
||||
debugElement = fixture.debugElement;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
@@ -90,9 +137,9 @@ fdescribe('OrcidQueueComponent test suite', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should ...', () => {
|
||||
const table = debugElement.queryAll(By.css('table'));
|
||||
expect(table.length).toBe(1);
|
||||
it('should show the ORCID queue elements', () => {
|
||||
const table = debugElement.queryAll(By.css('[data-test="orcidQueueElementRow"]'));
|
||||
expect(table.length).toBe(2);
|
||||
});
|
||||
|
||||
});
|
||||
|
@@ -1,5 +1,4 @@
|
||||
import { Component, OnDestroy, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { Component, Input, OnDestroy, OnInit } from '@angular/core';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { BehaviorSubject, combineLatest, Observable, Subscription } from 'rxjs';
|
||||
import { switchMap, tap } from 'rxjs/operators';
|
||||
@@ -15,6 +14,7 @@ import { hasValue } from '../../../shared/empty.util';
|
||||
import { NotificationsService } from '../../../shared/notifications/notifications.service';
|
||||
import { PaginationComponentOptions } from '../../../shared/pagination/pagination-component-options.model';
|
||||
import { AlertType } from '../../../shared/alert/aletr-type';
|
||||
import { Item } from '../../../core/shared/item.model';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-orcid-queue',
|
||||
@@ -22,6 +22,12 @@ import { AlertType } from '../../../shared/alert/aletr-type';
|
||||
styleUrls: ['./orcid-queue.component.scss']
|
||||
})
|
||||
export class OrcidQueueComponent implements OnInit, OnDestroy {
|
||||
|
||||
/**
|
||||
* The item for which showing the orcid settings
|
||||
*/
|
||||
@Input() item: Item;
|
||||
|
||||
/**
|
||||
* Pagination config used to display the list
|
||||
*/
|
||||
@@ -54,7 +60,6 @@ export class OrcidQueueComponent implements OnInit, OnDestroy {
|
||||
constructor(private orcidQueueService: OrcidQueueService,
|
||||
protected translateService: TranslateService,
|
||||
private paginationService: PaginationService,
|
||||
private route: ActivatedRoute,
|
||||
private notificationsService: NotificationsService,
|
||||
private orcidHistoryService: OrcidHistoryService,
|
||||
) { }
|
||||
@@ -67,7 +72,7 @@ export class OrcidQueueComponent implements OnInit, OnDestroy {
|
||||
this.subs.push(
|
||||
this.paginationService.getCurrentPagination(this.paginationOptions.id, this.paginationOptions).pipe(
|
||||
tap(() => this.processing$.next(true)),
|
||||
switchMap((config: PaginationComponentOptions) => this.orcidQueueService.searchByOwnerId(this.route.snapshot.paramMap.get('id'), config)),
|
||||
switchMap((config: PaginationComponentOptions) => this.orcidQueueService.searchByOwnerId(this.item.id, config)),
|
||||
getFirstCompletedRemoteData()
|
||||
).subscribe((result: RemoteData<PaginatedList<OrcidQueue>>) => {
|
||||
this.processing$.next(false);
|
||||
@@ -236,7 +241,7 @@ export class OrcidQueueComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
private getUnauthorizedErrorContent(): Observable<string> {
|
||||
return this.orcidQueueService.getOrcidAuthorizeUrl(this.route.snapshot.paramMap.get('id')).pipe(
|
||||
return this.orcidQueueService.getOrcidAuthorizeUrl(this.item.id).pipe(
|
||||
switchMap((authorizeUrl) => this.translateService.get('person.page.orcid.sync-queue.send.unauthorized-error.content', { orcid : authorizeUrl}))
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user