diff --git a/packages/angular-sdk-components/src/lib/_components/infra/Containers/flow-container/flow-container.component.ts b/packages/angular-sdk-components/src/lib/_components/infra/Containers/flow-container/flow-container.component.ts index c1870028..d77e964c 100644 --- a/packages/angular-sdk-components/src/lib/_components/infra/Containers/flow-container/flow-container.component.ts +++ b/packages/angular-sdk-components/src/lib/_components/infra/Containers/flow-container/flow-container.component.ts @@ -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()) { @@ -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; } diff --git a/packages/angular-sdk-components/src/lib/_components/infra/assignment/assignment.component.ts b/packages/angular-sdk-components/src/lib/_components/infra/assignment/assignment.component.ts index d9da6926..571ad90e 100644 --- a/packages/angular-sdk-components/src/lib/_components/infra/assignment/assignment.component.ts +++ b/packages/angular-sdk-components/src/lib/_components/infra/assignment/assignment.component.ts @@ -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 @@ -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(); } @@ -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', ''); @@ -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; } diff --git a/packages/angular-sdk-components/src/lib/_components/infra/navbar/navbar.component.ts b/packages/angular-sdk-components/src/lib/_components/infra/navbar/navbar.component.ts index 79190507..3ff9d05a 100644 --- a/packages/angular-sdk-components/src/lib/_components/infra/navbar/navbar.component.ts +++ b/packages/angular-sdk-components/src/lib/_components/infra/navbar/navbar.component.ts @@ -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() { diff --git a/projects/angular-test-app/tests/e2e/DigV2/Process/ApproveReject.spec.js b/projects/angular-test-app/tests/e2e/DigV2/Process/ApproveReject.spec.js new file mode 100644 index 00000000..111fccc2 --- /dev/null +++ b/projects/angular-test-app/tests/e2e/DigV2/Process/ApproveReject.spec.js @@ -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(); +});