import { Button } from '@contour/fet/lib/elements'; import MCA from '../../../enum/dc/mcaButtons'; import SubSideMenu from '../../../pages/sideMenu/subSideMenu.page'; import scenarioContext from '../../../util/scenarioContext'; import { loginToMainPageForScenario } from '../../login/glue/loginToMainPageForScenario'; import { navigateToCurrentDC } from '../../navigation/glue'; export async function performMcaFlow( party: string, type: string, nextParty: string, mcaType: string, scenario: string ) { const dcRef = scenarioContext().dc.uuid.substring(0, 8); const mcaOne = [ `checker-${MCA.DECLINE}`, `maker-${MCA.UPDATE}`, `checker-${MCA.VERIFY}`, `approver-${MCA.DECLINE}`, `maker-${MCA.UPDATE}`, `checker-${MCA.VERIFY}`, `approver-${MCA.APPROVE}` ]; const mcaTwo = [ `approver-${MCA.DECLINE}`, `maker-${MCA.UPDATE}`, `checkerApprover-${MCA.DECLINE}`, `admin1-${MCA.UPDATE}` ]; const mcaFlow = mcaType == 'mca1' ? mcaOne : mcaTwo; await performMcaAction(party, type, nextParty, dcRef, mcaFlow, scenario); } async function performMcaAction( party: string, type: string, nextParty: string, dcReference: string, action: string[], scenario: string ) { const submitButton = new Button(contourfet.getPageElement('actionButton', MCA.SUBMIT)); const confirmButton = new Button(contourfet.getPageElement('actionButton', MCA.CONFIRM)); const subSideMenu = new SubSideMenu(); for (const step of action) { const [role, actionButtonName] = step.split('-'); loginToMainPageForScenario(party, role, scenario); navigateToCurrentDC(party, dcReference); if (type == 'draftAmendment') { await subSideMenu.getSubMenuSubOption('Draft Text 1').clickElement(); } else if (type == 'draft') { await subSideMenu.getSubMenuSubOption('Draft').clickElement(); } const actionButton = new Button(contourfet.getPageElement('actionButton', actionButtonName)); await actionButton.clickElement(); if (role == 'maker' || role == 'admin1') { if (nextParty == 'IssuingBank' || nextParty == 'beneficiary' || nextParty == 'applicant') { await actionButton.clickElement(); //As per the current UI design, applicant's maker has to click update button 2 times before clicking submit } await submitButton.clickElement(); await browser.refresh(); } else { await confirmButton.clickElement(); } } }