Skip to content

Commit

Permalink
Add Approve & Reject case feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Vishal authored and vishalshrm539 committed Jul 19, 2024
1 parent 63aa2aa commit 18018f5
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -274,24 +274,30 @@ export class FlowContainerComponent implements OnInit, OnDestroy {
hasAssignments() {
let hasAssignments = false;
// @ts-ignore - second parameter pageReference for getValue method should be optional
const assignmentsList = this.pConn$.getValue(this.pCoreConstants.CASE_INFO.D_CASE_ASSIGNMENTS_RESULTS);
const thisOperator = PCore.getEnvironmentInfo().getOperatorIdentifier();
const assignmentsList: any[] = this.pConn$.getValue(this.pCoreConstants.CASE_INFO.D_CASE_ASSIGNMENTS_RESULTS);
// const thisOperator = PCore.getEnvironmentInfo().getOperatorIdentifier();
// 8.7 includes assignments in Assignments List that may be assigned to
// a different operator. So, see if there are any assignments for
// the current operator
const isEmbedded = window.location.href.includes('embedded');
let bAssignmentsForThisOperator = false;

if (isEmbedded) {
const thisOperator = PCore.getEnvironmentInfo().getOperatorIdentifier();
for (const assignment of assignmentsList) {
if (assignment.assigneeInfo.ID === thisOperator) {
bAssignmentsForThisOperator = true;
}
}
} else {
bAssignmentsForThisOperator = true;
}

// Bail if there is no assignmentsList
if (!assignmentsList) {
return hasAssignments;
}

for (const assignment of assignmentsList) {
if ((assignment as any).assigneeInfo.ID === thisOperator) {
bAssignmentsForThisOperator = true;
}
}

const hasChildCaseAssignments = this.hasChildCaseAssignments();

if (bAssignmentsForThisOperator || hasChildCaseAssignments || this.isCaseWideLocalAction()) {
Expand Down Expand Up @@ -469,7 +475,7 @@ export class FlowContainerComponent implements OnInit, OnDestroy {
PCore.getPubSubUtils().publish('assignmentFinished');

this.psService.sendMessage(false);
} else if (this.bHasCaseMessages$) {
} else {
this.bHasCaseMessages$ = false;
this.bShowConfirm = false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ export class AssignmentComponent implements OnInit, OnDestroy, OnChanges {
cancelAssignment: any;
cancelCreateStageAssignment: any;
showPage: any;
approveCase: any;
rejectCase: any;

// itemKey: string = ""; // JA - this is what Nebula/Constellation uses to pass to finishAssignment, navigateToStep

Expand Down Expand Up @@ -205,6 +207,8 @@ export class AssignmentComponent implements OnInit, OnDestroy, OnChanges {
this.showPage = actionsAPI.showPage.bind(actionsAPI);

this.cancelCreateStageAssignment = actionsAPI.cancelCreateStageAssignment.bind(actionsAPI);
this.approveCase = actionsAPI.approveCase?.bind(actionsAPI);
this.rejectCase = actionsAPI.rejectCase?.bind(actionsAPI);

this.createButtons();
}
Expand Down Expand Up @@ -411,11 +415,23 @@ export class AssignmentComponent implements OnInit, OnDestroy, OnChanges {
}
break;

case 'rejectCase': {
const rejectPromise = this.rejectCase(this.itemKey$);

rejectPromise
.then(() => {})
.catch(() => {
this.psService.sendMessage(false);
this.snackBar.open(`${this.localizedVal('Rejection failed!', this.localeCategory)}`, 'Ok');
});

break;
}

default:
break;
}
} else if (sButtonType == 'primary') {
// eslint-disable-next-line sonarjs/no-small-switch
switch (sAction) {
case 'finishAssignment':
this.erService.sendMessage('publish', '');
Expand All @@ -437,6 +453,19 @@ export class AssignmentComponent implements OnInit, OnDestroy, OnChanges {
this.erService.sendMessage('show', this.localizedVal('Please fix errors on form.', this.localeCategory));
}
break;

case 'approveCase': {
const approvePromise = this.approveCase(this.itemKey$);

approvePromise
.then(() => {})
.catch(() => {
this.psService.sendMessage(false);
this.snackBar.open(`${this.localizedVal('Approve failed!', this.localeCategory)}`, 'Ok');
});

break;
}
default:
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,9 @@ export class NavbarComponent implements OnInit, OnDestroy {
containerName: 'primary',
flowType: sFlowType || 'pyStartCase'
};
this.createWork(sCaseType, actionInfo);
this.createWork(sCaseType, actionInfo).then(() => {
console.log('createWork completed');
});
}

navPanelLogoutClick() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
const { test, expect } = require('@playwright/test');
const config = require('../../../config');
const common = require('../../../common');

test.beforeEach(async ({ page }) => {
await page.setViewportSize({ width: 1720, height: 1080 });
await page.goto(config.config.baseUrl, { waitUntil: 'networkidle' });
});

test.describe('E2E test', () => {
test('should login, create case and run different test cases for Approve and Reject actions', async ({ page }) => {
await common.login(config.config.apps.digv2.user.username, config.config.apps.digv2.user.password, page);

/** Testing announcement banner presence */
const announcementBanner = await page.locator('h2:has-text("Announcements")');
await expect(announcementBanner).toBeVisible();

/** Testing worklist presence */
const worklist = page.locator('div[id="worklist"]:has-text("My Worklist")');
await expect(worklist).toBeVisible();

/** Click on the Create Case button */
const createCase = page.locator('mat-list-item[id="create-case-button"]');
await createCase.click();

/** Creating a Process case-type */
const processCase = page.locator('mat-list-item[id="case-list-item"] > span:has-text("Process")');
await processCase.click();

await page.locator('button:has-text("Approve")').click();

let caseView = await page.locator('div[id="case-view"]');

await expect(caseView.locator('span >> text="Resolved-Completed"')).toBeVisible();

await createCase.click();

/** Creating another Process case-type */
await processCase.click();

await page.locator('button:has-text("Reject")').click();

caseView = await page.locator('div[id="case-view"]');

await expect(caseView.locator('span >> text="Resolved-Rejected"')).toBeVisible();
}, 10000);
});

test.afterEach(async ({ page }) => {
await page.close();
});

0 comments on commit 18018f5

Please sign in to comment.