1
0

fix test dependencies

This commit is contained in:
FrancescoMolinaro
2024-01-05 15:56:58 +01:00
parent e9159ce4e8
commit af3bfee74e
9 changed files with 55 additions and 17 deletions

View File

@@ -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();

View File

@@ -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();

View File

@@ -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();

View File

@@ -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>

View File

@@ -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;
}); });
} }

View File

@@ -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
*/ */

View File

@@ -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();
}); });

View File

@@ -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();

View File

@@ -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>