/** 
 | 
 * @file        ADSO-9499 
 | 
 * @description Edit optimizer strategy - advanced setting 
 | 
 * @author      Clarence (ccn7@3ds.com) 
 | 
 * @copyright   Dassault Systèmes 
 | 
 */ 
 | 
import { qCustomMatcher } from '../../e2elib/lib/src/main/qmatchers.const'; 
 | 
import { AppMP, Demo, Scenario } from '../../libmp/appmp'; 
 | 
import { StepDialog } from '../../libappsop/dialogsop'; 
 | 
import { StepList } from '../../libappsop/listsop'; 
 | 
import { DataFoodStrategyName } from '../../libmp/data/data.strategy'; 
 | 
import { btnOkTooltip, DialogStrategy, DialogStrategyFields } from '../../libmp/dialogs/dialog.strategy'; 
 | 
import { ListStrategy, ListStrategyColumn, ListStrategyContextMenuItem } from '../../libmp/forms/form.optimizerstrategies'; 
 | 
  
 | 
describe('ADSO-9499 - Edit optimizer strategy - advanced setting', () => { 
 | 
  const appMP = AppMP.getInstance(); 
 | 
  const listStrategy = appMP.viewOptimizerStrategies.frmOptimizerStrategies.listStrategy; 
 | 
  let dlgStrategy: DialogStrategy; 
 | 
  const fullMatchTooltip = true; 
 | 
  const editStrategyRow: ListStrategyColumn = {Name: DataFoodStrategyName.Default}; 
 | 
  const updateNumPeriodsAvgDemandInvalid: DialogStrategyFields = {NumPeriodsForAverageDemand: '0'}; 
 | 
  const updateNumPeriodsAvgDemandValid: DialogStrategyFields = {NumPeriodsForAverageDemand: '5'}; 
 | 
  const updateNumSmartPlanInvalid: DialogStrategyFields = {NumPeriodsForSmartPlan: '0'}; 
 | 
  const updateNumSmartPlanValid: DialogStrategyFields = {NumPeriodsForSmartPlan: '15'}; 
 | 
  const verifySlidingWindowDisabled: DialogStrategyFields = {NrOfPeriodsInWindow: 'false', NrOfPeriodsPerSlide: 'false'}; 
 | 
  const verifySlidingWindowEnabled: DialogStrategyFields = {UseSlidingWindow: 'true', NrOfPeriodsInWindow: 'true', NrOfPeriodsPerSlide: 'true'}; 
 | 
  const updateSlidingWindowValid: DialogStrategyFields = {NrOfPeriodsInWindow: '1', NrOfPeriodsPerSlide: '1'}; 
 | 
  const updateSlidingWindowValid2: DialogStrategyFields = {NrOfPeriodsInWindow: '2'}; 
 | 
  // Combine object values 
 | 
  const verifyDlgValuesAfterEditTabSettings: DialogStrategyFields = {...updateNumPeriodsAvgDemandValid, ...updateNumSmartPlanValid}; 
 | 
  const verifyDlgValuesAfterEditTabAdvanced: DialogStrategyFields = {UseSlidingWindow: 'true', ...updateSlidingWindowValid, ...updateSlidingWindowValid2}; 
 | 
  
 | 
  beforeAll(async () => { 
 | 
    jasmine.addMatchers(qCustomMatcher); 
 | 
    await appMP.login(); 
 | 
  }); 
 | 
  
 | 
  afterAll(async () => { 
 | 
    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 - ${appMP.viewOptimizerStrategies.stepDescription}`, async () => { 
 | 
    await appMP.viewOptimizerStrategies.switchTo(); 
 | 
  }); 
 | 
  
 | 
  it(`Step 2 - ${StepList.selectRowAndClickMenu(ListStrategy.title, editStrategyRow, ListStrategyContextMenuItem.Edit.Label)} ${StepDialog.clickTab('Settings')}`, async () => { 
 | 
    [dlgStrategy] = await listStrategy.selectContextMenu(ListStrategyContextMenuItem.Edit, await listStrategy.getRow(editStrategyRow)); 
 | 
    await dlgStrategy.panelSettings.clickTab(); 
 | 
  }); 
 | 
  
 | 
  it(`Step 3 - ${StepDialog.updateDialogValues(DialogStrategy.title, updateNumPeriodsAvgDemandInvalid)} ${StepDialog.verifyOKDisabled(btnOkTooltip.numPeriodsForAverageDemand_Invalid('0'))}`, async () => { 
 | 
    await dlgStrategy.updateDialogValues(updateNumPeriodsAvgDemandInvalid); 
 | 
    await dlgStrategy.verifyOKDisabled(btnOkTooltip.numPeriodsForAverageDemand_Invalid('0'), fullMatchTooltip); 
 | 
  }); 
 | 
  
 | 
  it(`Step 4 - ${StepDialog.updateDialogValues(DialogStrategy.title, updateNumPeriodsAvgDemandValid)} ${StepDialog.verifyOKEnabled()}`, async () => { 
 | 
    await dlgStrategy.updateDialogValues(updateNumPeriodsAvgDemandValid); 
 | 
    await dlgStrategy.verifyOKEnabled(); 
 | 
  }); 
 | 
  
 | 
  it(`Step 5 - ${StepDialog.updateDialogValues(DialogStrategy.title, updateNumSmartPlanInvalid)} ${StepDialog.verifyOKDisabled(btnOkTooltip.numPeriodsForSmartPlan_Invalid('0'))}`, async () => { 
 | 
    await dlgStrategy.updateDialogValues(updateNumSmartPlanInvalid); 
 | 
    await dlgStrategy.verifyOKDisabled(btnOkTooltip.numPeriodsForSmartPlan_Invalid('0'), fullMatchTooltip); 
 | 
  }); 
 | 
  
 | 
  it(`Step 6 - ${StepDialog.updateDialogValues(DialogStrategy.title, updateNumSmartPlanValid)} ${StepDialog.verifyOKEnabled()}`, async () => { 
 | 
    await dlgStrategy.updateDialogValues(updateNumSmartPlanValid); 
 | 
    await dlgStrategy.verifyOKEnabled(); 
 | 
  }); 
 | 
  
 | 
  it(`Step 7 - ${StepDialog.clickTab('Advanced')} ${StepDialog.verifyDialogEnabled(DialogStrategy.title, verifySlidingWindowDisabled)}`, async () => { 
 | 
    await dlgStrategy.panelAdvanced.clickTab(); 
 | 
    await dlgStrategy.verifyDialogEnabled(verifySlidingWindowDisabled); 
 | 
  }); 
 | 
  
 | 
  it(`Step 8 - ${StepDialog.updateDialogValues(DialogStrategy.title, {UseSlidingWindow: 'true'})} ${StepDialog.verifyDialogEnabled(DialogStrategy.title, verifySlidingWindowEnabled)} ${StepDialog.verifyOKDisabled(btnOkTooltip.numPeriodsForSlidingWindow_Invalid('0'))}`, async () => { 
 | 
    await dlgStrategy.updateDialogValues({UseSlidingWindow: 'true'}); 
 | 
    await dlgStrategy.verifyDialogEnabled(verifySlidingWindowEnabled); 
 | 
    await dlgStrategy.verifyOKDisabled(btnOkTooltip.numPeriodsForSlidingWindow_Invalid('0')); 
 | 
  }); 
 | 
  
 | 
  it(`Step 9 - ${StepDialog.updateDialogValues(DialogStrategy.title, updateSlidingWindowValid)} ${StepDialog.verifyOKEnabled()}`, async () => { 
 | 
    await dlgStrategy.updateDialogValues(updateSlidingWindowValid); 
 | 
    await dlgStrategy.verifyOKEnabled(); 
 | 
  }); 
 | 
  
 | 
  it(`Step 10 - ${StepDialog.updateDialogValues(DialogStrategy.title, updateSlidingWindowValid2)} ${StepDialog.clickOK()}`, async () => { 
 | 
    await dlgStrategy.updateDialogValues(updateSlidingWindowValid2); 
 | 
    await dlgStrategy.clickOK(); 
 | 
  }); 
 | 
  
 | 
  it(`Step 11 - ${StepList.selectRowAndClickMenu(ListStrategy.title, editStrategyRow, ListStrategyContextMenuItem.Edit.Label)}`, async () => { 
 | 
    [dlgStrategy] = await listStrategy.selectContextMenu(ListStrategyContextMenuItem.Edit, await listStrategy.getRow(editStrategyRow)); 
 | 
  }); 
 | 
  
 | 
  it(`Step 12 - ${StepDialog.clickTab('Settings')} ${StepDialog.verifyDialogValues(DialogStrategy.title, verifyDlgValuesAfterEditTabSettings)}`, async () => { 
 | 
    await dlgStrategy.panelSettings.clickTab(); 
 | 
    await dlgStrategy.verifyDialogValues(verifyDlgValuesAfterEditTabSettings); 
 | 
  }); 
 | 
  
 | 
  it(`Step 13 - ${StepDialog.clickTab('Advanced')} ${StepDialog.verifyDialogValues(DialogStrategy.title, verifyDlgValuesAfterEditTabAdvanced)} ${StepDialog.clickCancel()}`, async () => { 
 | 
    await dlgStrategy.panelAdvanced.clickTab(); 
 | 
    await dlgStrategy.verifyDialogValues(verifyDlgValuesAfterEditTabAdvanced); 
 | 
    await dlgStrategy.clickCancel(); 
 | 
  }); 
 | 
}); 
 |