| /** | 
|  * @file         ADSO-10183 | 
|  * @description  Edit single stocking cost via action bar - Allocate to a new account with new values | 
|  * @testcategory Web - Financials - Stocking points | 
|  * @author       Jayden Chew (jayden.chew@3ds.com) | 
|  * @copyright    Dassault Systemes | 
|  */ | 
| import { qCustomMatcher } from '../../../e2elib/lib/src/main/qmatchers.const'; | 
| import { AppMP, Demo, Scenario } from '../../../libmp/appmp'; | 
| import { DataFoodBaseAccountCostDriver, DataFoodBaseAccountName, DataFoodBaseAccountTimeUnit, DataFoodBaseAccountUoM } from '../../../libmp/data/data.account'; | 
| import { ActionTriggerType } from '../../../libappbase/utils'; | 
| import { ListStockingCostColumn } from '../../../libmp/forms/form.stockingcost'; | 
| import { DataFoodBaseEntityName } from '../../../libmp/data/data.navigation'; | 
| import { DialogStockingCost } from '../../../libmp/dialogs/dialog.stockingcost'; | 
| import { ListAccountContextMenuItem } from '../../../libmp/forms/form.account'; | 
| import { LogMessage } from '../../../libappbase/logmessage'; | 
| import { startOfPlanningYear } from '../../../libmp/data/data.period'; | 
|   | 
| describe('ADSO-10183 - Edit single stocking cost via action bar - Allocate to a new account with new values', () => { | 
|   const appMP = AppMP.getInstance(); | 
|   let startOfPlanningDate: Date; | 
|   let eopString: string; | 
|   let sopString: string; | 
|   const viewStockingCost = appMP.viewStockingCost; | 
|   const listStockingCost = appMP.viewStockingCost.frmStockingCost.lstStockingCost; | 
|   let dlgStockingCost: DialogStockingCost; | 
|   | 
|   const accNameSC = DataFoodBaseAccountName.StockingCosts; | 
|   const accNameGFC = DataFoodBaseAccountName.GeneralFixedCosts; | 
|   const stockingPointDCAust = DataFoodBaseEntityName.DCAustria; | 
|   const costDriver = DataFoodBaseAccountCostDriver.Fixed; | 
|   const timeUnitMonth = DataFoodBaseAccountTimeUnit.Month; | 
|   const timeUnitWeek = DataFoodBaseAccountTimeUnit.Week; | 
|   const lengthOfTime = 1; | 
|   const uoM = DataFoodBaseAccountUoM.EuroPerWeek; | 
|   const defaultstart = new Date(`1-Jan-${startOfPlanningYear - 1}`); | 
|   | 
|   beforeAll(async () => { | 
|     jasmine.addMatchers(qCustomMatcher); | 
|     await appMP.login(); | 
|   }); | 
|   | 
|   afterAll(async () => { | 
|     // reset view | 
|     await appMP.viewAccount.reset(); | 
|     await appMP.viewStockingCost.reset(); | 
|     await appMP.cleanupAndLogout(); | 
|   }); | 
|   | 
|   afterEach(async () => { | 
|     await appMP.checkToastMessage(); | 
|   }); | 
|   | 
|   it(`Setup - ${AppMP.getDemoDataPath(Demo.Food, Scenario.Base)}`, async () => { | 
|     await appMP.createDemoDataset(Demo.Food, Scenario.Base, false); | 
|   }); | 
|   | 
|   it(`Setup - Open view ${appMP.viewPeriod.viewPath}, get start and end of planning.`, async () => { | 
|     await appMP.viewPeriod.switchTo(); | 
|     ({ startOfPlanningDate, sopString, eopString } = await appMP.viewPeriod.frmPeriod.getStartAndEndOfPlanning()); | 
|   }); | 
|   | 
|   it(`Setup - Open view ${appMP.viewAccount.viewPath}.\ | 
|       Create account name = '${accNameSC}', cost driver = ${costDriver}, cost = 2000, time unit = ${timeUnitMonth} and length of time = ${lengthOfTime}.`, async () => { | 
|     await appMP.viewAccount.switchTo(); | 
|     const [dlgAccount] = await appMP.viewAccount.frmAccount.listAccount.selectContextMenu(ListAccountContextMenuItem.Create); | 
|     await dlgAccount.updateDialogValues({ Name: accNameSC, CostDriver: costDriver, Cost: '2000', TimeUnit: timeUnitMonth, LengthOfTime: lengthOfTime.toString() }); | 
|     await dlgAccount.clickOK(); | 
|   | 
|     await appMP.viewAccount.frmAccount.listAccount.verifyRowExists({ Name: accNameSC }); | 
|   }); | 
|   | 
|   it(`Step 1 - Open view ${appMP.viewStockingCost.viewPath}.`, async () => { | 
|     await viewStockingCost.switchTo(); | 
|   }); | 
|   | 
|   it(`Step 2 - Select ${accNameGFC} for ${stockingPointDCAust}. Click action bar button Edit.`, async () => { | 
|     const stockingCostRow = await listStockingCost.getRowByCellValue(ListStockingCostColumn.StockingPoint, DataFoodBaseEntityName.DCAustria); | 
|     dlgStockingCost = await listStockingCost.openStockingCostDialog(ActionTriggerType.Button, stockingCostRow); | 
|     // Verify default values in dialog | 
|     const verifyAfterDialogStockingCost = await dlgStockingCost.verifyDialogValue(accNameGFC, costDriver, stockingPointDCAust, defaultstart, timeUnitMonth, lengthOfTime, 1000); | 
|     expect(verifyAfterDialogStockingCost.length).toBe(0, verifyAfterDialogStockingCost.join('. \n')); | 
|   }); | 
|   | 
|   it(`Step 3 - Set start = 1-Jan-2021, cost = 400, time unit = ${timeUnitWeek}, length of time = ${lengthOfTime}. Click OK.`, async () => { | 
|     await dlgStockingCost.updateDialog(accNameSC, costDriver, undefined, startOfPlanningDate, 400, timeUnitWeek, lengthOfTime.toString()); | 
|     // Verify that cost driver is still fixed | 
|     const costDriverStr = await dlgStockingCost.ddlCostDriver.getSelectedString(); | 
|     expect(costDriverStr).toBe(costDriver, LogMessage.value_notMatched(costDriver, costDriverStr)); | 
|   | 
|     await dlgStockingCost.clickOK(); | 
|   }); | 
|   | 
|   it('Step 4 - Verify row updated based on previous step.', async () => { | 
|     await listStockingCost.waitForScreenUpdate(3000); | 
|     const stockingCostRow = await listStockingCost.getRowByValue([ | 
|       { columnID: ListStockingCostColumn.StockingPoint, value: DataFoodBaseEntityName.DCAustria }, | 
|       { columnID: ListStockingCostColumn.Account, value: accNameSC }, | 
|       { columnID: ListStockingCostColumn.Start, value: sopString }, | 
|       { columnID: ListStockingCostColumn.Cost, value: '400' }, | 
|       { columnID: ListStockingCostColumn.UoM, value: uoM }, | 
|       { columnID: ListStockingCostColumn.End, value: eopString }, | 
|     ]); | 
|     expect(stockingCostRow).toBeDefined(LogMessage.row_notFound(DataFoodBaseEntityName.DCAustria)); | 
|   }); | 
| }); |