/** 
 | 
 * @file        ADSO-10396 
 | 
 * @description Default settings of smart plan 
 | 
 * @author      Chan 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 { startOfPlanningYear } from '../../libmp/data/data.period'; 
 | 
import { DataFoodStrategyName } from '../../libmp/data/data.strategy'; 
 | 
import { DialogSmartPlan, DialogSmartPlanDirectionRadioButton } from '../../libmp/dialogs/dialog.smartplan'; 
 | 
  
 | 
describe('ADSO-10396 - Default settings of smart plan', () => { 
 | 
  const appMP = AppMP.getInstance(); 
 | 
  let dlgSmartPlan: DialogSmartPlan; 
 | 
  
 | 
  beforeAll(async () => { 
 | 
    jasmine.addMatchers(qCustomMatcher); 
 | 
    await appMP.login(); 
 | 
  }); 
 | 
  
 | 
  afterAll(async () => { 
 | 
    await appMP.viewSupplyPlanning.reset(); 
 | 
    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.viewSupplyPlanning.viewPath}`, async () => { 
 | 
    await appMP.viewSupplyPlanning.switchTo(); 
 | 
  }); 
 | 
  
 | 
  it(`Step 3 - In Product Planning matrix, right-click any PISPIP cell and click Smart plan menu.<br><br> 
 | 
      Verify in the Smart plan dialog default settings as below:<br> 
 | 
      (General tab) Save my preferences button = disabled<br> 
 | 
      Restore default button = disabled<br> 
 | 
      Strategy = Default <br> 
 | 
      Override locked planning = unchecked<br> 
 | 
      (Advanced tab) Smart plan direction = middle out<br> 
 | 
      Limit the units used by smart plan = unchecked<br> 
 | 
      Checkbox Only plan one step upstream hidden.`, async () => { 
 | 
    dlgSmartPlan = await appMP.viewSupplyPlanning.frmProductPlanning.meProductPlanning.startSettingSmartPlanDirection(0, `1-Jan-${startOfPlanningYear}`); 
 | 
  
 | 
    // Verify General tab (buttons disabled and checkbox uncheck) 
 | 
    await dlgSmartPlan.verifyDialogEnabled({ BtnSavePreferencesEnabled: 'false', BtnRestoreDefaultEnabled: 'false' }); 
 | 
    await dlgSmartPlan.verifyDialogValues({ Strategy: DataFoodStrategyName.Default, OverrideLockedPlan: 'false' }); 
 | 
  
 | 
    // Verify Advanced tab (Smart plan direction = Middle-out and checkboxes uncheck) 
 | 
    await dlgSmartPlan.pnlAdvanced.clickTab(); 
 | 
    await dlgSmartPlan.verifyDialogValues({ SmartPlanDirection: DialogSmartPlanDirectionRadioButton.MiddleOut, LimitUnits: 'false' }); 
 | 
    await dlgSmartPlan.verifyDialogUIVisible({ OnlyPlanOneStepUpstream: 'false' }); // Default hidden 
 | 
  }); 
 | 
  
 | 
  it(`Step 4 - (Advanced tab) Set Smart plan direction = Upstream.<br> 
 | 
      Verify checkbox Only plan one step upstream is now shown (and uncheck).`, async () => { 
 | 
    await dlgSmartPlan.updateDialogValues({ SmartPlanDirection: DialogSmartPlanDirectionRadioButton.Upstream }); 
 | 
    await dlgSmartPlan.verifyDialogUIVisible({ OnlyPlanOneStepUpstream: 'true' }); 
 | 
    await dlgSmartPlan.verifyDialogValues({ OnlyPlanOneStepUpstream: 'false' }); 
 | 
  }); 
 | 
  
 | 
  it('Step 5 - Click Cancel to dismiss dialog.', async () => { 
 | 
    await dlgSmartPlan.clickCancel(); 
 | 
  }); 
 | 
}); 
 |