import { DataTable } from '@cucumber/cucumber'; import PARTY from '../../enum/party'; import USER_ROLE from '../../enum/userRole'; import { getNodeProfile } from '../../env/nodeProfile'; import { API } from '../API'; import { checkerApproverResponse, isWorkflowReadyForExecution } from '../apiUtil'; import { HTTP_METHOD } from '../httpMethod'; import { makeAuthenticatedRequest } from '../loginUtil'; import scenarioContext from '../scenarioContext'; import { executeDraftAndMapNewId } from '../updateDcId'; import { generateDCPayload } from './generateDCPayload'; import { checkForIdentitySwitching } from './multiIdentityUtil'; export async function generateApplicantProceededDc( dcScenario: string, proceededUserRoles: string = USER_ROLE.ADMIN1, attachmentNum = 0, documentSourceDataTable: DataTable = null ) { logger.info(`generateApplicantProceededDc - starting...`); scenarioContext().currentParty = PARTY.APPLICANT; const roles = proceededUserRoles.split('.'); const applicantNode = scenarioContext().getPartyNode(dcScenario, PARTY.APPLICANT); const nodeProfile = getNodeProfile(applicantNode); const payload = await generateDCPayload(documentSourceDataTable, dcScenario, attachmentNum); logger.info(`switch to correct identity before action..`); await checkForIdentitySwitching(PARTY.APPLICANT, applicantNode, nodeProfile, roles[0]); let dcActionResponse = await makeAuthenticatedRequest( applicantNode, roles[0], API.LOCAL_APPLY_BYPASS, HTTP_METHOD.PUT, JSON.stringify(payload) ); dcActionResponse = isWorkflowReadyForExecution(dcActionResponse) ? dcActionResponse : await checkerApproverResponse(applicantNode, roles[1], dcActionResponse); await executeDraftAndMapNewId(applicantNode, await dcActionResponse.id); logger.debug(`generateApplicantProceededDc - end...`); }