/** 
 | 
 * @file        ADSO-9511 
 | 
 * @description Decrease weight optimizer strategy 
 | 
 * @author      Pethaperumal Natarajan (Pethaperumal.NATARAJAN.intern@3ds.com) 
 | 
 * @copyright   Dassault Systèmes 
 | 
 */ 
 | 
  
 | 
import { AppMP, Demo, Scenario } from '../../libmp/appmp'; 
 | 
import { qCustomMatcher } from '../../e2elib/lib/src/main/qmatchers.const'; 
 | 
import { ListStrategy, ListStrategyContextMenuItem } from '../../libmp/forms/form.optimizerstrategies'; 
 | 
import { DialogStrategy, ListActiveGoals, ListActiveGoalsContextMenuItem } from '../../libmp/dialogs/dialog.strategy'; 
 | 
import { StepList } from '../../libappsop/listsop'; 
 | 
import { StepDialog } from '../../libappsop/dialogsop'; 
 | 
import { DataKPIName } from '../../libmp/data/data.kpi'; 
 | 
import { DataFoodStrategyName } from '../../libmp/data/data.strategy'; 
 | 
  
 | 
describe('ADSO-9511 - Decrease weight optimizer strategy', () => { 
 | 
  const appMP = AppMP.getInstance(); 
 | 
  const listStrategy = appMP.viewOptimizerStrategies.frmOptimizerStrategies.listStrategy; 
 | 
  let dlgStrategy: DialogStrategy; 
 | 
  let listActiveGoals: ListActiveGoals; 
 | 
  
 | 
  beforeAll(async () => { 
 | 
    jasmine.addMatchers(qCustomMatcher); 
 | 
    await appMP.login(); 
 | 
  }); 
 | 
  
 | 
  afterAll(async () => { 
 | 
    await appMP.resetActiveView(appMP.viewScenarioAnalysisOverview); 
 | 
    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(`Step 1 - Open view ${appMP.viewOptimizerStrategies.viewPath}`, async () => { 
 | 
    await appMP.viewOptimizerStrategies.switchTo(); 
 | 
  }); 
 | 
  
 | 
  it(`Step 2 - ${StepList.selectRowAndClickMenu(ListStrategy.title, { Name: DataFoodStrategyName.PrioritizeFulfillment }, ListStrategyContextMenuItem.Edit.Label)}`, async () => { 
 | 
    const row = await listStrategy.getRow({ Name: DataFoodStrategyName.PrioritizeFulfillment }); 
 | 
    [dlgStrategy] = await listStrategy.selectContextMenu(ListStrategyContextMenuItem.Edit, row); 
 | 
  }); 
 | 
  
 | 
  it(`Step 3 - ${StepList.verifyRowExists(ListActiveGoals.name, { KPI: DataKPIName.Fulfillment, Weight: '5' })}`, async () => { 
 | 
    listActiveGoals = dlgStrategy.listActiveGoals; 
 | 
    await listActiveGoals.verifyRowExists({ KPI: DataKPIName.Fulfillment, Weight: '5' }); 
 | 
  }); 
 | 
  
 | 
  it(`Step 4 - ${StepList.selectRowAndClickMenu(ListActiveGoals.name, { KPI: DataKPIName.Fulfillment }, ListActiveGoalsContextMenuItem.DecreaseWeight.Label)}`, async () => { 
 | 
    const row = await listActiveGoals.getRow({ KPI: DataKPIName.Fulfillment }); 
 | 
    await listActiveGoals.selectContextMenu(ListActiveGoalsContextMenuItem.DecreaseWeight, row); 
 | 
  }); 
 | 
  
 | 
  it(`Step 5 - ${StepList.verifyRowExists(ListActiveGoals.name, { KPI: DataKPIName.Fulfillment, Weight: '4' })}`, async () => { 
 | 
    await listActiveGoals.verifyRowExists({ KPI: DataKPIName.Fulfillment, Weight: '4' }); 
 | 
  }); 
 | 
  
 | 
  it(`Step 6 - ${StepList.selectRowAndClickMenu(ListActiveGoals.name, { KPI: DataKPIName.Fulfillment }, ListActiveGoalsContextMenuItem.DecreaseWeight.Label)}`, async () => { 
 | 
    const row = await listActiveGoals.getRow({ KPI: DataKPIName.Fulfillment }); 
 | 
    await listActiveGoals.selectContextMenu(ListActiveGoalsContextMenuItem.DecreaseWeight, row); 
 | 
  }); 
 | 
  
 | 
  it(`Step 7 - ${StepList.selectRowAndClickMenu(ListActiveGoals.name, { KPI: DataKPIName.Fulfillment }, ListActiveGoalsContextMenuItem.DecreaseWeight.Label)}`, async () => { 
 | 
    const row = await listActiveGoals.getRow({ KPI: DataKPIName.Fulfillment }); 
 | 
    await listActiveGoals.selectContextMenu(ListActiveGoalsContextMenuItem.DecreaseWeight, row); 
 | 
  }); 
 | 
  
 | 
  it(`Step 8 - ${StepList.selectRowAndClickMenu(ListActiveGoals.name, { KPI: DataKPIName.Fulfillment }, ListActiveGoalsContextMenuItem.DecreaseWeight.Label)}`, async () => { 
 | 
    const row = await listActiveGoals.getRow({ KPI: DataKPIName.Fulfillment }); 
 | 
    await listActiveGoals.selectContextMenu(ListActiveGoalsContextMenuItem.DecreaseWeight, row); 
 | 
  }); 
 | 
  
 | 
  it(`Step 9 - ${StepList.verifyRowExists(ListActiveGoals.name, { KPI: DataKPIName.Fulfillment, Weight: '1' })}`, async () => { 
 | 
    await listActiveGoals.verifyRowExists({ KPI: DataKPIName.Fulfillment, Weight: '1' }); 
 | 
  }); 
 | 
  
 | 
  it(`Step 10 - ${StepList.verifyContextMenuDisabled(ListActiveGoals.name, ListActiveGoalsContextMenuItem.DecreaseWeight.Label)}`, async () => { 
 | 
    const row = await listActiveGoals.getRow({ KPI: DataKPIName.Fulfillment }); 
 | 
    await listActiveGoals.verifyContextMenuDisabled(ListActiveGoalsContextMenuItem.DecreaseWeight, [row]); 
 | 
  }); 
 | 
  
 | 
  it(`Step 11 - ${StepDialog.clickCancel()}`, async () => { 
 | 
    // Strategy is global to all food scenarios thus don't change the data else will effect subsequent tests 
 | 
    await dlgStrategy.clickCancel(); 
 | 
  }); 
 | 
}); 
 |