| /** | 
|  * @file        ADSO-50253 | 
|  * @description Postpone customer order in period | 
|  * @author      Clarence (ccn7@3ds.com) | 
|  * @copyright   Dassault Systèmes | 
|  */ | 
| import { AppMP, StepAppMP } from '../../libmp/appmp'; | 
| import { DataMetalBaseSalesSegmentName } from '../../libmp/data/data.salessegment'; | 
| import { DataMetalBaseProductName } from '../../libmp/data/data.product'; | 
| import { DataMetalStockingPointName } from '../../libmp/data/data.stockingpoint'; | 
| import { DialogPostponeForecast } from '../../libmp/dialogs/dialog.postponeforecast'; | 
| import { StepList } from '../../libappsop/listsop'; | 
| import { StepDialog } from '../../libappsop/dialogsop'; | 
| import { StepActionBarPage } from '../../libappsop/actionbarpagesop'; | 
| import { ListCustomerOrdersColumn, ListCustomerOrdersPlanningLevelColumn, ListCustomerOrdersPlanningLevelContextMenuItem } from '../../libmp/forms/form.customerorders'; | 
| import { startOfPlanningYear } from '../../libmp/data/data.period'; | 
|   | 
| describe('ADSO-50253 - Postpone customer order in period', () => { | 
|   const appMP = AppMP.getInstance(); | 
|   const scenarioToSelect = 'ADSO-50251'; | 
|   const janSOP = `1-Jan-${startOfPlanningYear}`; | 
|   const febSOP = `1-Feb-${startOfPlanningYear}`; | 
|   const marSOP = `1-Mar-${startOfPlanningYear}`; | 
|   const aprSOP = `1-Apr-${startOfPlanningYear}`; | 
|   let dlgPostponeForecast: DialogPostponeForecast; | 
|   const listCustomerOrders = appMP.viewCustomerOrders.formCustomerOrders.listCustomerOrders; | 
|   const listCustomerOrdersPlanningLevel = appMP.viewCustomerOrders.formCustomerOrders.listCustomerOrdersPlanningLevel; | 
|   const customerOrderToPostpone: ListCustomerOrdersColumn = {'Sales segment': DataMetalBaseSalesSegmentName.AudiA8, Product: DataMetalBaseProductName.BCCBWide, 'Stocking point': DataMetalStockingPointName.Europe, 'Order date': janSOP}; | 
|   const originalSDIPRow: ListCustomerOrdersPlanningLevelColumn = {Start: janSOP, Quantity: '60'}; | 
|   const customerOrderFirmed: ListCustomerOrdersColumn = {...customerOrderToPostpone, 'Order date': febSOP}; | 
|   | 
|   beforeAll(async () => { | 
|     await appMP.login(); | 
|   }); | 
|   | 
|   afterAll(async () => { | 
|     await appMP.resetActiveView(appMP.viewCustomerOrders); | 
|     await appMP.cleanupAndLogout(); | 
|   }); | 
|   | 
|   afterEach(async () => { | 
|     await appMP.checkToastMessage(); | 
|   }); | 
|   | 
|   it(`Step 1 - ${StepAppMP.selectScenario(scenarioToSelect)}`, async () => { | 
|     await appMP.selectScenario(scenarioToSelect); | 
|   }); | 
|   | 
|   it(`Step 2 - Open view ${appMP.viewCustomerOrders.viewPath}.`, async () => { | 
|     await appMP.viewCustomerOrders.switchTo(); | 
|   }); | 
|   | 
|   it(`Step 3 - ${StepList.selectRow(listCustomerOrders.title, customerOrderToPostpone)}`, async () => { | 
|     await listCustomerOrders.selectRow(customerOrderToPostpone); | 
|   }); | 
|   | 
|   it(`Step 4 - ${StepList.selectRowAndClickMenu(listCustomerOrdersPlanningLevel.title, {Start: janSOP}, ListCustomerOrdersPlanningLevelContextMenuItem.Postpone.Label)}`, async () => { | 
|     const row = await listCustomerOrdersPlanningLevel.getRow({Start: janSOP}); | 
|     [dlgPostponeForecast] = await listCustomerOrdersPlanningLevel.selectContextMenu(ListCustomerOrdersPlanningLevelContextMenuItem.Postpone, row); | 
|   }); | 
|   | 
|   it(`Step 5 - ${StepDialog.verifyDialogValues(DialogPostponeForecast.title, {PostponeToPeriod: febSOP, PostponeQuantity: '100'})}`, async () => { | 
|     await dlgPostponeForecast.verifyDialogValues({PostponeToPeriod: febSOP, PostponeQuantity: '100'}); | 
|   }); | 
|   | 
|   it(`Step 6 - ${StepDialog.verifyAvailableValues(DialogPostponeForecast.title, 'Postpone to period', [febSOP, marSOP, aprSOP])}`, async () => { | 
|     await dlgPostponeForecast.ddlPostponeToPeriod.verifyAvailableValues([febSOP, marSOP, aprSOP]); | 
|   }); | 
|   | 
|   it(`Step 7 - ${StepDialog.updateDialogValues(DialogPostponeForecast.title, {PostponeQuantity: '40', PostponeToPeriod: marSOP})} ${StepDialog.clickOK()}`, async () => { | 
|     await dlgPostponeForecast.updateDialogValues({PostponeQuantity: '40', PostponeToPeriod: marSOP}); | 
|     await dlgPostponeForecast.clickOK(); | 
|   }); | 
|   | 
|   it(`Step 8 - ${StepList.verifyRowExists(listCustomerOrdersPlanningLevel.title, originalSDIPRow)} ${StepList.verifyRowExists(listCustomerOrdersPlanningLevel.title, {Start: marSOP, Quantity: '40'}, [originalSDIPRow])}`, async () => { | 
|     await listCustomerOrdersPlanningLevel.verifyRowExists(originalSDIPRow); | 
|     await listCustomerOrdersPlanningLevel.verifyRowExists({Start: marSOP, Quantity: '40'}, [originalSDIPRow]); | 
|   }); | 
|   | 
|   it(`Step 9 - ${StepList.selectRow(listCustomerOrdersPlanningLevel.title, {Start: marSOP, Quantity: '40'})} | 
|       ${StepList.verifyContextMenuDisabled(listCustomerOrdersPlanningLevel.title, ListCustomerOrdersPlanningLevelContextMenuItem.Postpone.Label)}`, async () => { | 
|     // Postponed forecast in period cannot be further postponed | 
|     const rowPostponedForecastInPeriod = await listCustomerOrdersPlanningLevel.getRow({Start: marSOP, Quantity: '40'}, [originalSDIPRow]); | 
|     await listCustomerOrdersPlanningLevel.verifyContextMenuDisabled(ListCustomerOrdersPlanningLevelContextMenuItem.Postpone, [rowPostponedForecastInPeriod]); | 
|   }); | 
|   | 
|   it(`Step 10 - ${StepList.selectRow(listCustomerOrdersPlanningLevel.title, originalSDIPRow)} ${StepActionBarPage.clickButton('Postpone')}`, async () => { | 
|     const rowOriginalForecastInPeriod = await listCustomerOrdersPlanningLevel.selectRow(originalSDIPRow); | 
|     dlgPostponeForecast = await listCustomerOrdersPlanningLevel.clickActionButton(appMP.abpSales.btnPostponeForecast, undefined, rowOriginalForecastInPeriod); | 
|   }); | 
|   | 
|   it(`Step 11 - ${StepDialog.updateDialogValues(DialogPostponeForecast.title, {PostponeQuantity: '0'})} ${StepDialog.verifyOKDisabled()} ${StepDialog.clickCancel()}`, async () => { | 
|     await dlgPostponeForecast.updateDialogValues({PostponeQuantity: '0'}); | 
|     await dlgPostponeForecast.verifyOKDisabled(); | 
|     await dlgPostponeForecast.clickCancel(); | 
|   }); | 
|   | 
|   it(`Step 12 - ${StepList.selectRow(listCustomerOrders.title, customerOrderFirmed)}`, async () => { | 
|     await listCustomerOrders.selectRow(customerOrderFirmed); | 
|   }); | 
|   | 
|   it(`Step 13 - ${StepList.selectRow(listCustomerOrdersPlanningLevel.title, {Start: febSOP})} | 
|       ${StepList.verifyContextMenuDisabled(listCustomerOrdersPlanningLevel.title, ListCustomerOrdersPlanningLevelContextMenuItem.Postpone.Label)}`, async () => { | 
|     // Cannot postpone a firmed customer order | 
|     const row = await listCustomerOrdersPlanningLevel.getRow({Start: febSOP}); | 
|     await listCustomerOrdersPlanningLevel.verifyContextMenuDisabled(ListCustomerOrdersPlanningLevelContextMenuItem.Postpone, [row]); | 
|   }); | 
| }); |