mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
[TLC-674] Unit test fixes for comp, claimed/pooled tasks
This commit is contained in:
@@ -21,4 +21,7 @@ export class Duplicate {
|
||||
*/
|
||||
@autoserialize
|
||||
metadata: MetadataMap;
|
||||
|
||||
@autoserialize
|
||||
type: string;
|
||||
}
|
||||
|
@@ -4,7 +4,8 @@
|
||||
[showSubmitter]="showSubmitter"
|
||||
[badgeContext]="badgeContext"
|
||||
[workflowItem]="workflowitem$.value"></ds-themed-item-list-preview>
|
||||
<ng-container *ngVar="(duplicates$|async).length as duplicateCount">
|
||||
<!-- Display duplicate alert, if feature enabled and duplicates detected -->
|
||||
<ng-container *ngVar="(duplicates$|async)?.length as duplicateCount">
|
||||
<div [ngClass]="'col-md-12'" *ngIf="duplicateCount > 0">
|
||||
<div class="d-flex">
|
||||
{{ duplicateCount }} {{ 'submission.workflow.tasks.duplicates' | translate }}
|
||||
|
@@ -18,10 +18,11 @@ import { APP_CONFIG, AppConfig } from '../../../../../config/app-config.interfac
|
||||
import { ObjectCacheService } from '../../../../core/cache/object-cache.service';
|
||||
import { getFirstCompletedRemoteData } from '../../../../core/shared/operators';
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { mergeMap, tap } from 'rxjs/operators';
|
||||
import {map, mergeMap, tap} from 'rxjs/operators';
|
||||
import { isNotEmpty, hasValue } from '../../../empty.util';
|
||||
import { Context } from '../../../../core/shared/context.model';
|
||||
import { Duplicate } from '../../duplicate-data/duplicate.model';
|
||||
import { PaginatedList } from "../../../../core/data/paginated-list.model";
|
||||
|
||||
@Component({
|
||||
selector: 'ds-claimed-search-result-list-element',
|
||||
@@ -54,7 +55,7 @@ export class ClaimedSearchResultListElementComponent extends SearchResultListEle
|
||||
/**
|
||||
* The potential duplicates of this item
|
||||
*/
|
||||
public duplicates$: Observable<Duplicate[]>;
|
||||
public duplicates$: Observable<Duplicate[]> = new Observable<Duplicate[]>();
|
||||
|
||||
/**
|
||||
* Display thumbnails if required by configuration
|
||||
@@ -96,6 +97,16 @@ export class ClaimedSearchResultListElementComponent extends SearchResultListEle
|
||||
tap((itemRD: RemoteData<Item>) => {
|
||||
if (isNotEmpty(itemRD) && itemRD.hasSucceeded) {
|
||||
this.item$.next(itemRD.payload);
|
||||
this.duplicates$ = itemRD.payload.duplicates.pipe(
|
||||
getFirstCompletedRemoteData(),
|
||||
map((remoteData: RemoteData<PaginatedList<Duplicate>>) => {
|
||||
if (remoteData.hasSucceeded) {
|
||||
if (remoteData.payload.page) {
|
||||
return remoteData.payload.page;
|
||||
}
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
})
|
||||
).subscribe();
|
||||
|
@@ -4,7 +4,8 @@
|
||||
[showSubmitter]="showSubmitter"
|
||||
[badgeContext]="badgeContext"
|
||||
[workflowItem]="workflowitem$.value"></ds-themed-item-list-preview>
|
||||
<ng-container *ngVar="(duplicates$|async).length as duplicateCount">
|
||||
<!-- Display duplicate alert, if feature enabled and duplicates detected -->
|
||||
<ng-container *ngVar="(duplicates$|async)?.length as duplicateCount">
|
||||
<div [ngClass]="'col-md-12'" *ngIf="duplicateCount > 0">
|
||||
<div class="d-flex">
|
||||
{{ duplicateCount }} {{ 'submission.workflow.tasks.duplicates' | translate }}
|
||||
|
@@ -60,7 +60,7 @@ export class PoolSearchResultListElementComponent extends SearchResultListElemen
|
||||
/**
|
||||
* The potential duplicates of this workflow item
|
||||
*/
|
||||
public duplicates$: Observable<Duplicate[]>;
|
||||
public duplicates$: Observable<Duplicate[]> = new Observable<Duplicate[]>();
|
||||
|
||||
/**
|
||||
* The index of this list element
|
||||
@@ -107,11 +107,9 @@ export class PoolSearchResultListElementComponent extends SearchResultListElemen
|
||||
tap((itemRD: RemoteData<Item>) => {
|
||||
if (isNotEmpty(itemRD) && itemRD.hasSucceeded) {
|
||||
this.item$.next(itemRD.payload);
|
||||
console.dir(itemRD.payload);
|
||||
this.duplicates$ = itemRD.payload.duplicates.pipe(
|
||||
getFirstCompletedRemoteData(),
|
||||
map((remoteData: RemoteData<PaginatedList<Duplicate>>) => {
|
||||
console.dir(remoteData);
|
||||
if (remoteData.hasSucceeded) {
|
||||
if (remoteData.payload.page) {
|
||||
return remoteData.payload.page;
|
||||
@@ -124,6 +122,7 @@ export class PoolSearchResultListElementComponent extends SearchResultListElemen
|
||||
).subscribe();
|
||||
|
||||
this.showThumbnails = this.appConfig.browseBy.showThumbnails;
|
||||
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
|
@@ -2,7 +2,7 @@ import { ChangeDetectorRef, Component, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||
import { ComponentFixture, inject, TestBed, waitForAsync } from '@angular/core/testing';
|
||||
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
|
||||
import { NgxPaginationModule } from 'ngx-pagination';
|
||||
@@ -11,7 +11,6 @@ import { of as observableOf } from 'rxjs';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../../shared/remote-data.utils';
|
||||
import { createTestComponent } from '../../../shared/testing/utils.test';
|
||||
import { NotificationsService } from '../../../shared/notifications/notifications.service';
|
||||
import { NotificationsServiceStub } from '../../../shared/testing/notifications-service.stub';
|
||||
import { SubmissionService } from '../../submission.service';
|
||||
@@ -39,10 +38,6 @@ import { PaginationService } from '../../../core/pagination/pagination.service';
|
||||
import { PaginationServiceStub } from '../../../shared/testing/pagination-service.stub';
|
||||
import {Duplicate} from "../../../shared/object-list/duplicate-data/duplicate.model";
|
||||
import {MetadataValue} from "../../../core/shared/metadata.models";
|
||||
import {
|
||||
WorkspaceitemSectionDuplicatesObject
|
||||
} from "../../../core/submission/models/workspaceitem-section-duplicates.model";
|
||||
import {SectionDataObject} from "../models/section-data.model";
|
||||
import {defaultUUID} from "../../../shared/mocks/uuid.service.mock";
|
||||
|
||||
function getMockSubmissionFormsConfigService(): SubmissionFormsConfigDataService {
|
||||
@@ -76,19 +71,15 @@ const duplicates: Duplicate[]= [{
|
||||
'confidence': -1,
|
||||
'place': 0
|
||||
})]
|
||||
}
|
||||
},
|
||||
type: "DUPLICATE"
|
||||
}];
|
||||
|
||||
const potentialDuplicates: WorkspaceitemSectionDuplicatesObject = {
|
||||
potentialDuplicates: duplicates
|
||||
};
|
||||
|
||||
const sectionObject: SectionDataObject = {
|
||||
const sectionObject = {
|
||||
header: 'submission.sections.submit.progressbar.duplicates',
|
||||
config: 'https://dspace.org/api/config/submissionforms/duplicates',
|
||||
mandatory: true,
|
||||
opened: true,
|
||||
data: potentialDuplicates,
|
||||
data: {potentialDuplicates: duplicates},
|
||||
errorsToShow: [],
|
||||
serverValidationErrors: [],
|
||||
id: 'duplicates',
|
||||
@@ -160,8 +151,7 @@ describe('SubmissionSectionDuplicatesComponent test suite', () => {
|
||||
{ provide: 'submissionIdProvider', useValue: submissionId },
|
||||
{ provide: PaginationService, useValue: paginationService },
|
||||
ChangeDetectorRef,
|
||||
FormBuilderService,
|
||||
SubmissionSectionDuplicatesComponent
|
||||
FormBuilderService
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).compileComponents().then();
|
||||
@@ -177,9 +167,9 @@ describe('SubmissionSectionDuplicatesComponent test suite', () => {
|
||||
sectionsServiceStub.isSectionReadOnly.and.returnValue(observableOf(false));
|
||||
sectionsServiceStub.getSectionErrors.and.returnValue(observableOf([]));
|
||||
sectionsServiceStub.getSectionData.and.returnValue(observableOf(sectionObject));
|
||||
const html = `<ds-submission-section-duplicates></ds-submission-section-duplicates>`;
|
||||
testFixture = createTestComponent(html, TestComponent) as ComponentFixture<TestComponent>;
|
||||
testFixture = TestBed.createComponent(SubmissionSectionDuplicatesComponent);
|
||||
testComp = testFixture.componentInstance;
|
||||
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
@@ -187,7 +177,7 @@ describe('SubmissionSectionDuplicatesComponent test suite', () => {
|
||||
});
|
||||
|
||||
it('should create SubmissionSectionDuplicatesComponent', () => {
|
||||
expect(testComp).toBeDefined();
|
||||
expect(testComp).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -217,7 +207,7 @@ describe('SubmissionSectionDuplicatesComponent test suite', () => {
|
||||
sectionsServiceStub.isSectionReadOnly.and.returnValue(observableOf(false));
|
||||
compAsAny.submissionService.getSubmissionScope.and.returnValue(SubmissionScopeType.WorkspaceItem);
|
||||
spyOn(comp, 'getSectionStatus').and.returnValue(observableOf(true));
|
||||
spyOn(comp, 'getDuplicateData').and.returnValue(observableOf(potentialDuplicates));
|
||||
spyOn(comp, 'getDuplicateData').and.returnValue(observableOf({potentialDuplicates: duplicates}));
|
||||
expect(comp.isLoading).toBeTruthy();
|
||||
comp.onSectionInit();
|
||||
fixture.detectChanges();
|
||||
|
Reference in New Issue
Block a user