/** 
 | 
 * @file        ADSO-50530 
 | 
 * @description Verify meta optimizer dialog precondition 
 | 
 * @author      Clarence (ccn7@3ds.com) 
 | 
 * @copyright   Dassault Systèmes 
 | 
 */ 
 | 
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 } from '../../libmp/dialogs/dialog.strategy'; 
 | 
import { ListStrategy, ListStrategyContextMenuItem } from '../../libmp/forms/form.optimizerstrategies'; 
 | 
  
 | 
describe('ADSO-50530 - Verify meta optimizer dialog precondition', () => { 
 | 
  const appMP = AppMP.getInstance(); 
 | 
  const listStrategies = appMP.viewOptimizerStrategies.frmOptimizerStrategies.listStrategy; 
 | 
  let dlgStrategy: DialogStrategy; 
 | 
  
 | 
  beforeAll(async () => { 
 | 
    await appMP.login(); 
 | 
  }); 
 | 
  
 | 
  afterAll(async () => { 
 | 
    await appMP.cleanupAndLogout(); 
 | 
  }); 
 | 
  
 | 
  afterEach(async () => { 
 | 
    await appMP.checkToastMessage(); 
 | 
  }); 
 | 
  
 | 
  it(`Step 1 - ${AppMP.getDemoDataPath(Demo.Food, Scenario.Base)}.`, async () => { 
 | 
    await appMP.createDemoDataset(Demo.Food, Scenario.Base, false); 
 | 
  }); 
 | 
  
 | 
  it(`Step 2 - Open view ${appMP.viewOptimizerStrategies.viewPath}.`, async () => { 
 | 
    await appMP.viewOptimizerStrategies.switchTo(); 
 | 
  }); 
 | 
  
 | 
  it(`Step 3 - ${StepList.selectRowAndClickMenu(ListStrategy.title, {Name: DataFoodStrategyName.Default}, ListStrategyContextMenuItem.Edit.Label)}`, async () => { 
 | 
    const row = await listStrategies.getRow({Name: DataFoodStrategyName.Default}); 
 | 
    [dlgStrategy] = await listStrategies.selectContextMenu(ListStrategyContextMenuItem.Edit, row); 
 | 
  }); 
 | 
  
 | 
  it(`Step 4 - ${StepDialog.clickTab('Advanced')}`, async () => { 
 | 
    await dlgStrategy.panelAdvanced.clickTab(); 
 | 
  }); 
 | 
  
 | 
  it(`Step 5 - ${StepDialog.updateDialogValues(DialogStrategy.title, {UseMetaOptimizer: 'true', MetaOverrideFirstFocusLevel: 'true', MetaFirstFocusLevel: '-2'})} ${StepDialog.verifyOKDisabled(btnOkTooltip.metaFirstFocusLevel_Invalid('-2'))}`, async () => { 
 | 
    await dlgStrategy.updateDialogValues({UseMetaOptimizer: 'true', MetaOverrideFirstFocusLevel: 'true', MetaFirstFocusLevel: '-2'}); 
 | 
    await dlgStrategy.verifyOKDisabled(btnOkTooltip.metaFirstFocusLevel_Invalid('-2')); 
 | 
  }); 
 | 
  
 | 
  it(`Step 6 - ${StepDialog.updateDialogValues(DialogStrategy.title, {MetaFirstFocusLevel: '0'})} ${StepDialog.verifyOKEnabled()}`, async () => { 
 | 
    await dlgStrategy.updateDialogValues({MetaFirstFocusLevel: '0'}); 
 | 
    await dlgStrategy.verifyOKEnabled(); 
 | 
  }); 
 | 
  
 | 
  it(`Step 7 - ${StepDialog.updateDialogValues(DialogStrategy.title, {MetaOverrideLastFocusLevel: 'true'})} ${StepDialog.verifyOKDisabled(btnOkTooltip.metaLastFocusLevel_Invalid('0'))}`, async () => { 
 | 
    await dlgStrategy.updateDialogValues({MetaOverrideLastFocusLevel: 'true'}); 
 | 
    await dlgStrategy.verifyOKDisabled(btnOkTooltip.metaLastFocusLevel_Invalid('0')); 
 | 
  }); 
 | 
  
 | 
  it(`Step 8 - ${StepDialog.updateDialogValues(DialogStrategy.title, {MetaLastFocusLevel: '4'})} ${StepDialog.verifyOKEnabled()}`, async () => { 
 | 
    await dlgStrategy.updateDialogValues({MetaLastFocusLevel: '4'}); 
 | 
    await dlgStrategy.verifyOKEnabled(); 
 | 
  }); 
 | 
  
 | 
  it(`Step 9 - ${StepDialog.updateDialogValues(DialogStrategy.title, {MetaMaxTimeAllIterations: '0'})} ${StepDialog.verifyOKDisabled()}`, async () => { 
 | 
    await dlgStrategy.updateDialogValues({MetaMaxTimeAllIterations: '0'}); 
 | 
    await dlgStrategy.verifyOKDisabled(); 
 | 
  }); 
 | 
  
 | 
  it(`Step 10 - ${StepDialog.updateDialogValues(DialogStrategy.title, {MetaMaxTimeAllIterations: '999999'})} ${StepDialog.verifyOKEnabled()}`, async () => { 
 | 
    await dlgStrategy.updateDialogValues({MetaMaxTimeAllIterations: '999999'}); 
 | 
    await dlgStrategy.verifyOKEnabled(); 
 | 
  }); 
 | 
  
 | 
  it(`Step 11 - ${StepDialog.updateDialogValues(DialogStrategy.title, {MetaWeightCollapsedSlackLevel: '-150'})} ${StepDialog.verifyOKDisabled()}`, async () => { 
 | 
    await dlgStrategy.updateDialogValues({MetaWeightCollapsedSlackLevel: '-150'}); 
 | 
    await dlgStrategy.verifyOKDisabled(); 
 | 
  }); 
 | 
  
 | 
  it(`Step 12 - ${StepDialog.updateDialogValues(DialogStrategy.title, {MetaWeightCollapsedSlackLevel: '1000'})} ${StepDialog.verifyOKEnabled()} ${StepDialog.clickCancel()}`, async () => { 
 | 
    await dlgStrategy.updateDialogValues({MetaWeightCollapsedSlackLevel: '1000'}); 
 | 
    await dlgStrategy.verifyOKEnabled(); 
 | 
  
 | 
    await dlgStrategy.clickCancel(); 
 | 
  }); 
 | 
}); 
 |