mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
69940: Process detail and overview test cases
This commit is contained in:

committed by
Art Lowel

parent
b4bb3acb63
commit
cf492a92c8
@@ -0,0 +1,38 @@
|
||||
import { ProcessDetailFieldComponent } from './process-detail-field.component';
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { VarDirective } from '../../../shared/utils/var.directive';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
|
||||
describe('ProcessDetailFieldComponent', () => {
|
||||
let component: ProcessDetailFieldComponent;
|
||||
let fixture: ComponentFixture<ProcessDetailFieldComponent>;
|
||||
|
||||
let title;
|
||||
|
||||
beforeEach(async(() => {
|
||||
title = 'fake.title.message';
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ProcessDetailFieldComponent, VarDirective],
|
||||
imports: [TranslateModule.forRoot(), RouterTestingModule.withRoutes([])],
|
||||
providers: [
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ProcessDetailFieldComponent);
|
||||
component = fixture.componentInstance;
|
||||
component.title = title;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should display the given title', () => {
|
||||
const header = fixture.debugElement.query(By.css('h4')).nativeElement;
|
||||
expect(header.textContent).toContain(title);
|
||||
});
|
||||
});
|
@@ -1,19 +1,19 @@
|
||||
<div class="container" *ngVar="(processRD$ | async)?.payload as process">
|
||||
<h2>{{'process.page.detail.title' | translate:{ id: process?.processId, name: process?.scriptName } }}</h2>
|
||||
|
||||
<ds-process-detail-field [title]="'process.page.detail.script'">
|
||||
<ds-process-detail-field id="process-name" [title]="'process.page.detail.script'">
|
||||
<div>{{ process?.scriptName }}</div>
|
||||
</ds-process-detail-field>
|
||||
|
||||
<ds-process-detail-field [title]="'process.page.detail.arguments'">
|
||||
<ds-process-detail-field id="process-arguments" [title]="'process.page.detail.arguments'">
|
||||
<div *ngFor="let argument of process?.parameters">{{ argument?.name }} {{ argument?.value }}</div>
|
||||
</ds-process-detail-field>
|
||||
|
||||
<ds-process-detail-field [title]="'process.page.detail.output-files'">
|
||||
<ds-process-detail-field id="process-files" [title]="'process.page.detail.output-files'">
|
||||
<ds-alert [content]="'process.page.detail.output-files.alert'" [type]="AlertTypeEnum.Warning"></ds-alert>
|
||||
</ds-process-detail-field>
|
||||
|
||||
<ds-process-detail-field [title]="'process.page.detail.output'">
|
||||
<ds-process-detail-field id="process-output" [title]="'process.page.detail.output'">
|
||||
<pre class="font-weight-bold text-secondary bg-light p-3">{{'process.page.detail.output.alert' | translate}}</pre>
|
||||
</ds-process-detail-field>
|
||||
</div>
|
||||
|
67
src/app/process-page/detail/process-detail.component.spec.ts
Normal file
67
src/app/process-page/detail/process-detail.component.spec.ts
Normal file
@@ -0,0 +1,67 @@
|
||||
import { ProcessDetailComponent } from './process-detail.component';
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { VarDirective } from '../../shared/utils/var.directive';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { ProcessDetailFieldComponent } from './process-detail-field/process-detail-field.component';
|
||||
import { Process } from '../processes/process.model';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { createSuccessfulRemoteDataObject } from '../../shared/testing/utils';
|
||||
import { By } from '@angular/platform-browser';
|
||||
|
||||
describe('ProcessDetailComponent', () => {
|
||||
let component: ProcessDetailComponent;
|
||||
let fixture: ComponentFixture<ProcessDetailComponent>;
|
||||
|
||||
let process: Process;
|
||||
|
||||
function init() {
|
||||
process = Object.assign(new Process(), {
|
||||
processId: 1,
|
||||
scriptName: 'script-name',
|
||||
parameters: [
|
||||
{
|
||||
name: '-f',
|
||||
value: 'file.xml'
|
||||
},
|
||||
{
|
||||
name: '-i',
|
||||
value: 'identifier'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
beforeEach(async(() => {
|
||||
init();
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ProcessDetailComponent, ProcessDetailFieldComponent, VarDirective],
|
||||
imports: [TranslateModule.forRoot(), RouterTestingModule.withRoutes([])],
|
||||
providers: [
|
||||
{ provide: ActivatedRoute, useValue: { data: observableOf({ process: createSuccessfulRemoteDataObject(process) }) } }
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ProcessDetailComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should display the script\'s name', () => {
|
||||
const name = fixture.debugElement.query(By.css('#process-name')).nativeElement;
|
||||
expect(name.textContent).toContain(process.scriptName);
|
||||
});
|
||||
|
||||
it('should display the process\'s parameters', () => {
|
||||
const args = fixture.debugElement.query(By.css('#process-arguments')).nativeElement;
|
||||
process.parameters.forEach((param) => {
|
||||
expect(args.textContent).toContain(`${param.name} ${param.value}`)
|
||||
});
|
||||
});
|
||||
|
||||
});
|
157
src/app/process-page/overview/process-overview.component.spec.ts
Normal file
157
src/app/process-page/overview/process-overview.component.spec.ts
Normal file
@@ -0,0 +1,157 @@
|
||||
import { ProcessOverviewComponent } from './process-overview.component';
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { VarDirective } from '../../shared/utils/var.directive';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { ProcessDataService } from '../../core/data/processes/process-data.service';
|
||||
import { Process } from '../processes/process.model';
|
||||
import { EPersonDataService } from '../../core/eperson/eperson-data.service';
|
||||
import { EPerson } from '../../core/eperson/models/eperson.model';
|
||||
import { createPaginatedList, createSuccessfulRemoteDataObject$ } from '../../shared/testing/utils';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { ProcessStatus } from '../processes/process-status.model';
|
||||
|
||||
describe('ProcessOverviewComponent', () => {
|
||||
let component: ProcessOverviewComponent;
|
||||
let fixture: ComponentFixture<ProcessOverviewComponent>;
|
||||
|
||||
let processService: ProcessDataService;
|
||||
let ePersonService: EPersonDataService;
|
||||
|
||||
let processes: Process[];
|
||||
let ePerson: EPerson;
|
||||
|
||||
function init() {
|
||||
processes = [
|
||||
Object.assign(new Process(), {
|
||||
processId: 1,
|
||||
scriptName: 'script-name',
|
||||
startTime: '2020-03-19T13:20:23.535+0000',
|
||||
endTime: '2020-03-19T13:27:36.720+0000',
|
||||
processStatus: ProcessStatus.COMPLETED
|
||||
}),
|
||||
Object.assign(new Process(), {
|
||||
processId: 2,
|
||||
scriptName: 'script-name',
|
||||
startTime: '2020-03-20T11:21:23.487+0000',
|
||||
endTime: '2020-03-20T11:22:36.165+0000',
|
||||
processStatus: ProcessStatus.FAILED
|
||||
}),
|
||||
Object.assign(new Process(), {
|
||||
processId: 3,
|
||||
scriptName: 'another-script-name',
|
||||
startTime: '2020-03-21T20:05:00.784+0000',
|
||||
endTime: '2020-03-21T20:15:56.126+0000',
|
||||
processStatus: ProcessStatus.RUNNING
|
||||
})
|
||||
];
|
||||
ePerson = Object.assign(new EPerson(), {
|
||||
metadata: {
|
||||
'eperson.firstname': [
|
||||
{
|
||||
value: 'John',
|
||||
language: null
|
||||
}
|
||||
],
|
||||
'eperson.lastname': [
|
||||
{
|
||||
value: 'Doe',
|
||||
language: null
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
processService = jasmine.createSpyObj('processService', {
|
||||
findAll: createSuccessfulRemoteDataObject$(createPaginatedList(processes))
|
||||
});
|
||||
ePersonService = jasmine.createSpyObj('ePersonService', {
|
||||
findById: createSuccessfulRemoteDataObject$(ePerson)
|
||||
});
|
||||
}
|
||||
|
||||
beforeEach(async(() => {
|
||||
init();
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ProcessOverviewComponent, VarDirective],
|
||||
imports: [TranslateModule.forRoot(), RouterTestingModule.withRoutes([])],
|
||||
providers: [
|
||||
{ provide: ProcessDataService, useValue: processService },
|
||||
{ provide: EPersonDataService, useValue: ePersonService }
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ProcessOverviewComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
describe('table structure', () => {
|
||||
let rowElements;
|
||||
|
||||
beforeEach(() => {
|
||||
rowElements = fixture.debugElement.queryAll(By.css('tbody tr'));
|
||||
});
|
||||
|
||||
it(`should contain 3 rows`, () => {
|
||||
expect(rowElements.length).toEqual(3);
|
||||
});
|
||||
|
||||
it('should display the process IDs in the first column', () => {
|
||||
rowElements.forEach((rowElement, index) => {
|
||||
const el = rowElement.query(By.css('td:nth-child(1)')).nativeElement;
|
||||
expect(el.textContent).toContain(processes[index].processId);
|
||||
});
|
||||
});
|
||||
|
||||
it('should display the script names in the second column', () => {
|
||||
rowElements.forEach((rowElement, index) => {
|
||||
const el = rowElement.query(By.css('td:nth-child(2)')).nativeElement;
|
||||
expect(el.textContent).toContain(processes[index].scriptName);
|
||||
});
|
||||
});
|
||||
|
||||
it('should display the eperson\'s name in the third column', () => {
|
||||
rowElements.forEach((rowElement, index) => {
|
||||
const el = rowElement.query(By.css('td:nth-child(3)')).nativeElement;
|
||||
expect(el.textContent).toContain(ePerson.name);
|
||||
});
|
||||
});
|
||||
|
||||
it('should display the start time in the fourth column', () => {
|
||||
rowElements.forEach((rowElement, index) => {
|
||||
const el = rowElement.query(By.css('td:nth-child(4)')).nativeElement;
|
||||
expect(el.textContent).toContain(processes[index].startTime);
|
||||
});
|
||||
});
|
||||
|
||||
it('should display the end time in the fifth column', () => {
|
||||
rowElements.forEach((rowElement, index) => {
|
||||
const el = rowElement.query(By.css('td:nth-child(5)')).nativeElement;
|
||||
expect(el.textContent).toContain(processes[index].endTime);
|
||||
});
|
||||
});
|
||||
|
||||
it('should display the status in the sixth column', () => {
|
||||
rowElements.forEach((rowElement, index) => {
|
||||
const el = rowElement.query(By.css('td:nth-child(6)')).nativeElement;
|
||||
expect(el.textContent).toContain(processes[index].processStatus);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('onPageChange', () => {
|
||||
const toPage = 2;
|
||||
|
||||
beforeEach(() => {
|
||||
component.onPageChange(toPage);
|
||||
});
|
||||
|
||||
it('should call a new findAll with the corresponding page', () => {
|
||||
expect(processService.findAll).toHaveBeenCalledWith(jasmine.objectContaining({ currentPage: toPage }));
|
||||
});
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user