mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-14 21:43:04 +00:00
Merge remote-tracking branch 'atmire/w2p-98211_advanced-workflow-actions-7.2' into w2p-98211_advanced-workflow-actions-main
# Conflicts: # src/app/shared/testing/active-router.stub.ts # src/app/workflowitems-edit-page/advanced-workflow-action/advanced-workflow-action-select-reviewer/advanced-workflow-action-select-reviewer.component.ts
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import {
|
||||
AdvancedWorkflowActionSelectReviewerComponent,
|
||||
ADVANCED_WORKFLOW_TASK_OPTION_SELECT_REVIEWER
|
||||
ADVANCED_WORKFLOW_TASK_OPTION_SELECT_REVIEWER,
|
||||
} from './advanced-workflow-action-select-reviewer.component';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { WorkflowItemDataService } from '../../../core/submission/workflowitem-data.service';
|
||||
import { WorkflowItemDataServiceStub } from '../../../shared/testing/workflow-item-data-service.stub';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { WorkflowActionDataServiceStub } from '../../../shared/testing/workflow-action-data-service.stub';
|
||||
import { WorkflowActionDataService } from '../../../core/data/workflow-action-data.service';
|
||||
import { RouteService } from '../../../core/services/route.service';
|
||||
@@ -25,6 +24,7 @@ import { ProcessTaskResponse } from '../../../core/tasks/models/process-task-res
|
||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { RequestService } from '../../../core/data/request.service';
|
||||
import { RequestServiceStub } from '../../../shared/testing/request-service.stub';
|
||||
import { RouterStub } from '../../../shared/testing/router.stub';
|
||||
|
||||
const claimedTaskId = '2';
|
||||
const workflowId = '1';
|
||||
@@ -37,18 +37,19 @@ describe('AdvancedWorkflowActionSelectReviewerComponent', () => {
|
||||
|
||||
let claimedTaskDataService: ClaimedTaskDataServiceStub;
|
||||
let notificationService: NotificationsServiceStub;
|
||||
let router: RouterStub;
|
||||
let workflowActionDataService: WorkflowItemDataServiceStub;
|
||||
let workflowItemDataService: WorkflowItemDataServiceStub;
|
||||
|
||||
beforeEach(async () => {
|
||||
claimedTaskDataService = new ClaimedTaskDataServiceStub();
|
||||
notificationService = new NotificationsServiceStub();
|
||||
router = new RouterStub();
|
||||
workflowActionDataService = new WorkflowActionDataServiceStub();
|
||||
workflowItemDataService = new WorkflowItemDataServiceStub();
|
||||
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [
|
||||
RouterTestingModule,
|
||||
TranslateModule.forRoot(),
|
||||
],
|
||||
declarations: [
|
||||
@@ -66,10 +67,12 @@ describe('AdvancedWorkflowActionSelectReviewerComponent', () => {
|
||||
queryParams: {
|
||||
claimedTask: claimedTaskId,
|
||||
workflow: 'testaction',
|
||||
previousSearchQuery: 'Thor%20Love%20and%20Thunder',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{ provide: Router, useValue: router },
|
||||
{ provide: ClaimedTaskDataService, useValue: claimedTaskDataService },
|
||||
{ provide: NotificationsService, useValue: notificationService },
|
||||
{ provide: RouteService, useValue: routeServiceStub },
|
||||
@@ -85,14 +88,30 @@ describe('AdvancedWorkflowActionSelectReviewerComponent', () => {
|
||||
fixture = TestBed.createComponent(AdvancedWorkflowActionSelectReviewerComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
spyOn(component, 'previousPage');
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
fixture.debugElement.nativeElement.remove();
|
||||
});
|
||||
|
||||
describe('previousPage', () => {
|
||||
it('should navigate back to the Workflow tasks page with the previous query', () => {
|
||||
component.previousPage();
|
||||
|
||||
expect(router.navigate).toHaveBeenCalledWith(['/mydspace'], {
|
||||
queryParams: {
|
||||
configuration: 'workflow',
|
||||
query: 'Thor Love and Thunder',
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('performAction', () => {
|
||||
beforeEach(() => {
|
||||
spyOn(component, 'previousPage');
|
||||
});
|
||||
|
||||
it('should call the claimedTaskDataService with the list of selected ePersons', () => {
|
||||
spyOn(claimedTaskDataService, 'submitTask').and.returnValue(observableOf(new ProcessTaskResponse(true)));
|
||||
component.selectedReviewers = [EPersonMock, EPersonMock2];
|
||||
|
@@ -12,14 +12,15 @@ import {
|
||||
} from '../../../access-control/group-registry/group-form/members-list/members-list.component';
|
||||
import { Subscription } from 'rxjs';
|
||||
import { EPerson } from '../../../core/eperson/models/eperson.model';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { ActivatedRoute, Params, Router } from '@angular/router';
|
||||
import { WorkflowItemDataService } from '../../../core/submission/workflowitem-data.service';
|
||||
import { RouteService } from '../../../core/services/route.service';
|
||||
import { NotificationsService } from '../../../shared/notifications/notifications.service';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { WorkflowActionDataService } from '../../../core/data/workflow-action-data.service';
|
||||
import { ClaimedTaskDataService } from '../../../core/tasks/claimed-task-data.service';
|
||||
import { RequestService } from 'src/app/core/data/request.service';
|
||||
import { RequestService } from '../../../core/data/request.service';
|
||||
import { hasValue } from '../../../shared/empty.util';
|
||||
|
||||
export const ADVANCED_WORKFLOW_TASK_OPTION_SELECT_REVIEWER = 'submit_select_reviewer';
|
||||
export const ADVANCED_WORKFLOW_ACTION_SELECT_REVIEWER = 'selectrevieweraction';
|
||||
@@ -137,7 +138,13 @@ export class AdvancedWorkflowActionSelectReviewerComponent extends AdvancedWorkf
|
||||
* switching between the different pages
|
||||
*/
|
||||
previousPage(): void {
|
||||
void this.router.navigate(['/mydspace'], { queryParams: { configuration: 'workflow' } });
|
||||
const queryParams: Params = {
|
||||
configuration: 'workflow',
|
||||
};
|
||||
if (hasValue(this.route.snapshot.queryParams.previousSearchQuery)) {
|
||||
queryParams.query = decodeURIComponent(this.route.snapshot.queryParams.previousSearchQuery);
|
||||
}
|
||||
void this.router.navigate(['/mydspace'], { queryParams: queryParams });
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -78,7 +78,7 @@ export abstract class WorkflowItemActionPageComponent implements OnInit {
|
||||
const params: Params = {};
|
||||
if (url.split('?').length > 1) {
|
||||
for (const param of url.split('?')[1].split('&')) {
|
||||
params[param.split('=')[0]] = param.split('=')[1];
|
||||
params[param.split('=')[0]] = decodeURIComponent(param.split('=')[1]);
|
||||
}
|
||||
}
|
||||
void this.router.navigate([url.split('?')[0]], { queryParams: params });
|
||||
|
Reference in New Issue
Block a user