forked from hazza/dspace-angular
fix test dependencies
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
import { AdminNotifyDetailModalComponent } from './admin-notify-detail-modal.component';
|
import { AdminNotifyDetailModalComponent } from './admin-notify-detail-modal.component';
|
||||||
|
import { NgbActiveModal } from "@ng-bootstrap/ng-bootstrap";
|
||||||
|
|
||||||
describe('AdminNotifyDetailModalComponent', () => {
|
describe('AdminNotifyDetailModalComponent', () => {
|
||||||
let component: AdminNotifyDetailModalComponent;
|
let component: AdminNotifyDetailModalComponent;
|
||||||
@@ -8,7 +9,8 @@ describe('AdminNotifyDetailModalComponent', () => {
|
|||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await TestBed.configureTestingModule({
|
await TestBed.configureTestingModule({
|
||||||
declarations: [ AdminNotifyDetailModalComponent ]
|
declarations: [ AdminNotifyDetailModalComponent ],
|
||||||
|
providers: [NgbActiveModal]
|
||||||
})
|
})
|
||||||
.compileComponents();
|
.compileComponents();
|
||||||
|
|
||||||
|
@@ -2,6 +2,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|||||||
|
|
||||||
import { AdminNotifyIncomingComponent } from './admin-notify-incoming.component';
|
import { AdminNotifyIncomingComponent } from './admin-notify-incoming.component';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
|
import { ActivatedRoute } from "@angular/router";
|
||||||
|
|
||||||
describe('AdminNotifyLogsComponent', () => {
|
describe('AdminNotifyLogsComponent', () => {
|
||||||
let component: AdminNotifyIncomingComponent;
|
let component: AdminNotifyIncomingComponent;
|
||||||
@@ -10,7 +11,8 @@ describe('AdminNotifyLogsComponent', () => {
|
|||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await TestBed.configureTestingModule({
|
await TestBed.configureTestingModule({
|
||||||
imports: [TranslateModule.forRoot()],
|
imports: [TranslateModule.forRoot()],
|
||||||
declarations: [ AdminNotifyIncomingComponent ]
|
declarations: [ AdminNotifyIncomingComponent ],
|
||||||
|
providers: [ActivatedRoute]
|
||||||
})
|
})
|
||||||
.compileComponents();
|
.compileComponents();
|
||||||
|
|
||||||
|
@@ -2,6 +2,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|||||||
|
|
||||||
import { AdminNotifyOutgoingComponent } from './admin-notify-outgoing.component';
|
import { AdminNotifyOutgoingComponent } from './admin-notify-outgoing.component';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
|
import { ActivatedRoute } from "@angular/router";
|
||||||
|
|
||||||
describe('AdminNotifyLogsComponent', () => {
|
describe('AdminNotifyLogsComponent', () => {
|
||||||
let component: AdminNotifyOutgoingComponent;
|
let component: AdminNotifyOutgoingComponent;
|
||||||
@@ -10,7 +11,8 @@ describe('AdminNotifyLogsComponent', () => {
|
|||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await TestBed.configureTestingModule({
|
await TestBed.configureTestingModule({
|
||||||
imports: [TranslateModule.forRoot()],
|
imports: [TranslateModule.forRoot()],
|
||||||
declarations: [ AdminNotifyOutgoingComponent ]
|
declarations: [ AdminNotifyOutgoingComponent ],
|
||||||
|
providers: [ActivatedRoute]
|
||||||
})
|
})
|
||||||
.compileComponents();
|
.compileComponents();
|
||||||
|
|
||||||
|
@@ -30,7 +30,7 @@
|
|||||||
<td>
|
<td>
|
||||||
<div class="d-flex flex-column">
|
<div class="d-flex flex-column">
|
||||||
<button class="btn mb-2 btn-dark" (click)="openDetailModal(message)">Detail</button>
|
<button class="btn mb-2 btn-dark" (click)="openDetailModal(message)">Detail</button>
|
||||||
<button class="btn btn-warning">Reprocess</button>
|
<button *ngIf="message.queueStatusLabel === reprocessStatus" class="btn btn-warning">Reprocess</button>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core';
|
|||||||
import { AdminNotifySearchResult } from '../models/admin-notify-message-search-result.model';
|
import { AdminNotifySearchResult } from '../models/admin-notify-message-search-result.model';
|
||||||
import { ViewMode } from '../../../core/shared/view-mode.model';
|
import { ViewMode } from '../../../core/shared/view-mode.model';
|
||||||
import { Context } from '../../../core/shared/context.model';
|
import { Context } from '../../../core/shared/context.model';
|
||||||
import { AdminNotifyMessage } from '../models/admin-notify-message.model';
|
import { AdminNotifyMessage, QueueStatusMap } from '../models/admin-notify-message.model';
|
||||||
import {
|
import {
|
||||||
tabulatableObjectsComponent
|
tabulatableObjectsComponent
|
||||||
} from '../../../shared/object-collection/shared/tabulatable-objects/tabulatable-objects.decorator';
|
} from '../../../shared/object-collection/shared/tabulatable-objects/tabulatable-objects.decorator';
|
||||||
@@ -12,6 +12,7 @@ import {
|
|||||||
import { PaginatedList } from '../../../core/data/paginated-list.model';
|
import { PaginatedList } from '../../../core/data/paginated-list.model';
|
||||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
||||||
import { AdminNotifyDetailModalComponent } from '../admin-notify-detail-modal/admin-notify-detail-modal.component';
|
import { AdminNotifyDetailModalComponent } from '../admin-notify-detail-modal/admin-notify-detail-modal.component';
|
||||||
|
import { objects } from "../../../shared/search/search-results/search-results.component.spec";
|
||||||
|
|
||||||
@tabulatableObjectsComponent(PaginatedList<AdminNotifySearchResult>, ViewMode.Table, Context.CoarNotify)
|
@tabulatableObjectsComponent(PaginatedList<AdminNotifySearchResult>, ViewMode.Table, Context.CoarNotify)
|
||||||
@Component({
|
@Component({
|
||||||
@@ -21,12 +22,7 @@ import { AdminNotifyDetailModalComponent } from '../admin-notify-detail-modal/ad
|
|||||||
})
|
})
|
||||||
export class AdminNotifySearchResultComponent extends TabulatableResultListElementsComponent<PaginatedList<AdminNotifySearchResult>, AdminNotifySearchResult> implements OnInit{
|
export class AdminNotifySearchResultComponent extends TabulatableResultListElementsComponent<PaginatedList<AdminNotifySearchResult>, AdminNotifySearchResult> implements OnInit{
|
||||||
public notifyMessages: AdminNotifyMessage[];
|
public notifyMessages: AdminNotifyMessage[];
|
||||||
|
public reprocessStatus = QueueStatusMap.QUEUE_STATUS_QUEUED_FOR_RETRY;
|
||||||
private queueStatusMap = {
|
|
||||||
QUEUE_STATUS_PROCESSED: 'Processed',
|
|
||||||
QUEUE_STATUS_FAILED: 'Failed',
|
|
||||||
QUEUE_STATUS_UNMAPPED_ACTION: 'Unmapped action',
|
|
||||||
};
|
|
||||||
|
|
||||||
constructor(private modalService: NgbModal) {
|
constructor(private modalService: NgbModal) {
|
||||||
super();
|
super();
|
||||||
@@ -36,10 +32,11 @@ export class AdminNotifySearchResultComponent extends TabulatableResultListElem
|
|||||||
* Map messages on init for readable representation
|
* Map messages on init for readable representation
|
||||||
*/
|
*/
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
console.log(this.objects.page.splice(0,2))
|
||||||
this.notifyMessages = this.objects.page.map(object => {
|
this.notifyMessages = this.objects.page.map(object => {
|
||||||
const indexableObject = object.indexableObject;
|
const indexableObject = object.indexableObject;
|
||||||
indexableObject.coarNotifyType = indexableObject.coarNotifyType.split(':')[1];
|
indexableObject.coarNotifyType = indexableObject.coarNotifyType.split(':')[1];
|
||||||
indexableObject.queueStatusLabel = this.queueStatusMap[indexableObject.queueStatusLabel];
|
indexableObject.queueStatusLabel = QueueStatusMap[indexableObject.queueStatusLabel];
|
||||||
return indexableObject;
|
return indexableObject;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -6,6 +6,15 @@ import { DSpaceObject } from '../../../core/shared/dspace-object.model';
|
|||||||
import { GenericConstructor } from '../../../core/shared/generic-constructor';
|
import { GenericConstructor } from '../../../core/shared/generic-constructor';
|
||||||
import { ListableObject } from '../../../shared/object-collection/shared/listable-object.model';
|
import { ListableObject } from '../../../shared/object-collection/shared/listable-object.model';
|
||||||
|
|
||||||
|
export enum QueueStatusMap {
|
||||||
|
QUEUE_STATUS_PROCESSED = 'Processed',
|
||||||
|
QUEUE_STATUS_FAILED = 'Failed',
|
||||||
|
QUEUE_STATUS_UNMAPPED_ACTION = 'Unmapped action',
|
||||||
|
QUEUE_STATUS_QUEUED_FOR_RETRY = 'Queued for retry',
|
||||||
|
QUEUE_STATUS_PROCESSING = 'Processing',
|
||||||
|
QUEUE_STATUS_QUEUED = 'Queued',
|
||||||
|
QUEUE_STATUS_UNTRUSTED = 'Untrusted',
|
||||||
|
};
|
||||||
/**
|
/**
|
||||||
* A message that includes admin notify info
|
* A message that includes admin notify info
|
||||||
*/
|
*/
|
||||||
|
@@ -1,19 +1,45 @@
|
|||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
import { TabulatableObjectsLoaderComponent } from './tabulatable-objects-loader.component';
|
import { TabulatableObjectsLoaderComponent } from './tabulatable-objects-loader.component';
|
||||||
|
import { ThemeService } from "../../../theme-support/theme.service";
|
||||||
|
import { provideMockStore } from "@ngrx/store/testing";
|
||||||
|
import { ListableObject } from "../listable-object.model";
|
||||||
|
import { PaginatedList } from "../../../../core/data/paginated-list.model";
|
||||||
|
import { Context } from "../../../../core/shared/context.model";
|
||||||
|
import { GenericConstructor } from "../../../../core/shared/generic-constructor";
|
||||||
|
|
||||||
describe('TabulatableObjectsComponent', () => {
|
const testType = 'TestType';
|
||||||
|
class TestType extends ListableObject {
|
||||||
|
getRenderTypes(): (string | GenericConstructor<ListableObject>)[] {
|
||||||
|
return [testType];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class TestTypes extends PaginatedList<ListableObject> {
|
||||||
|
page: TestType[]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
describe('TabulatableObjectsLoaderComponent', () => {
|
||||||
let component: TabulatableObjectsLoaderComponent;
|
let component: TabulatableObjectsLoaderComponent;
|
||||||
let fixture: ComponentFixture<TabulatableObjectsLoaderComponent>;
|
let fixture: ComponentFixture<TabulatableObjectsLoaderComponent>;
|
||||||
|
|
||||||
|
let themeService: ThemeService;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await TestBed.configureTestingModule({
|
await TestBed.configureTestingModule({
|
||||||
declarations: [ TabulatableObjectsLoaderComponent ]
|
declarations: [ TabulatableObjectsLoaderComponent ],
|
||||||
|
providers: [
|
||||||
|
provideMockStore({}),
|
||||||
|
{ provide: ThemeService, useValue: themeService },
|
||||||
|
]
|
||||||
})
|
})
|
||||||
.compileComponents();
|
.compileComponents();
|
||||||
|
|
||||||
fixture = TestBed.createComponent(TabulatableObjectsLoaderComponent);
|
fixture = TestBed.createComponent(TabulatableObjectsLoaderComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
|
component.objects = new TestTypes();
|
||||||
|
component.context = Context.Search;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -148,7 +148,7 @@ export class TabulatableObjectsLoaderComponent implements OnInit, OnChanges, OnD
|
|||||||
|
|
||||||
private instantiateComponent(objects: PaginatedList<ListableObject>, changes?: SimpleChanges): void {
|
private instantiateComponent(objects: PaginatedList<ListableObject>, changes?: SimpleChanges): void {
|
||||||
// objects need to have same render type so we access just the first in the page
|
// objects need to have same render type so we access just the first in the page
|
||||||
const component = this.getComponent(objects.page[0].getRenderTypes(), this.viewMode, this.context);
|
const component = this.getComponent(objects.page[0]?.getRenderTypes(), this.viewMode, this.context);
|
||||||
|
|
||||||
const viewContainerRef = this.tabulatableObjectsDirective.viewContainerRef;
|
const viewContainerRef = this.tabulatableObjectsDirective.viewContainerRef;
|
||||||
viewContainerRef.clear();
|
viewContainerRef.clear();
|
||||||
|
@@ -26,8 +26,8 @@
|
|||||||
</ds-tabulatable-objects-loader>
|
</ds-tabulatable-objects-loader>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<ds-error *ngIf="objects.hasFailed" message="{{'error.objects' | translate}}"></ds-error>
|
<ds-error *ngIf="objects?.hasFailed" message="{{'error.objects' | translate}}"></ds-error>
|
||||||
<ds-themed-loading *ngIf="objects.isLoading" message="{{'loading.objects' | translate}}"></ds-themed-loading>
|
<ds-themed-loading *ngIf="objects?.isLoading" message="{{'loading.objects' | translate}}"></ds-themed-loading>
|
||||||
</ds-pagination>
|
</ds-pagination>
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user