[ACA-4299] Add e2e tests for task counters and notifications (#6726)

* [ACA-4299] Add ete tests for task counters and notifications

* Fix unit test

* Fix update for indirect counter changes
This commit is contained in:
davidcanonieto
2021-02-26 08:57:27 +01:00
committed by GitHub
parent f3c4680c2c
commit e96491fe25
15 changed files with 349 additions and 94 deletions

View File

@@ -17,23 +17,6 @@
import { Component, OnInit, ViewEncapsulation } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import { CloudLayoutService } from './services/cloud-layout.service';
import { NotificationModel, NotificationService } from '@alfresco/adf-core';
import { map } from 'rxjs/operators';
import { NotificationCloudService } from '@alfresco/adf-process-services-cloud';
import { TranslateService } from '@ngx-translate/core';
const SUBSCRIPTION_QUERY = `
subscription {
engineEvents(eventType: [
PROCESS_STARTED
TASK_ASSIGNED
TASK_UPDATED
]) {
eventType
entity
}
}
`;
@Component({
selector: 'app-cloud-layout',
@@ -48,26 +31,13 @@ export class CloudLayoutComponent implements OnInit {
constructor(
private router: Router,
private route: ActivatedRoute,
private cloudLayoutService: CloudLayoutService,
private notificationCloudService: NotificationCloudService,
private notificationService: NotificationService,
private translateService: TranslateService
private cloudLayoutService: CloudLayoutService
) { }
ngOnInit() {
let root: string = '';
this.route.params.subscribe((params) => {
this.appName = params.appName;
this.notificationCloudService.makeGQLQuery(
this.appName, SUBSCRIPTION_QUERY
)
.pipe(map((events: any) => events.data.engineEvents))
.subscribe((result) => {
result.map((engineEvent) => {
this.notifyEvent(engineEvent);
});
});
});
if (this.route.snapshot && this.route.snapshot.firstChild) {
@@ -92,37 +62,4 @@ export class CloudLayoutComponent implements OnInit {
onStartProcess() {
this.router.navigate([`/cloud/${this.appName}/start-process/`]);
}
notifyEvent(engineEvent) {
let message;
switch (engineEvent.eventType) {
case 'TASK_ASSIGNED':
message = this.translateService.instant('NOTIFICATIONS.TASK_ASSIGNED',
{ taskName: engineEvent.entity.name || '', assignee: engineEvent.entity.assignee });
this.pushNotification(engineEvent, message);
break;
case 'PROCESS_STARTED':
message = this.translateService.instant('NOTIFICATIONS.PROCESS_STARTED',
{ processName: engineEvent.entity.name });
this.pushNotification(engineEvent, message);
break;
case 'TASK_UPDATED':
message = this.translateService.instant('NOTIFICATIONS.TASK_UPDATED',
{ taskName: engineEvent.entity.name || '' });
this.pushNotification(engineEvent, message);
break;
default:
}
}
pushNotification(engineEvent: any, message: string) {
const notification = {
messages: [message],
icon: 'info',
datetime: new Date(),
initiator: { displayName: engineEvent.entity.initiator || 'System' }
} as NotificationModel;
this.notificationService.pushToNotificationHistory(notification);
}
}