Merge branch 'w2p-98211_advanced-workflow-actions-7.2' into w2p-98211_advanced-workflow-actions-main

This commit is contained in:
Alexandre Vryghem
2023-02-10 15:55:09 +01:00
8 changed files with 62 additions and 42 deletions

View File

@@ -1,4 +1,5 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { Location } from '@angular/common';
import {
AdvancedWorkflowActionSelectReviewerComponent,
ADVANCED_WORKFLOW_TASK_OPTION_SELECT_REVIEWER,
@@ -25,6 +26,7 @@ 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';
import { LocationStub } from '../../../shared/testing/location.stub';
const claimedTaskId = '2';
const workflowId = '1';
@@ -36,6 +38,7 @@ describe('AdvancedWorkflowActionSelectReviewerComponent', () => {
let fixture: ComponentFixture<AdvancedWorkflowActionSelectReviewerComponent>;
let claimedTaskDataService: ClaimedTaskDataServiceStub;
let location: LocationStub;
let notificationService: NotificationsServiceStub;
let router: RouterStub;
let workflowActionDataService: WorkflowItemDataServiceStub;
@@ -43,6 +46,7 @@ describe('AdvancedWorkflowActionSelectReviewerComponent', () => {
beforeEach(async () => {
claimedTaskDataService = new ClaimedTaskDataServiceStub();
location = new LocationStub();
notificationService = new NotificationsServiceStub();
router = new RouterStub();
workflowActionDataService = new WorkflowActionDataServiceStub();
@@ -72,9 +76,10 @@ describe('AdvancedWorkflowActionSelectReviewerComponent', () => {
},
},
},
{ provide: Router, useValue: router },
{ provide: ClaimedTaskDataService, useValue: claimedTaskDataService },
{ provide: Location, useValue: location },
{ provide: NotificationsService, useValue: notificationService },
{ provide: Router, useValue: router },
{ provide: RouteService, useValue: routeServiceStub },
{ provide: WorkflowActionDataService, useValue: workflowActionDataService },
{ provide: WorkflowItemDataService, useValue: workflowItemDataService },
@@ -96,6 +101,13 @@ describe('AdvancedWorkflowActionSelectReviewerComponent', () => {
describe('previousPage', () => {
it('should navigate back to the Workflow tasks page with the previous query', () => {
spyOn(location, 'getState').and.returnValue({
previousQueryParams: {
configuration: 'workflow',
query: 'Thor Love and Thunder',
},
});
component.previousPage();
expect(router.navigate).toHaveBeenCalledWith(['/mydspace'], {

View File

@@ -1,4 +1,5 @@
import { Component, OnInit, OnDestroy } from '@angular/core';
import { Location } from '@angular/common';
import {
rendersAdvancedWorkflowTaskOption
} from '../../../shared/mydspace-actions/claimed-task/switcher/claimed-task-actions-decorator';
@@ -62,6 +63,7 @@ export class AdvancedWorkflowActionSelectReviewerComponent extends AdvancedWorkf
protected workflowActionService: WorkflowActionDataService,
protected claimedTaskDataService: ClaimedTaskDataService,
protected requestService: RequestService,
protected location: Location,
) {
super(route, workflowItemService, router, routeService, notificationsService, translationService, workflowActionService, claimedTaskDataService, requestService);
}
@@ -138,11 +140,11 @@ export class AdvancedWorkflowActionSelectReviewerComponent extends AdvancedWorkf
* switching between the different pages
*/
previousPage(): void {
const queryParams: Params = {
configuration: 'workflow',
};
if (hasValue(this.route.snapshot.queryParams.previousSearchQuery)) {
queryParams.query = decodeURIComponent(this.route.snapshot.queryParams.previousSearchQuery);
let queryParams: Params = (this.location.getState() as { [key: string]: any }).previousQueryParams;
if (!hasValue(queryParams)) {
queryParams = {
configuration: 'workflow',
};
}
void this.router.navigate(['/mydspace'], { queryParams: queryParams });
}